Mercurial > pidgin
annotate libpurple/protocols/jabber/useravatar.c @ 26709:80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Instead of publishing our avatar to both PEP nodes, publish only to the new
and delete anything at the old. We still support receiving both/either.
Backward compatibility is achieved through vcard-temp:x:update.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 27 Apr 2009 05:49:32 +0000 |
parents | ca421152b5d4 |
children | a0e48796defb |
rev | line source |
---|---|
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
1 /* |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
2 * purple - Jabber Protocol Plugin |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
3 * |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
6 * source distribution. |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
7 * |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
12 * |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
17 * |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
21 * |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
22 */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
23 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
24 #include "internal.h" |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
25 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
26 #include "useravatar.h" |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
27 #include "pep.h" |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
28 #include "debug.h" |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
29 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
30 #define MAX_HTTP_BUDDYICON_BYTES (200 * 1024) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
31 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
32 static void update_buddy_metadata(JabberStream *js, const char *from, xmlnode *items); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
33 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
34 void jabber_avatar_init(void) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
35 { |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
36 jabber_pep_register_handler("avatar", NS_AVATAR_0_12_METADATA, |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
37 update_buddy_metadata); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
38 |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
39 jabber_add_feature("urn_avatarmeta", NS_AVATAR_1_1_METADATA, |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
40 jabber_pep_namespace_only_when_pep_enabled_cb); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
41 jabber_add_feature("urn_avatardata", NS_AVATAR_1_1_DATA, |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
42 jabber_pep_namespace_only_when_pep_enabled_cb); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
43 |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
44 jabber_pep_register_handler("urn_avatar", NS_AVATAR_1_1_METADATA, |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
45 update_buddy_metadata); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
46 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
47 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
48 static void |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
49 remove_avatar_0_12_nodes(JabberStream *js) |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
50 { |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
51 jabber_pep_delete_node(js, NS_AVATAR_0_12_METADATA); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
52 jabber_pep_delete_node(js, NS_AVATAR_0_12_DATA); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
53 } |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
54 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
55 void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img) |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
56 { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
57 xmlnode *publish, *metadata, *item; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
58 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
59 if (!js->pep) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
60 return; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
61 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
62 remove_avatar_0_12_nodes(js); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
63 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
64 if (!img) { |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
65 publish = xmlnode_new("publish"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
66 xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
67 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
68 item = xmlnode_new_child(publish, "item"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
69 metadata = xmlnode_new_child(item, "metadata"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
70 xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
71 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
72 /* publish */ |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
73 jabber_pep_publish(js, publish); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
74 } else { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
75 /* |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
76 * TODO: This is pretty gross. The Jabber PRPL really shouldn't |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
77 * do voodoo to try to determine the image type, height |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
78 * and width. |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
79 */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
80 /* A PNG header, including the IHDR, but nothing else */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
81 const struct { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
82 guchar signature[8]; /* must be hex 89 50 4E 47 0D 0A 1A 0A */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
83 struct { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
84 guint32 length; /* must be 0x0d */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
85 guchar type[4]; /* must be 'I' 'H' 'D' 'R' */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
86 guint32 width; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
87 guint32 height; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
88 guchar bitdepth; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
89 guchar colortype; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
90 guchar compression; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
91 guchar filter; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
92 guchar interlace; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
93 } ihdr; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
94 } *png = purple_imgstore_get_data(img); /* ATTN: this is in network byte order! */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
95 |
26706
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
96 /* check if the data is a valid png file (well, at least to some extent) */ |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
97 if(png->signature[0] == 0x89 && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
98 png->signature[1] == 0x50 && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
99 png->signature[2] == 0x4e && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
100 png->signature[3] == 0x47 && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
101 png->signature[4] == 0x0d && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
102 png->signature[5] == 0x0a && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
103 png->signature[6] == 0x1a && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
104 png->signature[7] == 0x0a && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
105 ntohl(png->ihdr.length) == 0x0d && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
106 png->ihdr.type[0] == 'I' && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
107 png->ihdr.type[1] == 'H' && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
108 png->ihdr.type[2] == 'D' && |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
109 png->ihdr.type[3] == 'R') { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
110 /* parse PNG header to get the size of the image (yes, this is required) */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
111 guint32 width = ntohl(png->ihdr.width); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
112 guint32 height = ntohl(png->ihdr.height); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
113 xmlnode *data, *info; |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
114 char *lengthstring, *widthstring, *heightstring; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
115 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
116 /* compute the sha1 hash */ |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
117 char *hash = jabber_calculate_data_sha1sum(purple_imgstore_get_data(img), |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
118 purple_imgstore_get_size(img)); |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
119 char *base64avatar = purple_base64_encode(purple_imgstore_get_data(img), |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
120 purple_imgstore_get_size(img)); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
121 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
122 publish = xmlnode_new("publish"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
123 xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_DATA); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
124 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
125 item = xmlnode_new_child(publish, "item"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
126 xmlnode_set_attrib(item, "id", hash); |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
127 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
128 data = xmlnode_new_child(item, "data"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
129 xmlnode_set_namespace(data, NS_AVATAR_1_1_DATA); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
130 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
131 xmlnode_insert_data(data, base64avatar, -1); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
132 /* publish the avatar itself */ |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
133 jabber_pep_publish(js, publish); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
134 |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
135 g_free(base64avatar); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
136 |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
137 lengthstring = g_strdup_printf("%" G_GSIZE_FORMAT, |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
138 purple_imgstore_get_size(img)); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
139 widthstring = g_strdup_printf("%u", width); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
140 heightstring = g_strdup_printf("%u", height); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
141 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
142 /* publish the metadata */ |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
143 publish = xmlnode_new("publish"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
144 xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
145 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
146 item = xmlnode_new_child(publish, "item"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
147 xmlnode_set_attrib(item, "id", hash); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
148 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
149 metadata = xmlnode_new_child(item, "metadata"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
150 xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
151 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
152 info = xmlnode_new_child(metadata, "info"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
153 xmlnode_set_attrib(info, "id", hash); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
154 xmlnode_set_attrib(info, "type", "image/png"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
155 xmlnode_set_attrib(info, "bytes", lengthstring); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
156 xmlnode_set_attrib(info, "width", widthstring); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
157 xmlnode_set_attrib(info, "height", heightstring); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
158 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
159 jabber_pep_publish(js, publish); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
160 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
161 g_free(lengthstring); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
162 g_free(widthstring); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
163 g_free(heightstring); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
164 g_free(hash); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
165 } else { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
166 purple_debug_error("jabber", "Cannot set PEP avatar to non-PNG data\n"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
167 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
168 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
169 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
170 |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
171 static void |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
172 do_got_own_avatar_cb(JabberStream *js, const char *from, xmlnode *items) |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
173 { |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
174 xmlnode *item = NULL, *metadata = NULL, *info = NULL; |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
175 PurpleAccount *account = purple_connection_get_account(js->gc); |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
176 const char *server_hash = NULL; |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
177 const char *ns; |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
178 |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
179 if ((item = xmlnode_get_child(items, "item")) && |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
180 (metadata = xmlnode_get_child(item, "metadata")) && |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
181 (info = xmlnode_get_child(metadata, "info"))) { |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
182 server_hash = xmlnode_get_attrib(info, "id"); |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
183 } |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
184 |
25424
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
185 if (!metadata) |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
186 return; |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
187 |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
188 ns = xmlnode_get_namespace(metadata); |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
189 if (!ns) |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
190 return; |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
191 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
192 /* |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
193 * We no longer publish avatars to the older namespace. If there is one |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
194 * there, delete it. |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
195 */ |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
196 if (g_str_equal(ns, NS_AVATAR_0_12_METADATA) && server_hash) { |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
197 remove_avatar_0_12_nodes(js); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
198 return; |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
199 } |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
200 |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
201 /* Publish ours if it's different than the server's */ |
26706
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
202 if (!purple_strequal(server_hash, js->initial_avatar_hash)) { |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
203 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26708
diff
changeset
|
204 jabber_avatar_set(js, img); |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
205 purple_imgstore_unref(img); |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
206 } |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
207 } |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
208 |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
209 void jabber_avatar_fetch_mine(JabberStream *js) |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
210 { |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
211 char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
212 jabber_pep_request_item(js, jid, NS_AVATAR_0_12_METADATA, NULL, |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
213 do_got_own_avatar_cb); |
25356
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
214 jabber_pep_request_item(js, jid, NS_AVATAR_1_1_METADATA, NULL, |
c0a27a44ebd6
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <paul@darkrain42.org>
parents:
25355
diff
changeset
|
215 do_got_own_avatar_cb); |
25353
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
216 g_free(jid); |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
217 } |
9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <paul@darkrain42.org>
parents:
25352
diff
changeset
|
218 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
219 typedef struct _JabberBuddyAvatarUpdateURLInfo { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
220 JabberStream *js; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
221 char *from; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
222 char *id; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
223 } JabberBuddyAvatarUpdateURLInfo; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
224 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
225 static void |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
226 do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data, |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
227 gpointer user_data, const gchar *url_text, |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
228 gsize len, const gchar *error_message) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
229 { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
230 JabberBuddyAvatarUpdateURLInfo *info = user_data; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
231 if(!url_text) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
232 purple_debug(PURPLE_DEBUG_ERROR, "jabber", |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
233 "do_buddy_avatar_update_fromurl got error \"%s\"", |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
234 error_message); |
25352
b68ac693ae2d
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <paul@darkrain42.org>
parents:
25351
diff
changeset
|
235 goto out; |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
236 } |
25357 | 237 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
238 purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, (void*)url_text, len, info->id); |
25352
b68ac693ae2d
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <paul@darkrain42.org>
parents:
25351
diff
changeset
|
239 |
b68ac693ae2d
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <paul@darkrain42.org>
parents:
25351
diff
changeset
|
240 out: |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
241 g_free(info->from); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
242 g_free(info->id); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
243 g_free(info); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
244 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
245 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
246 static void |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
247 do_buddy_avatar_update_data(JabberStream *js, const char *from, xmlnode *items) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
248 { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
249 xmlnode *item, *data; |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
250 const char *checksum, *ns; |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
251 char *b64data; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
252 void *img; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
253 size_t size; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
254 if(!items) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
255 return; |
25357 | 256 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
257 item = xmlnode_get_child(items, "item"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
258 if(!item) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
259 return; |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
260 |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
261 data = xmlnode_get_child(item, "data"); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
262 if(!data) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
263 return; |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
264 |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
265 ns = xmlnode_get_namespace(data); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
266 /* Make sure the namespace is one of the two valid possibilities */ |
26706
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
267 if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_DATA) && |
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
268 !g_str_equal(ns, NS_AVATAR_1_1_DATA))) |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
269 return; |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
270 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
271 checksum = xmlnode_get_attrib(item,"id"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
272 if(!checksum) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
273 return; |
25357 | 274 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
275 b64data = xmlnode_get_data(data); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
276 if(!b64data) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
277 return; |
25357 | 278 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
279 img = purple_base64_decode(b64data, &size); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
280 if(!img) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
281 g_free(b64data); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
282 return; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
283 } |
25357 | 284 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
285 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
286 g_free(b64data); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
287 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
288 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
289 static void |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
290 update_buddy_metadata(JabberStream *js, const char *from, xmlnode *items) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
291 { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
292 PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
293 const char *checksum, *ns; |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
294 xmlnode *item, *metadata; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
295 if(!buddy) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
296 return; |
25357 | 297 |
25424
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
298 if (!items) |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
299 return; |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
300 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
301 item = xmlnode_get_child(items,"item"); |
25424
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
302 if (!item) |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
303 return; |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
304 |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
305 metadata = xmlnode_get_child(item, "metadata"); |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
306 if(!metadata) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
307 return; |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
308 |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
309 ns = xmlnode_get_namespace(metadata); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
310 /* Make sure the namespace is one of the two valid possibilities */ |
26706
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
311 if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_METADATA) && |
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
312 !g_str_equal(ns, NS_AVATAR_1_1_METADATA))) |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
313 return; |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
314 |
25424
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
315 checksum = purple_buddy_icons_get_checksum_for_user(buddy); |
b3dbc9e8b6ef
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <paul@darkrain42.org>
parents:
25403
diff
changeset
|
316 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
317 /* check if we have received a stop */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
318 if(xmlnode_get_child(metadata, "stop")) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
319 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
320 } else { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
321 xmlnode *info, *goodinfo = NULL; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
322 gboolean has_children = FALSE; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
323 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
324 /* iterate over all info nodes to get one we can use */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
325 for(info = metadata->child; info; info = info->next) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
326 if(info->type == XMLNODE_TYPE_TAG) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
327 has_children = TRUE; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
328 if(info->type == XMLNODE_TYPE_TAG && !strcmp(info->name,"info")) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
329 const char *type = xmlnode_get_attrib(info,"type"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
330 const char *id = xmlnode_get_attrib(info,"id"); |
25357 | 331 |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
332 if(checksum && id && !strcmp(id, checksum)) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
333 /* we already have that avatar, so we don't have to do anything */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
334 goodinfo = NULL; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
335 break; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
336 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
337 /* We'll only pick the png one for now. It's a very nice image format anyways. */ |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
338 if(type && id && !goodinfo && !strcmp(type, "image/png")) |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
339 goodinfo = info; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
340 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
341 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
342 if(has_children == FALSE) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
343 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
344 } else if(goodinfo) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
345 const char *url = xmlnode_get_attrib(goodinfo, "url"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
346 const char *id = xmlnode_get_attrib(goodinfo,"id"); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
347 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
348 /* the avatar might either be stored in a pep node, or on a HTTP(S) URL */ |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
349 if(!url) { |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
350 const char *data_ns; |
26706
fbb2b8e2d91e
Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents:
25426
diff
changeset
|
351 data_ns = (g_str_equal(ns, NS_AVATAR_0_12_METADATA) ? |
25355
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
352 NS_AVATAR_0_12_DATA : NS_AVATAR_1_1_DATA); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
353 jabber_pep_request_item(js, from, data_ns, id, |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
354 do_buddy_avatar_update_data); |
ba8f51cb3691
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <paul@darkrain42.org>
parents:
25353
diff
changeset
|
355 } else { |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
356 PurpleUtilFetchUrlData *url_data; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
357 JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
358 info->js = js; |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
359 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
360 url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
361 MAX_HTTP_BUDDYICON_BYTES, |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
362 do_buddy_avatar_update_fromurl, info); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
363 if (url_data) { |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
364 info->from = g_strdup(from); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
365 info->id = g_strdup(id); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
366 js->url_datas = g_slist_prepend(js->url_datas, url_data); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
367 } else |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
368 g_free(info); |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
369 |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
370 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
371 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
372 } |
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
373 } |