pidgin: 4f4eeff7: Convert jabber prpl to use accessor func...
andrew.victor at mxit.com
andrew.victor at mxit.com
Tue Aug 30 18:26:24 EDT 2011
----------------------------------------------------------------------
Revision: 4f4eeff73259808faef1d91db262ed3d2d67b508
Parent: b8478e7e4b5b23e993200435bc3381a77d0ef30e
Author: andrew.victor at mxit.com
Date: 08/30/11 15:11:26
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4f4eeff73259808faef1d91db262ed3d2d67b508
Changelog:
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Changes against parent b8478e7e4b5b23e993200435bc3381a77d0ef30e
patched libpurple/protocols/jabber/adhoccommands.c
patched libpurple/protocols/jabber/buddy.c
patched libpurple/protocols/jabber/caps.c
patched libpurple/protocols/jabber/chat.c
patched libpurple/protocols/jabber/jabber.c
patched libpurple/protocols/jabber/jutil.c
patched libpurple/protocols/jabber/message.c
patched libpurple/protocols/jabber/presence.c
patched libpurple/protocols/jabber/roster.c
patched libpurple/protocols/jabber/si.c
patched libpurple/protocols/jabber/usertune.c
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 1273648d9cc2187cae93e7b66a7aad403236d818
+++ libpurple/protocols/jabber/jabber.c aa22aa1a5a26946b75f27bc4c539d62ee8013345
@@ -616,7 +616,7 @@ static gboolean jabber_keepalive_timeout
static gboolean jabber_keepalive_timeout(PurpleConnection *gc)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("Ping timed out"));
js->keepalive_timeout = 0;
@@ -642,7 +642,7 @@ jabber_recv_cb_ssl(gpointer data, Purple
PurpleInputCondition cond)
{
PurpleConnection *gc = data;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
int len;
static char buf[4096];
@@ -747,7 +747,7 @@ jabber_login_callback_ssl(gpointer data,
g_return_if_reached();
}
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
if(js->state == JABBER_STREAM_CONNECTING)
jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
@@ -842,7 +842,7 @@ jabber_ssl_connect_failure(PurpleSslConn
/* If the connection is already disconnected, we don't need to do anything else */
g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
js->gsc = NULL;
purple_connection_ssl_error (gc, error);
@@ -928,7 +928,8 @@ jabber_stream_new(PurpleAccount *account
gchar *user;
gchar *slash;
- js = gc->proto_data = g_new0(JabberStream, 1);
+ js = g_new0(JabberStream, 1);
+ purple_connection_set_protocol_data(gc, js);
js->gc = gc;
js->fd = -1;
@@ -1559,14 +1560,14 @@ void jabber_unregister_account(PurpleAcc
if(gc->state != PURPLE_CONNECTED) {
if(gc->state != PURPLE_CONNECTING)
jabber_login(account);
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
js->unregistration = TRUE;
js->unregistration_cb = cb;
js->unregistration_user_data = user_data;
return;
}
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
if (js->unregistration) {
purple_debug_error("jabber", "Unregistration in process; ignoring duplicate request.\n");
@@ -1726,7 +1727,7 @@ void jabber_close(PurpleConnection *gc)
g_free(js);
- gc->proto_data = NULL;
+ purple_connection_set_protocol_data(gc, NULL);
}
void jabber_stream_set_state(JabberStream *js, JabberStreamState state)
@@ -1780,7 +1781,7 @@ void jabber_idle_set(PurpleConnection *g
void jabber_idle_set(PurpleConnection *gc, int idle)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
js->idle = idle ? time(NULL) - idle : idle;
@@ -2133,7 +2134,7 @@ const char* jabber_list_emblem(PurpleBud
if(!gc)
return NULL;
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
if(js)
jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
@@ -2174,8 +2175,8 @@ char *jabber_status_text(PurpleBuddy *b)
PurpleAccount *account = purple_buddy_get_account(b);
PurpleConnection *gc = purple_account_get_connection(account);
- if (gc && gc->proto_data)
- jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
+ if (gc && purple_connection_get_protocol_data(gc))
+ jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), purple_buddy_get_name(b), FALSE);
if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
ret = g_strdup(_("Not Authorized"));
@@ -2250,6 +2251,7 @@ void jabber_tooltip_text(PurpleBuddy *b,
JabberBuddy *jb;
PurpleAccount *account;
PurpleConnection *gc;
+ JabberStream *js;
g_return_if_fail(b != NULL);
@@ -2258,10 +2260,12 @@ void jabber_tooltip_text(PurpleBuddy *b,
gc = purple_account_get_connection(account);
g_return_if_fail(gc != NULL);
- g_return_if_fail(gc->proto_data != NULL);
- jb = jabber_buddy_find(gc->proto_data, purple_buddy_get_name(b), FALSE);
+ js = purple_connection_get_protocol_data(gc);
+ g_return_if_fail(js != NULL);
+ jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE);
+
if(jb) {
JabberBuddyResource *jbr = NULL;
PurplePresence *presence = purple_buddy_get_presence(b);
@@ -2531,7 +2535,7 @@ static void jabber_password_change(Purpl
{
PurpleConnection *gc = (PurpleConnection *) action->context;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
PurpleRequestFields *fields;
PurpleRequestFieldGroup *group;
PurpleRequestField *field;
@@ -2563,7 +2567,7 @@ GList *jabber_actions(PurplePlugin *plug
GList *jabber_actions(PurplePlugin *plugin, gpointer context)
{
PurpleConnection *gc = (PurpleConnection *) context;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
GList *m = NULL;
PurplePluginAction *act;
@@ -2634,7 +2638,7 @@ void jabber_convo_closed(PurpleConnectio
void jabber_convo_closed(PurpleConnection *gc, const char *who)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberID *jid;
JabberBuddy *jb;
JabberBuddyResource *jbr;
@@ -3159,7 +3163,7 @@ static PurpleCmdRet jabber_cmd_buzz(Purp
static PurpleCmdRet jabber_cmd_buzz(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberStream *js = conv->account->gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(conv->account->gc);
const gchar *who;
gchar *description;
PurpleBuddy *buddy;
@@ -3206,7 +3210,7 @@ gboolean jabber_send_attention(PurpleCon
gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
gchar *error = NULL;
if (!_jabber_send_buzz(js, username, &error)) {
@@ -3289,8 +3293,8 @@ jabber_initiate_media(PurpleAccount *acc
PurpleMediaSessionType type)
{
#ifdef USE_VV
- JabberStream *js = (JabberStream *)
- purple_account_get_connection(account)->proto_data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberBuddy *jb;
JabberBuddyResource *jbr = NULL;
char *resource;
@@ -3301,7 +3305,6 @@ jabber_initiate_media(PurpleAccount *acc
return FALSE;
}
-
if((resource = jabber_get_resource(who)) != NULL) {
/* they've specified a resource, no need to ask or
* default or anything, just do it */
@@ -3432,8 +3435,8 @@ PurpleMediaCaps jabber_get_media_caps(Pu
PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who)
{
#ifdef USE_VV
- JabberStream *js = (JabberStream *)
- purple_account_get_connection(account)->proto_data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberBuddy *jb;
JabberBuddyResource *jbr;
PurpleMediaCaps total = PURPLE_MEDIA_CAPS_NONE;
@@ -3521,7 +3524,7 @@ gboolean jabber_can_receive_file(PurpleC
gboolean jabber_can_receive_file(PurpleConnection *gc, const char *who)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
if (js) {
JabberBuddy *jb = jabber_buddy_find(js, who, FALSE);
@@ -3571,7 +3574,7 @@ jabber_cmd_mood(PurpleConversation *conv
jabber_cmd_mood(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- JabberStream *js = conv->account->gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(conv->account->gc);
if (js->pep) {
/* if no argument was given, unset mood */
@@ -3755,7 +3758,7 @@ jabber_ipc_contact_has_feature(PurpleAcc
if (!purple_account_is_connected(account))
return FALSE;
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
if (!(resource = jabber_get_resource(jid)) ||
!(jb = jabber_buddy_find(js, jid, FALSE)) ||
============================================================
--- libpurple/protocols/jabber/jutil.c 9fc4123aa40107476fdf19d2066be9592bd4c532
+++ libpurple/protocols/jabber/jutil.c fb2f14727f8fb8c945f41c8faa6ee1bd6447f0fa
@@ -583,11 +583,16 @@ const char *jabber_normalize(const Purpl
const char *jabber_normalize(const PurpleAccount *account, const char *in)
{
- PurpleConnection *gc = account ? account->gc : NULL;
- JabberStream *js = gc ? gc->proto_data : NULL;
+ PurpleConnection *gc = NULL;
+ JabberStream *js = NULL;
static char buf[3072]; /* maximum legal length of a jabber jid */
JabberID *jid;
+ if (account)
+ gc = purple_account_get_connection(account);
+ if (gc)
+ js = purple_connection_get_protocol_data(gc);
+
jid = jabber_id_new_internal(in, TRUE);
if(!jid)
return NULL;
============================================================
--- libpurple/protocols/jabber/buddy.c 192ff18e3fa0f353cc38303aa5c97bd81041d5bc
+++ libpurple/protocols/jabber/buddy.c 2c5ddbe26c173291d392387a3515a024d6bc552d
@@ -557,7 +557,7 @@ void jabber_set_buddy_icon(PurpleConnect
PurpleAccount *account = purple_connection_get_account(gc);
/* Publish the avatar as specified in XEP-0084 */
- jabber_avatar_set(gc->proto_data, img);
+ jabber_avatar_set(purple_connection_get_protocol_data(gc), img);
/* Set the image in our vCard */
jabber_set_info(gc, purple_account_get_user_info(account));
============================================================
--- libpurple/protocols/jabber/chat.c 995b5ae99f912a4cdb222c7fe541b1607406410f
+++ libpurple/protocols/jabber/chat.c 4c815064086009aa2452714e65230db5316d5181
@@ -70,7 +70,7 @@ GHashTable *jabber_chat_info_defaults(Pu
GHashTable *jabber_chat_info_defaults(PurpleConnection *gc, const char *chat_name)
{
GHashTable *defaults;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
@@ -146,7 +146,7 @@ JabberChat *jabber_chat_find_by_conv(Pur
int id;
if (!gc)
return NULL;
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));
return jabber_chat_find_by_id(js, id);
}
@@ -154,7 +154,7 @@ void jabber_chat_invite(PurpleConnection
void jabber_chat_invite(PurpleConnection *gc, int id, const char *msg,
const char *name)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberChat *chat;
xmlnode *message, *body, *x, *invite;
char *room_jid;
@@ -360,7 +360,7 @@ void jabber_chat_join(PurpleConnection *
{
char *room, *server, *handle, *passwd;
JabberID *jid;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
char *tmp;
room = g_hash_table_lookup(data, "room");
@@ -418,10 +418,9 @@ void jabber_chat_leave(PurpleConnection
void jabber_chat_leave(PurpleConnection *gc, int id)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberChat *chat = jabber_chat_find_by_id(js, id);
-
if(!chat)
return;
@@ -459,7 +458,7 @@ char *jabber_chat_buddy_real_name(Purple
char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberChat *chat;
JabberChatMember *jcm;
@@ -893,7 +892,7 @@ PurpleRoomlist *jabber_roomlist_get_list
PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
GList *fields = NULL;
PurpleRoomlistField *f;
@@ -934,7 +933,7 @@ void jabber_roomlist_cancel(PurpleRoomli
account = purple_roomlist_get_account(list);
gc = purple_account_get_connection(account);
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
purple_roomlist_set_in_progress(list, FALSE);
============================================================
--- libpurple/protocols/jabber/message.c 56cb48ae5198a3d7b0180dd2a2facf6999ed83c5
+++ libpurple/protocols/jabber/message.c 9c7fb4598c328e353013cb7d5a2077b8df154e3b
@@ -1148,13 +1148,13 @@ int jabber_message_send_im(PurpleConnect
resource = jabber_get_resource(who);
- jb = jabber_buddy_find(gc->proto_data, who, TRUE);
+ jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), who, TRUE);
jbr = jabber_buddy_find_resource(jb, resource);
g_free(resource);
jm = g_new0(JabberMessage, 1);
- jm->js = gc->proto_data;
+ jm->js = purple_connection_get_protocol_data(gc);
jm->type = JABBER_MESSAGE_CHAT;
jm->chat_state = JM_STATE_ACTIVE;
jm->to = g_strdup(who);
@@ -1211,14 +1211,14 @@ int jabber_message_send_chat(PurpleConne
if(!msg || !gc)
return 0;
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
chat = jabber_chat_find_by_id(js, id);
if(!chat)
return 0;
jm = g_new0(JabberMessage, 1);
- jm->js = gc->proto_data;
+ jm->js = purple_connection_get_protocol_data(gc);
jm->type = JABBER_MESSAGE_GROUPCHAT;
jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
jm->id = jabber_get_next_id(jm->js);
============================================================
--- libpurple/protocols/jabber/presence.c 0754e42d7bd0daabb0eb5b38f19860d3fac7865d
+++ libpurple/protocols/jabber/presence.c f648991d384e65ea6a2f1e8232ccc580c1dc9cdb
@@ -393,7 +393,7 @@ static void authorize_add_cb(gpointer da
{
struct _jabber_add_permit *jap = data;
if(PURPLE_CONNECTION_IS_VALID(jap->gc))
- jabber_presence_subscription_set(jap->gc->proto_data,
+ jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc),
jap->who, "subscribed");
g_free(jap->who);
g_free(jap);
@@ -403,7 +403,7 @@ static void deny_add_cb(gpointer data)
{
struct _jabber_add_permit *jap = data;
if(PURPLE_CONNECTION_IS_VALID(jap->gc))
- jabber_presence_subscription_set(jap->gc->proto_data,
+ jabber_presence_subscription_set(purple_connection_get_protocol_data(jap->gc),
jap->who, "unsubscribed");
g_free(jap->who);
g_free(jap);
============================================================
--- libpurple/protocols/jabber/roster.c 35bdcb53d9cfc3e3f89ccfead5dc6dcfc707aeda
+++ libpurple/protocols/jabber/roster.c abd09ae9dec3654a629197ef9ac431f243506642
@@ -360,7 +360,7 @@ void jabber_roster_add_buddy(PurpleConne
void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
PurpleGroup *group)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
char *who;
JabberID *jid;
JabberBuddy *jb;
@@ -431,7 +431,7 @@ void jabber_roster_alias_change(PurpleCo
purple_debug_info("jabber", "jabber_roster_alias_change(): Aliased %s to %s\n",
name, alias ? alias : "(null)");
- jabber_roster_update(gc->proto_data, name, NULL);
+ jabber_roster_update(purple_connection_get_protocol_data(gc), name, NULL);
}
}
@@ -461,7 +461,7 @@ void jabber_roster_group_change(PurpleCo
purple_debug_info("jabber", "jabber_roster_group_change(): Moving %s from %s to %s\n",
name, old_group, new_group);
- jabber_roster_update(gc->proto_data, name, groups);
+ jabber_roster_update(purple_connection_get_protocol_data(gc), name, groups);
}
void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name,
@@ -496,9 +496,9 @@ void jabber_roster_remove_buddy(PurpleCo
purple_debug_info("jabber", "jabber_roster_remove_buddy(): Removing %s from %s\n",
purple_buddy_get_name(buddy), purple_group_get_name(group));
- jabber_roster_update(gc->proto_data, name, groups);
+ jabber_roster_update(purple_connection_get_protocol_data(gc), name, groups);
} else {
- JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET,
+ JabberIq *iq = jabber_iq_new_query(purple_connection_get_protocol_data(gc), JABBER_IQ_SET,
"jabber:iq:roster");
xmlnode *query = xmlnode_get_child(iq->node, "query");
xmlnode *item = xmlnode_new_child(query, "item");
============================================================
--- libpurple/protocols/jabber/si.c b3d04501f5dd2fc6e237f90bb86b846b154e61cf
+++ libpurple/protocols/jabber/si.c 8ca38c55fd30eb95e7bb64fe2c45a5ae74dfae3d
@@ -1615,7 +1615,7 @@ PurpleXfer *jabber_si_new_xfer(PurpleCon
PurpleXfer *xfer;
JabberSIXfer *jsx;
- js = gc->proto_data;
+ js = purple_connection_get_protocol_data(gc);
xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
if (xfer)
============================================================
--- libpurple/protocols/jabber/usertune.c b04883371a7f0df857c74d4ad4992a04472ad2ee
+++ libpurple/protocols/jabber/usertune.c 1029198d93a16464bfac2880c822433eeede1868
@@ -117,7 +117,7 @@ void jabber_tune_set(PurpleConnection *g
void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo) {
xmlnode *publish, *tunenode;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
publish = xmlnode_new("publish");
xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/tune");
============================================================
--- libpurple/protocols/jabber/adhoccommands.c 8bd27c2dc8d608e56b0855281ccb40fae88a13f5
+++ libpurple/protocols/jabber/adhoccommands.c f0e2c0d54cc2898a57b0d885cb89661120ac7997
@@ -228,7 +228,8 @@ void jabber_adhoc_execute_action(PurpleB
JabberAdHocCommands *cmd = data;
PurpleBuddy *buddy = (PurpleBuddy *) node;
PurpleAccount *account = purple_buddy_get_account(buddy);
- JabberStream *js = purple_account_get_connection(account)->proto_data;
+ PurpleConnection *gc = purple_account_get_connection(account);
+ JabberStream *js = purple_connection_get_protocol_data(gc);
jabber_adhoc_execute(js, cmd);
}
@@ -321,7 +322,7 @@ static void jabber_adhoc_server_execute(
JabberAdHocCommands *cmd = action->user_data;
if(cmd) {
PurpleConnection *gc = (PurpleConnection *) action->context;
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
jabber_adhoc_execute(js, cmd);
}
============================================================
--- libpurple/protocols/jabber/caps.c 6621a1aa9502eb19a737a7df1576fa81bea6d02b
+++ libpurple/protocols/jabber/caps.c 441ddbc88ecf5229d8f75e1ea088e1ecc655a9bc
@@ -958,7 +958,7 @@ void jabber_caps_broadcast_change()
const char *prpl_id = purple_account_get_protocol_id(account);
if (g_str_equal("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
PurpleConnection *gc = purple_account_get_connection(account);
- jabber_presence_send(gc->proto_data, TRUE);
+ jabber_presence_send(purple_connection_get_protocol_data(gc), TRUE);
}
}
More information about the Commits
mailing list