comparison libgaim/protocols/jabber/jabber.c @ 14296:8342b39f975b

[gaim-migrate @ 16986] 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 committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 22 Aug 2006 19:43:30 +0000
parents 8a6154a52b84
children 9ad313800b19
comparison
equal deleted inserted replaced
14295:b76462fea543 14296:8342b39f975b
166 166
167 static void tls_init(JabberStream *js); 167 static void tls_init(JabberStream *js);
168 168
169 void jabber_process_packet(JabberStream *js, xmlnode *packet) 169 void jabber_process_packet(JabberStream *js, xmlnode *packet)
170 { 170 {
171 gaim_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, &packet);
172
173 /* if the signal leaves us with a null packet, we're done */
174 if(NULL == packet)
175 return;
176
171 if(!strcmp(packet->name, "iq")) { 177 if(!strcmp(packet->name, "iq")) {
172 jabber_iq_parse(js, packet); 178 jabber_iq_parse(js, packet);
173 } else if(!strcmp(packet->name, "presence")) { 179 } else if(!strcmp(packet->name, "presence")) {
174 jabber_presence_parse(js, packet); 180 jabber_presence_parse(js, packet);
175 } else if(!strcmp(packet->name, "message")) { 181 } else if(!strcmp(packet->name, "message")) {
324 330
325 void jabber_send(JabberStream *js, xmlnode *packet) 331 void jabber_send(JabberStream *js, xmlnode *packet)
326 { 332 {
327 char *txt; 333 char *txt;
328 int len; 334 int len;
335
336 gaim_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet);
337
338 /* if we get NULL back, we're done processing */
339 if(NULL == packet)
340 return;
329 341
330 txt = xmlnode_to_str(packet, &len); 342 txt = xmlnode_to_str(packet, &len);
331 jabber_send_raw(js, txt, len); 343 jabber_send_raw(js, txt, len);
332 g_free(txt); 344 g_free(txt);
333 } 345 }
1880 jabber_si_new_xfer, /* new_xfer */ 1892 jabber_si_new_xfer, /* new_xfer */
1881 jabber_offline_message, /* offline_message */ 1893 jabber_offline_message, /* offline_message */
1882 NULL, /* whiteboard_prpl_ops */ 1894 NULL, /* whiteboard_prpl_ops */
1883 }; 1895 };
1884 1896
1897 static gboolean load_plugin(GaimPlugin *plugin)
1898 {
1899 gaim_signal_register(plugin, "jabber-receiving-xmlnode",
1900 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
1901 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION),
1902 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE));
1903
1904 gaim_signal_register(plugin, "jabber-sending-xmlnode",
1905 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
1906 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION),
1907 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE));
1908
1909 return TRUE;
1910 }
1911
1912 static gboolean unload_plugin(GaimPlugin *plugin)
1913 {
1914 gaim_signal_unregister(plugin, "jabber-receiving-xmlnode");
1915
1916 gaim_signal_unregister(plugin, "jabber-sending-xmlnode");
1917
1918 return TRUE;
1919 }
1920
1885 static GaimPluginInfo info = 1921 static GaimPluginInfo info =
1886 { 1922 {
1887 GAIM_PLUGIN_MAGIC, 1923 GAIM_PLUGIN_MAGIC,
1888 GAIM_MAJOR_VERSION, 1924 GAIM_MAJOR_VERSION,
1889 GAIM_MINOR_VERSION, 1925 GAIM_MINOR_VERSION,
1901 /** description */ 1937 /** description */
1902 N_("Jabber Protocol Plugin"), 1938 N_("Jabber Protocol Plugin"),
1903 NULL, /**< author */ 1939 NULL, /**< author */
1904 GAIM_WEBSITE, /**< homepage */ 1940 GAIM_WEBSITE, /**< homepage */
1905 1941
1906 NULL, /**< load */ 1942 load_plugin, /**< load */
1907 NULL, /**< unload */ 1943 unload_plugin, /**< unload */
1908 NULL, /**< destroy */ 1944 NULL, /**< destroy */
1909 1945
1910 NULL, /**< ui_info */ 1946 NULL, /**< ui_info */
1911 &prpl_info, /**< extra_info */ 1947 &prpl_info, /**< extra_info */
1912 NULL, /**< prefs_info */ 1948 NULL, /**< prefs_info */