annotate libpurple/protocols/jabber/iq.c @ 25931:89c4edb5e545

Track the node name in addition to the namespace for handlers (try #2)
author Paul Aurich <paul@darkrain42.org>
date Sun, 08 Feb 2009 07:04:34 +0000
parents ced3d4ab745a
children a4cba207068f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
2 * purple - Jabber Protocol Plugin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18294
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "internal.h"
18292
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
22 #include "core.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "prefs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "disco.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "google.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "oob.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "roster.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "si.h"
17562
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 15823
diff changeset
34 #include "ping.h"
17598
43df07968000 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 <pidgin@monitzer.com>
parents: 17562
diff changeset
35 #include "adhoccommands.h"
23445
4ac5db6e39f3 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents: 22913
diff changeset
36 #include "data.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "utsname.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 GHashTable *iq_handlers = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 iq = g_new0(JabberIq, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 iq->type = type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 iq->node = xmlnode_new("iq");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 switch(iq->type) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 case JABBER_IQ_SET:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 xmlnode_set_attrib(iq->node, "type", "set");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 case JABBER_IQ_GET:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 xmlnode_set_attrib(iq->node, "type", "get");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 case JABBER_IQ_ERROR:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 xmlnode_set_attrib(iq->node, "type", "error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 case JABBER_IQ_RESULT:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 xmlnode_set_attrib(iq->node, "type", "result");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 case JABBER_IQ_NONE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 /* this shouldn't ever happen */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 iq->js = js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 iq->id = jabber_get_next_id(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 xmlnode_set_attrib(iq->node, "id", iq->id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 return iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 const char *xmlns)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 JabberIq *iq = jabber_iq_new(js, type);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 query = xmlnode_new_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 xmlnode_set_namespace(query, xmlns);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 return iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 typedef struct _JabberCallbackData {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 JabberIqCallback *callback;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 gpointer data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 } JabberCallbackData;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 iq->callback = callback;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 iq->callback_data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 void jabber_iq_set_id(JabberIq *iq, const char *id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 {
24244
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
108 g_free(iq->id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 if(id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 xmlnode_set_attrib(iq->node, "id", id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 iq->id = g_strdup(id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 xmlnode_remove_attrib(iq->node, "id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 iq->id = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 void jabber_iq_send(JabberIq *iq)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 JabberCallbackData *jcd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 g_return_if_fail(iq != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 jabber_send(iq->js, iq->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 if(iq->id && iq->callback) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 jcd = g_new0(JabberCallbackData, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 jcd->callback = iq->callback;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 jcd->data = iq->callback_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 g_hash_table_insert(iq->js->iq_callbacks, g_strdup(iq->id), jcd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 jabber_iq_free(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 void jabber_iq_free(JabberIq *iq)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 g_return_if_fail(iq != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 g_free(iq->id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 xmlnode_free(iq->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 g_free(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 static void jabber_iq_last_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 const char *type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 const char *from;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 const char *id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 char *idle_time;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 from = xmlnode_get_attrib(packet, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 id = xmlnode_get_attrib(packet, "id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 if(type && !strcmp(type, "get")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 jabber_iq_set_id(iq, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 xmlnode_set_attrib(iq->node, "to", from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 xmlnode_set_attrib(query, "seconds", idle_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 g_free(idle_time);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 static void jabber_iq_time_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 {
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
175 const char *type, *from, *id, *xmlns;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 JabberIq *iq;
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
177 xmlnode *child;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 time_t now_t;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 struct tm *now;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 time(&now_t);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 now = localtime(&now_t);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 from = xmlnode_get_attrib(packet, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 id = xmlnode_get_attrib(packet, "id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
188 if ((child = xmlnode_get_child(packet, "query"))) {
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
189 xmlns = "jabber:iq:time";
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
190 } else if ((child = xmlnode_get_child(packet, "time"))) {
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
191 xmlns = "urn:xmpp:time";
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
192 } else {
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
193 purple_debug_warning("jabber", "Malformed IQ time packet\n");
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
194 return;
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
195 }
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
196
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 if(type && !strcmp(type, "get")) {
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
198 xmlnode *utc;
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
199 const char *date, *tz, *display;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
201 iq = jabber_iq_new(js, JABBER_IQ_RESULT);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 jabber_iq_set_id(iq, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 xmlnode_set_attrib(iq->node, "to", from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
205 child = xmlnode_new_child(iq->node, child->name);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
206 utc = xmlnode_new_child(child, "utc");
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
207
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
208 if(!strcmp("urn:xmpp:time", xmlns)) {
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
209 tz = purple_get_tzoff_str(now, TRUE);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
210 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
212 date = purple_utf8_strftime("%FT%TZ", now);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
213 xmlnode_insert_data(utc, date, -1);
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
214 } else { /* jabber:iq:time */
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
215 tz = purple_utf8_strftime("%Z", now);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
216 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
25926
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
218 date = purple_utf8_strftime("%Y%m%dT%T", now);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
219 xmlnode_insert_data(utc, date, -1);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
220
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
221 display = purple_utf8_strftime("%d %b %Y %T", now);
865123f21a72 Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents: 25924
diff changeset
222 xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1);
18259
c5c265dff90c support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18122
diff changeset
223 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 jabber_iq_send(iq);
18109
3d7129ac1de9 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17859
diff changeset
226 }
3d7129ac1de9 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17859
diff changeset
227 }
3d7129ac1de9 respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents: 17859
diff changeset
228
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 static void jabber_iq_version_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 const char *type, *from, *id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 xmlnode *query;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 if(type && !strcmp(type, "get")) {
18292
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
238 GHashTable *ui_info;
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
239 const char *ui_name = NULL, *ui_version = NULL;
20220
23248bf2bffd applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents: 19696
diff changeset
240 #if 0
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20220
diff changeset
241 char *os = NULL;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
242 if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 struct utsname osinfo;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 uname(&osinfo);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 osinfo.machine);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 }
20220
23248bf2bffd applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents: 19696
diff changeset
249 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 from = xmlnode_get_attrib(packet, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 id = xmlnode_get_attrib(packet, "id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 xmlnode_set_attrib(iq->node, "to", from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 jabber_iq_set_id(iq, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
18292
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
259 ui_info = purple_core_get_ui_info();
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
260
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
261 if(NULL != ui_info) {
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
262 ui_name = g_hash_table_lookup(ui_info, "name");
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
263 ui_version = g_hash_table_lookup(ui_info, "version");
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
264 }
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
265
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
266 if(NULL != ui_name && NULL != ui_version) {
18294
c58b83d2b188 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18292
diff changeset
267 char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version);
c58b83d2b188 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18292
diff changeset
268 xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1);
c58b83d2b188 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18292
diff changeset
269 xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1);
c58b83d2b188 I like this better
Nathan Walp <nwalp@pidgin.im>
parents: 18292
diff changeset
270 g_free(version_complete);
18292
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
271 } else {
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
272 xmlnode_insert_data(xmlnode_new_child(query, "name"), "libpurple", -1);
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
273 xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
274 }
9db52d9b8436 core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents: 18259
diff changeset
275
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20220
diff changeset
276 #if 0
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 if(os) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 xmlnode_insert_data(xmlnode_new_child(query, "os"), os, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 g_free(os);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 }
20333
53afc5cce143 applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents: 20220
diff changeset
281 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 g_hash_table_remove(js->iq_callbacks, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 void jabber_iq_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 JabberCallbackData *jcd;
25924
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
295 xmlnode *child, *error, *x;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 const char *xmlns;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 const char *type, *id, *from;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
25924
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
299 /*
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
300 * child will be either the first tag child or NULL if there is no child.
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
301 * Historically, we used just the 'query' subchild, but newer XEPs use
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
302 * differently named children. Grabbing the first child is (for the time
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
303 * being) sufficient.
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
304 */
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
305 for (child = packet->child; child; child = child->next) {
25929
19fa48931b9d This is shorter and easier to read.
Paul Aurich <paul@darkrain42.org>
parents: 25927
diff changeset
306 if (child->type == XMLNODE_TYPE_TAG)
19fa48931b9d This is shorter and easier to read.
Paul Aurich <paul@darkrain42.org>
parents: 25927
diff changeset
307 break;
25924
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
308 }
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
309
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 from = xmlnode_get_attrib(packet, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 id = xmlnode_get_attrib(packet, "id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
24244
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
314 if(type == NULL || !(!strcmp(type, "get") || !strcmp(type, "set")
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
315 || !strcmp(type, "result") || !strcmp(type, "error"))) {
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
316 purple_debug_error("jabber", "IQ with invalid type ('%s') - ignoring.\n",
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
317 type ? type : "(null)");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
318 return;
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
319 }
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
320
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
321 /* All IQs must have an ID, so send an error for a set/get that doesn't */
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
322 if(!id || !*id) {
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
323
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
324 if(!strcmp(type, "set") || !strcmp(type, "get")) {
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
325 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
326
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
327 xmlnode_free(iq->node);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
328 iq->node = xmlnode_copy(packet);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
329 xmlnode_set_attrib(iq->node, "to", from);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
330 xmlnode_remove_attrib(iq->node, "from");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
331 xmlnode_set_attrib(iq->node, "type", "error");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
332 /* This id is clearly not useful, but we must put something there for a valid stanza */
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
333 iq->id = jabber_get_next_id(js);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
334 xmlnode_set_attrib(iq->node, "id", iq->id);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
335 error = xmlnode_new_child(iq->node, "error");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
336 xmlnode_set_attrib(error, "type", "modify");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
337 x = xmlnode_new_child(error, "bad-request");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
338 xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas");
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
339
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
340 jabber_iq_send(iq);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
341 } else
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
342 purple_debug_error("jabber", "IQ of type '%s' missing id - ignoring.\n", type);
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
343
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
344 return;
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
345 }
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
346
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 /* First, lets see if a special callback got registered */
24244
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
348 if(!strcmp(type, "result") || !strcmp(type, "error")) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 if(id && *id && (jcd = g_hash_table_lookup(js->iq_callbacks, id))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 jcd->callback(js, packet, jcd->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 jabber_iq_remove_callback_by_id(js, id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 /* Apparently not, so lets see if we have a pre-defined handler */
25924
b5052c66701c Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents: 24244
diff changeset
357 if(child && (xmlns = xmlnode_get_namespace(child))) {
25931
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
358 char *key = g_strdup_printf("%s %s", child->name, xmlns);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
359 JabberIqHandler *jih = g_hash_table_lookup(iq_handlers, key);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
360 g_free(key);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
361
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
362 if(jih) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 jih(js, packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
17562
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 15823
diff changeset
368 purple_debug_info("jabber", "jabber_iq_parse\n");
6ab1089e2101 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents: 15823
diff changeset
369
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 /* If we get here, send the default error reply mandated by XMPP-CORE */
24244
040c66dffbf0 Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23988
diff changeset
371 if(!strcmp(type, "set") || !strcmp(type, "get")) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 xmlnode_free(iq->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 iq->node = xmlnode_copy(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 xmlnode_set_attrib(iq->node, "to", from);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 xmlnode_remove_attrib(iq->node, "from");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 xmlnode_set_attrib(iq->node, "type", "error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 error = xmlnode_new_child(iq->node, "error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 xmlnode_set_attrib(error, "type", "cancel");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 xmlnode_set_attrib(error, "code", "501");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 x = xmlnode_new_child(error, "feature-not-implemented");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
25931
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
389 void jabber_iq_register_handler(const char *node, const char *xmlns, JabberIqHandler *handlerfunc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 {
25931
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
391 /*
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
392 * This is valid because nodes nor namespaces cannot have spaces in them
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
393 * (see http://www.w3.org/TR/2006/REC-xml-20060816/ and
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
394 * http://www.w3.org/TR/REC-xml-names/)
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
395 */
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
396 char *key = g_strdup_printf("%s %s", node, xmlns);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
397 g_hash_table_replace(iq_handlers, key, handlerfunc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 void jabber_iq_init(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
25931
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
404 jabber_iq_register_handler("mailbox", "google:mail:notify", jabber_gmail_poke);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
405 jabber_iq_register_handler("new-mail", "google:mail:notify", jabber_gmail_poke);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
406 jabber_iq_register_handler("query", "http://jabber.org/protocol/bytestreams", jabber_bytestreams_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
407 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#info", jabber_disco_info_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
408 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#items", jabber_disco_items_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
409 jabber_iq_register_handler("si", "http://jabber.org/protocol/si", jabber_si_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
410 jabber_iq_register_handler("query", "jabber:iq:last", jabber_iq_last_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
411 jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
412 jabber_iq_register_handler("query", "jabber:iq:register", jabber_register_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
413 jabber_iq_register_handler("query", "jabber:iq:roster", jabber_roster_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
414 jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
415 jabber_iq_register_handler("query", "jabber:iq:version", jabber_iq_version_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
416 jabber_iq_register_handler("data", XEP_0231_NAMESPACE, jabber_data_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
417 jabber_iq_register_handler("ping", "urn:xmpp:ping", jabber_ping_parse);
89c4edb5e545 Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents: 25930
diff changeset
418 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 void jabber_iq_uninit(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 g_hash_table_destroy(iq_handlers);
21603
a4b6854737d5 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20333
diff changeset
424 iq_handlers = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426