Sun, 16 Aug 2020 18:58:39 -0500
Fix some leaks.
Also, expand `g_ascii_dtostr` buffers to `G_ASCII_DTOSTR_BUF_SIZE`.
This is the size it's guaranteed to be under, so might as well have it be that size. It not too much bigger than the existing choice anyway.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/71/
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28155
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28155
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28155
diff
changeset
|
6 | * source distribution. |
| 7014 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18443
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | * |
| 22 | */ | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40312
diff
changeset
|
25 | #include <purple.h> |
| 7014 | 26 | |
| 7395 | 27 | #include "buddy.h" |
| 8312 | 28 | #include "disco.h" |
|
29913
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29399
diff
changeset
|
29 | #include "google/gmail.h" |
|
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29399
diff
changeset
|
30 | #include "google/google.h" |
|
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29399
diff
changeset
|
31 | #include "google/jingleinfo.h" |
|
58f5122fbcd3
First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents:
29399
diff
changeset
|
32 | #include "google/google_session.h" |
| 7014 | 33 | #include "iq.h" |
|
26143
673b6665624d
Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents:
23754
diff
changeset
|
34 | #include "jingle/jingle.h" |
| 7170 | 35 | #include "oob.h" |
| 7014 | 36 | #include "roster.h" |
| 7395 | 37 | #include "si.h" |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
15884
diff
changeset
|
38 | #include "ping.h" |
|
17805
5bd417a1c847
Implemented XEP-0050: Ad-Hoc Commands. Note that this XEP requires sending an initial command to the peer, which is not implemented in libpurple itself (since this requires a discovery browser or equivalent).
Andreas Monitzer <am@adiumx.com>
parents:
17769
diff
changeset
|
39 | #include "adhoccommands.h" |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23076
diff
changeset
|
40 | #include "data.h" |
|
24372
830701cec96f
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents:
23076
diff
changeset
|
41 | #include "ibb.h" |
| 7014 | 42 | |
|
29399
cce925ddb58a
These should be static
Paul Aurich <darkrain42@pidgin.im>
parents:
29359
diff
changeset
|
43 | static GHashTable *iq_handlers = NULL; |
|
cce925ddb58a
These should be static
Paul Aurich <darkrain42@pidgin.im>
parents:
29359
diff
changeset
|
44 | static GHashTable *signal_iq_handlers = NULL; |
| 14356 | 45 | |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
46 | struct _JabberIqCallbackData { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
47 | JabberIqCallback *callback; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
48 | gpointer data; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
49 | JabberID *to; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
50 | }; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
51 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
52 | void jabber_iq_callbackdata_free(JabberIqCallbackData *jcd) |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
53 | { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
54 | jabber_id_free(jcd->to); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
55 | g_free(jcd); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
56 | } |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
57 | |
| 7014 | 58 | JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type) |
| 59 | { | |
| 60 | JabberIq *iq; | |
| 61 | ||
| 62 | iq = g_new0(JabberIq, 1); | |
| 63 | ||
| 64 | iq->type = type; | |
| 65 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
66 | iq->node = purple_xmlnode_new("iq"); |
| 7014 | 67 | switch(iq->type) { |
| 68 | case JABBER_IQ_SET: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
69 | purple_xmlnode_set_attrib(iq->node, "type", "set"); |
| 7014 | 70 | break; |
| 71 | case JABBER_IQ_GET: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
72 | purple_xmlnode_set_attrib(iq->node, "type", "get"); |
| 7014 | 73 | break; |
| 74 | case JABBER_IQ_ERROR: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
75 | purple_xmlnode_set_attrib(iq->node, "type", "error"); |
| 7014 | 76 | break; |
| 77 | case JABBER_IQ_RESULT: | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
78 | purple_xmlnode_set_attrib(iq->node, "type", "result"); |
| 7014 | 79 | break; |
| 80 | case JABBER_IQ_NONE: | |
| 81 | /* this shouldn't ever happen */ | |
| 82 | break; | |
| 83 | } | |
| 84 | ||
| 85 | iq->js = js; | |
| 86 | ||
| 87 | if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) { | |
| 88 | iq->id = jabber_get_next_id(js); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
89 | purple_xmlnode_set_attrib(iq->node, "id", iq->id); |
| 7014 | 90 | } |
| 91 | ||
| 92 | return iq; | |
| 93 | } | |
| 94 | ||
| 95 | JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, | |
| 96 | const char *xmlns) | |
| 97 | { | |
| 98 | JabberIq *iq = jabber_iq_new(js, type); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
99 | PurpleXmlNode *query; |
| 7014 | 100 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
101 | query = purple_xmlnode_new_child(iq->node, "query"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
102 | purple_xmlnode_set_namespace(query, xmlns); |
| 7014 | 103 | |
| 104 | return iq; | |
| 105 | } | |
| 106 | ||
| 7395 | 107 | void |
| 108 | jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *callback, gpointer data) | |
| 7014 | 109 | { |
| 110 | iq->callback = callback; | |
| 7395 | 111 | iq->callback_data = data; |
| 7014 | 112 | } |
| 113 | ||
| 114 | void jabber_iq_set_id(JabberIq *iq, const char *id) | |
| 115 | { | |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
116 | g_free(iq->id); |
| 7014 | 117 | |
| 118 | if(id) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
119 | purple_xmlnode_set_attrib(iq->node, "id", id); |
| 7014 | 120 | iq->id = g_strdup(id); |
| 121 | } else { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
122 | purple_xmlnode_remove_attrib(iq->node, "id"); |
| 7014 | 123 | iq->id = NULL; |
| 124 | } | |
| 125 | } | |
| 126 | ||
| 127 | void jabber_iq_send(JabberIq *iq) | |
| 128 | { | |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
129 | JabberIqCallbackData *jcd; |
| 7014 | 130 | g_return_if_fail(iq != NULL); |
| 131 | ||
| 132 | jabber_send(iq->js, iq->node); | |
| 133 | ||
| 7395 | 134 | if(iq->id && iq->callback) { |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
135 | jcd = g_new0(JabberIqCallbackData, 1); |
| 7395 | 136 | jcd->callback = iq->callback; |
| 137 | jcd->data = iq->callback_data; | |
|
35265
77664079d0f0
Merge with a fair number of conflicts. Nothing too crazy.
Mark Doliner <mark@kingant.net>
diff
changeset
|
138 | jcd->to = jabber_id_new(purple_xmlnode_get_attrib(iq->node, "to")); |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
139 | |
| 8312 | 140 | g_hash_table_insert(iq->js->iq_callbacks, g_strdup(iq->id), jcd); |
| 7395 | 141 | } |
| 7014 | 142 | |
| 143 | jabber_iq_free(iq); | |
| 144 | } | |
| 145 | ||
| 146 | void jabber_iq_free(JabberIq *iq) | |
| 147 | { | |
| 148 | g_return_if_fail(iq != NULL); | |
| 149 | ||
| 150 | g_free(iq->id); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
151 | purple_xmlnode_free(iq->node); |
| 7014 | 152 | g_free(iq); |
| 153 | } | |
| 154 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
155 | static void jabber_iq_last_parse(JabberStream *js, const char *from, |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
156 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
157 | PurpleXmlNode *packet) |
| 7014 | 158 | { |
| 159 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
160 | PurpleXmlNode *query; |
|
14453
1cc75906700c
[gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents:
14375
diff
changeset
|
161 | char *idle_time; |
| 7014 | 162 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
163 | if(type == JABBER_IQ_GET) { |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
164 | iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, NS_LAST_ACTIVITY); |
| 8006 | 165 | jabber_iq_set_id(iq, id); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
166 | if (from) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
167 | purple_xmlnode_set_attrib(iq->node, "to", from); |
| 7014 | 168 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
169 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 7014 | 170 | |
|
14453
1cc75906700c
[gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents:
14375
diff
changeset
|
171 | idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
172 | purple_xmlnode_set_attrib(query, "seconds", idle_time); |
|
14453
1cc75906700c
[gaim-migrate @ 17098]
Mark Doliner <markdoliner@pidgin.im>
parents:
14375
diff
changeset
|
173 | g_free(idle_time); |
| 7401 | 174 | |
| 8006 | 175 | jabber_iq_send(iq); |
| 176 | } | |
| 7014 | 177 | } |
| 178 | ||
|
27433
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
179 | static void jabber_time_parse(JabberStream *js, const char *from, |
|
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
180 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
181 | PurpleXmlNode *child) |
| 7014 | 182 | { |
| 183 | JabberIq *iq; | |
|
18317
6c814e134e56
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18194
diff
changeset
|
184 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
185 | if(type == JABBER_IQ_GET) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
186 | PurpleXmlNode *tzo, *utc; |
|
39015
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
187 | GDateTime *now, *now_utc; |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
188 | gchar *date, *tz; |
| 7014 | 189 | |
|
25556
300d8959e04c
Fix the implementation of XEP-0202 (Entity Time) (thanks again to Marcus)
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
190 | iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
| 8006 | 191 | jabber_iq_set_id(iq, id); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
192 | if (from) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
193 | purple_xmlnode_set_attrib(iq->node, "to", from); |
| 7014 | 194 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
195 | child = purple_xmlnode_new_child(iq->node, child->name); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
196 | purple_xmlnode_set_namespace(child, NS_ENTITY_TIME); |
| 10941 | 197 | |
|
27433
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
198 | /* <tzo>-06:00</tzo> */ |
|
39015
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
199 | now = g_date_time_new_now_local(); |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
200 | tz = g_date_time_format(now, "%:z"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
201 | tzo = purple_xmlnode_new_child(child, "tzo"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
202 | purple_xmlnode_insert_data(tzo, tz, -1); |
|
39015
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
203 | g_free(tz); |
| 10941 | 204 | |
|
27433
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
205 | /* <utc>2006-12-19T17:58:35Z</utc> */ |
|
39015
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
206 | now_utc = g_date_time_to_utc(now); |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
207 | date = g_date_time_format(now_utc, "%FT%TZ"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
208 | utc = purple_xmlnode_new_child(child, "utc"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
209 | purple_xmlnode_insert_data(utc, date, -1); |
|
39015
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
210 | g_free(date); |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
211 | |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
212 | g_date_time_unref(now); |
|
bb929248da3d
jabber: Port purple_get_tzoff_str() to GDateTime functions
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
213 | g_date_time_unref(now_utc); |
| 7014 | 214 | |
| 8006 | 215 | jabber_iq_send(iq); |
|
27433
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
216 | } else { |
|
8eaac1cf4214
Remove obsoleted XEP-0090 (Legacy Entity Time)
Paul Aurich <darkrain42@pidgin.im>
parents:
27175
diff
changeset
|
217 | /* TODO: Errors */ |
|
18181
736c6abf62f4
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17753
diff
changeset
|
218 | } |
|
736c6abf62f4
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17753
diff
changeset
|
219 | } |
|
736c6abf62f4
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17753
diff
changeset
|
220 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
221 | static void jabber_iq_version_parse(JabberStream *js, const char *from, |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
222 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
223 | PurpleXmlNode *packet) |
| 7014 | 224 | { |
| 225 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
226 | PurpleXmlNode *query; |
| 7014 | 227 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
228 | if(type == JABBER_IQ_GET) { |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
229 | PurpleUiInfo *ui_info; |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
230 | const char *ui_name = NULL, *ui_version = NULL; |
| 7014 | 231 | |
| 8006 | 232 | iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version"); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
233 | if (from) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
234 | purple_xmlnode_set_attrib(iq->node, "to", from); |
| 8006 | 235 | jabber_iq_set_id(iq, id); |
| 7014 | 236 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
237 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 7014 | 238 | |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
239 | ui_info = purple_core_get_ui_info(); |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
240 | |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
241 | if(PURPLE_IS_UI_INFO(ui_info)) { |
|
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
242 | ui_name = purple_ui_info_get_name(ui_info); |
|
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
243 | ui_version = purple_ui_info_get_version(ui_info); |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
244 | } |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
245 | |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
246 | if(NULL != ui_name && NULL != ui_version) { |
| 18443 | 247 | char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
248 | purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "name"), ui_name, -1); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
249 | purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "version"), version_complete, -1); |
| 18443 | 250 | g_free(version_complete); |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
251 | } else { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
252 | purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "name"), "libpurple", -1); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
253 | purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "version"), VERSION, -1); |
|
18441
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
254 | } |
|
d255d04c0aa1
core support for UI info...now to do the UI piece
Nathan Walp <nwalp@pidgin.im>
parents:
18317
diff
changeset
|
255 | |
| 8006 | 256 | jabber_iq_send(iq); |
|
40312
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
257 | |
|
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
258 | if(PURPLE_IS_UI_INFO(ui_info)) { |
|
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
259 | g_object_unref(G_OBJECT(ui_info)); |
|
956745ff3ee8
Replace the ui info GHashTable with a gobject.
Gary Kramlich <grim@reaperworld.com>
parents:
39015
diff
changeset
|
260 | } |
| 7014 | 261 | } |
| 262 | } | |
| 263 | ||
| 13794 | 264 | void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id) |
| 265 | { | |
| 266 | g_hash_table_remove(js->iq_callbacks, id); | |
| 267 | } | |
| 268 | ||
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
269 | /** |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
270 | * Verify that the 'from' attribute of an IQ reply is a valid match for |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
271 | * a given IQ request. The expected behavior is outlined in section |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
272 | * 8.1.2.1 of the XMPP CORE spec (RFC 6120). We consider the reply to |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
273 | * be a valid match if any of the following is true: |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
274 | * - Request 'to' matches reply 'from' (including the case where |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
275 | * neither are set). |
|
36131
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
276 | * - Request 'to' was my JID (bare or full) and reply 'from' is empty. |
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
277 | * - Request 'to' was empty and reply 'from' is my JID. The spec says |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
278 | * we should only allow bare JID, but we also allow full JID for |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
279 | * compatibility with some servers. |
|
36131
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
280 | * - Request 'to' was empty and reply 'from' is server JID. Not allowed by |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
281 | * any spec, but for compatibility with some servers. |
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
282 | * |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
283 | * These rules should allow valid IQ replies while preventing spoofed |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
284 | * ones. |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
285 | * |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
286 | * For more discussion see the "Spoofing of iq ids and misbehaving |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
287 | * servers" email thread from January 2014 on the jdev and security |
|
36131
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
288 | * mailing lists. Also see https://developer.pidgin.im/ticket/15879 |
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
289 | * |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
290 | * @return TRUE if this reply is valid for the given request. |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
291 | */ |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
292 | static gboolean does_reply_from_match_request_to(JabberStream *js, JabberID *to, JabberID *from) |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
293 | { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
294 | if (jabber_id_equal(to, from)) { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
295 | /* Request 'to' matches reply 'from' */ |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
296 | return TRUE; |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
297 | } |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
298 | |
|
36131
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
299 | if (!from && purple_strequal(to->node, js->user->node) |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
300 | && purple_strequal(to->domain, js->user->domain)) { |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
301 | /* Request 'to' was my JID (bare or full) and reply 'from' is empty */ |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
302 | return TRUE; |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
303 | } |
|
c6926e608dc4
Allow incoming IQ stanzas with an empty 'from' if they're in response to
Mark Doliner <mark@kingant.net>
parents:
35308
diff
changeset
|
304 | |
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
305 | if (!to && purple_strequal(from->domain, js->user->domain)) { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
306 | /* Request 'to' is empty and reply 'from' domain matches our domain */ |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
307 | |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
308 | if (!from->node && !from->resource) { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
309 | /* Reply 'from' is server bare JID */ |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
310 | return TRUE; |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
311 | } |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
312 | |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
313 | if (purple_strequal(from->node, js->user->node) |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
314 | && (!from->resource || purple_strequal(from->resource, js->user->resource))) { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
315 | /* Reply 'from' is my full or bare JID */ |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
316 | return TRUE; |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
317 | } |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
318 | } |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
319 | |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
320 | return FALSE; |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
321 | } |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
322 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
323 | void jabber_iq_parse(JabberStream *js, PurpleXmlNode *packet) |
| 7014 | 324 | { |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
325 | JabberIqCallbackData *jcd; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
326 | PurpleXmlNode *child, *error, *x; |
| 7014 | 327 | const char *xmlns; |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
328 | const char *iq_type, *id, *from; |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
329 | JabberIqType type = JABBER_IQ_NONE; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
330 | gboolean signal_return; |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
331 | JabberID *from_id; |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
332 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
333 | from = purple_xmlnode_get_attrib(packet, "from"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
334 | id = purple_xmlnode_get_attrib(packet, "id"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
335 | iq_type = purple_xmlnode_get_attrib(packet, "type"); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
336 | |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
337 | /* |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
338 | * Ensure the 'from' attribute is valid. No point in handling a stanza |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
339 | * of which we don't understand where it came from. |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
340 | */ |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
341 | from_id = jabber_id_new(from); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
342 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
343 | if (from && !from_id) { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
344 | purple_debug_error("jabber", "Received an iq with an invalid from: %s\n", from); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
345 | return; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
346 | } |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
347 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
348 | /* |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
349 | * child will be either the first tag child or NULL if there is no child. |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
350 | * Historically, we used just the 'query' subchild, but newer XEPs use |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
351 | * differently named children. Grabbing the first child is (for the time |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
352 | * being) sufficient. |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
353 | */ |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
354 | for (child = packet->child; child; child = child->next) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
355 | if (child->type == PURPLE_XMLNODE_TYPE_TAG) |
|
25813
2e5e39a3107c
This is shorter and easier to read.
Paul Aurich <darkrain42@pidgin.im>
parents:
25557
diff
changeset
|
356 | break; |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
357 | } |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
24520
diff
changeset
|
358 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
359 | if (iq_type) { |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36131
diff
changeset
|
360 | if (purple_strequal(iq_type, "get")) |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
361 | type = JABBER_IQ_GET; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36131
diff
changeset
|
362 | else if (purple_strequal(iq_type, "set")) |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
363 | type = JABBER_IQ_SET; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36131
diff
changeset
|
364 | else if (purple_strequal(iq_type, "result")) |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
365 | type = JABBER_IQ_RESULT; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36131
diff
changeset
|
366 | else if (purple_strequal(iq_type, "error")) |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
367 | type = JABBER_IQ_ERROR; |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
368 | } |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
369 | |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
370 | if (type == JABBER_IQ_NONE) { |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
371 | purple_debug_error("jabber", "IQ with invalid type ('%s') - ignoring.\n", |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
372 | iq_type ? iq_type : "(null)"); |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
373 | jabber_id_free(from_id); |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
374 | return; |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
375 | } |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
376 | |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
377 | /* All IQs must have an ID, so send an error for a set/get that doesn't */ |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
378 | if(!id || !*id) { |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
379 | |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
380 | if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) { |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
381 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR); |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
382 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
383 | purple_xmlnode_free(iq->node); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
384 | iq->node = purple_xmlnode_copy(packet); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
385 | if (from) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
386 | purple_xmlnode_set_attrib(iq->node, "to", from); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
387 | purple_xmlnode_remove_attrib(iq->node, "from"); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
388 | } |
|
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
389 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
390 | purple_xmlnode_set_attrib(iq->node, "type", "error"); |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
391 | /* This id is clearly not useful, but we must put something there for a valid stanza */ |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
392 | iq->id = jabber_get_next_id(js); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
393 | purple_xmlnode_set_attrib(iq->node, "id", iq->id); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
394 | error = purple_xmlnode_new_child(iq->node, "error"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
395 | purple_xmlnode_set_attrib(error, "type", "modify"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
396 | x = purple_xmlnode_new_child(error, "bad-request"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
397 | purple_xmlnode_set_namespace(x, NS_XMPP_STANZAS); |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
398 | |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
399 | jabber_iq_send(iq); |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
400 | } else |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
401 | purple_debug_error("jabber", "IQ of type '%s' missing id - ignoring.\n", |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
402 | iq_type); |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
403 | |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
404 | jabber_id_free(from_id); |
|
24520
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
405 | return; |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
406 | } |
|
726138a1c69b
Perform some sanity checking on inbound IQs and send an error / drop as needed.
Daniel Atallah <datallah@pidgin.im>
parents:
24254
diff
changeset
|
407 | |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
408 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc), |
|
28155
de9b298ef02e
jabber: Emit jabber-receiving-iq after we've ensured id is !NULL
Paul Aurich <darkrain42@pidgin.im>
parents:
27433
diff
changeset
|
409 | "jabber-receiving-iq", js->gc, iq_type, id, from, packet)); |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
410 | if (signal_return) { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
411 | jabber_id_free(from_id); |
|
28155
de9b298ef02e
jabber: Emit jabber-receiving-iq after we've ensured id is !NULL
Paul Aurich <darkrain42@pidgin.im>
parents:
27433
diff
changeset
|
412 | return; |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
413 | } |
|
28155
de9b298ef02e
jabber: Emit jabber-receiving-iq after we've ensured id is !NULL
Paul Aurich <darkrain42@pidgin.im>
parents:
27433
diff
changeset
|
414 | |
| 8312 | 415 | /* First, lets see if a special callback got registered */ |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
416 | if(type == JABBER_IQ_RESULT || type == JABBER_IQ_ERROR) { |
|
35308
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
417 | jcd = g_hash_table_lookup(js->iq_callbacks, id); |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
418 | if (jcd) { |
|
b8e2a5fbffd3
Fix problems logging into some servers including jabber.org and
Mark Doliner <mark@kingant.net>
parents:
35235
diff
changeset
|
419 | if (does_reply_from_match_request_to(js, jcd->to, from_id)) { |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
420 | jcd->callback(js, from, type, id, packet, jcd->data); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
421 | jabber_iq_remove_callback_by_id(js, id); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
422 | jabber_id_free(from_id); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
423 | return; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
424 | } else { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
425 | char *expected_to; |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
426 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
427 | if (jcd->to) { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
428 | expected_to = jabber_id_get_full_jid(jcd->to); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
429 | } else { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
430 | expected_to = jabber_id_get_bare_jid(js->user); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
431 | } |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
432 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
433 | purple_debug_error("jabber", "Got a result iq with id %s from %s instead of expected %s!\n", id, from ? from : "(null)", expected_to); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
434 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
435 | g_free(expected_to); |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
436 | } |
| 8312 | 437 | } |
| 438 | } | |
| 439 | ||
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
440 | /* |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
441 | * Apparently not, so let's see if we have a pre-defined handler |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
442 | * or if an outside plugin is interested. |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
443 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
444 | if(child && (xmlns = purple_xmlnode_get_namespace(child))) { |
|
25820
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
445 | char *key = g_strdup_printf("%s %s", child->name, xmlns); |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
446 | JabberIqHandler *jih = g_hash_table_lookup(iq_handlers, key); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
447 | int signal_ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key)); |
|
25820
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
448 | g_free(key); |
| 7014 | 449 | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
450 | if (signal_ref > 0) { |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36362
diff
changeset
|
451 | signal_return = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_connection_get_protocol(js->gc), "jabber-watched-iq", |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
452 | js->gc, iq_type, id, from, child)); |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
453 | if (signal_return) { |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
454 | jabber_id_free(from_id); |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
455 | return; |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
456 | } |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
457 | } |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
458 | |
|
25820
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
459 | if(jih) { |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
460 | jih(js, from, type, id, child); |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
461 | jabber_id_free(from_id); |
| 8262 | 462 | return; |
| 463 | } | |
| 7395 | 464 | } |
|
26454
94130b583e0b
Clean up usage of USE_VV in the XMPP protocol.
Michael Ruprecht <maiku@pidgin.im>
parents:
26337
diff
changeset
|
465 | |
|
29359
cec28224afd4
jabber: Log a more useful message on unhandled IQs
Paul Aurich <darkrain42@pidgin.im>
parents:
29020
diff
changeset
|
466 | purple_debug_misc("jabber", "Unhandled IQ with id %s\n", id); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
15884
diff
changeset
|
467 | |
| 8312 | 468 | /* If we get here, send the default error reply mandated by XMPP-CORE */ |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
469 | if(type == JABBER_IQ_SET || type == JABBER_IQ_GET) { |
| 8315 | 470 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR); |
| 8135 | 471 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
472 | purple_xmlnode_free(iq->node); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
473 | iq->node = purple_xmlnode_copy(packet); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
474 | if (from) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
475 | purple_xmlnode_set_attrib(iq->node, "to", from); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
476 | purple_xmlnode_remove_attrib(iq->node, "from"); |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
477 | } |
|
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
478 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
479 | purple_xmlnode_set_attrib(iq->node, "type", "error"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
480 | error = purple_xmlnode_new_child(iq->node, "error"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
481 | purple_xmlnode_set_attrib(error, "type", "cancel"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
482 | purple_xmlnode_set_attrib(error, "code", "501"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
483 | x = purple_xmlnode_new_child(error, "feature-not-implemented"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
29913
diff
changeset
|
484 | purple_xmlnode_set_namespace(x, NS_XMPP_STANZAS); |
| 8169 | 485 | |
| 8315 | 486 | jabber_iq_send(iq); |
| 487 | } | |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
488 | |
|
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
29913
diff
changeset
|
489 | jabber_id_free(from_id); |
| 7014 | 490 | } |
| 491 | ||
|
25820
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
492 | void jabber_iq_register_handler(const char *node, const char *xmlns, JabberIqHandler *handlerfunc) |
| 14356 | 493 | { |
|
25820
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
494 | /* |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
495 | * This is valid because nodes nor namespaces cannot have spaces in them |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
496 | * (see http://www.w3.org/TR/2006/REC-xml-20060816/ and |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
497 | * http://www.w3.org/TR/REC-xml-names/) |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
498 | */ |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
499 | char *key = g_strdup_printf("%s %s", node, xmlns); |
|
c0ebe6bd49aa
Track the node name in addition to the namespace for handlers (try #2)
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
500 | g_hash_table_replace(iq_handlers, key, handlerfunc); |
| 14356 | 501 | } |
| 502 | ||
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
503 | void jabber_iq_signal_register(const gchar *node, const gchar *xmlns) |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
504 | { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
505 | gchar *key; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
506 | int ref; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
507 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
508 | g_return_if_fail(node != NULL && *node != '\0'); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
509 | g_return_if_fail(xmlns != NULL && *xmlns != '\0'); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
510 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
511 | key = g_strdup_printf("%s %s", node, xmlns); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
512 | ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
513 | if (ref == 0) { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
514 | g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(1)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
515 | } else { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
516 | g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(ref + 1)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
517 | g_free(key); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
518 | } |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
519 | } |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
520 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
521 | void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns) |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
522 | { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
523 | gchar *key; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
524 | int ref; |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
525 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
526 | g_return_if_fail(node != NULL && *node != '\0'); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
527 | g_return_if_fail(xmlns != NULL && *xmlns != '\0'); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
528 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
529 | key = g_strdup_printf("%s %s", node, xmlns); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
530 | ref = GPOINTER_TO_INT(g_hash_table_lookup(signal_iq_handlers, key)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
531 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
532 | if (ref == 1) { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
533 | g_hash_table_remove(signal_iq_handlers, key); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
534 | } else if (ref > 1) { |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
535 | g_hash_table_insert(signal_iq_handlers, key, GINT_TO_POINTER(ref - 1)); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
536 | } |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
537 | |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
538 | g_free(key); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
539 | } |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
540 | |
| 14356 | 541 | void jabber_iq_init(void) |
| 542 | { | |
| 543 | iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
544 | signal_iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
| 14356 | 545 | |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
546 | jabber_iq_register_handler("jingle", JINGLE, jingle_parse); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
547 | jabber_iq_register_handler("mailbox", NS_GOOGLE_MAIL_NOTIFY, |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
548 | jabber_gmail_poke); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
549 | jabber_iq_register_handler("new-mail", NS_GOOGLE_MAIL_NOTIFY, |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
550 | jabber_gmail_poke); |
|
28979
191942cc7747
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents:
28832
diff
changeset
|
551 | jabber_iq_register_handler("ping", NS_PING, jabber_ping_parse); |
|
191942cc7747
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents:
28832
diff
changeset
|
552 | jabber_iq_register_handler("query", NS_GOOGLE_JINGLE_INFO, |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
553 | jabber_google_handle_jingle_info); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
554 | jabber_iq_register_handler("query", NS_BYTESTREAMS, |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
555 | jabber_bytestreams_parse); |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
556 | jabber_iq_register_handler("query", NS_DISCO_INFO, jabber_disco_info_parse); |
|
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
557 | jabber_iq_register_handler("query", NS_DISCO_ITEMS, jabber_disco_items_parse); |
|
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
558 | jabber_iq_register_handler("query", NS_LAST_ACTIVITY, jabber_iq_last_parse); |
|
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
559 | jabber_iq_register_handler("query", NS_OOB_IQ_DATA, jabber_oob_parse); |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
560 | jabber_iq_register_handler("query", "jabber:iq:register", |
|
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
561 | jabber_register_parse); |
|
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
562 | jabber_iq_register_handler("query", "jabber:iq:roster", |
|
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
563 | jabber_roster_parse); |
|
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
564 | jabber_iq_register_handler("query", "jabber:iq:version", |
|
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
565 | jabber_iq_version_parse); |
|
26697
2f086177af37
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents:
26695
diff
changeset
|
566 | #ifdef USE_VV |
|
28980
4a0f7340b539
jabber: Add the missing file and fix up the Google session namespaces
Paul Aurich <darkrain42@pidgin.im>
parents:
28979
diff
changeset
|
567 | jabber_iq_register_handler("session", NS_GOOGLE_SESSION, |
|
26697
2f086177af37
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents:
26695
diff
changeset
|
568 | jabber_google_session_parse); |
|
2f086177af37
Fix-up the merge some more (*sigh*), readding <session/> handler
Paul Aurich <darkrain42@pidgin.im>
parents:
26695
diff
changeset
|
569 | #endif |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
570 | jabber_iq_register_handler("block", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push); |
|
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
571 | jabber_iq_register_handler("unblock", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push); |
|
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28980
diff
changeset
|
572 | jabber_iq_register_handler("time", NS_ENTITY_TIME, jabber_time_parse); |
|
26704
e6dba3759625
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <darkrain42@pidgin.im>
parents:
26701
diff
changeset
|
573 | |
| 14356 | 574 | } |
| 575 | ||
| 576 | void jabber_iq_uninit(void) | |
| 577 | { | |
| 578 | g_hash_table_destroy(iq_handlers); | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
579 | g_hash_table_destroy(signal_iq_handlers); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26704
diff
changeset
|
580 | iq_handlers = signal_iq_handlers = NULL; |
| 14356 | 581 | } |