Mercurial > pidgin
annotate libpurple/protocols/jabber/iq.c @ 26465:ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 13 Mar 2009 02:26:45 +0000 |
parents | 439f07ce4c8a |
children | 4f14455a86d2 |
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" |
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" |
17835
6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
34 #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
|
35 #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
|
36 #include "data.h" |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
22911
diff
changeset
|
37 #include "ibb.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "utsname.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 GHashTable *iq_handlers = NULL; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 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
|
47 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 iq = g_new0(JabberIq, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 iq->type = type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 iq->node = xmlnode_new("iq"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 switch(iq->type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 case JABBER_IQ_SET: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 xmlnode_set_attrib(iq->node, "type", "set"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 case JABBER_IQ_GET: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 xmlnode_set_attrib(iq->node, "type", "get"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 case JABBER_IQ_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 xmlnode_set_attrib(iq->node, "type", "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 case JABBER_IQ_RESULT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 xmlnode_set_attrib(iq->node, "type", "result"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 case JABBER_IQ_NONE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 /* this shouldn't ever happen */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 break; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 iq->js = js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 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
|
76 iq->id = jabber_get_next_id(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 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
|
78 } |
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 return iq; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 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
|
84 const char *xmlns) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 JabberIq *iq = jabber_iq_new(js, type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 query = xmlnode_new_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 xmlnode_set_namespace(query, xmlns); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 return iq; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 typedef struct _JabberCallbackData { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 JabberIqCallback *callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 gpointer data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 } JabberCallbackData; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 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
|
102 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 iq->callback = callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 iq->callback_data = data; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 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
|
108 { |
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
|
109 g_free(iq->id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 if(id) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 xmlnode_set_attrib(iq->node, "id", id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 iq->id = g_strdup(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 xmlnode_remove_attrib(iq->node, "id"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 iq->id = NULL; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 void jabber_iq_send(JabberIq *iq) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 JabberCallbackData *jcd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 g_return_if_fail(iq != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 jabber_send(iq->js, iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 if(iq->id && iq->callback) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 jcd = g_new0(JabberCallbackData, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 jcd->callback = iq->callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 jcd->data = iq->callback_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 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
|
132 } |
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 jabber_iq_free(iq); |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 void jabber_iq_free(JabberIq *iq) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 g_return_if_fail(iq != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 g_free(iq->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 xmlnode_free(iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 g_free(iq); |
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 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
146 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
|
147 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
|
148 xmlnode *packet) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 JabberIq *iq; |
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 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
154 if(type == JABBER_IQ_GET) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 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
|
156 jabber_iq_set_id(iq, id); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
157 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
158 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
|
159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 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
|
163 xmlnode_set_attrib(query, "seconds", idle_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 g_free(idle_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 } |
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 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
170 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
|
171 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
|
172 xmlnode *child) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 { |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
174 const char *xmlns; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 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
|
177 struct tm now_local; |
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
178 struct tm now_utc; |
15373
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); |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
183 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
|
184 now = gmtime(&now_t); |
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
185 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
|
186 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
187 xmlns = xmlnode_get_namespace(child); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
189 if(type == JABBER_IQ_GET) { |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
190 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
|
191 const char *date, *tz, *display; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
193 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
|
194 jabber_iq_set_id(iq, id); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
195 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
196 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
|
197 |
25641
865123f21a72
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <paul@darkrain42.org>
parents:
25639
diff
changeset
|
198 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
|
199 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
|
200 utc = xmlnode_new_child(child, "utc"); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
201 |
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
206 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
|
207 xmlnode_insert_data(utc, date, -1); |
18259
c5c265dff90c
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18122
diff
changeset
|
208 } 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
|
209 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
|
210 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
|
211 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
212 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
|
213 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
|
214 |
25657
af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
Paul Aurich <paul@darkrain42.org>
parents:
25652
diff
changeset
|
215 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
|
216 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
|
217 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 jabber_iq_send(iq); |
18109
3d7129ac1de9
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17935
diff
changeset
|
220 } |
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 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
223 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
|
224 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
|
225 xmlnode *packet) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 xmlnode *query; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
230 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
|
231 GHashTable *ui_info; |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
232 const char *ui_name = NULL, *ui_version = NULL; |
20220
23248bf2bffd
applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents:
19697
diff
changeset
|
233 #if 0 |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
234 char *os = NULL; |
15822 | 235 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
|
236 struct utsname osinfo; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 uname(&osinfo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 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
|
240 osinfo.machine); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 } |
20220
23248bf2bffd
applied changes from 8543caa9958f323a231c630bebd65c74dec3401f
Richard Laager <rlaager@wiktel.com>
parents:
19697
diff
changeset
|
242 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 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
|
245 if (from) |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
246 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
|
247 jabber_iq_set_id(iq, id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
18292
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
251 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
|
252 |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
253 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
|
254 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
|
255 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
|
256 } |
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 if(NULL != ui_name && NULL != ui_version) { |
18294 | 259 char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version); |
260 xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1); | |
261 xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1); | |
262 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
|
263 } else { |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
264 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
|
265 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
|
266 } |
9db52d9b8436
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18259
diff
changeset
|
267 |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
268 #if 0 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 if(os) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 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
|
271 g_free(os); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 } |
20333
53afc5cce143
applied changes from d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
Luke Schierer <lschiere@pidgin.im>
parents:
20220
diff
changeset
|
273 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 } |
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 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
|
280 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 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
|
282 } |
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 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
|
285 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 JabberCallbackData *jcd; |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
287 xmlnode *child, *error, *x; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 const char *xmlns; |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
289 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
|
290 JabberIqType type = JABBER_IQ_NONE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
292 /* |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
293 * 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
|
294 * 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
|
295 * 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
|
296 * being) sufficient. |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
297 */ |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
298 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
|
299 if (child->type == XMLNODE_TYPE_TAG) |
19fa48931b9d
This is shorter and easier to read.
Paul Aurich <paul@darkrain42.org>
parents:
25642
diff
changeset
|
300 break; |
25639
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
301 } |
b5052c66701c
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <paul@darkrain42.org>
parents:
24302
diff
changeset
|
302 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
303 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
|
304 from = xmlnode_get_attrib(packet, "from"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 id = xmlnode_get_attrib(packet, "id"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
307 if (iq_type) { |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
308 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
|
309 type = JABBER_IQ_GET; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
310 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
|
311 type = JABBER_IQ_SET; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
312 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
|
313 type = JABBER_IQ_RESULT; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
314 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
|
315 type = JABBER_IQ_ERROR; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
316 } |
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 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
|
319 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
|
320 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
|
321 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
|
322 } |
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 /* 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
|
325 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
|
326 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
327 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
|
328 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
|
329 |
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 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
|
331 iq->node = xmlnode_copy(packet); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
332 if (from) { |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
333 xmlnode_set_attrib(iq->node, "to", from); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
334 xmlnode_remove_attrib(iq->node, "from"); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
335 } |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
336 |
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
|
337 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
|
338 /* 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 |
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 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
|
347 } else |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
348 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
|
349 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
|
350 |
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 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
|
352 } |
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 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 /* 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 } |
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 /* 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
|
364 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
|
365 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
|
366 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
|
367 g_free(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 |
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
369 if(jih) { |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25647
diff
changeset
|
370 jih(js, from, type, id, child); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 } |
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 |
17835
6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <pidgin@monitzer.com>
parents:
15822
diff
changeset
|
375 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
|
376 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 /* 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
|
378 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
|
379 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
|
380 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 xmlnode_free(iq->node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 iq->node = xmlnode_copy(packet); |
25649
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
383 if (from) { |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
384 xmlnode_set_attrib(iq->node, "to", from); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
385 xmlnode_remove_attrib(iq->node, "from"); |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
386 } |
c8606917787a
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <paul@darkrain42.org>
parents:
25648
diff
changeset
|
387 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 xmlnode_set_attrib(iq->node, "type", "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 error = xmlnode_new_child(iq->node, "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 xmlnode_set_attrib(error, "type", "cancel"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 xmlnode_set_attrib(error, "code", "501"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 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
|
393 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
|
394 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 } |
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 |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
399 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
|
400 { |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
401 /* |
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
402 * 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
|
403 * (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
|
404 * 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
|
405 */ |
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
406 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
|
407 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
|
408 } |
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 void jabber_iq_init(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 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
|
413 |
25646
89c4edb5e545
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <paul@darkrain42.org>
parents:
25645
diff
changeset
|
414 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:
25645
diff
changeset
|
415 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:
25645
diff
changeset
|
416 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:
25645
diff
changeset
|
417 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:
25645
diff
changeset
|
418 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:
25645
diff
changeset
|
419 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:
25645
diff
changeset
|
420 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
|
421 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:
25645
diff
changeset
|
422 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:
25645
diff
changeset
|
423 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:
25645
diff
changeset
|
424 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:
25645
diff
changeset
|
425 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:
25645
diff
changeset
|
426 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:
25645
diff
changeset
|
427 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:
25645
diff
changeset
|
428 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 void jabber_iq_uninit(void) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 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
|
434 iq_handlers = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 } |