cpw.darkrain42.xmpp.disco: dc58db7b: Use the jabber-sending-xmlnode signal to...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Jun 3 02:50:33 EDT 2009
-----------------------------------------------------------------
Revision: dc58db7bac2bc32659355e5e1844935f531ca94f
Ancestor: 226823554fed7cb05810a5a8446141237a984e25
Author: darkrain42 at pidgin.im
Date: 2009-06-03T06:45:25
Branch: im.pidgin.cpw.darkrain42.xmpp.disco
URL: http://d.pidgin.im/viewmtn/revision/info/dc58db7bac2bc32659355e5e1844935f531ca94f
Modified files:
ChangeLog.API libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
libpurple/protocols/jabber/libxmpp.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- ChangeLog.API ca7d983fe02f8e38b5ce40742bd4ac549af4228f
+++ ChangeLog.API 2f99b4086363cf19921f6ba2495ee84f2143097c
@@ -16,6 +16,9 @@ version 2.6.0 (??/??/2009):
* 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
============================================================
--- libpurple/protocols/jabber/jabber.c 410b915f8170086de9d98a051ad12ac0244e5ab2
+++ libpurple/protocols/jabber/jabber.c ebe2a8826d36195f98226bfadba33988e1a9850f
@@ -449,22 +449,25 @@ int jabber_prpl_send_raw(PurpleConnectio
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;
============================================================
--- libpurple/protocols/jabber/jabber.h e1c50968a6daa05074ce7731365d10fed65cc985
+++ libpurple/protocols/jabber/jabber.h 68f4a86b04521eecd98908f31c949aaae27511e7
@@ -302,6 +302,8 @@ void jabber_send_raw(JabberStream *js, c
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);
============================================================
--- libpurple/protocols/jabber/libxmpp.c 10165279c70eaae138f633233dc66c0f3ddb14c1
+++ libpurple/protocols/jabber/libxmpp.c f9d790cbac8895b01124c5628315461898c26a67
@@ -137,6 +137,14 @@ static gboolean load_plugin(PurplePlugin
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),
More information about the Commits
mailing list