cpw.darkrain42.xmpp.iq-handlers: 3cd4018e: Convert all the XMPP IQ callbacks to a t...

paul at darkrain42.org paul at darkrain42.org
Sun Mar 22 23:10:46 EDT 2009


-----------------------------------------------------------------
Revision: 3cd4018e77e0ed680e9ff810136923604c31ecf0
Ancestor: 86f85692a27dc8f702b16ebcf8fa31e5f6200de8
Author: paul at darkrain42.org
Date: 2009-03-13T02:26:45
Branch: im.pidgin.cpw.darkrain42.xmpp.iq-handlers
URL: http://d.pidgin.im/viewmtn/revision/info/3cd4018e77e0ed680e9ff810136923604c31ecf0

Modified files:
        libpurple/protocols/jabber/adhoccommands.c
        libpurple/protocols/jabber/adhoccommands.h
        libpurple/protocols/jabber/auth.c
        libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/chat.c
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/google.c
        libpurple/protocols/jabber/ibb.c
        libpurple/protocols/jabber/iq.c
        libpurple/protocols/jabber/iq.h
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/message.c
        libpurple/protocols/jabber/pep.c
        libpurple/protocols/jabber/ping.c
        libpurple/protocols/jabber/presence.c
        libpurple/protocols/jabber/si.c

ChangeLog: 

Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/adhoccommands.c	420b1f707723c1fbecdbbd8a4e0e0082fa1c146f
+++ libpurple/protocols/jabber/adhoccommands.c	855252c767e3b29b5e7ebadb7f56398df6fb57b7
@@ -39,16 +39,17 @@ typedef struct _JabberAdHocActionInfo {
 	GList *actionslist;
 } JabberAdHocActionInfo;
 
-void jabber_adhoc_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data) {
-	const char *from = xmlnode_get_attrib(packet, "from");
-	const char *type = xmlnode_get_attrib(packet, "type");
+void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data)
+{
 	const char *node;
 	xmlnode *query, *item;
 	JabberID *jabberid;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr = NULL;
 
-	if(strcmp(type, "result"))
+	if (type == JABBER_IQ_ERROR)
 		return;
 
 	query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items");
@@ -95,8 +96,11 @@ void jabber_adhoc_disco_result_cb(Jabber
 	}
 }
 
-static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data);
+static void jabber_adhoc_parse(JabberStream *js, const char *from,
+                               JabberIqType type, const char *id,
+                               xmlnode *packet, gpointer data);
 
+
 static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data) {
 	xmlnode *command;
 	GList *action;
@@ -131,13 +135,16 @@ static void do_adhoc_action_cb(JabberStr
 	jabber_iq_send(iq);
 }
 
-static void jabber_adhoc_parse(JabberStream *js, xmlnode *packet, gpointer data) {
+static void
+jabber_adhoc_parse(JabberStream *js, const char *from,
+                   JabberIqType type, const char *id,
+                   xmlnode *packet, gpointer data)
+{
 	xmlnode *command = xmlnode_get_child_with_namespace(packet, "command", "http://jabber.org/protocol/commands");
 	const char *status = xmlnode_get_attrib(command,"status");
 	xmlnode *xdata = xmlnode_get_child_with_namespace(command,"x","jabber:x:data");
-	const char *type = xmlnode_get_attrib(packet,"type");
 
-	if(type && !strcmp(type,"error")) {
+	if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 		if(!msg)
 			msg = g_strdup(_("Unknown Error"));
@@ -147,8 +154,6 @@ static void jabber_adhoc_parse(JabberStr
 		g_free(msg);
 		return;
 	}
-	if(!type || strcmp(type,"result"))
-		return;
 
 	if(!status)
 		return;
@@ -159,7 +164,7 @@ static void jabber_adhoc_parse(JabberStr
 
 		if(note) {
 			char *data = xmlnode_get_data(note);
-			purple_notify_info(NULL, xmlnode_get_attrib(packet, "from"), data, NULL);
+			purple_notify_info(NULL, from, data, NULL);
 			g_free(data);
 		}
 
@@ -199,7 +204,7 @@ static void jabber_adhoc_parse(JabberStr
 
 		actionInfo = g_new0(JabberAdHocActionInfo, 1);
 		actionInfo->sessionid = g_strdup(xmlnode_get_attrib(command,"sessionid"));
-		actionInfo->who = g_strdup(xmlnode_get_attrib(packet,"from"));
+		actionInfo->who = g_strdup(from);
 		actionInfo->node = g_strdup(xmlnode_get_attrib(command,"node"));
 		actionInfo->actionslist = actionslist;
 
@@ -218,7 +223,11 @@ void jabber_adhoc_execute_action(PurpleB
 	}
 }
 
-static void jabber_adhoc_server_got_list_cb(JabberStream *js, xmlnode *packet, gpointer data) {
+static void
+jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data)
+{
 	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items");
 	xmlnode *item;
 
============================================================
--- libpurple/protocols/jabber/adhoccommands.h	cda1dd59a60bf379de0b84dfb7a838f1bc505afa
+++ libpurple/protocols/jabber/adhoccommands.h	c882e33aefc07804fbcd0d9b735517cfcbd5d360
@@ -26,7 +26,9 @@
 
 /* Implementation of XEP-0050 */
 
-void jabber_adhoc_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data);
+void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data);
 
 void jabber_adhoc_execute(JabberStream *js, JabberAdHocCommands *cmd);
 
============================================================
--- libpurple/protocols/jabber/auth.c	a7b6afb6a1dad1308124d7caf95a6d6765e866ec
+++ libpurple/protocols/jabber/auth.c	6e754b3f8a6035331a777e9fce85153de2681561
@@ -36,8 +36,9 @@
 #include "iq.h"
 #include "notify.h"
 
-static void auth_old_result_cb(JabberStream *js, xmlnode *packet,
-		gpointer data);
+static void auth_old_result_cb(JabberStream *js, const char *from,
+                               JabberIqType type, const char *id,
+                               xmlnode *packet, gpointer data);
 
 gboolean
 jabber_process_starttls(JabberStream *js, xmlnode *packet)
@@ -566,11 +567,11 @@ jabber_auth_start(JabberStream *js, xmln
 #endif
 }
 
-static void auth_old_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void auth_old_result_cb(JabberStream *js, const char *from,
+                               JabberIqType type, const char *id,
+                               xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
-
-	if(type && !strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
 	} else {
 		PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
@@ -593,24 +594,20 @@ static void auth_old_result_cb(JabberStr
 	}
 }
 
-static void auth_old_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void auth_old_cb(JabberStream *js, const char *from,
+                        JabberIqType type, const char *id,
+                        xmlnode *packet, gpointer data)
 {
 	JabberIq *iq;
 	xmlnode *query, *x;
-	const char *type = xmlnode_get_attrib(packet, "type");
 	const char *pw = purple_connection_get_password(js->gc);
 
-	if(!type) {
-		purple_connection_error_reason (js->gc,
-			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
-			_("Invalid response from server."));
-		return;
-	} else if(!strcmp(type, "error")) {
+	if (type == JABBER_IQ_ERROR) {
 		PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 		char *msg = jabber_parse_error(js, packet, &reason);
 		purple_connection_error_reason (js->gc, reason, msg);
 		g_free(msg);
-	} else if(!strcmp(type, "result")) {
+	} else if (type == JABBER_IQ_RESULT) {
 		query = xmlnode_get_child(packet, "query");
 		if(js->stream_id && xmlnode_get_child(query, "digest")) {
 			char *s, *hash;
============================================================
--- libpurple/protocols/jabber/buddy.c	8ed82dcf52bd1dc5cb19fd51ba16907b01bccf4c
+++ libpurple/protocols/jabber/buddy.c	2725aa5f83203d5e70e9bf3a4ce437085ad0953f
@@ -1187,12 +1187,19 @@ static void jabber_buddy_info_remove_id(
 	}
 }
 
-static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_vcard_save_mine(JabberStream *js, const char *from,
+                                   JabberIqType type, const char *id,
+                                   xmlnode *packet, gpointer data)
 {
 	xmlnode *vcard;
 	char *txt;
 	PurpleStoredImage *img;
 
+	if (type == JABBER_IQ_ERROR) {
+		purple_debug_warning("jabber", "Server returned error while retrieving vCard");
+		return;
+	}
+
 	if((vcard = xmlnode_get_child(packet, "vCard")) ||
 			(vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp")))
 	{
@@ -1223,9 +1230,10 @@ void jabber_vcard_fetch_mine(JabberStrea
 	jabber_iq_send(iq);
 }
 
-static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_vcard_parse(JabberStream *js, const char *from,
+                               JabberIqType type, const char *id,
+                               xmlnode *packet, gpointer data)
 {
-	const char *id, *from;
 	char *bare_jid;
 	char *text;
 	char *serverside_alias = NULL;
@@ -1234,9 +1242,6 @@ static void jabber_vcard_parse(JabberStr
 	JabberBuddyInfo *jbi = data;
 	PurpleNotifyUserInfo *user_info;
 
-	from = xmlnode_get_attrib(packet, "from");
-	id = xmlnode_get_attrib(packet, "id");
-
 	if(!jbi)
 		return;
 
@@ -1586,19 +1591,16 @@ static void jabber_buddy_info_resource_f
 	g_free(jbri);
 }
 
-static void jabber_version_parse(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_version_parse(JabberStream *js, const char *from,
+                                 JabberIqType type, const char *id,
+                                 xmlnode *packet, gpointer data)
 {
 	JabberBuddyInfo *jbi = data;
-	const char *type, *id, *from;
 	xmlnode *query;
 	char *resource_name;
 
 	g_return_if_fail(jbi != NULL);
 
-	type = xmlnode_get_attrib(packet, "type");
-	id = xmlnode_get_attrib(packet, "id");
-	from = xmlnode_get_attrib(packet, "from");
-
 	jabber_buddy_info_remove_id(jbi, id);
 
 	if(!from)
@@ -1607,7 +1609,7 @@ static void jabber_version_parse(JabberS
 	resource_name = jabber_get_resource(from);
 
 	if(resource_name) {
-		if(type && !strcmp(type, "result")) {
+		if (type == JABBER_IQ_RESULT) {
 			if((query = xmlnode_get_child(packet, "query"))) {
 				JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
 				if(jbr) {
@@ -1630,19 +1632,17 @@ static void jabber_version_parse(JabberS
 	jabber_buddy_info_show_if_ready(jbi);
 }
 
-static void jabber_last_parse(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_last_parse(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *packet, gpointer data)
 {
 	JabberBuddyInfo *jbi = data;
 	xmlnode *query;
 	char *resource_name;
-	const char *type, *id, *from, *seconds;
+	const char *seconds;
 
 	g_return_if_fail(jbi != NULL);
 
-	type = xmlnode_get_attrib(packet, "type");
-	id = xmlnode_get_attrib(packet, "id");
-	from = xmlnode_get_attrib(packet, "from");
-
 	jabber_buddy_info_remove_id(jbi, id);
 
 	if(!from)
@@ -1651,7 +1651,7 @@ static void jabber_last_parse(JabberStre
 	resource_name = jabber_get_resource(from);
 
 	if(resource_name) {
-		if(type && !strcmp(type, "result")) {
+		if (type == JABBER_IQ_RESULT) {
 			if((query = xmlnode_get_child(packet, "query"))) {
 				seconds = xmlnode_get_attrib(query, "seconds");
 				if(seconds) {
@@ -1672,19 +1672,16 @@ static void jabber_last_parse(JabberStre
 	jabber_buddy_info_show_if_ready(jbi);
 }
 
-static void jabber_time_parse(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_time_parse(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *packet, gpointer data)
 {
 	JabberBuddyInfo *jbi = data;
 	JabberBuddyResource *jbr;
 	char *resource_name;
-	const char *type, *id, *from;
 
 	g_return_if_fail(jbi != NULL);
 
-	id = xmlnode_get_attrib(packet, "id");
-	type = xmlnode_get_attrib(packet, "type");
-	from = xmlnode_get_attrib(packet, "from");
-
 	jabber_buddy_info_remove_id(jbi, id);
 
 	if (!from)
@@ -1694,7 +1691,7 @@ static void jabber_time_parse(JabberStre
 	jbr = resource_name ? jabber_buddy_find_resource(jbi->jb, resource_name) : NULL;
 	g_free(resource_name);
 	if (jbr) {
-		if (type && !strcmp(type, "result")) {
+		if (type == JABBER_IQ_RESULT) {
 			xmlnode *time = xmlnode_get_child(packet, "time");
 			xmlnode *tzo = time ? xmlnode_get_child(time, "tzo") : NULL;
 			char *tzo_data = tzo ? xmlnode_get_data(tzo) : NULL;
@@ -2265,7 +2262,9 @@ static void user_search_result_add_buddy
 			g_list_nth_data(row, 0), NULL, NULL);
 }
 
-static void user_search_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void user_search_result_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data)
 {
 	PurpleNotifySearchResults *results;
 	PurpleNotifySearchColumn *column;
@@ -2461,15 +2460,16 @@ static const char * jabber_user_dir_comm
 };
 #endif
 
-static void user_search_fields_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void user_search_fields_result_cb(JabberStream *js, const char *from,
+                                         JabberIqType type, const char *id,
+                                         xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *x;
-	const char *from, *type;
 
-	if(!(from = xmlnode_get_attrib(packet, "from")))
+	if (!from)
 		return;
 
-	if(!(type = xmlnode_get_attrib(packet, "type")) || !strcmp(type, "error")) {
+	if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 
 		if(!msg)
============================================================
--- libpurple/protocols/jabber/caps.c	659b7a59b80d43d38a590102053b466e3b28e159
+++ libpurple/protocols/jabber/caps.c	5c698bef0f27f3f2f980c8ed21354175d080409b
@@ -369,7 +369,10 @@ static void jabber_caps_get_info_check_c
 	}
 }
 
-static void jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data) {
+static void jabber_caps_ext_iqcb(JabberStream *js, const char *from,
+                                 JabberIqType type, const char *id,
+                                 xmlnode *packet, gpointer data)
+{
 	/* collect data and fetch all exts */
 	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#info");
 	jabber_ext_userdata *extuserdata = data;
@@ -433,7 +436,10 @@ static void jabber_caps_ext_iqcb(JabberS
 	jabber_caps_get_info_check_completion(userdata);
 }
 
-static void jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data) {
+static void jabber_caps_client_iqcb(JabberStream *js, const char *from,
+                                    JabberIqType type, const char *id,
+                                    xmlnode *packet, gpointer data)
+{
 	/* collect data and fetch all exts */
 	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
 		"http://jabber.org/protocol/disco#info");
============================================================
--- libpurple/protocols/jabber/chat.c	aff1c7801100a8150225bad780108498affeee7c
+++ libpurple/protocols/jabber/chat.c	c61f9b2656b26a97349feeca261782ccb7457ae8
@@ -376,21 +376,19 @@ static void jabber_chat_room_configure_x
 	jabber_iq_send(iq);
 }
 
-static void jabber_chat_room_configure_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_chat_room_configure_cb(JabberStream *js, const char *from,
+                                          JabberIqType type, const char *id,
+                                          xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *x;
-	const char *type = xmlnode_get_attrib(packet, "type");
-	const char *from = xmlnode_get_attrib(packet, "from");
 	char *msg;
 	JabberChat *chat;
 	JabberID *jid;
 
-	if(!type || !from)
+	if (!from)
 		return;
 
-
-
-	if(!strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		jid = jabber_id_new(from);
 
 		if(!jid)
@@ -416,7 +414,7 @@ static void jabber_chat_room_configure_c
 				return;
 			}
 		}
-	} else if(!strcmp(type, "error")) {
+	} else if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 
 		purple_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg);
@@ -486,11 +484,12 @@ void jabber_chat_create_instant_room(Jab
 	g_free(room_jid);
 }
 
-static void jabber_chat_register_x_data_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void
+jabber_chat_register_x_data_result_cb(JabberStream *js, const char *from,
+                                      JabberIqType type, const char *id,
+                                      xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
-
-	if(type && !strcmp(type, "error")) {
+	if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 
 		purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
@@ -521,19 +520,19 @@ static void jabber_chat_register_x_data_
 	jabber_iq_send(iq);
 }
 
-static void jabber_chat_register_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_chat_register_cb(JabberStream *js, const char *from,
+                                    JabberIqType type, const char *id,
+                                    xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *x;
-	const char *type = xmlnode_get_attrib(packet, "type");
-	const char *from = xmlnode_get_attrib(packet, "from");
 	char *msg;
 	JabberChat *chat;
 	JabberID *jid;
 
-	if(!type || !from)
+	if (!from)
 		return;
 
-	if(!strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		jid = jabber_id_new(from);
 
 		if(!jid)
@@ -559,7 +558,7 @@ static void jabber_chat_register_cb(Jabb
 				return;
 			}
 		}
-	} else if(!strcmp(type, "error")) {
+	} else if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 
 		purple_notify_error(js->gc, _("Registration error"), _("Registration error"), msg);
@@ -690,16 +689,17 @@ void jabber_chat_part(JabberChat *chat, 
 	g_free(room_jid);
 }
 
-static void roomlist_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void roomlist_disco_result_cb(JabberStream *js, const char *from,
+                                     JabberIqType type, const char *id,
+                                     xmlnode *packet, gpointer data)
 {
 	xmlnode *query;
 	xmlnode *item;
-	const char *type;
 
 	if(!js->roomlist)
 		return;
 
-	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
+	if (type == JABBER_IQ_ERROR) {
 		char *err = jabber_parse_error(js, packet, NULL);
 		purple_notify_error(js->gc, _("Error"),
 				_("Error retrieving room list"), err);
@@ -988,13 +988,17 @@ gboolean jabber_chat_kick_user(JabberCha
 	return TRUE;
 }
 
-static void jabber_chat_disco_traffic_cb(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_chat_disco_traffic_cb(JabberStream *js, const char *from,
+                                         JabberIqType type, const char *id,
+                                         xmlnode *packet, gpointer data)
 {
 	JabberChat *chat;
-	/*xmlnode *query;*/
-	int id = GPOINTER_TO_INT(data);
+#if 0
+	xmlnode *query, *x;
+#endif
+	int chat_id = GPOINTER_TO_INT(data);
 
-	if(!(chat = jabber_chat_find_by_id(js, id)))
+	if(!(chat = jabber_chat_find_by_id(js, chat_id)))
 		return;
 
 	/* defaults, in case the conference server doesn't
@@ -1002,8 +1006,9 @@ static void jabber_chat_disco_traffic_cb
 	chat->xhtml = TRUE;
 
 	/* disabling this until more MUC servers support
-	 * announcing this
-	if(xmlnode_get_child(packet, "error")) {
+	 * announcing this */
+#if 0
+	if (type == JABBER_IQ_ERROR) {
 		return;
 	}
 
@@ -1019,7 +1024,7 @@ static void jabber_chat_disco_traffic_cb
 			chat->xhtml = TRUE;
 		}
 	}
-	*/
+#endif
 }
 
 void jabber_chat_disco_traffic(JabberChat *chat)
============================================================
--- libpurple/protocols/jabber/disco.c	ab3f96f317b3097295e45f3ce72403155248dce2
+++ libpurple/protocols/jabber/disco.c	a0abc31436b8422c61b37e08e471dc53971ca030
@@ -45,9 +45,11 @@ static void
 }
 
 static void
-jabber_disco_bytestream_server_cb(JabberStream *js, xmlnode *packet, gpointer data) {
+jabber_disco_bytestream_server_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data)
+{
 	JabberBytestreamsStreamhost *sh = data;
-	const char *from = xmlnode_get_attrib(packet, "from");
 	xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
 		"http://jabber.org/protocol/bytestreams");
 
@@ -384,19 +386,18 @@ static void
 }
 
 static void
-jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_disco_server_info_result_cb(JabberStream *js, const char *from,
+                                   JabberIqType type, const char *id,
+                                   xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *child;
-	const char *from = xmlnode_get_attrib(packet, "from");
-	const char *type = xmlnode_get_attrib(packet, "type");
 
-	if((!from || !type) ||
-	   (strcmp(from, js->user->domain))) {
+	if (!from || strcmp(from, js->user->domain)) {
 		jabber_disco_finish_server_info_result_cb(js);
 		return;
 	}
 
-	if(strcmp(type, "result")) {
+	if (type == JABBER_IQ_ERROR) {
 		/* A common way to get here is for the server not to support xmlns http://jabber.org/protocol/disco#info */
 		jabber_disco_finish_server_info_result_cb(js);
 		return;
@@ -457,21 +458,18 @@ static void
 }
 
 static void
-jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_disco_server_items_result_cb(JabberStream *js, const char *from,
+                                    JabberIqType type, const char *id,
+                                    xmlnode *packet, gpointer data)
 {
 	xmlnode *query, *child;
-	const char *from = xmlnode_get_attrib(packet, "from");
-	const char *type = xmlnode_get_attrib(packet, "type");
 
-	if(!from || !type)
+	if (!from || strcmp(from, js->user->domain) != 0)
 		return;
 
-	if(strcmp(from, js->user->domain))
+	if (type == JABBER_IQ_ERROR)
 		return;
 
-	if(strcmp(type, "result"))
-		return;
-
 	while(js->chat_servers) {
 		g_free(js->chat_servers->data);
 		js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
============================================================
--- libpurple/protocols/jabber/google.c	5ee92bb1287300d655782067fca241df968b424f
+++ libpurple/protocols/jabber/google.c	320c4b8794ad11abacba501096df683a02796ad8
@@ -30,13 +30,13 @@ static void
 #include "iq.h"
 
 static void
-jabber_gmail_parse(JabberStream *js, xmlnode *packet, gpointer nul)
+jabber_gmail_parse(JabberStream *js, const char *from,
+                   JabberIqType type, const char *id,
+                   xmlnode *packet, gpointer nul)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
 	xmlnode *child;
-	xmlnode *message, *sender_node, *subject_node;
-	const char *from, *to, *url, *tid;
-	char *subject;
+	xmlnode *message;
+	const char *to, *url;
 	const char *in_str;
 	char *to_name;
 	char *default_tos[1];
@@ -46,7 +46,7 @@ jabber_gmail_parse(JabberStream *js, xml
 	const char **tos, **froms, **urls;
 	char **subjects;
 
-	if (strcmp(type, "result"))
+	if (type == JABBER_IQ_ERROR)
 		return;
 
 	child = xmlnode_get_child(packet, "mailbox");
@@ -87,6 +87,10 @@ jabber_gmail_parse(JabberStream *js, xml
 
 	message= xmlnode_get_child(child, "mail-thread-info");
 	for (i=0; message; message = xmlnode_get_next_twin(message), i++) {
+		xmlnode *sender_node, *subject_node;
+		const char *from, *tid;
+		char *subject;
+
 		subject_node = xmlnode_get_child(message, "subject");
 		sender_node  = xmlnode_get_child(message, "senders");
 		sender_node  = xmlnode_get_child(sender_node, "sender");
============================================================
--- libpurple/protocols/jabber/ibb.c	154ededf518a249217e348d11844dee18ef27868
+++ libpurple/protocols/jabber/ibb.c	8f8e8be282e9cd727a5a430ec742bc3eae721ac5
@@ -198,11 +198,13 @@ static void
 }
 
 static void
-jabber_ibb_session_opened_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_ibb_session_opened_cb(JabberStream *js, const char *from,
+                             JabberIqType type, const char *id,
+                             xmlnode *packet, gpointer data)
 {
 	JabberIBBSession *sess = (JabberIBBSession *) data;
 
-	if (strcmp(xmlnode_get_attrib(packet, "type"), "error") == 0) {
+	if (type == JABBER_IQ_ERROR) {
 		sess->state = JABBER_IBB_SESSION_ERROR;
 	} else {
 		sess->state = JABBER_IBB_SESSION_OPENED;
@@ -274,10 +276,11 @@ static void
 }
 
 static void
-jabber_ibb_session_send_acknowledge_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_ibb_session_send_acknowledge_cb(JabberStream *js, const char *from,
+                                       JabberIqType type, const char *id,
+                                       xmlnode *packet, gpointer data)
 {
 	JabberIBBSession *sess = (JabberIBBSession *) data;
-	xmlnode *error = xmlnode_get_child(packet, "error");
 
 	if (sess) {
 		/* reset callback */
@@ -286,7 +289,7 @@ jabber_ibb_session_send_acknowledge_cb(J
 			sess->last_iq_id = NULL;
 		}
 
-		if (error) {
+		if (type == JABBER_IQ_ERROR) {
 			jabber_ibb_session_close(sess);
 			sess->state = JABBER_IBB_SESSION_ERROR;
 
============================================================
--- libpurple/protocols/jabber/iq.c	3813ce0326dfc3cea097c1a02da9794d0a97fc99
+++ libpurple/protocols/jabber/iq.c	d502d663162f60a3c79a1ab288b308bca67ac6cb
@@ -354,7 +354,7 @@ void jabber_iq_parse(JabberStream *js, x
 	/* First, lets see if a special callback got registered */
 	if(type == JABBER_IQ_RESULT || type == JABBER_IQ_ERROR) {
 		if((jcd = g_hash_table_lookup(js->iq_callbacks, id))) {
-			jcd->callback(js, packet, jcd->data);
+			jcd->callback(js, from, type, id, packet, jcd->data);
 			jabber_iq_remove_callback_by_id(js, id);
 			return;
 		}
============================================================
--- libpurple/protocols/jabber/iq.h	d2b38aca858a2177f36dc16f3446178a7b041b36
+++ libpurple/protocols/jabber/iq.h	d86e1424452579e501fb15b60f6837ddc2a1763d
@@ -38,7 +38,9 @@ typedef void (JabberIqHandler)(JabberStr
                                JabberIqType type, const char *id,
                                xmlnode *child);
 
-typedef void (JabberIqCallback)(JabberStream *js, xmlnode *packet, gpointer data);
+typedef void (JabberIqCallback)(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data);
 
 struct _JabberIq {
 	JabberIqType type;
============================================================
--- libpurple/protocols/jabber/jabber.c	9645afb2f25ad1c3edcc56419d5df4f77e3091b5
+++ libpurple/protocols/jabber/jabber.c	107ae8ad5e046d6e17107428d6094ebc0e2c67cd
@@ -85,10 +85,11 @@ static void
 }
 
 static void
-jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_session_initialized_cb(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
-	if(type && !strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
 		if(js->unregistration)
 			jabber_unregister_account_cb(js);
@@ -112,13 +113,13 @@ static void jabber_session_init(JabberSt
 	jabber_iq_send(iq);
 }
 
-static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet,
-		gpointer data)
+static void jabber_bind_result_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
 	xmlnode *bind;
 
-	if(type && !strcmp(type, "result") &&
+	if (type == JABBER_IQ_RESULT &&
 			(bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) {
 		xmlnode *jid;
 		char *full_jid;
@@ -785,14 +786,15 @@ static void
 }
 
 static void
-jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_registration_result_cb(JabberStream *js, const char *from,
+                              JabberIqType type, const char *id,
+                              xmlnode *packet, gpointer data)
 {
 	PurpleAccount *account = purple_connection_get_account(js->gc);
-	const char *type = xmlnode_get_attrib(packet, "type");
 	char *buf;
 	char *to = data;
 
-	if(!strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		if(js->registration) {
 		buf = g_strdup_printf(_("Registration of %s@%s successful"),
 				js->user->node, js->user->domain);
@@ -820,13 +822,14 @@ jabber_registration_result_cb(JabberStre
 	}
 	g_free(to);
 	if(js->registration)
-	jabber_connection_schedule_close(js);
+		jabber_connection_schedule_close(js);
 }
 
 static void
-jabber_unregistration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_unregistration_result_cb(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
 	char *buf;
 	char *to = data;
 
@@ -834,7 +837,7 @@ jabber_unregistration_result_cb(JabberSt
 	 * the server, so there should always be a 'to' address. */
 	g_return_if_fail(to != NULL);
 
-	if(!strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		buf = g_strdup_printf(_("Registration from %s successfully removed"),
 							  to);
 		purple_notify_info(NULL, _("Unregistration Successful"),
@@ -1240,10 +1243,14 @@ void jabber_register_account(PurpleAccou
 	}
 }
 
-static void jabber_unregister_account_iq_cb(JabberStream *js, xmlnode *packet, gpointer data) {
+static void
+jabber_unregister_account_iq_cb(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data)
+{
 	PurpleAccount *account = purple_connection_get_account(js->gc);
-	const char *type = xmlnode_get_attrib(packet,"type");
-	if(!strcmp(type,"error")) {
+
+	if (type == JABBER_IQ_ERROR) {
 		char *msg = jabber_parse_error(js, packet, NULL);
 
 		purple_notify_error(js->gc, _("Error unregistering account"),
@@ -1251,7 +1258,7 @@ static void jabber_unregister_account_iq
 		g_free(msg);
 		if(js->unregistration_cb)
 			js->unregistration_cb(account, FALSE, js->unregistration_user_data);
-	} else if(!strcmp(type,"result")) {
+	} else {
 		purple_notify_info(js->gc, _("Account successfully unregistered"),
 						   _("Account successfully unregistered"), NULL);
 		if(js->unregistration_cb)
@@ -1480,7 +1487,9 @@ void jabber_idle_set(PurpleConnection *g
 	js->idle = idle ? time(NULL) - idle : idle;
 }
 
-static void jabber_blocklist_parse(JabberStream *js, xmlnode *packet, gpointer data)
+static void jabber_blocklist_parse(JabberStream *js, const char *from,
+                                   JabberIqType type, const char *id,
+                                   xmlnode *packet, gpointer data)
 {
 	xmlnode *blocklist, *item;
 	PurpleAccount *account;
@@ -1904,14 +1913,11 @@ static void
 }
 
 static void
-jabber_password_change_result_cb(JabberStream *js, xmlnode *packet,
-		gpointer data)
+jabber_password_change_result_cb(JabberStream *js, const char *from,
+                                 JabberIqType type, const char *id,
+                                 xmlnode *packet, gpointer data)
 {
-	const char *type;
-
-	type = xmlnode_get_attrib(packet, "type");
-
-	if(type && !strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
 				_("Your password has been changed."));
 
============================================================
--- libpurple/protocols/jabber/message.c	540d6e21c311ee9e858346a21ce744ebbea3c940
+++ libpurple/protocols/jabber/message.c	98719f68430c637c6f5495f1637c3e843ec46736
@@ -477,7 +477,9 @@ static void
 } JabberDataRef;
 
 static void
-jabber_message_get_data_cb(JabberStream *js, xmlnode *packet, gpointer data)
+jabber_message_get_data_cb(JabberStream *js, const char *from,
+                           JabberIqType type, const char *id,
+                           xmlnode *packet, gpointer data)
 {
 	JabberDataRef *ref = (JabberDataRef *) data;
 	PurpleConversation *conv = ref->conv;
============================================================
--- libpurple/protocols/jabber/pep.c	28124c8b558c2e1956b7a13e5d057c1859bc99b1
+++ libpurple/protocols/jabber/pep.c	488ee6252029386943906e258d5437d827368aa2
@@ -52,8 +52,11 @@ void jabber_pep_register_handler(const c
 	g_hash_table_replace(pep_handlers, g_strdup(xmlns), handlerfunc);
 }
 
-static void do_pep_iq_request_item_callback(JabberStream *js, xmlnode *packet, gpointer data) {
-	const char *from = xmlnode_get_attrib(packet,"from");
+static void
+do_pep_iq_request_item_callback(JabberStream *js, const char *from,
+                                JabberIqType type, const char *id,
+                                xmlnode *packet, gpointer data)
+{
 	xmlnode *pubsub = xmlnode_get_child_with_namespace(packet,"pubsub","http://jabber.org/protocol/pubsub");
 	xmlnode *items = NULL;
 	JabberPEPHandler *cb = data;
============================================================
--- libpurple/protocols/jabber/ping.c	b826144e95aa9ae66244e219b0e678daabefe3d4
+++ libpurple/protocols/jabber/ping.c	7ed02e1242210454344eba065576ffaf7343a060
@@ -51,11 +51,10 @@ jabber_ping_parse(JabberStream *js, cons
 	}
 }
 
-static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet,
-                                  gpointer data)
+static void jabber_ping_result_cb(JabberStream *js, const char *from,
+                                  JabberIqType type, const char *id,
+                                  xmlnode *packet, gpointer data)
 {
-	const char *type = xmlnode_get_attrib(packet, "type");
-	const char *from = xmlnode_get_attrib(packet, "from");
 	char *own_bare_jid = g_strdup_printf("%s@%s", js->user->node,
 	                                     js->user->domain);
 
@@ -66,7 +65,7 @@ static void jabber_ping_result_cb(Jabber
 	}
 	g_free(own_bare_jid);
 
-	if(type && !strcmp(type, "result")) {
+	if (type == JABBER_IQ_RESULT) {
 		purple_debug_info("jabber", "PONG!\n");
 	} else {
 		purple_debug_info("jabber", "(not supported)\n");
============================================================
--- libpurple/protocols/jabber/presence.c	5f9d47d40fe95fb230ae95040b9f794f20f8c7eb
+++ libpurple/protocols/jabber/presence.c	51437deddd44a53273f8fa44ea8344dfc50cc79b
@@ -326,14 +326,16 @@ static void deny_add_cb(gpointer data)
 	g_free(jap);
 }
 
-static void jabber_vcard_parse_avatar(JabberStream *js, xmlnode *packet, gpointer blah)
+static void
+jabber_vcard_parse_avatar(JabberStream *js, const char *from,
+                          JabberIqType type, const char *id,
+                          xmlnode *packet, gpointer blah)
 {
 	JabberBuddy *jb = NULL;
 	xmlnode *vcard, *photo, *binval;
 	char *text;
 	guchar *data;
 	gsize size;
-	const char *from = xmlnode_get_attrib(packet, "from");
 
 	if(!from)
 		return;
============================================================
--- libpurple/protocols/jabber/si.c	b4c32ed008c44a703034ccf6b7d987c6ba55f929
+++ libpurple/protocols/jabber/si.c	7252917bdcd73fd1a137cfdd5194901610c6fb4d
@@ -683,13 +683,14 @@ static void
 }
 
 static void
-jabber_si_connect_proxy_cb(JabberStream *js, xmlnode *packet,
-		gpointer data)
+jabber_si_connect_proxy_cb(JabberStream *js, const char *from,
+                           JabberIqType type, const char *id,
+                           xmlnode *packet, gpointer data)
 {
 	PurpleXfer *xfer = data;
 	JabberSIXfer *jsx;
 	xmlnode *query, *streamhost_used;
-	const char *from, *type, *jid;
+	const char *jid;
 	GList *matched;
 
 	/* TODO: This need to send errors if we don't see what we're looking for */
@@ -706,37 +707,34 @@ jabber_si_connect_proxy_cb(JabberStream 
 
 	jsx = xfer->data;
 
-	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
-	  purple_debug_info("jabber",
-			    "jabber_si_xfer_connect_proxy_cb: type = %s\n",
-			    type);
-		if (type && !strcmp(type, "error")) {
-			/* if IBB is available, open IBB session */
-			purple_debug_info("jabber",
-				"jabber_si_xfer_connect_proxy_cb: got error, method: %d\n",
-				jsx->stream_method);
-			if (jsx->stream_method & STREAM_METHOD_IBB) {
-				purple_debug_info("jabber", "IBB is possible, try it\n");
-				/* if we are the sender and haven't already opened an IBB
-				  session, do so now (we might already have failed to open
-				  the bytestream proxy ourselves when receiving this <iq/> */
-				if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
-					&& !jsx->ibb_session) {
-					jabber_si_xfer_ibb_send_init(js, xfer);
-				} else {
-					jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
-						jabber_si_bytestreams_ibb_timeout_cb, xfer);
-				}
-				/* if we are receiver, just wait for IBB open stanza, callback
-				  is already set up */
+	if(type != JABBER_IQ_RESULT) {
+		purple_debug_info("jabber",
+			    "jabber_si_xfer_connect_proxy_cb: type = error\n");
+		/* if IBB is available, open IBB session */
+		purple_debug_info("jabber",
+			"jabber_si_xfer_connect_proxy_cb: got error, method: %d\n",
+			jsx->stream_method);
+		if (jsx->stream_method & STREAM_METHOD_IBB) {
+			purple_debug_info("jabber", "IBB is possible, try it\n");
+			/* if we are the sender and haven't already opened an IBB
+			  session, do so now (we might already have failed to open
+			  the bytestream proxy ourselves when receiving this <iq/> */
+			if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
+				&& !jsx->ibb_session) {
+				jabber_si_xfer_ibb_send_init(js, xfer);
 			} else {
-				purple_xfer_cancel_remote(xfer);
+				jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
+					jabber_si_bytestreams_ibb_timeout_cb, xfer);
 			}
+			/* if we are receiver, just wait for IBB open stanza, callback
+			  is already set up */
+		} else {
+			purple_xfer_cancel_remote(xfer);
 		}
 		return;
 	}
 
-	if(!(from = xmlnode_get_attrib(packet, "from")))
+	if (!from)
 		return;
 
 	if(!(query = xmlnode_get_child(packet, "query")))
@@ -1180,8 +1178,9 @@ jabber_si_xfer_ibb_send_init(JabberStrea
 	}
 }
 
-static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet,
-		gpointer data)
+static void jabber_si_xfer_send_method_cb(JabberStream *js, const char *from,
+                                          JabberIqType type, const char *id,
+                                          xmlnode *packet, gpointer data)
 {
 	PurpleXfer *xfer = data;
 	xmlnode *si, *feature, *x, *field, *value;


More information about the Commits mailing list