Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/data.c @ 24630:8f757b2139d2
String changes (a few of which I had already made, grumble grumble).
I tried to re-use strings that exist in other protocols as much as
possible. When calling purple_connection_update_progress() the strings
should not have ellipsis. When calling purple_connection_error_reason()
due to a keep alive timeout, do not include the number of seconds,
because there shouldn't be a reason for users to care
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 11 Dec 2008 07:17:32 +0000 |
parents | 2c6c9d72f54f |
children | e30e9779e7bf 5f9a24d1c25e 860ebaf275ae |
rev | line source |
---|---|
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
1 /* |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
2 * 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
|
3 * 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
|
4 * 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
|
5 * (at your option) any later version. |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
6 * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
10 * GNU Library General Public License for more details. |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
12 * 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
|
13 * along with this program; if not, write to the Free Software |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
15 */ |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
16 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
17 #include <stdlib.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
18 #include <glib.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
19 #include <string.h> |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
20 |
23990
0952f73a452c
Patch from Phil Hannent fixing build on Windows
Marcus Lundblad <ml@update.uu.se>
parents:
23989
diff
changeset
|
21 #include "internal.h" |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 #include "data.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
23 #include "debug.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
24 #include "xmlnode.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
25 #include "util.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
26 #include "iq.h" |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
27 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
28 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
|
29 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
|
30 static GHashTable *remote_data_by_cid = NULL; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
31 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
32 JabberData * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
33 jabber_data_create_from_data(gconstpointer rawdata, gsize size, const char *type, |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
34 JabberStream *js) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
35 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
36 JabberData *data = g_new0(JabberData, 1); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
37 gchar *checksum = purple_util_get_image_checksum(rawdata, size); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
38 gchar cid[256]; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
40 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
|
41 g_free(checksum); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
42 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 data->cid = g_strdup(cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
44 data->type = g_strdup(type); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
45 data->size = size; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
46 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
47 data->data = g_memdup(rawdata, size); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
48 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
49 return data; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
50 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
51 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
52 JabberData * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
53 jabber_data_create_from_xml(xmlnode *tag) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
54 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
55 JabberData *data = g_new0(JabberData, 1); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
56 gsize size; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
57 gpointer raw_data = NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
58 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
59 if (data == NULL) { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
60 purple_debug_error("jabber", "Could not allocate data object\n"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
61 g_free(data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
62 return NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
63 } |
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 /* check if this is a "data" tag */ |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 if (strcmp(tag->name, "data") != 0) { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
67 purple_debug_error("jabber", "Invalid data element"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
68 g_free(data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
69 return NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
70 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
71 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
72 data->cid = g_strdup(xmlnode_get_attrib(tag, "cid")); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
73 data->type = g_strdup(xmlnode_get_attrib(tag, "type")); |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
74 |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
75 raw_data = xmlnode_get_data(tag); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
76 data->data = purple_base64_decode(raw_data, &size); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
77 data->size = size; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
78 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
79 g_free(raw_data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
81 return data; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
82 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
83 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
84 |
24110
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23991
diff
changeset
|
85 static void |
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23991
diff
changeset
|
86 jabber_data_delete(gpointer cbdata) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
87 { |
24110
2c6c9d72f54f
A couple of compile warning fixes, a couple of memory leak plugs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23991
diff
changeset
|
88 JabberData *data = cbdata; |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
89 g_free(data->cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
90 g_free(data->type); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
91 g_free(data->data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 g_free(data); |
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 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
95 const char * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
96 jabber_data_get_cid(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
97 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
98 return data->cid; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
99 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 |
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 const char * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 jabber_data_get_type(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
104 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
105 return data->type; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
106 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
107 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
108 gsize |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
109 jabber_data_get_size(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
110 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
111 return data->size; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
112 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
113 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
114 gpointer |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
115 jabber_data_get_data(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
116 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
117 return data->data; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
118 } |
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 xmlnode * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
121 jabber_data_get_xml_definition(const JabberData *data) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
122 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
123 xmlnode *tag = xmlnode_new("data"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
124 char *base64data = purple_base64_encode(data->data, data->size); |
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 xmlnode_set_namespace(tag, XEP_0231_NAMESPACE); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
127 xmlnode_set_attrib(tag, "cid", data->cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
128 xmlnode_set_attrib(tag, "type", data->type); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
129 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
130 xmlnode_insert_data(tag, base64data, -1); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
131 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
132 g_free(base64data); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
133 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
134 return tag; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
135 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
136 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
137 xmlnode * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
138 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
|
139 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 xmlnode *img = xmlnode_new("img"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
141 char src[128]; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
142 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
143 xmlnode_set_attrib(img, "alt", alt); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
144 g_snprintf(src, sizeof(src), "cid:%s", data->cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
145 xmlnode_set_attrib(img, "src", src); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
147 return img; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
148 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 xmlnode * |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
151 jabber_data_get_xml_request(const gchar *cid) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
153 xmlnode *tag = xmlnode_new("data"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
155 xmlnode_set_namespace(tag, XEP_0231_NAMESPACE); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
156 xmlnode_set_attrib(tag, "cid", cid); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
157 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
158 return tag; |
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 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
161 const JabberData * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
162 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
|
163 { |
23991
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
164 purple_debug_info("jabber", "looking up local smiley 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
|
165 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
|
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 const JabberData * |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
169 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
|
170 { |
23991
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
171 purple_debug_info("jabber", "lookup local smiley 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
|
172 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
|
173 } |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
174 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
175 const JabberData * |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
176 jabber_data_find_remote_by_cid(const gchar *cid) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
177 { |
23991
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
178 purple_debug_info("jabber", "lookup remote smiley with cid = %s\n", cid); |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
179 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
180 return g_hash_table_lookup(remote_data_by_cid, cid); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 } |
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 void |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
184 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
|
185 { |
23991
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
186 purple_debug_info("jabber", "associating local smiley\n alt = %s, cid = %s\n", |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
187 alt, 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
|
188 g_hash_table_insert(local_data_by_alt, g_strdup(alt), data); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
189 g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
190 data); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
191 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
192 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
193 void |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
194 jabber_data_associate_remote(JabberData *data) |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
195 { |
23991
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
196 purple_debug_info("jabber", "associating remote smiley, cid = %s\n", |
fba7c73c8f02
Fixed a memory error, which was due to me destroying some hashtables in the
Marcus Lundblad <ml@update.uu.se>
parents:
23990
diff
changeset
|
197 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
|
198 g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)), |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
199 data); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
200 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
201 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
202 void |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
203 jabber_data_parse(JabberStream *js, xmlnode *packet) |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
204 { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
205 JabberIq *result = NULL; |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
206 const char *who = xmlnode_get_attrib(packet, "from"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 xmlnode *data_node = xmlnode_get_child(packet, "data"); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
208 const JabberData *data = |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
209 jabber_data_find_local_by_cid(xmlnode_get_attrib(data_node, "cid")); |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
210 |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
211 if (!data) { |
23448
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
212 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
|
213 |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
214 result = jabber_iq_new(js, JABBER_IQ_ERROR); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 xmlnode_set_attrib(result->node, "to", who); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
217 xmlnode_insert_child(result->node, item_not_found); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
218 } else { |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
220 xmlnode_set_attrib(result->node, "to", who); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
221 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
222 xmlnode_insert_child(result->node, |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
223 jabber_data_get_xml_definition(data)); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
224 } |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
225 jabber_iq_send(result); |
9d83ae2c1a4f
New files used for custom smileys.
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
226 } |
23988
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
227 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
228 void |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
229 jabber_data_init(void) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
230 { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
231 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
|
232 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
|
233 g_free, NULL); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
234 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
|
235 g_free, jabber_data_delete); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
236 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
|
237 g_free, jabber_data_delete); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
238 } |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
239 |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
240 void |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
241 jabber_data_uninit(void) |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
242 { |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 g_hash_table_destroy(remote_data_by_cid); |
305fac6af8f9
Updated to use latest spec. in XEP-0231
Marcus Lundblad <ml@update.uu.se>
parents:
23448
diff
changeset
|
247 } |