Tue, 02 Nov 2021 00:30:07 -0500
Fix some bugs with proxies for xmpp
Testing Done:
Compiled and ran, was unable to get it to actually use charles proxy though.
Reviewed at https://reviews.imfreedom.org/r/1118/
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
2 | * purple - Jabber Protocol Plugin |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
3 | * |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
6 | * source distribution. |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
12 | * |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
17 | * |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
28321
c8d617c408ab
Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents:
28048
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
21 | * |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
22 | */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
23 | |
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
24 | #include <config.h> |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
25 | |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
26 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
27 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40058
diff
changeset
|
28 | #include <purple.h> |
|
40756
3a58ef28ee44
Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents:
40668
diff
changeset
|
29 | #include "libpurple/glibcompat.h" |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
30 | |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
31 | #include <libsoup/soup.h> |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
32 | |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
33 | #include "useravatar.h" |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
34 | #include "pep.h" |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
35 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
36 | #define MAX_HTTP_BUDDYICON_BYTES (200 * 1024) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
37 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
38 | static void update_buddy_metadata(JabberStream *js, const char *from, PurpleXmlNode *items); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
39 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
40 | void jabber_avatar_init(void) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
41 | { |
| 26959 | 42 | jabber_add_feature(NS_AVATAR_1_1_METADATA, |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
43 | jabber_pep_namespace_only_when_pep_enabled_cb); |
| 26959 | 44 | jabber_add_feature(NS_AVATAR_1_1_DATA, |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
45 | jabber_pep_namespace_only_when_pep_enabled_cb); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
46 | |
| 26959 | 47 | jabber_pep_register_handler(NS_AVATAR_1_1_METADATA, |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
48 | update_buddy_metadata); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
49 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
50 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
51 | void jabber_avatar_set(JabberStream *js, PurpleImage *img) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
52 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
53 | PurpleXmlNode *publish, *metadata, *item; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
54 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
55 | if (!js->pep) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
56 | return; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
57 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
58 | if (!img) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
59 | publish = purple_xmlnode_new("publish"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
60 | purple_xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
61 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
62 | item = purple_xmlnode_new_child(publish, "item"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
63 | metadata = purple_xmlnode_new_child(item, "metadata"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
64 | purple_xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
65 | |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
66 | /* publish */ |
|
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
67 | jabber_pep_publish(js, publish); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
68 | } else { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
69 | /* |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
70 | * TODO: This is pretty gross. The Jabber protocol really shouldn't |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
71 | * do voodoo to try to determine the image type, height |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
72 | * and width. |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
73 | */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
74 | /* A PNG header, including the IHDR, but nothing else */ |
|
33766
49eb0136f2ec
jabber: avoid possible heap overflow when a very small file has been chosen for
Daniel Atallah <datallah@pidgin.im>
parents:
29910
diff
changeset
|
75 | /* ATTN: this is in network byte order! */ |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
76 | const struct { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
77 | guchar signature[8]; /* must be hex 89 50 4E 47 0D 0A 1A 0A */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
78 | struct { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
79 | guint32 length; /* must be 0x0d */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
80 | guchar type[4]; /* must be 'I' 'H' 'D' 'R' */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
81 | guint32 width; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
82 | guint32 height; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
83 | guchar bitdepth; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
84 | guchar colortype; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
85 | guchar compression; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
86 | guchar filter; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
87 | guchar interlace; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
88 | } ihdr; |
|
33766
49eb0136f2ec
jabber: avoid possible heap overflow when a very small file has been chosen for
Daniel Atallah <datallah@pidgin.im>
parents:
29910
diff
changeset
|
89 | } *png = NULL; |
|
49eb0136f2ec
jabber: avoid possible heap overflow when a very small file has been chosen for
Daniel Atallah <datallah@pidgin.im>
parents:
29910
diff
changeset
|
90 | |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37134
diff
changeset
|
91 | if (purple_image_get_data_size(img) > sizeof(*png)) |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
92 | png = purple_image_get_data(img); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
93 | |
|
26947
176ef2bfef9f
Use purple_strequal and g_str_equal
Paul Aurich <darkrain42@pidgin.im>
parents:
25811
diff
changeset
|
94 | /* check if the data is a valid png file (well, at least to some extent) */ |
|
33766
49eb0136f2ec
jabber: avoid possible heap overflow when a very small file has been chosen for
Daniel Atallah <datallah@pidgin.im>
parents:
29910
diff
changeset
|
95 | if(png && png->signature[0] == 0x89 && |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
96 | png->signature[1] == 0x50 && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
97 | png->signature[2] == 0x4e && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
98 | png->signature[3] == 0x47 && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
99 | png->signature[4] == 0x0d && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
100 | png->signature[5] == 0x0a && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
101 | png->signature[6] == 0x1a && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
102 | png->signature[7] == 0x0a && |
|
40653
503cfa50c8c3
Use GLib's byte-order macros.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40441
diff
changeset
|
103 | GUINT32_FROM_BE(png->ihdr.length) == 0x0d && |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
104 | png->ihdr.type[0] == 'I' && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
105 | png->ihdr.type[1] == 'H' && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
106 | png->ihdr.type[2] == 'D' && |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
107 | png->ihdr.type[3] == 'R') { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
108 | /* parse PNG header to get the size of the image (yes, this is required) */ |
|
40653
503cfa50c8c3
Use GLib's byte-order macros.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40441
diff
changeset
|
109 | guint32 width = GUINT32_FROM_BE(png->ihdr.width); |
|
503cfa50c8c3
Use GLib's byte-order macros.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40441
diff
changeset
|
110 | guint32 height = GUINT32_FROM_BE(png->ihdr.height); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
111 | PurpleXmlNode *data, *info; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
112 | char *lengthstring, *widthstring, *heightstring; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
113 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
114 | /* compute the sha1 hash */ |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
115 | char *hash = g_compute_checksum_for_data( |
|
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
116 | G_CHECKSUM_SHA1, |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
117 | purple_image_get_data(img), |
|
38334
cb3f85d86752
Merge/update port to GChecksum changes, resolving conflicts
Mike Ruprecht <cmaiku@gmail.com>
diff
changeset
|
118 | purple_image_get_data_size(img)); |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
119 | char *base64avatar = g_base64_encode( |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
120 | purple_image_get_data(img), |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37134
diff
changeset
|
121 | purple_image_get_data_size(img)); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
122 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
123 | publish = purple_xmlnode_new("publish"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
124 | purple_xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_DATA); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
125 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
126 | item = purple_xmlnode_new_child(publish, "item"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
127 | purple_xmlnode_set_attrib(item, "id", hash); |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
128 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
129 | data = purple_xmlnode_new_child(item, "data"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
130 | purple_xmlnode_set_namespace(data, NS_AVATAR_1_1_DATA); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
131 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
132 | purple_xmlnode_insert_data(data, base64avatar, -1); |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
133 | /* publish the avatar itself */ |
|
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
134 | jabber_pep_publish(js, publish); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
135 | |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
136 | g_free(base64avatar); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
137 | |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
138 | lengthstring = g_strdup_printf("%" G_GSIZE_FORMAT, |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37134
diff
changeset
|
139 | purple_image_get_data_size(img)); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
140 | widthstring = g_strdup_printf("%u", width); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
141 | heightstring = g_strdup_printf("%u", height); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
142 | |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
143 | /* publish the metadata */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
144 | publish = purple_xmlnode_new("publish"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
145 | purple_xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
146 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
147 | item = purple_xmlnode_new_child(publish, "item"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
148 | purple_xmlnode_set_attrib(item, "id", hash); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
149 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
150 | metadata = purple_xmlnode_new_child(item, "metadata"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
151 | purple_xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
152 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
153 | info = purple_xmlnode_new_child(metadata, "info"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
154 | purple_xmlnode_set_attrib(info, "id", hash); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
155 | purple_xmlnode_set_attrib(info, "type", "image/png"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
156 | purple_xmlnode_set_attrib(info, "bytes", lengthstring); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
157 | purple_xmlnode_set_attrib(info, "width", widthstring); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
158 | purple_xmlnode_set_attrib(info, "height", heightstring); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
159 | |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
160 | jabber_pep_publish(js, publish); |
|
25480
6e01ab2bc943
Support both XEP-0084 namespaces for fetching our own avatars at login
Paul Aurich <darkrain42@pidgin.im>
parents:
25479
diff
changeset
|
161 | |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
162 | g_free(lengthstring); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
163 | g_free(widthstring); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
164 | g_free(heightstring); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
165 | g_free(hash); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
166 | } else { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
167 | purple_debug_error("jabber", "Cannot set PEP avatar to non-PNG data\n"); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
168 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
169 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
170 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
171 | |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
172 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
173 | do_got_own_avatar_cb(JabberStream *js, const char *from, PurpleXmlNode *items) |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
174 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
175 | PurpleXmlNode *item = NULL, *metadata = NULL, *info = NULL; |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
176 | PurpleAccount *account = purple_connection_get_account(js->gc); |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
177 | const char *server_hash = NULL; |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
178 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
179 | if (items && (item = purple_xmlnode_get_child(items, "item")) && |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
180 | (metadata = purple_xmlnode_get_child(item, "metadata")) && |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
181 | (info = purple_xmlnode_get_child(metadata, "info"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
182 | server_hash = purple_xmlnode_get_attrib(info, "id"); |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
183 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
184 | |
|
28048
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
185 | /* |
|
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
186 | * If we have an avatar and the server returned an error/malformed data, |
|
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
187 | * push our avatar. If the server avatar doesn't match the local one, push |
|
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
188 | * our avatar. |
|
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
189 | */ |
|
28881
244fb329e5df
jabber: Go back to not overwriting avatars if there is not one locally set.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
190 | if ((!items || !metadata) || |
|
28048
cdc92f9d634a
jabber: Fix setting the PEP node the first time.
Paul Aurich <darkrain42@pidgin.im>
parents:
27358
diff
changeset
|
191 | !purple_strequal(server_hash, js->initial_avatar_hash)) { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
192 | PurpleImage *img = purple_buddy_icons_find_account_icon(account); |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26949
diff
changeset
|
193 | jabber_avatar_set(js, img); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
194 | if (img) |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34935
diff
changeset
|
195 | g_object_unref(img); |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
196 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
197 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
198 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
199 | void jabber_avatar_fetch_mine(JabberStream *js) |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
200 | { |
|
28881
244fb329e5df
jabber: Go back to not overwriting avatars if there is not one locally set.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
201 | if (js->initial_avatar_hash) { |
|
29782
ca4fedd9e890
jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
202 | jabber_pep_request_item(js, NULL, NS_AVATAR_1_1_METADATA, NULL, |
|
28881
244fb329e5df
jabber: Go back to not overwriting avatars if there is not one locally set.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
203 | do_got_own_avatar_cb); |
|
244fb329e5df
jabber: Go back to not overwriting avatars if there is not one locally set.
Paul Aurich <darkrain42@pidgin.im>
parents:
28828
diff
changeset
|
204 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
205 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25476
diff
changeset
|
206 | |
|
39556
622bf98df0ac
Remove unnecessary struct tags.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38854
diff
changeset
|
207 | typedef struct { |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
208 | JabberStream *js; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
209 | char *from; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
210 | char *id; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
211 | } JabberBuddyAvatarUpdateURLInfo; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
212 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
213 | static void |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
214 | do_buddy_avatar_update_fromurl(G_GNUC_UNUSED SoupSession *session, |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
215 | SoupMessage *msg, gpointer data) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
216 | { |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
217 | JabberBuddyAvatarUpdateURLInfo *info = data; |
|
27358
a1e3486558a0
Need to make a copy of this because purple_util_fetch_url frees its.
Paul Aurich <darkrain42@pidgin.im>
parents:
27035
diff
changeset
|
218 | gpointer icon_data; |
|
a1e3486558a0
Need to make a copy of this because purple_util_fetch_url frees its.
Paul Aurich <darkrain42@pidgin.im>
parents:
27035
diff
changeset
|
219 | |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
220 | if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) { |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
221 | purple_debug_error("jabber", |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
222 | "do_buddy_avatar_update_fromurl got error \"%s\"", |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
223 | msg->reason_phrase); |
|
25476
d31fcddd65a4
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
224 | goto out; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
225 | } |
| 25481 | 226 | |
|
40756
3a58ef28ee44
Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents:
40668
diff
changeset
|
227 | icon_data = g_memdup2(msg->response_body->data, msg->response_body->length); |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
228 | purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
229 | info->from, icon_data, |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
230 | msg->response_body->length, info->id); |
|
25476
d31fcddd65a4
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
231 | |
|
d31fcddd65a4
Don't leak a JabberBuddyAvatarUpdateURLInfo struct in the error case
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
232 | out: |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
233 | g_free(info->from); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
234 | g_free(info->id); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
235 | g_free(info); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
236 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
237 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
238 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
239 | do_buddy_avatar_update_data(JabberStream *js, const char *from, PurpleXmlNode *items) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
240 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
241 | PurpleXmlNode *item, *data; |
|
27017
02ddb8e8c3d2
Drop support for XEP-0084 v0.12 and publish a <stop/> instead of deleting the node.
Paul Aurich <darkrain42@pidgin.im>
parents:
26959
diff
changeset
|
242 | const char *checksum; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
243 | char *b64data; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
244 | void *img; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
245 | size_t size; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
246 | if(!items) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
247 | return; |
| 25481 | 248 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
249 | item = purple_xmlnode_get_child(items, "item"); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
250 | if(!item) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
251 | return; |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
252 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
253 | data = purple_xmlnode_get_child(item, "data"); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
254 | if(!data) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
255 | return; |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
256 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
257 | checksum = purple_xmlnode_get_attrib(item,"id"); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
258 | if(!checksum) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
259 | return; |
| 25481 | 260 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
261 | b64data = purple_xmlnode_get_data(data); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
262 | if(!b64data) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
263 | return; |
| 25481 | 264 | |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
265 | img = g_base64_decode(b64data, &size); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
266 | if(!img) { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
267 | g_free(b64data); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
268 | return; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
269 | } |
| 25481 | 270 | |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
271 | purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
272 | g_free(b64data); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
273 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
274 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
275 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
276 | update_buddy_metadata(JabberStream *js, const char *from, PurpleXmlNode *items) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
277 | { |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34227
diff
changeset
|
278 | PurpleBuddy *buddy = purple_blist_find_buddy(purple_connection_get_account(js->gc), from); |
|
27017
02ddb8e8c3d2
Drop support for XEP-0084 v0.12 and publish a <stop/> instead of deleting the node.
Paul Aurich <darkrain42@pidgin.im>
parents:
26959
diff
changeset
|
279 | const char *checksum; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
280 | PurpleXmlNode *item, *metadata; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
281 | if(!buddy) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
282 | return; |
| 25481 | 283 | |
|
25809
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
284 | if (!items) |
|
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
285 | return; |
|
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
286 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
287 | item = purple_xmlnode_get_child(items,"item"); |
|
25809
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
288 | if (!item) |
|
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
289 | return; |
|
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
290 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
291 | metadata = purple_xmlnode_get_child(item, "metadata"); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
292 | if(!metadata) |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
293 | return; |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
294 | |
|
25809
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
295 | checksum = purple_buddy_icons_get_checksum_for_user(buddy); |
|
f0d37a73663a
I had the distinct pleasure of throwing invalid garbage at this code; it
Paul Aurich <darkrain42@pidgin.im>
parents:
25543
diff
changeset
|
296 | |
|
27017
02ddb8e8c3d2
Drop support for XEP-0084 v0.12 and publish a <stop/> instead of deleting the node.
Paul Aurich <darkrain42@pidgin.im>
parents:
26959
diff
changeset
|
297 | /* <stop/> was the pre-v1.1 method of publishing an empty avatar */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
298 | if(purple_xmlnode_get_child(metadata, "stop")) { |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
299 | purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
300 | } else { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
301 | PurpleXmlNode *info, *goodinfo = NULL; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
302 | gboolean has_children = FALSE; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
303 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
304 | /* iterate over all info nodes to get one we can use */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
305 | for(info = metadata->child; info; info = info->next) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
306 | if(info->type == PURPLE_XMLNODE_TYPE_TAG) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
307 | has_children = TRUE; |
| 38358 | 308 | if(info->type == PURPLE_XMLNODE_TYPE_TAG && purple_strequal(info->name,"info")) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
309 | const char *type = purple_xmlnode_get_attrib(info,"type"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
310 | const char *id = purple_xmlnode_get_attrib(info,"id"); |
| 25481 | 311 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33766
diff
changeset
|
312 | if(checksum && id && purple_strequal(id, checksum)) { |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
313 | /* we already have that avatar, so we don't have to do anything */ |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
314 | goodinfo = NULL; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
315 | break; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
316 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
317 | /* We'll only pick the png one for now. It's a very nice image format anyways. */ |
| 38260 | 318 | if(id && !goodinfo && purple_strequal(type, "image/png")) |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
319 | goodinfo = info; |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
320 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
321 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
322 | if(has_children == FALSE) { |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
323 | purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
324 | } else if(goodinfo) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
325 | const char *url = purple_xmlnode_get_attrib(goodinfo, "url"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
326 | const char *id = purple_xmlnode_get_attrib(goodinfo,"id"); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
327 | |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
328 | /* the avatar might either be stored in a pep node, or on a HTTP(S) URL */ |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
329 | if(!url) { |
|
27017
02ddb8e8c3d2
Drop support for XEP-0084 v0.12 and publish a <stop/> instead of deleting the node.
Paul Aurich <darkrain42@pidgin.im>
parents:
26959
diff
changeset
|
330 | jabber_pep_request_item(js, from, NS_AVATAR_1_1_DATA, id, |
|
25479
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
331 | do_buddy_avatar_update_data); |
|
416673fd83b4
Support XEP-0084 (User Avatar) v1.1 alongside v0.12
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
332 | } else { |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
333 | SoupMessage *msg; |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
334 | JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
335 | info->js = js; |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33774
diff
changeset
|
336 | info->from = g_strdup(from); |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33774
diff
changeset
|
337 | info->id = g_strdup(id); |
|
40006
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
338 | |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
339 | msg = soup_message_new("GET", url); |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
340 | soup_session_queue_message(js->http_conns, msg, |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
341 | do_buddy_avatar_update_fromurl, |
|
3a848f644aa2
Use libsoup to download XMPP avatars.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39556
diff
changeset
|
342 | info); |
|
25475
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
343 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
344 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
345 | } |
|
ad7612a5d678
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
346 | } |