Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/data.c @ 31449:1c660ba17ba1
propagate from branch 'im.pidgin.pidgin' (head 6f879669a6513a5c40335bbaefe842389a92b39e)
to branch 'im.pidgin.cpw.qulogic.cairo' (head 4ab0199887f74442673fd46dcbb662bc7f070bc4)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sun, 21 Nov 2010 20:30:12 +0000 |
parents | fcc36743697c |
children | a8cc50c2279f |
rev | line source |
---|---|
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
1 /* |
30301
7fbb7612e3dd
Fix license to refer to GPLv2 in a files...
Marcus Lundblad <ml@update.uu.se>
parents:
30247
diff
changeset
|
2 * purple - Jabber Service Discovery |
7fbb7612e3dd
Fix license to refer to GPLv2 in a files...
Marcus Lundblad <ml@update.uu.se>
parents:
30247
diff
changeset
|
3 * |
28397
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
27014
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
27014
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
27014
diff
changeset
|
6 * source distribution. |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
27014
diff
changeset
|
7 * |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * (at your option) any later version. |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24110
diff
changeset
|
12 * |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
30301
7fbb7612e3dd
Fix license to refer to GPLv2 in a files...
Marcus Lundblad <ml@update.uu.se>
parents:
30247
diff
changeset
|
16 * GNU General Public License for more details. |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24110
diff
changeset
|
17 * |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
28420
7921a53b94b3
Oops, Elliott correctly pointed out this was wrong...
Paul Aurich <paul@darkrain42.org>
parents:
28397
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
30301
7fbb7612e3dd
Fix license to refer to GPLv2 in a files...
Marcus Lundblad <ml@update.uu.se>
parents:
30247
diff
changeset
|
21 * |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 */ |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24110
diff
changeset
|
23 |
29028
f1437342cc0e
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents:
29026
diff
changeset
|
24 #include "internal.h" |
f1437342cc0e
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents:
29026
diff
changeset
|
25 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
26 #include <stdlib.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
27 #include <glib.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
28 #include <string.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
29 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
30 #include "data.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
31 #include "debug.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
32 #include "xmlnode.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
33 #include "util.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
34 #include "iq.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
35 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
36 static GHashTable *local_data_by_alt = NULL; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
37 static GHashTable *local_data_by_cid = NULL; |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
38 static GHashTable *remote_data_by_cid = NULL; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
40 JabberData * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
41 jabber_data_create_from_data(gconstpointer rawdata, gsize size, const char *type, |
30201
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
42 gboolean ephemeral, JabberStream *js) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
44 JabberData *data; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
45 gchar *checksum; |
30625
24ed54cf50b9
jabber: Don't use a static array when it might not be sufficient.
Paul Aurich <paul@darkrain42.org>
parents:
30624
diff
changeset
|
46 gchar cid[256]; /* "Big enough" for a SHA1 hex hash value */ |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
47 |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
48 g_return_val_if_fail(rawdata != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
49 g_return_val_if_fail(size > 0, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
50 g_return_val_if_fail(type != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
51 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
52 data = g_new0(JabberData, 1); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
53 checksum = jabber_calculate_data_hash(rawdata, size, "sha1"); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
54 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
55 g_snprintf(cid, sizeof(cid), "sha1+%s@bob.xmpp.org", checksum); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
56 g_free(checksum); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
57 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
58 data->cid = g_strdup(cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
59 data->type = g_strdup(type); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
60 data->size = size; |
30201
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
61 data->ephemeral = ephemeral; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
62 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
63 data->data = g_memdup(rawdata, size); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
64 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
65 return data; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
67 |
30031
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
68 static void |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
69 jabber_data_delete(gpointer cbdata) |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
70 { |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
71 JabberData *data = cbdata; |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
72 |
30031
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
73 g_free(data->cid); |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
74 g_free(data->type); |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
75 g_free(data->data); |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
76 g_free(data); |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
77 } |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
78 |
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
79 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 JabberData * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
81 jabber_data_create_from_xml(xmlnode *tag) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
82 { |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
83 JabberData *data; |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
84 gchar *raw_data = NULL; |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
85 const gchar *cid, *type; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
86 |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
87 g_return_val_if_fail(tag != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
88 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
89 /* check if this is a "data" tag */ |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
90 if (strcmp(tag->name, "data") != 0) { |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
91 purple_debug_error("jabber", "Invalid data element\n"); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 return NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
93 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
94 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
95 cid = xmlnode_get_attrib(tag, "cid"); |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
96 type = xmlnode_get_attrib(tag, "type"); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
97 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
98 if (!cid || !type) { |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
99 purple_debug_error("jabber", "cid or type missing\n"); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 return NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
101 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
102 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 raw_data = xmlnode_get_data(tag); |
28515
191bb5bf2fc5
Don't crash when receiving an error iq response when trying fetch a custom
Marcus Lundblad <ml@update.uu.se>
parents:
28420
diff
changeset
|
104 |
28517
40d8427d1813
Minor merge duplication.
Paul Aurich <paul@darkrain42.org>
parents:
28516
diff
changeset
|
105 if (raw_data == NULL || *raw_data == '\0') { |
28515
191bb5bf2fc5
Don't crash when receiving an error iq response when trying fetch a custom
Marcus Lundblad <ml@update.uu.se>
parents:
28420
diff
changeset
|
106 purple_debug_error("jabber", "data element was empty"); |
28518
8aa7df246e13
Eighth^WNinth time's the charm...
Paul Aurich <paul@darkrain42.org>
parents:
28517
diff
changeset
|
107 g_free(raw_data); |
28515
191bb5bf2fc5
Don't crash when receiving an error iq response when trying fetch a custom
Marcus Lundblad <ml@update.uu.se>
parents:
28420
diff
changeset
|
108 return NULL; |
191bb5bf2fc5
Don't crash when receiving an error iq response when trying fetch a custom
Marcus Lundblad <ml@update.uu.se>
parents:
28420
diff
changeset
|
109 } |
191bb5bf2fc5
Don't crash when receiving an error iq response when trying fetch a custom
Marcus Lundblad <ml@update.uu.se>
parents:
28420
diff
changeset
|
110 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
111 data = g_new0(JabberData, 1); |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
112 data->data = purple_base64_decode(raw_data, &data->size); |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
113 g_free(raw_data); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
114 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
115 if (data->data == NULL) { |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
116 purple_debug_error("jabber", "Malformed base64 data\n"); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
117 g_free(data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
118 return NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
119 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
120 |
28513
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
121 data->cid = g_strdup(cid); |
7f447db0e03b
jabber: Stricter parsing of a BoB data stanza
Paul Aurich <paul@darkrain42.org>
parents:
28420
diff
changeset
|
122 data->type = g_strdup(type); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
123 |
30031
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
30028
diff
changeset
|
124 return data; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
125 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
126 |
30200
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
127 void |
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
128 jabber_data_destroy(JabberData *data) |
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
129 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
130 g_return_if_fail(data != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
131 |
30200
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
132 jabber_data_delete(data); |
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
133 } |
51bc0be83108
Added a function to destroy JabberData instances.
Marcus Lundblad <ml@update.uu.se>
parents:
30199
diff
changeset
|
134 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
135 const char * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
136 jabber_data_get_cid(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
137 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
138 g_return_val_if_fail(data != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
139 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 return data->cid; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
141 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
142 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
143 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
144 const char * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
145 jabber_data_get_type(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
147 g_return_val_if_fail(data != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
148 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 return data->type; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
151 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 gsize |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
153 jabber_data_get_size(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
155 g_return_val_if_fail(data != NULL, 0); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
156 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
157 return data->size; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
158 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
159 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
160 gpointer |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
161 jabber_data_get_data(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
162 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
163 g_return_val_if_fail(data != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
164 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
165 return data->data; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
166 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
167 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
168 xmlnode * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
169 jabber_data_get_xml_definition(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
170 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
171 xmlnode *tag; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
172 char *base64data; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
173 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
174 g_return_val_if_fail(data != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
175 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
176 tag = xmlnode_new("data"); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
177 base64data = purple_base64_encode(data->data, data->size); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
178 |
29026
7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents:
28518
diff
changeset
|
179 xmlnode_set_namespace(tag, NS_BOB); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
180 xmlnode_set_attrib(tag, "cid", data->cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 xmlnode_set_attrib(tag, "type", data->type); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
182 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
183 xmlnode_insert_data(tag, base64data, -1); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
184 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
185 g_free(base64data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
186 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
187 return tag; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
188 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
189 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
190 xmlnode * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
191 jabber_data_get_xhtml_im(const JabberData *data, const gchar *alt) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
192 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
193 xmlnode *img; |
30625
24ed54cf50b9
jabber: Don't use a static array when it might not be sufficient.
Paul Aurich <paul@darkrain42.org>
parents:
30624
diff
changeset
|
194 char *src; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
195 |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
196 g_return_val_if_fail(data != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
197 g_return_val_if_fail(alt != NULL, NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
198 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
199 img = xmlnode_new("img"); |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
200 xmlnode_set_attrib(img, "alt", alt); |
30625
24ed54cf50b9
jabber: Don't use a static array when it might not be sufficient.
Paul Aurich <paul@darkrain42.org>
parents:
30624
diff
changeset
|
201 |
24ed54cf50b9
jabber: Don't use a static array when it might not be sufficient.
Paul Aurich <paul@darkrain42.org>
parents:
30624
diff
changeset
|
202 src = g_strconcat("cid:", data->cid, NULL); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
203 xmlnode_set_attrib(img, "src", src); |
30625
24ed54cf50b9
jabber: Don't use a static array when it might not be sufficient.
Paul Aurich <paul@darkrain42.org>
parents:
30624
diff
changeset
|
204 g_free(src); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
205 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
206 return img; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
208 |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
209 static xmlnode * |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
210 jabber_data_get_xml_request(const gchar *cid) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
211 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
212 xmlnode *tag = xmlnode_new("data"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
213 |
29026
7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents:
28518
diff
changeset
|
214 xmlnode_set_namespace(tag, NS_BOB); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 xmlnode_set_attrib(tag, "cid", cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
217 return tag; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
218 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
220 static gboolean |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
221 jabber_data_has_valid_hash(const JabberData *data) |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
222 { |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
223 const gchar *cid = jabber_data_get_cid(data); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
224 gchar **cid_parts = g_strsplit(cid, "@", -1); |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
225 guint num_cid_parts = 0; |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
226 gboolean ret = FALSE; |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
227 |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
228 if (cid_parts) |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
229 num_cid_parts = g_strv_length(cid_parts); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
230 |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
231 if (num_cid_parts == 2 && purple_strequal(cid_parts[1], "bob.xmpp.org")) { |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
232 gchar **sub_parts = g_strsplit(cid_parts[0], "+", -1); |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
233 guint num_sub_parts = 0; |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
234 |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
235 if (sub_parts) |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
236 num_sub_parts = g_strv_length(sub_parts); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
237 |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
238 if (num_sub_parts == 2) { |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
239 const gchar *hash_algo = sub_parts[0]; |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
240 const gchar *hash_value = sub_parts[1]; |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
241 gchar *digest = |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
242 jabber_calculate_data_hash(jabber_data_get_data(data), |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
243 jabber_data_get_size(data), hash_algo); |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
244 |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
245 if (digest) { |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
246 ret = purple_strequal(digest, hash_value); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
247 |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
248 if (!ret) |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
249 purple_debug_warning("jabber", "Unable to validate BoB " |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
250 "hash; expecting %s, got %s\n", |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
251 cid, digest); |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
252 |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
253 g_free(digest); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
254 } else { |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
255 purple_debug_warning("jabber", "Unable to validate BoB hash; " |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
256 "unknown hash algorithm %s\n", hash_algo); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
257 } |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
258 } else { |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
259 purple_debug_warning("jabber", "Malformed BoB CID\n"); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
260 } |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
261 |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
262 g_strfreev(sub_parts); |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
263 } |
30056
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
264 |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
265 g_strfreev(cid_parts); |
84ec9e3cbb6d
jabber: Plug some leaks and make the success case quieter.
Paul Aurich <paul@darkrain42.org>
parents:
30034
diff
changeset
|
266 return ret; |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
267 } |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
268 |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
269 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
270 typedef struct { |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
271 gpointer userdata; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
272 gchar *alt; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
273 gboolean ephemeral; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
274 JabberDataRequestCallback *cb; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
275 } JabberDataRequestData; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
276 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
277 static void |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
278 jabber_data_request_cb(JabberStream *js, const char *from, |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
279 JabberIqType type, const char *id, xmlnode *packet, gpointer data) |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
280 { |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
281 JabberDataRequestData *request_data = (JabberDataRequestData *) data; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
282 gpointer userdata = request_data->userdata; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
283 gchar *alt = request_data->alt; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
284 gboolean ephemeral = request_data->ephemeral; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
285 JabberDataRequestCallback *cb = request_data->cb; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
286 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
287 xmlnode *data_element = xmlnode_get_child(packet, "data"); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
288 xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found"); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
289 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
290 /* did we get a data element as result? */ |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
291 if (data_element && type == JABBER_IQ_RESULT) { |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
292 JabberData *data = jabber_data_create_from_xml(data_element); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
293 |
30626
fcc36743697c
jabber: Fix a crash in the BoB code when receiving from Jabbim.
Paul Aurich <paul@darkrain42.org>
parents:
30625
diff
changeset
|
294 if (data && !ephemeral) { |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
295 jabber_data_associate_remote(js, from, data); |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
296 } |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
297 cb(data, alt, userdata); |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
298 } else if (item_not_found) { |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
299 purple_debug_info("jabber", |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
300 "Responder didn't recognize requested data\n"); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
301 cb(NULL, alt, userdata); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
302 } else { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
303 purple_debug_warning("jabber", "Unknown response to data request\n"); |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
304 cb(NULL, alt, userdata); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
305 } |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
306 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
307 g_free(request_data); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
308 } |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
309 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
310 void |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
311 jabber_data_request(JabberStream *js, const gchar *cid, const gchar *who, |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
312 gchar *alt, gboolean ephemeral, JabberDataRequestCallback cb, |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
313 gpointer userdata) |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
314 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
315 JabberIq *request; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
316 xmlnode *data_request; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
317 JabberDataRequestData *data; |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
318 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
319 g_return_if_fail(cid != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
320 g_return_if_fail(who != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
321 g_return_if_fail(alt != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
322 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
323 request = jabber_iq_new(js, JABBER_IQ_GET); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
324 data_request = jabber_data_get_xml_request(cid); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
325 data = g_new0(JabberDataRequestData, 1); |
30027
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
326 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
327 data->userdata = userdata; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
328 data->alt = alt; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
329 data->ephemeral = ephemeral; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
330 data->cb = cb; |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
331 |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
332 xmlnode_set_attrib(request->node, "to", who); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
333 jabber_iq_set_callback(request, jabber_data_request_cb, data); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
334 xmlnode_insert_child(request->node, data_request); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
335 jabber_iq_send(request); |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
336 } |
fce17268c9ec
jabber: Refactor BoB request code to reside inside data.c
Marcus Lundblad <ml@update.uu.se>
parents:
29954
diff
changeset
|
337 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
338 const JabberData * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
339 jabber_data_find_local_by_alt(const gchar *alt) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
340 { |
30204
4beb825ff4bc
Change debug outputs to say "data object" instead of "smiley", since BoB is not
Marcus Lundblad <ml@update.uu.se>
parents:
30203
diff
changeset
|
341 purple_debug_info("jabber", "looking up local data object with alt = %s\n", alt); |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
342 return g_hash_table_lookup(local_data_by_alt, alt); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
343 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
344 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
345 const JabberData * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
346 jabber_data_find_local_by_cid(const gchar *cid) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
347 { |
30204
4beb825ff4bc
Change debug outputs to say "data object" instead of "smiley", since BoB is not
Marcus Lundblad <ml@update.uu.se>
parents:
30203
diff
changeset
|
348 purple_debug_info("jabber", "lookup local data object with cid = %s\n", cid); |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
349 return g_hash_table_lookup(local_data_by_cid, cid); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
350 } |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
351 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
352 const JabberData * |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
353 jabber_data_find_remote_by_cid(JabberStream *js, const gchar *who, |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
354 const gchar *cid) |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
355 { |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
356 const JabberData *data = g_hash_table_lookup(remote_data_by_cid, cid); |
30204
4beb825ff4bc
Change debug outputs to say "data object" instead of "smiley", since BoB is not
Marcus Lundblad <ml@update.uu.se>
parents:
30203
diff
changeset
|
357 purple_debug_info("jabber", "lookup remote data object with cid = %s\n", cid); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24110
diff
changeset
|
358 |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
359 if (data == NULL) { |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
360 gchar *jid_cid = |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
361 g_strdup_printf("%s@%s/%s%s%s", js->user->node, js->user->domain, |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
362 js->user->resource, who, cid); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
363 purple_debug_info("jabber", |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
364 "didn't find BoB object by pure CID, try including JIDs: %s\n", |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
365 jid_cid); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
366 data = g_hash_table_lookup(remote_data_by_cid, jid_cid); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
367 g_free(jid_cid); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
368 } |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
369 return data; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
370 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
371 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
372 void |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
373 jabber_data_associate_local(JabberData *data, const gchar *alt) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
374 { |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
375 g_return_if_fail(data != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
376 |
30204
4beb825ff4bc
Change debug outputs to say "data object" instead of "smiley", since BoB is not
Marcus Lundblad <ml@update.uu.se>
parents:
30203
diff
changeset
|
377 purple_debug_info("jabber", "associating local data object\n alt = %s, cid = %s\n", |
4beb825ff4bc
Change debug outputs to say "data object" instead of "smiley", since BoB is not
Marcus Lundblad <ml@update.uu.se>
parents:
30203
diff
changeset
|
378 alt , jabber_data_get_cid(data)); |
30199
bae447e1fa96
Allow the "alt" property on a Bits of Binary object to be NULL (do not store
Marcus Lundblad <ml@update.uu.se>
parents:
27014
diff
changeset
|
379 if (alt) |
bae447e1fa96
Allow the "alt" property on a Bits of Binary object to be NULL (do not store
Marcus Lundblad <ml@update.uu.se>
parents:
27014
diff
changeset
|
380 g_hash_table_insert(local_data_by_alt, g_strdup(alt), data); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24110
diff
changeset
|
381 g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
382 data); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
383 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
384 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
385 void |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
386 jabber_data_associate_remote(JabberStream *js, const gchar *who, JabberData *data) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
387 { |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
388 gchar *cid; |
30623
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
389 |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
390 g_return_if_fail(data != NULL); |
8cd8c26ea2f9
jabber: Add a bunch of g_return_if_fail checks to the BoB code
Paul Aurich <paul@darkrain42.org>
parents:
30301
diff
changeset
|
391 |
30034
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
392 if (jabber_data_has_valid_hash(data)) { |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
393 cid = g_strdup(jabber_data_get_cid(data)); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
394 } else { |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
395 cid = g_strdup_printf("%s@%s/%s%s%s", js->user->node, js->user->domain, |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
396 js->user->resource, who, jabber_data_get_cid(data)); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
397 } |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
398 |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
399 purple_debug_info("jabber", "associating remote BoB object with cid = %s\n", |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
400 cid); |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
401 |
1bde873d1b94
jabber: Cache incoming BoB object per JID (and local JID) instead of discarding
Marcus Lundblad <ml@update.uu.se>
parents:
30031
diff
changeset
|
402 g_hash_table_insert(remote_data_by_cid, cid, data); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
403 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
404 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
405 void |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
406 jabber_data_parse(JabberStream *js, const char *who, JabberIqType type, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
407 const char *id, xmlnode *data_node) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
408 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
409 JabberIq *result = NULL; |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
410 const char *cid = xmlnode_get_attrib(data_node, "cid"); |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
411 const JabberData *data = cid ? jabber_data_find_local_by_cid(cid) : NULL; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
412 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
413 if (!data) { |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
414 xmlnode *item_not_found = xmlnode_new("item-not-found"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
415 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
416 result = jabber_iq_new(js, JABBER_IQ_ERROR); |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
417 if (who) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
418 xmlnode_set_attrib(result->node, "to", who); |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
419 xmlnode_set_attrib(result->node, "id", id); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
420 xmlnode_insert_child(result->node, item_not_found); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
421 } else { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
422 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
423 if (who) |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
424 xmlnode_set_attrib(result->node, "to", who); |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25067
diff
changeset
|
425 xmlnode_set_attrib(result->node, "id", id); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
426 xmlnode_insert_child(result->node, |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
427 jabber_data_get_xml_definition(data)); |
30201
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
428 /* if the data object is temporary, destroy it and remove the references |
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
429 to it */ |
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
430 if (data->ephemeral) { |
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
431 g_hash_table_remove(local_data_by_cid, cid); |
b6dda7d483a2
Added an "ephemeral" argument when creating local data objects (given a CID).
Marcus Lundblad <ml@update.uu.se>
parents:
30200
diff
changeset
|
432 } |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
433 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
434 jabber_iq_send(result); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
435 } |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
436 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
437 void |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
438 jabber_data_init(void) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
439 { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
440 purple_debug_info("jabber", "creating hash tables for data objects\n"); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
441 local_data_by_alt = g_hash_table_new_full(g_str_hash, g_str_equal, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
442 g_free, NULL); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
443 local_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
444 g_free, jabber_data_delete); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
445 remote_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
446 g_free, jabber_data_delete); |
26564
457dca546b23
Gratuitous alphabetization of the IQ handlers (again!) and move the data handler to jabber_data_init
Paul Aurich <paul@darkrain42.org>
parents:
25983
diff
changeset
|
447 |
29026
7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents:
28518
diff
changeset
|
448 jabber_iq_register_handler("data", NS_BOB, jabber_data_parse); |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
449 } |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
450 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
451 void |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
452 jabber_data_uninit(void) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
453 { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
454 purple_debug_info("jabber", "destroying hash tables for data objects\n"); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
455 g_hash_table_destroy(local_data_by_alt); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
456 g_hash_table_destroy(local_data_by_cid); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
457 g_hash_table_destroy(remote_data_by_cid); |
25763
860ebaf275ae
Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents:
24110
diff
changeset
|
458 local_data_by_alt = local_data_by_cid = remote_data_by_cid = NULL; |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
459 } |