/dev/tomkiewicz/gg11: ca6d1b4d24b5: Gadu-Gadu: add an option to ...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Mon Sep 16 05:14:15 EDT 2013
Changeset: ca6d1b4d24b5cfd63f2d0c95fc45701d4c016fea
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-09-16 11:08 +0200
Branch: default
URL: https://hg.pidgin.im/dev/tomkiewicz/gg11/rev/ca6d1b4d24b5
Description:
Gadu-Gadu: add an option to disable new libgadu API
diffstat:
libpurple/protocols/gg/chat.c | 12 +++++++++++
libpurple/protocols/gg/chat.h | 4 +++
libpurple/protocols/gg/gg.c | 34 +++++++++++++++++++++++++++++++++
libpurple/protocols/gg/gg.h | 5 ++-
libpurple/protocols/gg/libgadu-events.c | 2 +
libpurple/protocols/gg/libgadu-events.h | 4 +++
libpurple/protocols/gg/libgaduw.c | 9 ++++++-
libpurple/protocols/gg/message-prpl.c | 15 ++++++++++++++
libpurple/protocols/gg/status.c | 8 ++++++-
libpurple/protocols/gg/tcpsocket.c | 11 ++++++++++
10 files changed, 99 insertions(+), 5 deletions(-)
diffs (truncated from 417 to 300 lines):
diff --git a/libpurple/protocols/gg/chat.c b/libpurple/protocols/gg/chat.c
--- a/libpurple/protocols/gg/chat.c
+++ b/libpurple/protocols/gg/chat.c
@@ -6,6 +6,8 @@
#include "utils.h"
#include "message-prpl.h"
+#if GGP_ENABLE_GG11
+
typedef struct _ggp_chat_local_info ggp_chat_local_info;
struct _ggp_chat_session_data
@@ -605,3 +607,13 @@ PurpleRoomlist * ggp_chat_roomlist_get_l
purple_timeout_add(1, ggp_chat_roomlist_get_list_finish, roomlist);
return roomlist;
}
+
+#else
+void ggp_chat_setup(PurpleConnection *gc)
+{
+}
+
+void ggp_chat_cleanup(PurpleConnection *gc)
+{
+}
+#endif
diff --git a/libpurple/protocols/gg/chat.h b/libpurple/protocols/gg/chat.h
--- a/libpurple/protocols/gg/chat.h
+++ b/libpurple/protocols/gg/chat.h
@@ -6,9 +6,12 @@
typedef struct _ggp_chat_session_data ggp_chat_session_data;
+#include "gg.h"
+
void ggp_chat_setup(PurpleConnection *gc);
void ggp_chat_cleanup(PurpleConnection *gc);
+#if GGP_ENABLE_GG11
void ggp_chat_got_event(PurpleConnection *gc, const struct gg_event *ev);
GList * ggp_chat_info(PurpleConnection *gc);
@@ -26,5 +29,6 @@ void ggp_chat_got_message(PurpleConnecti
const char *message, time_t time, uin_t who);
PurpleRoomlist * ggp_chat_roomlist_get_list(PurpleConnection *gc);
+#endif
#endif /* _GGP_CHAT_H */
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -332,8 +332,10 @@ static void ggp_callback_recv(gpointer _
case GG_EVENT_MSG:
ggp_message_got(gc, &ev->event.msg);
break;
+#if GGP_ENABLE_GG11
case GG_EVENT_ACK110:
break;
+#endif
case GG_EVENT_IMAGE_REPLY:
ggp_image_recv(gc, &ev->event.image_reply);
break;
@@ -355,9 +357,11 @@ static void ggp_callback_recv(gpointer _
case GG_EVENT_USER_DATA:
ggp_events_user_data(gc, &ev->event.user_data);
break;
+#if GGP_ENABLE_GG11
case GG_EVENT_JSON_EVENT:
ggp_events_json(gc, &ev->event.json_event);
break;
+#endif
case GG_EVENT_USERLIST100_VERSION:
ggp_roster_version(gc, &ev->event.userlist100_version);
break;
@@ -370,6 +374,7 @@ static void ggp_callback_recv(gpointer _
case GG_EVENT_MULTILOGON_INFO:
ggp_multilogon_info(gc, &ev->event.multilogon_info);
break;
+#if GGP_ENABLE_GG11
case GG_EVENT_IMTOKEN:
purple_debug_info("gg", "gg11: got IMTOKEN\n");
g_free(info->imtoken);
@@ -385,6 +390,7 @@ static void ggp_callback_recv(gpointer _
case GG_EVENT_CHAT_INVITE_ACK:
ggp_chat_got_event(gc, ev);
break;
+#endif
default:
purple_debug_warning("gg",
"unsupported event type=%d\n", ev->type);
@@ -432,12 +438,14 @@ void ggp_async_login_handler(gpointer _g
case GG_STATE_TLS_NEGOTIATION:
purple_debug_info("gg", "GG_STATE_TLS_NEGOTIATION\n");
break;
+#if GGP_ENABLE_GG11
case GG_STATE_RESOLVING_HUB:
purple_debug_info("gg", "GG_STATE_RESOLVING_HUB\n");
break;
case GG_STATE_READING_HUB:
purple_debug_info("gg", "GG_STATE_READING_HUB\n");
break;
+#endif
default:
purple_debug_error("gg", "unknown state = %d\n",
info->session->state);
@@ -472,11 +480,13 @@ void ggp_async_login_handler(gpointer _g
break;
case GG_EVENT_CONN_SUCCESS:
{
+#if GGP_ENABLE_GG11
purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS:"
" successfully connected to %s\n",
info->session->connect_host);
ggp_servconn_add_server(info->session->
connect_host);
+#endif
purple_input_remove(info->inpa);
info->inpa = purple_input_add(info->session->fd,
PURPLE_INPUT_READ,
@@ -632,7 +642,9 @@ static void ggp_login(PurpleAccount *acc
PurpleConnection *gc = purple_account_get_connection(account);
struct gg_login_params *glp;
GGPInfo *info;
+#if GGP_ENABLE_GG11
const char *address;
+#endif
const gchar *encryption_type, *protocol_version;
if (!ggp_deprecated_setup_proxy(gc))
@@ -641,7 +653,9 @@ static void ggp_login(PurpleAccount *acc
purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC);
glp = g_new0(struct gg_login_params, 1);
+#if GGP_ENABLE_GG11
glp->struct_size = sizeof(struct gg_login_params);
+#endif
info = g_new0(GGPInfo, 1);
purple_connection_set_protocol_data(gc, info);
@@ -708,19 +722,27 @@ static void ggp_login(PurpleAccount *acc
"protocol_version", "default");
purple_debug_info("gg", "Requested protocol version: %s\n",
protocol_version);
+#if GGP_ENABLE_GG11
if (g_strcmp0(protocol_version, "gg10") == 0)
glp->protocol_version = GG_PROTOCOL_VERSION_100;
else if (g_strcmp0(protocol_version, "gg11") == 0)
glp->protocol_version = GG_PROTOCOL_VERSION_110;
+#else
+ glp->protocol_version = 0x2e;
+#endif
ggp_status_set_initial(gc, glp);
+#if GGP_ENABLE_GG11
address = purple_account_get_string(account, "gg_server", "");
if (address && *address)
glp->connect_host = g_strdup(address);
+#endif
info->session = gg_login(glp);
+#if GGP_ENABLE_GG11
g_free(glp->connect_host);
+#endif
purple_str_wipe(glp->password);
g_free(glp);
@@ -940,8 +962,12 @@ static PurplePluginProtocolInfo prpl_inf
ggp_tooltip_text, /* tooltip_text */
ggp_status_types, /* status_types */
NULL, /* blist_node_menu */
+#if GGP_ENABLE_GG11
ggp_chat_info, /* chat_info */
ggp_chat_info_defaults, /* chat_info_defaults */
+#else
+ NULL, NULL,
+#endif
ggp_login, /* login */
ggp_close, /* close */
ggp_message_send_im, /* send_im */
@@ -960,6 +986,7 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* rem_permit */
ggp_rem_deny, /* rem_deny */
NULL, /* set_permit_deny */
+#if GGP_ENABLE_GG11
ggp_chat_join, /* join_chat */
NULL, /* TODO */ /* reject_chat */
ggp_chat_get_name, /* get_chat_name */
@@ -967,6 +994,9 @@ static PurplePluginProtocolInfo prpl_inf
ggp_chat_leave, /* chat_leave */
NULL, /* chat_whisper */
ggp_chat_send, /* chat_send */
+#else
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+#endif
ggp_keepalive, /* keepalive */
ggp_account_register, /* register_user */
NULL, /* get_cb_info */
@@ -981,7 +1011,11 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* get_cb_real_name */
NULL, /* set_chat_topic */
NULL, /* find_blist_chat */
+#if GGP_ENABLE_GG11
ggp_chat_roomlist_get_list, /* roomlist_get_list */
+#else
+ NULL,
+#endif
NULL, /* roomlist_cancel */
NULL, /* roomlist_expand_category */
ggp_edisc_xfer_can_receive_file,/* can_receive_file */
diff --git a/libpurple/protocols/gg/gg.h b/libpurple/protocols/gg/gg.h
--- a/libpurple/protocols/gg/gg.h
+++ b/libpurple/protocols/gg/gg.h
@@ -24,6 +24,9 @@
#ifndef _PURPLE_GG_H
#define _PURPLE_GG_H
+#define GGP_UIN_LEN_MAX 10
+#define GGP_ENABLE_GG11 0
+
#include <libgadu.h>
#include "internal.h"
#include "search.h"
@@ -39,8 +42,6 @@
#include "message-prpl.h"
#include "edisc.h"
-#define GGP_UIN_LEN_MAX 10
-
typedef struct {
struct gg_session *session;
guint inpa;
diff --git a/libpurple/protocols/gg/libgadu-events.c b/libpurple/protocols/gg/libgadu-events.c
--- a/libpurple/protocols/gg/libgadu-events.c
+++ b/libpurple/protocols/gg/libgadu-events.c
@@ -83,6 +83,7 @@ void ggp_events_user_data(PurpleConnecti
}
}
+#if GGP_ENABLE_GG11
static void ggp_events_new_version(const gchar *data)
{
/* data = {"severity":"download"} */
@@ -124,3 +125,4 @@ void ggp_events_json(PurpleConnection *g
purple_debug_warning("gg", "ggp_events_json: "
"unhandled event \"%s\"\n", ev->type);
}
+#endif
diff --git a/libpurple/protocols/gg/libgadu-events.h b/libpurple/protocols/gg/libgadu-events.h
--- a/libpurple/protocols/gg/libgadu-events.h
+++ b/libpurple/protocols/gg/libgadu-events.h
@@ -33,9 +33,13 @@
#include <internal.h>
#include <libgadu.h>
+#include "gg.h"
+
void ggp_events_user_data(PurpleConnection *gc,
struct gg_event_user_data *data);
+#if GGP_ENABLE_GG11
void ggp_events_json(PurpleConnection *gc, struct gg_event_json_event *ev);
+#endif
#endif /* _GGP_LIBGADU_EVENTS_H */
diff --git a/libpurple/protocols/gg/libgaduw.c b/libpurple/protocols/gg/libgaduw.c
--- a/libpurple/protocols/gg/libgaduw.c
+++ b/libpurple/protocols/gg/libgaduw.c
@@ -72,8 +72,11 @@ static void ggp_libgaduw_debug_handler(i
char *msg;
if ((level & GG_DEBUG_NET) ||
- (level & GG_DEBUG_FUNCTION) ||
- (level & GG_DEBUG_VERBOSE)) {
+ (level & GG_DEBUG_FUNCTION)
+#if GGP_ENABLE_GG11
+ || (level & GG_DEBUG_VERBOSE)
+#endif
+ ) {
if (!purple_debug_is_verbose())
return;
}
@@ -86,11 +89,13 @@ static void ggp_libgaduw_debug_handler(i
msg = g_strdup_vprintf(format, args);
+#if GGP_ENABLE_GG11
if (level & GG_DEBUG_ERROR)
purple_level = PURPLE_DEBUG_ERROR;
else if (level & GG_DEBUG_WARNING)
purple_level = PURPLE_DEBUG_WARNING;
else
+#endif
purple_level = PURPLE_DEBUG_MISC;
purple_debug(purple_level, "gg", "%s", msg);
diff --git a/libpurple/protocols/gg/message-prpl.c b/libpurple/protocols/gg/message-prpl.c
--- a/libpurple/protocols/gg/message-prpl.c
+++ b/libpurple/protocols/gg/message-prpl.c
More information about the Commits
mailing list