changeset 27007:d148ca9e4d9a

Use the modified signal in more places.
author Paul Aurich <paul@darkrain42.org>
date Wed, 03 Jun 2009 06:54:35 +0000
parents d31af94a715d
children 986304bcc66a
files libpurple/plugins/signals-test.c pidgin/plugins/disco/xmppdisco.c
diffstat 2 files changed, 18 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/signals-test.c	Wed Jun 03 06:45:25 2009 +0000
+++ b/libpurple/plugins/signals-test.c	Wed Jun 03 06:54:35 2009 +0000
@@ -671,22 +671,16 @@
 	                  xmlnode_get_namespace(child));
 
 	if (g_str_equal(type, "get") || g_str_equal(type, "set")) {
-		PurplePlugin *prpl;
-		PurplePluginProtocolInfo *prpl_info;
-		char *str;
-
 		/* Send the requisite reply */
 		xmlnode *iq = xmlnode_new("iq");
 		xmlnode_set_attrib(iq, "to", from);
 		xmlnode_set_attrib(iq, "id", id);
 		xmlnode_set_attrib(iq, "type", "result");
 
-		str = xmlnode_to_str(iq, NULL);
-		prpl = purple_connection_get_prpl(pc);
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-		prpl_info->send_raw(pc, str, -1);
-		g_free(str);
-		xmlnode_free(iq);
+		purple_signal_emit(purple_connection_get_prpl(pc),
+		                   "jabber-sending-xmlnode", pc, &iq);
+		if (iq != NULL)
+			xmlnode_free(iq);
 	}
 
 	/* Cookie monster eats IQ stanzas; the prpl shouldn't keep processing */
--- a/pidgin/plugins/disco/xmppdisco.c	Wed Jun 03 06:45:25 2009 +0000
+++ b/pidgin/plugins/disco/xmppdisco.c	Wed Jun 03 06:54:35 2009 +0000
@@ -141,11 +141,8 @@
 xmpp_disco_info_do(PurpleConnection *pc, gpointer cbdata, const char *jid,
                    const char *node, XmppIqCallback cb)
 {
-	PurplePlugin *prpl;
-	PurplePluginProtocolInfo *prpl_info;
 	xmlnode *iq, *query;
 	char *id = generate_next_id();
-	char *str;
 
 	iq = xmlnode_new("iq");
 	xmlnode_set_attrib(iq, "type", "get");
@@ -157,26 +154,21 @@
 	if (node)
 		xmlnode_set_attrib(query, "node", node);
 
+	/* Steals id */
 	xmpp_iq_register_callback(pc, id, cbdata, cb);
 
-	str = xmlnode_to_str(iq, NULL);
-	prpl = purple_connection_get_prpl(pc);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	prpl_info->send_raw(pc, str, -1);
-	g_free(str);
-	xmlnode_free(iq);
-	g_free(id);
+	purple_signal_emit(purple_connection_get_prpl(pc), "jabber-sending-xmlnode",
+	                   pc, &iq);
+	if (iq != NULL)
+		xmlnode_free(iq);
 }
 
 static void
 xmpp_disco_items_do(PurpleConnection *pc, gpointer cbdata, const char *jid,
                     const char *node, XmppIqCallback cb)
 {
-	PurplePlugin *prpl;
-	PurplePluginProtocolInfo *prpl_info;
 	xmlnode *iq, *query;
 	char *id = generate_next_id();
-	char *str;
 
 	iq = xmlnode_new("iq");
 	xmlnode_set_attrib(iq, "type", "get");
@@ -188,15 +180,13 @@
 	if (node)
 		xmlnode_set_attrib(query, "node", node);
 
+	/* Steals id */
 	xmpp_iq_register_callback(pc, id, cbdata, cb);
 
-	str = xmlnode_to_str(iq, NULL);
-	prpl = purple_connection_get_prpl(pc);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	prpl_info->send_raw(pc, str, -1);
-	g_free(str);
-	xmlnode_free(iq);
-	g_free(id);
+	purple_signal_emit(purple_connection_get_prpl(pc), "jabber-sending-xmlnode",
+	                   pc, &iq);
+	if (iq != NULL)
+		xmlnode_free(iq);
 }
 
 static XmppDiscoServiceType
@@ -533,11 +523,8 @@
 
 void xmpp_disco_service_register(XmppDiscoService *service)
 {
-	PurplePlugin *prpl;
-	PurplePluginProtocolInfo *prpl_info;
 	xmlnode *iq, *query;
 	char *id = generate_next_id();
-	char *str;
 
 	iq = xmlnode_new("iq");
 	xmlnode_set_attrib(iq, "type", "get");
@@ -547,12 +534,10 @@
 	query = xmlnode_new_child(iq, "query");
 	xmlnode_set_namespace(query, NS_REGISTER);
 
-	str = xmlnode_to_str(iq, NULL);
-	prpl = purple_connection_get_prpl(service->list->pc);
-	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	prpl_info->send_raw(service->list->pc, str, -1);
-	g_free(str);
-	xmlnode_free(iq);
+	purple_signal_emit(purple_connection_get_prpl(service->list->pc),
+			"jabber-sending-xmlnode", service->list->pc, &iq);
+	if (iq != NULL)
+		xmlnode_free(iq);
 	g_free(id);
 }