Mercurial > pidgin
annotate libpurple/protocols/jabber/iq.c @ 26587:925a5a7605b6
propagate from branch 'im.pidgin.pidgin' (head 580055bb22fea0076d3a90d9df9346abd1789bab)
to branch 'im.pidgin.cpw.malu.xmpp.idle' (head 6f02916e339d8e3c634c28d01510959a953da47a)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 13 Apr 2009 13:33:47 +0000 |
parents | 457dca546b23 |
children | 92565c8e1e3a 676494d92262 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber Protocol Plugin |
15373
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 |
19681
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 |
15373
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" |
15373
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" |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
23854
diff
changeset
|
31 #include "jingle/jingle.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "oob.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "roster.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "si.h" |
17835
6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
35 #include "ping.h" |
17871
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:
17835
diff
changeset
|
36 #include "adhoccommands.h" |
23777
4ac5db6e39f3
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <ml@update.uu.se>
parents:
22911
diff
changeset
|
37 #include "data.h" |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
22911
diff
changeset
|
38 #include "ibb.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "utsname.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 #endif |
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 GHashTable *iq_handlers = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 |
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 *jabber_iq_new(JabberStream *js, JabberIqType type) |
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 JabberIq *iq; |
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 = g_new0(JabberIq, 1); |
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->type = type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 iq->node = xmlnode_new("iq"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 switch(iq->type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 case JABBER_IQ_SET: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 xmlnode_set_attrib(iq->node, "type", "set"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 case JABBER_IQ_GET: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 xmlnode_set_attrib(iq->node, "type", "get"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 case JABBER_IQ_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 xmlnode_set_attrib(iq->node, "type", "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 case JABBER_IQ_RESULT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 xmlnode_set_attrib(iq->node, "type", "result"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 case JABBER_IQ_NONE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 /* this shouldn't ever happen */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 } |
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 iq->js = js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 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
|
77 iq->id = jabber_get_next_id(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 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
|
79 } |
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 return iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 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
|
85 const char *xmlns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 JabberIq *iq = jabber_iq_new(js, type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 query = xmlnode_new_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 xmlnode_set_namespace(query, xmlns); |
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 return iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 typedef struct _JabberCallbackData { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 JabberIqCallback *callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 gpointer data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 } JabberCallbackData; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 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
|
103 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 iq->callback = callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 iq->callback_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 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
|
109 { |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
110 g_free(iq->id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 if(id) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 xmlnode_set_attrib(iq->node, "id", id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 iq->id = g_strdup(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 xmlnode_remove_attrib(iq->node, "id"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 iq->id = NULL; |
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 } |
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 void jabber_iq_send(JabberIq *iq) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 JabberCallbackData *jcd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 g_return_if_fail(iq != NULL); |
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 jabber_send(iq->js, iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 if(iq->id && iq->callback) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 jcd = g_new0(JabberCallbackData, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 jcd->callback = iq->callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 jcd->data = iq->callback_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 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
|
133 } |
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 jabber_iq_free(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 } |
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 void jabber_iq_free(JabberIq *iq) |
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_return_if_fail(iq != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 g_free(iq->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 xmlnode_free(iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 g_free(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
147 static void jabber_iq_last_parse(JabberStream *js, const char *from, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
148 JabberIqType type, const char *id, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
149 xmlnode *packet) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 char *idle_time; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
155 if(type == JABBER_IQ_GET) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 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
|
157 jabber_iq_set_id(iq, id); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
158 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
159 xmlnode_set_attrib(iq->node, "to", from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 query = xmlnode_get_child(iq->node, "query"); |
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 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
|
164 xmlnode_set_attrib(query, "seconds", idle_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 g_free(idle_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 jabber_iq_send(iq); |
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 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
171 static void jabber_iq_time_parse(JabberStream *js, const char *from, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
172 JabberIqType type, const char *id, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
173 xmlnode *child) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 { |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
175 const char *xmlns; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 time_t now_t; |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
178 struct tm now_local; |
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
179 struct tm now_utc; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 struct tm *now; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 time(&now_t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 now = localtime(&now_t); |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
184 memcpy(&now_local, now, sizeof(struct tm)); |
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
185 now = gmtime(&now_t); |
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
186 memcpy(&now_utc, now, sizeof(struct tm)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
188 xmlns = xmlnode_get_namespace(child); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
189 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
190 if(type == JABBER_IQ_GET) { |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
191 xmlnode *utc; |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
192 const char *date, *tz, *display; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
194 iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 jabber_iq_set_id(iq, id); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
196 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
197 xmlnode_set_attrib(iq->node, "to", from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
199 child = xmlnode_new_child(iq->node, child->name); |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
200 xmlnode_set_namespace(child, xmlns); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
201 utc = xmlnode_new_child(child, "utc"); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
202 |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
203 if(!strcmp("urn:xmpp:time", xmlns)) { |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
204 tz = purple_get_tzoff_str(&now_local, TRUE); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
205 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
207 date = purple_utf8_strftime("%FT%TZ", &now_utc); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
208 xmlnode_insert_data(utc, date, -1); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
209 } else { /* jabber:iq:time */ |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
210 tz = purple_utf8_strftime("%Z", &now_local); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
211 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
213 date = purple_utf8_strftime("%Y%m%dT%T", &now_utc); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
214 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:
25639
diff
changeset
|
215 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
216 display = purple_utf8_strftime("%d %b %Y %T", &now_local); |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
217 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
|
218 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 jabber_iq_send(iq); |
18109
3d7129ac1de9
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17935
diff
changeset
|
221 } |
3d7129ac1de9
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17935
diff
changeset
|
222 } |
3d7129ac1de9
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17935
diff
changeset
|
223 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
224 static void jabber_iq_version_parse(JabberStream *js, const char *from, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
225 JabberIqType type, const char *id, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
226 xmlnode *packet) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
231 if(type == JABBER_IQ_GET) { |
18292
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
232 GHashTable *ui_info; |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
233 const char *ui_name = NULL, *ui_version = NULL; |
20220
23248bf2bffd
applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents:
19697
diff
changeset
|
234 #if 0 |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
235 char *os = NULL; |
15822 | 236 if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 struct utsname osinfo; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 uname(&osinfo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 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
|
241 osinfo.machine); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 } |
20220
23248bf2bffd
applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents:
19697
diff
changeset
|
243 #endif |
15373
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 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version"); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
246 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
247 xmlnode_set_attrib(iq->node, "to", from); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 jabber_iq_set_id(iq, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 |
18292
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
252 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
|
253 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 } |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
258 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
259 if(NULL != ui_name && NULL != ui_version) { |
18294 | 260 char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version); |
261 xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1); | |
262 xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1); | |
263 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
|
264 } else { |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
265 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
|
266 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
|
267 } |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
268 |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
269 #if 0 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 if(os) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 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
|
272 g_free(os); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 } |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
274 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 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
|
281 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 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
|
283 } |
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 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
|
286 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 JabberCallbackData *jcd; |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
288 xmlnode *child, *error, *x; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 const char *xmlns; |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
290 const char *iq_type, *id, *from; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
291 JabberIqType type = JABBER_IQ_NONE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
293 /* |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
294 * 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:
24302
diff
changeset
|
295 * 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:
24302
diff
changeset
|
296 * 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:
24302
diff
changeset
|
297 * being) sufficient. |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
298 */ |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
299 for (child = packet->child; child; child = child->next) { |
25644
19fa48931b9d
This is shorter and easier to read.
Paul Aurich <paul@darkrain42.org>
parents:
25642
diff
changeset
|
300 if (child->type == XMLNODE_TYPE_TAG) |
19fa48931b9d
This is shorter and easier to read.
Paul Aurich <paul@darkrain42.org>
parents:
25642
diff
changeset
|
301 break; |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
302 } |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
303 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
304 iq_type = xmlnode_get_attrib(packet, "type"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 from = xmlnode_get_attrib(packet, "from"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 id = xmlnode_get_attrib(packet, "id"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
308 if (iq_type) { |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
309 if (!strcmp(iq_type, "get")) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
310 type = JABBER_IQ_GET; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
311 else if (!strcmp(iq_type, "set")) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
312 type = JABBER_IQ_SET; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
313 else if (!strcmp(iq_type, "result")) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
314 type = JABBER_IQ_RESULT; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
315 else if (!strcmp(iq_type, "error")) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
316 type = JABBER_IQ_ERROR; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
317 } |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
318 |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
319 if (type == JABBER_IQ_NONE) { |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
320 purple_debug_error("jabber", "IQ with invalid type ('%s') - ignoring.\n", |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
321 iq_type ? iq_type : "(null)"); |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
322 return; |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
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:
24058
diff
changeset
|
324 |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
325 /* 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:
24058
diff
changeset
|
326 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:
24058
diff
changeset
|
327 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
328 if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) { |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
329 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:
24058
diff
changeset
|
330 |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
331 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:
24058
diff
changeset
|
332 iq->node = xmlnode_copy(packet); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
333 if (from) { |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
334 xmlnode_set_attrib(iq->node, "to", from); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
335 xmlnode_remove_attrib(iq->node, "from"); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
336 } |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
337 |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
338 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:
24058
diff
changeset
|
339 /* 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:
24058
diff
changeset
|
340 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:
24058
diff
changeset
|
341 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:
24058
diff
changeset
|
342 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:
24058
diff
changeset
|
343 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:
24058
diff
changeset
|
344 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:
24058
diff
changeset
|
345 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:
24058
diff
changeset
|
346 |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
347 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:
24058
diff
changeset
|
348 } else |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
349 purple_debug_error("jabber", "IQ of type '%s' missing id - ignoring.\n", |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
350 iq_type); |
24302
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
351 |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
352 return; |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
353 } |
040c66dffbf0
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24058
diff
changeset
|
354 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 /* First, lets see if a special callback got registered */ |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
356 if(type == JABBER_IQ_RESULT || type == JABBER_IQ_ERROR) { |
25662
ba2b63988b3c
Remove a "suggested parenthes around assignment" warning
Paul Aurich <paul@darkrain42.org>
parents:
25661
diff
changeset
|
357 if((jcd = g_hash_table_lookup(js->iq_callbacks, id))) { |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
358 jcd->callback(js, from, type, id, packet, jcd->data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 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
|
360 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 /* Apparently not, so lets see if we have a pre-defined handler */ |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
365 if(child && (xmlns = xmlnode_get_namespace(child))) { |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
366 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:
25645
diff
changeset
|
367 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:
25645
diff
changeset
|
368 g_free(key); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
370 if(jih) { |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
371 jih(js, from, type, id, child); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 return; |
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 } |
26334
6f0200f1e497
Clean up usage of USE_VV in the XMPP protocol.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26131
diff
changeset
|
375 |
17835
6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
376 purple_debug_info("jabber", "jabber_iq_parse\n"); |
6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
377 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 /* If we get here, send the default error reply mandated by XMPP-CORE */ |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
379 if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 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
|
381 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 xmlnode_free(iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 iq->node = xmlnode_copy(packet); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
384 if (from) { |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
385 xmlnode_set_attrib(iq->node, "to", from); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
386 xmlnode_remove_attrib(iq->node, "from"); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
387 } |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
388 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 xmlnode_set_attrib(iq->node, "type", "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 error = xmlnode_new_child(iq->node, "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 xmlnode_set_attrib(error, "type", "cancel"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 xmlnode_set_attrib(error, "code", "501"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 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
|
394 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
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 } |
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 |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
400 void jabber_iq_register_handler(const char *node, const char *xmlns, JabberIqHandler *handlerfunc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 { |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
402 /* |
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
403 * 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:
25645
diff
changeset
|
404 * (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:
25645
diff
changeset
|
405 * 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:
25645
diff
changeset
|
406 */ |
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
407 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:
25645
diff
changeset
|
408 g_hash_table_replace(iq_handlers, key, handlerfunc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 void jabber_iq_init(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 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
|
414 |
26482
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
415 jabber_iq_register_handler("jingle", JINGLE, jingle_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
416 jabber_iq_register_handler("mailbox", "google:mail:notify", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
417 jabber_gmail_poke); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
418 jabber_iq_register_handler("new-mail", "google:mail:notify", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
419 jabber_gmail_poke); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
420 jabber_iq_register_handler("ping", "urn:xmpp:ping", jabber_ping_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
421 jabber_iq_register_handler("query", GOOGLE_JINGLE_INFO_NAMESPACE, |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
422 jabber_google_handle_jingle_info); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
423 jabber_iq_register_handler("query", "http://jabber.org/protocol/bytestreams", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
424 jabber_bytestreams_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
425 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#info", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
426 jabber_disco_info_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
427 jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#items", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
428 jabber_disco_items_parse); |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
429 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:
25645
diff
changeset
|
430 jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse); |
26482
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
431 jabber_iq_register_handler("query", "jabber:iq:register", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
432 jabber_register_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
433 jabber_iq_register_handler("query", "jabber:iq:roster", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
434 jabber_roster_parse); |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
435 jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse); |
26482
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
436 jabber_iq_register_handler("query", "jabber:iq:version", |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
437 jabber_iq_version_parse); |
26475
bf9438ea308d
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
438 #ifdef USE_VV |
bf9438ea308d
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
439 jabber_iq_register_handler("session", "http://www.google.com/session", |
bf9438ea308d
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
440 jabber_google_session_parse); |
bf9438ea308d
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
441 #endif |
26482
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
442 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse); |
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
26479
diff
changeset
|
443 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 void jabber_iq_uninit(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 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
|
449 iq_handlers = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 } |