Fri, 04 Nov 2022 02:32:53 -0500
Fix string size specifier in debug prints
The `%*s` specifies the *width* of the string, but this was intended to specify
the maximum number of characters (in case the `GBytes` was unterminated), which is `%.*s`.
Testing Done:
Compiled only, though I did write a small test program with `printf` to confirm that this worked the intended way.
Reviewed at https://reviews.imfreedom.org/r/2023/
|
33348
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
1 | /* purple |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
2 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
5 | * source distribution. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
6 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
7 | * Rewritten from scratch during Google Summer of Code 2012 |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
8 | * by Tomek Wasilczyk (http://www.wasilczyk.pl). |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
9 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
10 | * Previously implemented by: |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
11 | * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001); |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
12 | * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005; |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
13 | * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011). |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
14 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
15 | * This program is free software; you can redistribute it and/or modify |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
16 | * it under the terms of the GNU General Public License as published by |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
17 | * the Free Software Foundation; either version 2 of the License, or |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
18 | * (at your option) any later version. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
19 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
20 | * This program is distributed in the hope that it will be useful, |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
23 | * GNU General Public License for more details. |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
24 | * |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
25 | * You should have received a copy of the GNU General Public License |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
26 | * along with this program; if not, write to the Free Software |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
28 | */ |
|
2394cd23ce8f
Gadu-Gadu: add GSoC copyright note
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33343
diff
changeset
|
29 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
30 | #include "avatar.h" |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
31 | |
|
40756
3a58ef28ee44
Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
32 | #include "libpurple/glibcompat.h" |
|
41212
9f0f4c23132e
Use accessor for SoupMessage->status_code
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40756
diff
changeset
|
33 | #include "libpurple/soupcompat.h" |
|
40756
3a58ef28ee44
Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
34 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
35 | #include "gg.h" |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
36 | #include "utils.h" |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
37 | #include "oauth/oauth-purple.h" |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
38 | |
|
35354
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
39 | /* Common */ |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
40 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
41 | #define GGP_AVATAR_USERAGENT "GG Client build 11.0.0.7562" |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
42 | #define GGP_AVATAR_SIZE_MAX 1048576 |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
43 | |
|
35354
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
44 | /* Buddy avatars updating */ |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
45 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
46 | typedef struct |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
47 | { |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
48 | uin_t uin; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
49 | time_t timestamp; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
50 | PurpleConnection *gc; |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
51 | SoupMessage *msg; |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
52 | } ggp_avatar_buddy_update_req; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
53 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
54 | #define GGP_AVATAR_BUDDY_URL "http://avatars.gg.pl/%u/s,big" |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
55 | |
|
35354
aa1f0e988567
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35353
diff
changeset
|
56 | /* Own avatar setting */ |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
57 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
58 | struct _ggp_avatar_session_data { |
|
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
59 | PurpleImage *own_img; |
|
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
60 | }; |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
61 | |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
62 | #define GGP_AVATAR_RESPONSE_MAX 10240 |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
63 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
64 | /******************************************************************************* |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
65 | * Common. |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
66 | ******************************************************************************/ |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
67 | |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
68 | static inline ggp_avatar_session_data * |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
69 | ggp_avatar_get_avdata(PurpleConnection *gc) |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
70 | { |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
71 | GGPInfo *accdata = purple_connection_get_protocol_data(gc); |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
72 | return accdata->avatar_data; |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
73 | } |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
74 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
75 | void ggp_avatar_setup(PurpleConnection *gc) |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
76 | { |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
77 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
78 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
79 | info->avatar_data = g_new0(ggp_avatar_session_data, 1); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
80 | } |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
81 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
82 | void ggp_avatar_cleanup(PurpleConnection *gc) |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
83 | { |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
84 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
85 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
86 | g_free(info->avatar_data); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
87 | } |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
88 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
89 | /******************************************************************************* |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
90 | * Buddy avatars updating. |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
91 | ******************************************************************************/ |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
92 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
93 | void ggp_avatar_buddy_remove(PurpleConnection *gc, uin_t uin) |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
94 | { |
|
34419
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
95 | if (purple_debug_is_verbose()) { |
|
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
96 | purple_debug_misc("gg", "ggp_avatar_buddy_remove(%p, %u)\n", gc, uin); |
|
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
97 | } |
|
33328
c71e5e8976ba
Gadu-Gadu: avatar removal is possible, so lets handle it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33313
diff
changeset
|
98 | |
|
c71e5e8976ba
Gadu-Gadu: avatar removal is possible, so lets handle it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33313
diff
changeset
|
99 | purple_buddy_icons_set_for_user(purple_connection_get_account(gc), |
|
c71e5e8976ba
Gadu-Gadu: avatar removal is possible, so lets handle it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33313
diff
changeset
|
100 | ggp_uin_to_str(uin), NULL, 0, NULL); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
101 | } |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
102 | |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
103 | static void |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
104 | ggp_avatar_buddy_update_received(GObject *source, GAsyncResult *result, |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
105 | gpointer data) |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
106 | { |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
107 | ggp_avatar_buddy_update_req *pending_update = data; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
108 | GBytes *response_body = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
109 | GError *error = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
110 | const char *error_message = NULL; |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
111 | PurpleBuddy *buddy; |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
112 | PurpleAccount *account; |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
113 | PurpleConnection *gc = pending_update->gc; |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
114 | gchar timestamp_str[20]; |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
115 | char *got_data = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
116 | gsize got_len = 0; |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
117 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
118 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
119 | |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
120 | if(SOUP_STATUS_IS_SUCCESSFUL(soup_message_get_status(pending_update->msg))) { |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
121 | response_body = soup_session_send_and_read_finish(SOUP_SESSION(source), |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
122 | result, &error); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
123 | error_message = error != NULL ? error->message : "unknown"; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
124 | } else { |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
125 | error_message = soup_message_get_reason_phrase(pending_update->msg); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
126 | } |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
127 | if(response_body == NULL) { |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
128 | purple_debug_error("gg", |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
129 | "ggp_avatar_buddy_update_received: bad response " |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
130 | "while getting avatar for %u: %s", |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
131 | pending_update->uin, error_message); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
132 | g_object_unref(pending_update->msg); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
133 | g_free(pending_update); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
134 | g_clear_error(&error); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
135 | return; |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
136 | } |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
137 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
138 | account = purple_connection_get_account(gc); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
139 | buddy = purple_blist_find_buddy(account, |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
140 | ggp_uin_to_str(pending_update->uin)); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
141 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
142 | if (!buddy) { |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
143 | purple_debug_warning( |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
144 | "gg", "ggp_avatar_buddy_update_received: buddy %u disappeared", |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
145 | pending_update->uin); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
146 | g_object_unref(pending_update->msg); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
147 | g_free(pending_update); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
148 | return; |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
149 | } |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
150 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
151 | g_snprintf(timestamp_str, sizeof(timestamp_str), "%lu", |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
152 | pending_update->timestamp); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
153 | got_data = g_bytes_unref_to_data(response_body, &got_len); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
154 | purple_buddy_icons_set_for_user(account, purple_buddy_get_name(buddy), |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
155 | got_data, got_len, timestamp_str); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
156 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
157 | purple_debug_info("gg", |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
158 | "ggp_avatar_buddy_update_received: got avatar for buddy " |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
159 | "%u [ts=%lu]", |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
160 | pending_update->uin, pending_update->timestamp); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
161 | g_object_unref(pending_update->msg); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
162 | g_free(pending_update); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
163 | } |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
164 | |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
165 | void |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
166 | ggp_avatar_buddy_update(PurpleConnection *gc, uin_t uin, time_t timestamp) |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
167 | { |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
168 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
169 | gchar *url; |
|
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
170 | SoupMessage *req; |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
171 | ggp_avatar_buddy_update_req *pending_update; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
172 | PurpleBuddy *buddy; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
173 | PurpleAccount *account = purple_connection_get_account(gc); |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
174 | time_t old_timestamp; |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
175 | const char *old_timestamp_str; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
176 | |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
177 | if (purple_debug_is_verbose()) { |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
178 | purple_debug_misc("gg", "ggp_avatar_buddy_update(%p, %u, %lu)", gc, uin, |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
179 | timestamp); |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
180 | } |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
181 | |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
182 | buddy = purple_blist_find_buddy(account, ggp_uin_to_str(uin)); |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35351
diff
changeset
|
183 | |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
184 | if (!buddy) { |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
185 | if (ggp_str_to_uin(purple_account_get_username(account)) == uin) { |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
186 | purple_debug_misc( |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
187 | "gg", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
188 | "ggp_avatar_buddy_update(%p): own avatar update requested, " |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
189 | "but we don't have ourselves on buddy list", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
190 | gc); |
|
35360
29d788c72350
Style: fix gg braces (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35354
diff
changeset
|
191 | } else { |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
192 | purple_debug_warning("gg", |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
193 | "ggp_avatar_buddy_update(%p): %u update " |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
194 | "requested, but he's not on buddy list", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
195 | gc, uin); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
196 | } |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
197 | return; |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
198 | } |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
199 | |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
200 | old_timestamp_str = purple_buddy_icons_get_checksum_for_user(buddy); |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
201 | old_timestamp = old_timestamp_str ? g_ascii_strtoull( |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
202 | old_timestamp_str, NULL, 10) : 0; |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
203 | if (old_timestamp == timestamp) { |
|
34419
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
204 | if (purple_debug_is_verbose()) { |
|
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
205 | purple_debug_misc("gg", |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
206 | "ggp_avatar_buddy_update(%p): %u have up to date " |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
207 | "avatar with ts=%lu", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
208 | gc, uin, timestamp); |
|
34419
8446175c6c08
Gadu-Gadu: make gg prpl less verbose in non-verbose mode
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34378
diff
changeset
|
209 | } |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
210 | return; |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
211 | } |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
212 | if (old_timestamp > timestamp) { |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
213 | purple_debug_warning("gg", |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
214 | "ggp_avatar_buddy_update(%p): saved timestamp for " |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
215 | "%u is newer than received (%lu > %lu)", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
216 | gc, uin, old_timestamp, timestamp); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
217 | } |
|
35353
1f5964260577
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35351
diff
changeset
|
218 | |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
219 | purple_debug_info("gg", |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
220 | "ggp_avatar_buddy_update(%p): updating %u with ts=%lu...", |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
221 | gc, uin, timestamp); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
222 | |
|
40023
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
223 | pending_update = g_new(ggp_avatar_buddy_update_req, 1); |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
224 | pending_update->uin = uin; |
|
a35b3942a698
Remove manual queuing of GG avatar fetching.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40019
diff
changeset
|
225 | pending_update->timestamp = timestamp; |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
226 | pending_update->gc = gc; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
227 | |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
228 | url = g_strdup_printf(GGP_AVATAR_BUDDY_URL, pending_update->uin); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
229 | pending_update->msg = req = soup_message_new("GET", url); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
230 | g_free(url); |
|
41214
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
231 | soup_message_headers_replace(soup_message_get_request_headers(req), |
|
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
232 | "User-Agent", GGP_AVATAR_USERAGENT); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
233 | // purple_http_request_set_max_len(req, GGP_AVATAR_SIZE_MAX); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
234 | soup_session_send_and_read_async(info->http, req, G_PRIORITY_DEFAULT, NULL, |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
235 | ggp_avatar_buddy_update_received, |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
236 | pending_update); |
|
33313
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
237 | } |
|
5a0c6582d5b1
Gadu-Gadu: refactoring of buddy avatars handling. Fixes #13739, #14305
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
238 | |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
239 | /******************************************************************************* |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
240 | * Own avatar setting. |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
241 | ******************************************************************************/ |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
242 | |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
243 | /** |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
244 | * TODO: use new, GG11 method, when IMToken will be provided by libgadu. |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
245 | * |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
246 | * POST https://avatars.mpa.gg.pl/avatars/user,<uin>/0 |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
247 | * Authorization: IMToken 0123456789abcdef0123456789abcdef01234567 |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
248 | * photo=<avatar content> |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
249 | */ |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
250 | |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
251 | static void |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
252 | ggp_avatar_own_sent(GObject *source, GAsyncResult *result, gpointer data) { |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
253 | SoupMessage *msg = data; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
254 | GBytes *response_body = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
255 | GError *error = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
256 | const char *buffer = NULL; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
257 | gsize size = 0; |
|
35351
b48e08029b65
Style: fix gg (partially)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34999
diff
changeset
|
258 | |
|
41212
9f0f4c23132e
Use accessor for SoupMessage->status_code
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40756
diff
changeset
|
259 | if (!SOUP_STATUS_IS_SUCCESSFUL(soup_message_get_status(msg))) { |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
260 | purple_debug_error("gg", "ggp_avatar_own_sent: avatar not sent. %s", |
|
41213
0b5c475770e2
Use accessor for SoupMessage->reason_phrase
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41212
diff
changeset
|
261 | soup_message_get_reason_phrase(msg)); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
262 | g_object_unref(msg); |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
263 | return; |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
264 | } |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
265 | g_clear_object(&msg); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
266 | |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
267 | response_body = soup_session_send_and_read_finish(SOUP_SESSION(source), |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
268 | result, &error); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
269 | if(response_body == NULL) { |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
270 | purple_debug_error("gg", "ggp_avatar_own_sent: avatar not sent. %s", |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
271 | error->message); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
272 | g_error_free(error); |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
273 | return; |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
274 | } |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
275 | |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
276 | buffer = g_bytes_get_data(response_body, &size); |
|
41883
c67c45d70006
Fix string size specifier in debug prints
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41878
diff
changeset
|
277 | purple_debug_info("gg", "ggp_avatar_own_sent: %.*s", (int)size, buffer); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
278 | g_bytes_unref(response_body); |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
279 | } |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
280 | |
|
35819
cc375b914104
imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35360
diff
changeset
|
281 | static void |
|
cc375b914104
imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35360
diff
changeset
|
282 | ggp_avatar_own_got_token(PurpleConnection *gc, const gchar *token, |
|
cc375b914104
imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35360
diff
changeset
|
283 | gpointer _img) |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
284 | { |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
285 | GGPInfo *info = purple_connection_get_protocol_data(gc); |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
286 | ggp_avatar_session_data *avdata = ggp_avatar_get_avdata(gc); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
287 | SoupMessage *req; |
|
41214
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
288 | SoupMessageHeaders *headers; |
|
35819
cc375b914104
imgstore: remove refs from gg prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35360
diff
changeset
|
289 | PurpleImage *img = _img; |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
290 | gchar *img_data, *uin_str; |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
291 | PurpleAccount *account = purple_connection_get_account(gc); |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
292 | uin_t uin = ggp_str_to_uin(purple_account_get_username(account)); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
293 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
294 | if (img != avdata->own_img) { |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
295 | purple_debug_warning("gg", "ggp_avatar_own_got_token: " |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
296 | "avatar was changed in meantime\n"); |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
297 | return; |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
298 | } |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
299 | avdata->own_img = NULL; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
300 | |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38298
diff
changeset
|
301 | img_data = g_base64_encode(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:
36068
diff
changeset
|
302 | purple_image_get_data_size(img)); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
303 | uin_str = g_strdup_printf("%d", uin); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
304 | |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
305 | purple_debug_misc("gg", "ggp_avatar_own_got_token: " |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
306 | "uploading new avatar...\n"); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
307 | |
|
41216
5c4269ad7ee4
Replace the removed soup_form_request_new API
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41214
diff
changeset
|
308 | req = soup_message_new_from_encoded_form( |
|
5c4269ad7ee4
Replace the removed soup_form_request_new API
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41214
diff
changeset
|
309 | "POST", "http://avatars.nowe.gg/upload", |
|
5c4269ad7ee4
Replace the removed soup_form_request_new API
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41214
diff
changeset
|
310 | soup_form_encode("uin", uin_str, "photo", img_data, NULL)); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
311 | // purple_http_request_set_max_len(req, GGP_AVATAR_RESPONSE_MAX); |
|
41214
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
312 | headers = soup_message_get_request_headers(req); |
|
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
313 | soup_message_headers_replace(headers, "Authorization", token); |
|
b0b7d118475f
Use accessor for SoupMessage->request_headers
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
41213
diff
changeset
|
314 | soup_message_headers_replace(headers, "From", "avatars to avatars"); |
|
41878
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
315 | soup_session_send_and_read_async(info->http, req, G_PRIORITY_DEFAULT, NULL, |
|
64e455cfb6b4
Port some of gg to libsoup3
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41216
diff
changeset
|
316 | ggp_avatar_own_sent, req); |
|
40019
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
317 | g_free(img_data); |
|
5bf1b06ebd65
Convert GG avatar fetching to libsoup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40011
diff
changeset
|
318 | g_free(uin_str); |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
319 | } |
|
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
320 | |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
321 | void |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
322 | ggp_avatar_own_set(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
323 | PurpleImage *img) |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
324 | { |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
325 | ggp_avatar_session_data *avdata; |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
326 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35819
diff
changeset
|
327 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
328 | |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
329 | purple_debug_info("gg", "ggp_avatar_own_set(%p, %p)", gc, img); |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
330 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
331 | avdata = ggp_avatar_get_avdata(gc); |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
332 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
333 | if (img == NULL) { |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
334 | purple_debug_warning("gg", "ggp_avatar_own_set: avatar removing is " |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
335 | "probably not possible within old protocol"); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
336 | return; |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33865
diff
changeset
|
337 | } |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
338 | |
|
40024
dad0e4c75135
Remove extra indirection with ggp_avatar_session_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40023
diff
changeset
|
339 | avdata->own_img = img; |
|
40011
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
340 | |
|
3225e0bb6cea
Re-arrange GG avatar file to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38433
diff
changeset
|
341 | ggp_oauth_request(gc, ggp_avatar_own_got_token, img, NULL, NULL); |
|
33333
b20aed44c357
Gadu-Gadu: setting own buddy icon
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33328
diff
changeset
|
342 | } |