From: <fac...@us...> - 2006-08-22 19:43:49
|
Revision: 16986 Author: faceprint Date: 2006-08-22 12:43:30 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16986&view=rev Log Message: ----------- I got a patch from Ian Goldberg about a year ago to let plugins tweak XML packets as they were sent or received I finally tweaked it the way I wanted it, and here it is. If it sucks, blame me, otherwise give him credit Modified Paths: -------------- trunk/COPYRIGHT trunk/libgaim/protocols/jabber/jabber.c trunk/libgaim/value.h Modified: trunk/COPYRIGHT =================================================================== --- trunk/COPYRIGHT 2006-08-22 19:18:46 UTC (rev 16985) +++ trunk/COPYRIGHT 2006-08-22 19:43:30 UTC (rev 16986) @@ -111,6 +111,7 @@ Ike Gingerich Gustavo Giráldez Richard Gobeille +Ian Goldberg Michael Golden Charlie Gordon Ryan C. Gordon Modified: trunk/libgaim/protocols/jabber/jabber.c =================================================================== --- trunk/libgaim/protocols/jabber/jabber.c 2006-08-22 19:18:46 UTC (rev 16985) +++ trunk/libgaim/protocols/jabber/jabber.c 2006-08-22 19:43:30 UTC (rev 16986) @@ -168,6 +168,12 @@ void jabber_process_packet(JabberStream *js, xmlnode *packet) { + gaim_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, &packet); + + /* if the signal leaves us with a null packet, we're done */ + if(NULL == packet) + return; + if(!strcmp(packet->name, "iq")) { jabber_iq_parse(js, packet); } else if(!strcmp(packet->name, "presence")) { @@ -327,6 +333,12 @@ char *txt; int len; + gaim_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet); + + /* if we get NULL back, we're done processing */ + if(NULL == packet) + return; + txt = xmlnode_to_str(packet, &len); jabber_send_raw(js, txt, len); g_free(txt); @@ -1882,6 +1894,30 @@ NULL, /* whiteboard_prpl_ops */ }; +static gboolean load_plugin(GaimPlugin *plugin) +{ + gaim_signal_register(plugin, "jabber-receiving-xmlnode", + gaim_marshal_VOID__POINTER_POINTER, NULL, 2, + gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), + gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE)); + + gaim_signal_register(plugin, "jabber-sending-xmlnode", + gaim_marshal_VOID__POINTER_POINTER, NULL, 2, + gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), + gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE)); + + return TRUE; +} + +static gboolean unload_plugin(GaimPlugin *plugin) +{ + gaim_signal_unregister(plugin, "jabber-receiving-xmlnode"); + + gaim_signal_unregister(plugin, "jabber-sending-xmlnode"); + + return TRUE; +} + static GaimPluginInfo info = { GAIM_PLUGIN_MAGIC, @@ -1903,8 +1939,8 @@ NULL, /**< author */ GAIM_WEBSITE, /**< homepage */ - NULL, /**< load */ - NULL, /**< unload */ + load_plugin, /**< load */ + unload_plugin, /**< unload */ NULL, /**< destroy */ NULL, /**< ui_info */ Modified: trunk/libgaim/value.h =================================================================== --- trunk/libgaim/value.h 2006-08-22 19:18:46 UTC (rev 16985) +++ trunk/libgaim/value.h 2006-08-22 19:43:30 UTC (rev 16986) @@ -74,7 +74,8 @@ GAIM_SUBTYPE_STATUS, GAIM_SUBTYPE_LOG, GAIM_SUBTYPE_XFER, - GAIM_SUBTYPE_SAVEDSTATUS + GAIM_SUBTYPE_SAVEDSTATUS, + GAIM_SUBTYPE_XMLNODE } GaimSubType; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |