Mercurial > pidgin
changeset 27006:d31af94a715d
Use the jabber-sending-xmlnode signal to send all XMPP stanzas.
Allows plugins to send stanzas instead of stringifying+send_raw; allows
other plugins to see the sending stanzas. This may be a little hacky; I'm
on the fence.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 03 Jun 2009 06:45:25 +0000 |
parents | 8502d69e45ed |
children | d148ca9e4d9a |
files | ChangeLog.API libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/libxmpp.c |
diffstat | 4 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Wed Jun 03 06:03:22 2009 +0000 +++ b/ChangeLog.API Wed Jun 03 06:45:25 2009 +0000 @@ -16,6 +16,9 @@ * blist-node-added and blist-node-removed signals (see blist-signals.dox) * Jabber plugin signals (see jabber-signals.dox) + * Plugins may now emit the jabber-sending-xmlnode signal in order + to send stanzas; this method is preferred to the prpl send_raw + function as other plugins listening to the signal see them. * purple_buddy_destroy * purple_buddy_get_protocol_data * purple_buddy_set_protocol_data
--- a/libpurple/protocols/jabber/jabber.c Wed Jun 03 06:03:22 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed Jun 03 06:45:25 2009 +0000 @@ -449,22 +449,25 @@ return len; } -void jabber_send(JabberStream *js, xmlnode *packet) +void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet, + gpointer unused) { char *txt; int len; - purple_signal_emit(jabber_plugin, "jabber-sending-xmlnode", js->gc, &packet); - - /* if we get NULL back, we're done processing */ - if(NULL == packet) + if (NULL == packet) return; - txt = xmlnode_to_str(packet, &len); - jabber_send_raw(js, txt, len); + txt = xmlnode_to_str(*packet, &len); + jabber_send_raw(purple_connection_get_protocol_data(pc), txt, len); g_free(txt); } +void jabber_send(JabberStream *js, xmlnode *packet) +{ + purple_signal_emit(jabber_plugin, "jabber-sending-xmlnode", js->gc, &packet); +} + static gboolean jabber_keepalive_timeout(PurpleConnection *gc) { JabberStream *js = gc->proto_data;
--- a/libpurple/protocols/jabber/jabber.h Wed Jun 03 06:03:22 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.h Wed Jun 03 06:45:25 2009 +0000 @@ -302,6 +302,8 @@ void jabber_process_packet(JabberStream *js, xmlnode **packet); void jabber_send(JabberStream *js, xmlnode *data); void jabber_send_raw(JabberStream *js, const char *data, int len); +void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet, + gpointer unused); void jabber_stream_set_state(JabberStream *js, JabberStreamState state);
--- a/libpurple/protocols/jabber/libxmpp.c Wed Jun 03 06:03:22 2009 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Wed Jun 03 06:45:25 2009 +0000 @@ -137,6 +137,14 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE)); + /* + * Do not remove this or the plugin will fail. Completely. You have been + * warned! + */ + purple_signal_connect_priority(plugin, "jabber-sending-xmlnode", + plugin, PURPLE_CALLBACK(jabber_send_signal_cb), + NULL, PURPLE_SIGNAL_PRIORITY_HIGHEST); + purple_signal_register(plugin, "jabber-sending-text", purple_marshal_VOID__POINTER_POINTER, NULL, 2, purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),