libpurple/protocols/jabber/iq.c

Wed, 13 May 2009 20:29:03 +0000

author
Marcus Lundblad <malu@pidgin.im>
date
Wed, 13 May 2009 20:29:03 +0000
changeset 27110
05ca719b901b
parent 27103
815af6acd59b
child 27175
e027ae421bf3
permissions
-rw-r--r--

Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18443
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
18441
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
22 #include "core.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "debug.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #include "prefs.h"
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
25 #include "util.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
27 #include "buddy.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
28 #include "disco.h"
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 14453
diff changeset
29 #include "google.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "iq.h"
26143
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 23754
diff changeset
31 #include "jingle/jingle.h"
7170
93a12931a1fd [gaim-migrate @ 7737]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
32 #include "oob.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "roster.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
34 #include "si.h"
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
35 #include "ping.h"
17805
5bd417a1c847 Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents: 17769
diff changeset
36 #include "adhoccommands.h"
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23076
diff changeset
37 #include "data.h"
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23076
diff changeset
38 #include "ibb.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
7058
c62db98b7a2a [gaim-migrate @ 7621]
Herman Bloggs <herman@bluedigits.com>
parents: 7014
diff changeset
40 #ifdef _WIN32
c62db98b7a2a [gaim-migrate @ 7621]
Herman Bloggs <herman@bluedigits.com>
parents: 7014
diff changeset
41 #include "utsname.h"
c62db98b7a2a [gaim-migrate @ 7621]
Herman Bloggs <herman@bluedigits.com>
parents: 7014
diff changeset
42 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
44 GHashTable *iq_handlers = NULL;
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
45 GHashTable *signal_iq_handlers = NULL;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
46
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 iq = g_new0(JabberIq, 1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 iq->type = type;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 iq->node = xmlnode_new("iq");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 switch(iq->type) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 case JABBER_IQ_SET:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 xmlnode_set_attrib(iq->node, "type", "set");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60 case JABBER_IQ_GET:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 xmlnode_set_attrib(iq->node, "type", "get");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 case JABBER_IQ_ERROR:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 xmlnode_set_attrib(iq->node, "type", "error");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 case JABBER_IQ_RESULT:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 xmlnode_set_attrib(iq->node, "type", "result");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69 case JABBER_IQ_NONE:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 /* this shouldn't ever happen */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 iq->js = js;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 iq->id = jabber_get_next_id(js);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 xmlnode_set_attrib(iq->node, "id", iq->id);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81 return iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 const char *xmlns)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87 JabberIq *iq = jabber_iq_new(js, type);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 xmlnode *query;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 query = xmlnode_new_child(iq->node, "query");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13794
diff changeset
91 xmlnode_set_namespace(query, xmlns);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 return iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
96 typedef struct _JabberCallbackData {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
97 JabberIqCallback *callback;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
98 gpointer data;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
99 } JabberCallbackData;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
100
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
101 void
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
102 jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 iq->callback = callback;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
105 iq->callback_data = data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 void jabber_iq_set_id(JabberIq *iq, const char *id)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 {
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
110 g_free(iq->id);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 if(id) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 xmlnode_set_attrib(iq->node, "id", id);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 iq->id = g_strdup(id);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 xmlnode_remove_attrib(iq->node, "id");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 iq->id = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
120
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121 void jabber_iq_send(JabberIq *iq)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 {
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
123 JabberCallbackData *jcd;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124 g_return_if_fail(iq != NULL);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 jabber_send(iq->js, iq->node);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
128 if(iq->id && iq->callback) {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
129 jcd = g_new0(JabberCallbackData, 1);
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
130 jcd->callback = iq->callback;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
131 jcd->data = iq->callback_data;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
132 g_hash_table_insert(iq->js->iq_callbacks, g_strdup(iq->id), jcd);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
133 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 jabber_iq_free(iq);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 void jabber_iq_free(JabberIq *iq)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 g_return_if_fail(iq != NULL);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 g_free(iq->id);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 xmlnode_free(iq->node);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 g_free(iq);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
147 static void jabber_iq_last_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
148 JabberIqType type, const char *id,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
149 xmlnode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 xmlnode *query;
14453
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
153 char *idle_time;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
155 if(type == JABBER_IQ_GET) {
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
156 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
157 jabber_iq_set_id(iq, id);
25818
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
158 if (from)
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
159 xmlnode_set_attrib(iq->node, "to", from);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
161 query = xmlnode_get_child(iq->node, "query");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162
14453
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
163 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
164 xmlnode_set_attrib(query, "seconds", idle_time);
1cc75906700c [gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents: 14375
diff changeset
165 g_free(idle_time);
7401
3328147f3d53 [gaim-migrate @ 7997]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
166
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
167 jabber_iq_send(iq);
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
168 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
171 static void jabber_iq_time_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
172 JabberIqType type, const char *id,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
173 xmlnode *child)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 {
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
175 const char *xmlns;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 time_t now_t;
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
178 struct tm now_local;
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
179 struct tm now_utc;
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 8315
diff changeset
180 struct tm *now;
9722
c1072806bcae [gaim-migrate @ 10583]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
181
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 time(&now_t);
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 8315
diff changeset
183 now = localtime(&now_t);
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
184 memcpy(&now_local, now, sizeof(struct tm));
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
185 now = gmtime(&now_t);
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
186 memcpy(&now_utc, now, sizeof(struct tm));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
188 xmlns = xmlnode_get_namespace(child);
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
189
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
190 if(type == JABBER_IQ_GET) {
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
191 xmlnode *utc;
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
192 const char *date, *tz, *display;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
194 iq = jabber_iq_new(js, JABBER_IQ_RESULT);
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
195 jabber_iq_set_id(iq, id);
25818
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
196 if (from)
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
197 xmlnode_set_attrib(iq->node, "to", from);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
199 child = xmlnode_new_child(iq->node, child->name);
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
200 xmlnode_set_namespace(child, xmlns);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
201 utc = xmlnode_new_child(child, "utc");
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
202
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
203 if(!strcmp("urn:xmpp:time", xmlns)) {
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
204 tz = purple_get_tzoff_str(&now_local, TRUE);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
205 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1);
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
206
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
207 date = purple_utf8_strftime("%FT%TZ", &now_utc);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
208 xmlnode_insert_data(utc, date, -1);
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
209 } else { /* jabber:iq:time */
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
210 tz = purple_utf8_strftime("%Z", &now_local);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
211 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1);
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
212
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
213 date = purple_utf8_strftime("%Y%m%dT%T", &now_utc);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
214 xmlnode_insert_data(utc, date, -1);
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
215
25826
62e1a74d98ce Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <darkrain42@pidgin.im>
parents: 25821
diff changeset
216 display = purple_utf8_strftime("%d %b %Y %T", &now_local);
25556
300d8959e04c Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents: 25554
diff changeset
217 xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1);
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18194
diff changeset
218 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
220 jabber_iq_send(iq);
18181
736c6abf62f4 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17753
diff changeset
221 }
736c6abf62f4 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17753
diff changeset
222 }
736c6abf62f4 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17753
diff changeset
223
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
224 static void jabber_iq_version_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
225 JabberIqType type, const char *id,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
226 xmlnode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 xmlnode *query;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
231 if(type == JABBER_IQ_GET) {
18441
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
232 GHashTable *ui_info;
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
233 const char *ui_name = NULL, *ui_version = NULL;
20116
9952c317df4c applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@pidgin.im>
parents: 19897
diff changeset
234 #if 0
20225
684334efdc19 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20116
diff changeset
235 char *os = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
236 if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
237 struct utsname osinfo;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
239 uname(&osinfo);
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
240 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
241 osinfo.machine);
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
242 }
20116
9952c317df4c applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@pidgin.im>
parents: 19897
diff changeset
243 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
245 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
25818
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
246 if (from)
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
247 xmlnode_set_attrib(iq->node, "to", from);
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
248 jabber_iq_set_id(iq, id);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
250 query = xmlnode_get_child(iq->node, "query");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251
18441
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
252 ui_info = purple_core_get_ui_info();
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
253
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
254 if(NULL != ui_info) {
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
255 ui_name = g_hash_table_lookup(ui_info, "name");
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
256 ui_version = g_hash_table_lookup(ui_info, "version");
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
257 }
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
258
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
259 if(NULL != ui_name && NULL != ui_version) {
18443
8ddab006e3f1 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18441
diff changeset
260 char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version);
8ddab006e3f1 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18441
diff changeset
261 xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1);
8ddab006e3f1 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18441
diff changeset
262 xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1);
8ddab006e3f1 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18441
diff changeset
263 g_free(version_complete);
18441
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
264 } else {
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
265 xmlnode_insert_data(xmlnode_new_child(query, "name"), "libpurple", -1);
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
266 xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
267 }
d255d04c0aa1 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18317
diff changeset
268
20225
684334efdc19 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20116
diff changeset
269 #if 0
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
270 if(os) {
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
271 xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1);
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
272 g_free(os);
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
273 }
20225
684334efdc19 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20116
diff changeset
274 #endif
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10487
diff changeset
275
8006
39ba515743cd [gaim-migrate @ 8683]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
276 jabber_iq_send(iq);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
280 void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
281 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
282 g_hash_table_remove(js->iq_callbacks, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
283 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
284
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 void jabber_iq_parse(JabberStream *js, xmlnode *packet)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 {
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
287 JabberCallbackData *jcd;
25554
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
288 xmlnode *child, *error, *x;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 const char *xmlns;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
290 const char *iq_type, *id, *from;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
291 JabberIqType type = JABBER_IQ_NONE;
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
292 gboolean signal_return;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
293
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
294 from = xmlnode_get_attrib(packet, "from");
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
295 id = xmlnode_get_attrib(packet, "id");
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
296 iq_type = xmlnode_get_attrib(packet, "type");
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
297
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
298 signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(jabber_plugin,
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
299 "jabber-receiving-iq", js->gc, iq_type, id, from, packet));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
300 if (signal_return)
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
301 return;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302
25554
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
303 /*
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
304 * child will be either the first tag child or NULL if there is no child.
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
305 * Historically, we used just the 'query' subchild, but newer XEPs use
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
306 * differently named children. Grabbing the first child is (for the time
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
307 * being) sufficient.
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
308 */
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
309 for (child = packet->child; child; child = child->next) {
25813
2e5e39a3107c This is shorter and easier to read.
Paul Aurich <darkrain42@pidgin.im>
parents: 25557
diff changeset
310 if (child->type == XMLNODE_TYPE_TAG)
2e5e39a3107c This is shorter and easier to read.
Paul Aurich <darkrain42@pidgin.im>
parents: 25557
diff changeset
311 break;
25554
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
312 }
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
313
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
314 if (iq_type) {
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
315 if (!strcmp(iq_type, "get"))
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
316 type = JABBER_IQ_GET;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
317 else if (!strcmp(iq_type, "set"))
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
318 type = JABBER_IQ_SET;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
319 else if (!strcmp(iq_type, "result"))
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
320 type = JABBER_IQ_RESULT;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
321 else if (!strcmp(iq_type, "error"))
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
322 type = JABBER_IQ_ERROR;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
323 }
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
324
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
325 if (type == JABBER_IQ_NONE) {
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
326 purple_debug_error("jabber", "IQ with invalid type ('%s') - ignoring.\n",
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
327 iq_type ? iq_type : "(null)");
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
328 return;
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
329 }
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
330
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
331 /* All IQs must have an ID, so send an error for a set/get that doesn't */
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
332 if(!id || !*id) {
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
333
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
334 if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) {
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
335 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
336
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
337 xmlnode_free(iq->node);
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
338 iq->node = xmlnode_copy(packet);
25818
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
339 if (from) {
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
340 xmlnode_set_attrib(iq->node, "to", from);
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
341 xmlnode_remove_attrib(iq->node, "from");
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
342 }
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
343
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
344 xmlnode_set_attrib(iq->node, "type", "error");
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
345 /* This id is clearly not useful, but we must put something there for a valid stanza */
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
346 iq->id = jabber_get_next_id(js);
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
347 xmlnode_set_attrib(iq->node, "id", iq->id);
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
348 error = xmlnode_new_child(iq->node, "error");
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
349 xmlnode_set_attrib(error, "type", "modify");
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
350 x = xmlnode_new_child(error, "bad-request");
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
351 xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas");
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
352
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
353 jabber_iq_send(iq);
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
354 } else
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
355 purple_debug_error("jabber", "IQ of type '%s' missing id - ignoring.\n",
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
356 iq_type);
24520
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
357
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
358 return;
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
359 }
726138a1c69b Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents: 24254
diff changeset
360
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
361 /* First, lets see if a special callback got registered */
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
362 if(type == JABBER_IQ_RESULT || type == JABBER_IQ_ERROR) {
25831
1ff20e8f93b5 Remove a "suggested parenthes around assignment" warning
Paul Aurich <darkrain42@pidgin.im>
parents: 25830
diff changeset
363 if((jcd = g_hash_table_lookup(js->iq_callbacks, id))) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
364 jcd->callback(js, from, type, id, packet, jcd->data);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13105
diff changeset
365 jabber_iq_remove_callback_by_id(js, id);
8314
ae6f48fc3426 [gaim-migrate @ 9038]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
366 return;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
367 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
368 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
369
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
370 /*
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
371 * Apparently not, so let's see if we have a pre-defined handler
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
372 * or if an outside plugin is interested.
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
373 */
25554
53e161fc0658 Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents: 24520
diff changeset
374 if(child && (xmlns = xmlnode_get_namespace(child))) {
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
375 char *key = g_strdup_printf("%s %s", child->name, xmlns);
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
376 JabberIqHandler *jih = g_hash_table_lookup(iq_handlers, key);
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
377 int signal_ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key));
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
378 g_free(key);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
380 if (signal_ref > 0) {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
381 signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(jabber_plugin, "jabber-watched-iq",
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
382 js->gc, iq_type, id, from, child));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
383 if (signal_return)
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
384 return;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
385 }
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
386
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
387 if(jih) {
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
388 jih(js, from, type, id, child);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
389 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8169
diff changeset
390 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7170
diff changeset
391 }
26454
94130b583e0b Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents: 26337
diff changeset
392
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
393 purple_debug_info("jabber", "jabber_iq_parse\n");
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 15884
diff changeset
394
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
395 /* If we get here, send the default error reply mandated by XMPP-CORE */
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25815
diff changeset
396 if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) {
8315
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
397 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
398
8315
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
399 xmlnode_free(iq->node);
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
400 iq->node = xmlnode_copy(packet);
25818
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
401 if (from) {
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
402 xmlnode_set_attrib(iq->node, "to", from);
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
403 xmlnode_remove_attrib(iq->node, "from");
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
404 }
d087a2754595 Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 25817
diff changeset
405
8315
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
406 xmlnode_set_attrib(iq->node, "type", "error");
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
407 error = xmlnode_new_child(iq->node, "error");
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
408 xmlnode_set_attrib(error, "type", "cancel");
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
409 xmlnode_set_attrib(error, "code", "501");
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
410 x = xmlnode_new_child(error, "feature-not-implemented");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13794
diff changeset
411 xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas");
8169
f079f992248d [gaim-migrate @ 8882]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
412
8315
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
413 jabber_iq_send(iq);
39f375cfb8d7 [gaim-migrate @ 9039]
Nathan Walp <nwalp@pidgin.im>
parents: 8314
diff changeset
414 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
417 void jabber_iq_register_handler(const char *node, const char *xmlns, JabberIqHandler *handlerfunc)
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
418 {
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
419 /*
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
420 * This is valid because nodes nor namespaces cannot have spaces in them
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
421 * (see http://www.w3.org/TR/2006/REC-xml-20060816/ and
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
422 * http://www.w3.org/TR/REC-xml-names/)
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
423 */
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
424 char *key = g_strdup_printf("%s %s", node, xmlns);
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
425 g_hash_table_replace(iq_handlers, key, handlerfunc);
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
426 }
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
427
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
428 void jabber_iq_signal_register(const gchar *node, const gchar *xmlns)
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
429 {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
430 gchar *key;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
431 int ref;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
432
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
433 g_return_if_fail(node != NULL && *node != '\0');
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
434 g_return_if_fail(xmlns != NULL && *xmlns != '\0');
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
435
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
436 key = g_strdup_printf("%s %s", node, xmlns);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
437 ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
438 if (ref == 0) {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
439 g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(1));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
440 } else {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
441 g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(ref + 1));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
442 g_free(key);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
443 }
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
444 }
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
445
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
446 void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns)
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
447 {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
448 gchar *key;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
449 int ref;
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
450
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
451 g_return_if_fail(node != NULL && *node != '\0');
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
452 g_return_if_fail(xmlns != NULL && *xmlns != '\0');
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
453
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
454 key = g_strdup_printf("%s %s", node, xmlns);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
455 ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
456
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
457 if (ref == 1) {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
458 g_hash_table_remove(signal_iq_handlers, key);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
459 } else if (ref > 1) {
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
460 g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(ref - 1));
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
461 }
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
462
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
463 g_free(key);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
464 }
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
465
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
466 void jabber_iq_init(void)
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
467 {
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
468 iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
469 signal_iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
470
26704
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
471 jabber_iq_register_handler("jingle", JINGLE, jingle_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
472 jabber_iq_register_handler("mailbox", "google:mail:notify",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
473 jabber_gmail_poke);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
474 jabber_iq_register_handler("new-mail", "google:mail:notify",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
475 jabber_gmail_poke);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
476 jabber_iq_register_handler("ping", "urn:xmpp:ping", jabber_ping_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
477 jabber_iq_register_handler("query", GOOGLE_JINGLE_INFO_NAMESPACE,
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
478 jabber_google_handle_jingle_info);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
479 jabber_iq_register_handler("query", "http://jabber.org/protocol/bytestreams",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
480 jabber_bytestreams_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
481 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#info",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
482 jabber_disco_info_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
483 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#items",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
484 jabber_disco_items_parse);
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
485 jabber_iq_register_handler("query", "jabber:iq:last", jabber_iq_last_parse);
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
486 jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse);
26704
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
487 jabber_iq_register_handler("query", "jabber:iq:register",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
488 jabber_register_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
489 jabber_iq_register_handler("query", "jabber:iq:roster",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
490 jabber_roster_parse);
25820
c0ebe6bd49aa Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents: 25814
diff changeset
491 jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse);
26704
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
492 jabber_iq_register_handler("query", "jabber:iq:version",
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
493 jabber_iq_version_parse);
26697
2f086177af37 Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26695
diff changeset
494 #ifdef USE_VV
2f086177af37 Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26695
diff changeset
495 jabber_iq_register_handler("session", "http://www.google.com/session",
2f086177af37 Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26695
diff changeset
496 jabber_google_session_parse);
2f086177af37 Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26695
diff changeset
497 #endif
26704
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
498 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse);
e6dba3759625 Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents: 26701
diff changeset
499
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
500 }
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
501
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
502 void jabber_iq_uninit(void)
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
503 {
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
504 g_hash_table_destroy(iq_handlers);
27103
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
505 g_hash_table_destroy(signal_iq_handlers);
815af6acd59b Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents: 26704
diff changeset
506 iq_handlers = signal_iq_handlers = NULL;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
507 }

mercurial