Sat, 07 Sep 2013 00:11:42 +0530
Merged soc.2013.gobjectification branch
| 9306 | 1 | /* |
| 15884 | 2 | * purple |
| 9306 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 9306 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 9306 | 21 | * |
| 22 | */ | |
| 23 | ||
| 24 | #include "internal.h" | |
| 25 | ||
| 26 | #include "account.h" | |
| 27 | #include "accountopt.h" | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34703
diff
changeset
|
28 | #include "buddylist.h" |
| 9306 | 29 | #include "debug.h" |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
30 | #include "http.h" |
|
36543
a8c3fecee2d3
Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
31 | #include "protocol.h" |
| 9306 | 32 | #include "proxy.h" |
| 33 | #include "util.h" | |
| 34 | ||
|
36670
418f1f8581de
Add/remove YahooProtocol, YahooJPProtocol via the single yahoo plugin
Ankit Vani <a@nevitus.org>
parents:
36543
diff
changeset
|
35 | #include "ymsg.h" |
| 10392 | 36 | #include "yahoo_packet.h" |
| 9306 | 37 | #include "yahoo_friend.h" |
| 38 | #include "yahoo_picture.h" | |
| 39 | ||
| 40 | ||
| 41 | struct yahoo_fetch_picture_data { | |
| 15884 | 42 | PurpleConnection *gc; |
| 9306 | 43 | char *who; |
| 44 | int checksum; | |
| 45 | }; | |
| 46 | ||
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
47 | static void |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
48 | yahoo_fetch_picture_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
49 | gpointer _data) |
| 9306 | 50 | { |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
51 | struct yahoo_fetch_picture_data *d = _data; |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
52 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
53 | if (!purple_http_response_is_successful(response)) { |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
54 | purple_debug_error("yahoo", "Fetching buddy icon failed: %s\n", |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
55 | purple_http_response_get_error(response)); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14321
diff
changeset
|
56 | } else { |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
57 | char *checksum = g_strdup_printf("%i", d->checksum); |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
58 | const gchar *pic_data; |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
59 | size_t pic_len; |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
60 | |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
61 | pic_data = purple_http_response_get_data(response, &pic_len); |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
62 | |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
63 | purple_buddy_icons_set_for_user( |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
64 | purple_connection_get_account(d->gc), d->who, |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
65 | g_memdup(pic_data, pic_len), pic_len, checksum); |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
66 | g_free(checksum); |
| 9306 | 67 | } |
| 68 | ||
| 69 | g_free(d->who); | |
| 70 | g_free(d); | |
| 71 | } | |
| 72 | ||
| 15884 | 73 | void yahoo_process_picture(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 74 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27958
diff
changeset
|
75 | YahooData *yd; |
| 9306 | 76 | GSList *l = pkt->hash; |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33424
diff
changeset
|
77 | char *who = NULL; |
| 9306 | 78 | gboolean got_icon_info = FALSE, send_icon_info = FALSE; |
| 79 | char *url = NULL; | |
| 80 | int checksum = 0; | |
| 81 | ||
| 82 | while (l) { | |
| 83 | struct yahoo_pair *pair = l->data; | |
| 84 | ||
| 85 | switch (pair->key) { | |
| 86 | case 1: | |
| 87 | case 4: | |
| 88 | who = pair->value; | |
| 89 | break; | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33424
diff
changeset
|
90 | case 5: /* us */ |
| 9306 | 91 | break; |
| 92 | case 13: { | |
| 93 | int tmp; | |
| 94 | tmp = strtol(pair->value, NULL, 10); | |
| 95 | if (tmp == 1) { | |
| 96 | send_icon_info = TRUE; | |
| 97 | } else if (tmp == 2) { | |
| 98 | got_icon_info = TRUE; | |
| 99 | } | |
| 100 | break; | |
| 101 | } | |
| 102 | case 20: | |
| 103 | url = pair->value; | |
| 104 | break; | |
| 105 | case 192: | |
| 106 | checksum = strtol(pair->value, NULL, 10); | |
| 107 | break; | |
| 108 | } | |
| 109 | ||
| 110 | l = l->next; | |
| 111 | } | |
| 112 | ||
|
27400
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
113 | if (!who) |
|
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
114 | return; |
|
d8c31c7e084d
This should prevent pidgin from crashing, as reported by the ticket #9426.
Sulabh Mahajan <sulabh@pidgin.im>
parents:
27361
diff
changeset
|
115 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
116 | if (!purple_account_privacy_check(purple_connection_get_account(gc), who)) { |
|
23960
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
117 | purple_debug_info("yahoo", "Picture packet from %s dropped.\n", who); |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
118 | return; |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
119 | } |
|
e57706b32d2a
Patch from "Chris G." to extend the yahoo privacy to picture requests to help
Daniel Atallah <datallah@pidgin.im>
parents:
23181
diff
changeset
|
120 | |
|
9675
127db3bbb4f2
[gaim-migrate @ 10527]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9329
diff
changeset
|
121 | /* Yahoo IM 6 spits out 0.png as the URL if the buddy icon is not set */ |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17151
diff
changeset
|
122 | if (who && got_icon_info && url && !g_ascii_strncasecmp(url, "http://", 7)) { |
| 9306 | 123 | /* TODO: make this work p2p, try p2p before the url */ |
| 124 | struct yahoo_fetch_picture_data *data; | |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
125 | |
| 9306 | 126 | data = g_new0(struct yahoo_fetch_picture_data, 1); |
| 127 | data->gc = gc; | |
| 128 | data->who = g_strdup(who); | |
| 129 | data->checksum = checksum; | |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33892
diff
changeset
|
130 | yd = purple_connection_get_protocol_data(gc); |
|
34269
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34235
diff
changeset
|
131 | purple_http_connection_set_add(yd->http_reqs, purple_http_get( |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34235
diff
changeset
|
132 | gc, yahoo_fetch_picture_cb, data, url)); |
| 9306 | 133 | } else if (who && send_icon_info) { |
| 134 | yahoo_send_picture_info(gc, who); | |
| 135 | } | |
| 136 | } | |
| 137 | ||
| 15884 | 138 | void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 139 | { |
| 140 | GSList *l = pkt->hash; | |
| 141 | char *who = NULL; | |
| 142 | int checksum = 0; | |
| 143 | ||
| 144 | while (l) { | |
| 145 | struct yahoo_pair *pair = l->data; | |
| 146 | ||
| 147 | switch (pair->key) { | |
| 148 | case 4: | |
| 149 | who = pair->value; | |
| 150 | break; | |
| 151 | case 5: | |
| 152 | /* us */ | |
| 153 | break; | |
| 154 | case 192: | |
| 155 | checksum = strtol(pair->value, NULL, 10); | |
| 156 | break; | |
| 157 | } | |
| 158 | l = l->next; | |
| 159 | } | |
| 160 | ||
| 161 | if (who) { | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
162 | PurpleBuddy *b = purple_blist_find_buddy(purple_connection_get_account(gc), who); |
|
16606
b31fca4f6f60
Thanks to Bleeter, yahoo will not crash for non-existent buddyicons anymore.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16539
diff
changeset
|
163 | const char *locksum = NULL; |
|
16534
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
164 | |
|
2ab9e23f99d9
Move the prpl icon checksum code into the core, so we can delete the
Richard Laager <rlaager@pidgin.im>
parents:
16076
diff
changeset
|
165 | /* FIXME: Cleanup this strtol() stuff if possible. */ |
|
17151
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
166 | if (b) { |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
167 | locksum = purple_buddy_icons_get_checksum_for_user(b); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
168 | if (!locksum || (checksum != strtol(locksum, NULL, 10))) |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
169 | yahoo_send_picture_request(gc, who); |
|
7d28dd13c4db
Patch #1038. Fix receiving of Yahoo buddy icons. Thanks, vampire!
Sean Egan <seanegan@pidgin.im>
parents:
16757
diff
changeset
|
170 | } |
| 9306 | 171 | } |
| 172 | } | |
| 173 | ||
| 15884 | 174 | void yahoo_process_picture_upload(PurpleConnection *gc, struct yahoo_packet *pkt) |
| 9306 | 175 | { |
| 15884 | 176 | PurpleAccount *account = purple_connection_get_account(gc); |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
177 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 178 | GSList *l = pkt->hash; |
| 179 | char *url = NULL; | |
| 180 | ||
| 181 | while (l) { | |
| 182 | struct yahoo_pair *pair = l->data; | |
| 183 | ||
| 184 | switch (pair->key) { | |
| 185 | case 5: | |
| 186 | /* us */ | |
| 187 | break; | |
| 188 | case 27: | |
| 189 | /* filename on our computer. */ | |
| 190 | break; | |
| 191 | case 20: /* url at yahoo */ | |
| 192 | url = pair->value; | |
| 193 | case 38: /* timestamp */ | |
| 194 | break; | |
| 195 | } | |
| 196 | l = l->next; | |
| 197 | } | |
| 198 | ||
| 199 | if (url) { | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
200 | g_free(yd->picture_url); |
| 9306 | 201 | yd->picture_url = g_strdup(url); |
| 15884 | 202 | purple_account_set_string(account, YAHOO_PICURL_SETTING, url); |
| 203 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, yd->picture_checksum); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
204 | yahoo_send_picture_checksum(gc); |
| 9310 | 205 | yahoo_send_picture_update(gc, 2); |
| 9306 | 206 | } |
| 207 | } | |
| 208 | ||
| 15884 | 209 | void yahoo_process_avatar_update(PurpleConnection *gc, struct yahoo_packet *pkt) |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
210 | { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
211 | GSList *l = pkt->hash; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
212 | char *who = NULL; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
213 | int avatar = 0; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
214 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
215 | while (l) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
216 | struct yahoo_pair *pair = l->data; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
217 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
218 | switch (pair->key) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
219 | case 4: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
220 | who = pair->value; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
221 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
222 | case 5: |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
223 | /* us */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
224 | break; |
|
27467
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
225 | case 206: /* Older versions. Still needed? */ |
|
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
226 | case 213: /* Newer versions */ |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
227 | /* |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
228 | * 0 - No icon or avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
229 | * 1 - Using an avatar |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
230 | * 2 - Using an icon |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
231 | */ |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
232 | avatar = strtol(pair->value, NULL, 10); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
233 | break; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
234 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
235 | l = l->next; |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
236 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
237 | |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
238 | if (who) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
239 | if (avatar == 2) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
240 | yahoo_send_picture_request(gc, who); |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
241 | else if ((avatar == 0) || (avatar == 1)) { |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
242 | YahooFriend *f; |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32596
diff
changeset
|
243 | purple_buddy_icons_set_for_user(purple_connection_get_account(gc), who, NULL, 0, NULL); |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
244 | if ((f = yahoo_friend_find(gc, who))) |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
245 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); |
| 15884 | 246 | purple_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); |
|
14030
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
247 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
248 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
249 | } |
|
23144f1dc950
[gaim-migrate @ 16525]
Mark Doliner <markdoliner@pidgin.im>
parents:
13277
diff
changeset
|
250 | |
| 15884 | 251 | void yahoo_send_picture_info(PurpleConnection *gc, const char *who) |
| 9322 | 252 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
253 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9322 | 254 | struct yahoo_packet *pkt; |
| 255 | ||
| 9329 | 256 | if (!yd->picture_url) { |
| 15884 | 257 | purple_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); |
| 9322 | 258 | return; |
| 9329 | 259 | } |
| 9322 | 260 | |
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
261 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27413
2c10bbbac69c
This fixes sending updates to buddies when I change my pic.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27412
diff
changeset
|
262 | yahoo_packet_hash(pkt, "ssssi", 1, purple_connection_get_display_name(gc), |
|
2c10bbbac69c
This fixes sending updates to buddies when I change my pic.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27412
diff
changeset
|
263 | 5, who, |
| 10394 | 264 | 13, "2", 20, yd->picture_url, 192, yd->picture_checksum); |
| 10392 | 265 | yahoo_packet_send_and_free(pkt, yd); |
| 9322 | 266 | } |
| 9306 | 267 | |
| 15884 | 268 | void yahoo_send_picture_request(PurpleConnection *gc, const char *who) |
| 9306 | 269 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
270 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 271 | struct yahoo_packet *pkt; |
| 272 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
273 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27412
1db60cfcad9b
This fixes buddyicon fetches for me.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27409
diff
changeset
|
274 | yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); /* me */ |
| 10394 | 275 | yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ |
| 276 | yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */ | |
| 10392 | 277 | yahoo_packet_send_and_free(pkt, yd); |
| 9306 | 278 | } |
| 279 | ||
| 15884 | 280 | void yahoo_send_picture_checksum(PurpleConnection *gc) |
| 9310 | 281 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
282 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 283 | struct yahoo_packet *pkt; |
| 284 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
285 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 15884 | 286 | yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), |
| 10394 | 287 | 212, "1", 192, yd->picture_checksum); |
| 10392 | 288 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 289 | } |
| 290 | ||
| 15884 | 291 | void yahoo_send_picture_update_to_user(PurpleConnection *gc, const char *who, int type) |
| 9310 | 292 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
293 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 294 | struct yahoo_packet *pkt; |
| 295 | ||
|
27866
4a8d47263e98
Change a bunch more of our yahoo packets to use the session ID. I believe this
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27555
diff
changeset
|
296 | pkt = yahoo_packet_new(YAHOO_SERVICE_AVATAR_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
|
27467
5fd6936c4ed7
Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27413
diff
changeset
|
297 | yahoo_packet_hash(pkt, "si", 3, who, 213, type); |
| 10392 | 298 | yahoo_packet_send_and_free(pkt, yd); |
| 9310 | 299 | } |
| 300 | ||
| 301 | struct yspufe { | |
| 15884 | 302 | PurpleConnection *gc; |
| 9310 | 303 | int type; |
| 304 | }; | |
| 305 | ||
| 306 | static void yahoo_send_picture_update_foreach(gpointer key, gpointer value, gpointer data) | |
| 307 | { | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
308 | const char *who = key; |
| 9310 | 309 | YahooFriend *f = value; |
| 310 | struct yspufe *d = data; | |
| 311 | ||
| 312 | if (f->status != YAHOO_STATUS_OFFLINE) | |
| 313 | yahoo_send_picture_update_to_user(d->gc, who, d->type); | |
| 314 | } | |
| 315 | ||
| 15884 | 316 | void yahoo_send_picture_update(PurpleConnection *gc, int type) |
| 9310 | 317 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
318 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9310 | 319 | struct yspufe data; |
| 320 | ||
| 321 | data.gc = gc; | |
| 322 | data.type = type; | |
| 323 | ||
| 324 | g_hash_table_foreach(yd->friends, yahoo_send_picture_update_foreach, &data); | |
| 325 | } | |
| 326 | ||
| 9306 | 327 | void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d) |
| 328 | { | |
| 15884 | 329 | purple_debug_misc("yahoo", "In yahoo_buddy_icon_upload_data_free()\n"); |
| 9306 | 330 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
331 | if (d->picture_data) |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
332 | g_string_free(d->picture_data, TRUE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
333 | g_free(d->filename); |
| 9306 | 334 | g_free(d); |
| 335 | } | |
| 336 | ||
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
337 | static void |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
338 | yahoo_buddy_icon_upload_done(PurpleHttpConnection *http_conn, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
339 | PurpleHttpResponse *response, gpointer _d) |
| 9306 | 340 | { |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
341 | struct yahoo_buddy_icon_upload_data *d = _d; |
| 15884 | 342 | PurpleConnection *gc = d->gc; |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
343 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 344 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
345 | yd->picture_upload_hc = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
346 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
347 | if (!purple_http_response_is_successful(response)) |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
348 | purple_debug_info("yahoo", "Error uploading buddy icon.\n"); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
349 | else |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
350 | purple_debug_misc("yahoo", "Finished uploading buddy icon.\n"); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
351 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
352 | yahoo_buddy_icon_upload_data_free(d); |
| 9306 | 353 | } |
| 354 | ||
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
355 | static void |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
356 | yahoo_buddy_icon_build_packet(struct yahoo_buddy_icon_upload_data *d) |
| 9306 | 357 | { |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
358 | struct yahoo_packet *pkt; |
| 15884 | 359 | PurpleConnection *gc = d->gc; |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
360 | YahooData *yd = purple_connection_get_protocol_data(gc); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
361 | gchar *len_str; |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
362 | guchar *pkt_buf; |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
363 | gsize pkt_buf_len; |
| 9306 | 364 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
365 | pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
366 | YAHOO_STATUS_AVAILABLE, yd->session_id); |
| 9306 | 367 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
368 | len_str = g_strdup_printf("%" G_GSIZE_FORMAT, d->picture_data->len); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
369 | /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
370 | * 14 = NULL, 29 = data |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
371 | */ |
| 15884 | 372 | yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); |
| 10394 | 373 | yahoo_packet_hash_str(pkt, 38, "604800"); /* time til expire */ |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
374 | purple_account_set_int(purple_connection_get_account(gc), |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
375 | YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800); |
| 15884 | 376 | yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
377 | yahoo_packet_hash_str(pkt, 28, len_str); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
378 | g_free(len_str); |
| 10394 | 379 | yahoo_packet_hash_str(pkt, 27, d->filename); |
| 380 | yahoo_packet_hash_str(pkt, 14, ""); | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
381 | /* 4 padding for the 29 key name */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
382 | pkt_buf_len = yahoo_packet_build(pkt, 4, FALSE, yd->jp, &pkt_buf); |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
383 | yahoo_packet_free(pkt); |
| 9306 | 384 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
385 | /* There's no magic here, we just need to prepend in reverse order */ |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
386 | g_string_prepend(d->picture_data, "29\xc0\x80"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
387 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
388 | g_string_prepend_len(d->picture_data, (char *)pkt_buf, pkt_buf_len); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12412
diff
changeset
|
389 | g_free(pkt_buf); |
| 9306 | 390 | } |
| 391 | ||
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
392 | void |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
393 | yahoo_buddy_icon_upload(PurpleConnection *gc, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
394 | struct yahoo_buddy_icon_upload_data *d) |
| 9306 | 395 | { |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
396 | PurpleHttpRequest *req; |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
397 | PurpleHttpCookieJar *cjar; |
| 15884 | 398 | PurpleAccount *account = purple_connection_get_account(gc); |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
399 | YahooData *yd = purple_connection_get_protocol_data(gc); |
| 9306 | 400 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
401 | /* Cancel any in-progress buddy icon upload */ |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
402 | purple_http_conn_cancel(yd->picture_upload_hc); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
403 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
404 | req = purple_http_request_new(NULL); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34285
diff
changeset
|
405 | purple_http_request_set_url_printf(req, "http://%s/notifyft", |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
406 | purple_account_get_string(account, "xfer_host", yd->jp ? |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34285
diff
changeset
|
407 | YAHOOJP_XFER_HOST : YAHOO_XFER_HOST)); |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
408 | purple_http_request_set_method(req, "POST"); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
409 | cjar = purple_http_request_get_cookie_jar(req); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
410 | purple_http_cookie_jar_set(cjar, "T", yd->cookie_t); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
411 | purple_http_cookie_jar_set(cjar, "Y", yd->cookie_y); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
412 | purple_http_request_header_set(req, "Cache-Control", "no-cache"); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
413 | purple_http_request_header_set(req, "User-Agent", |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
414 | YAHOO_CLIENT_USERAGENT); |
|
14693
9e3d4f9609e1
[gaim-migrate @ 17377]
Evan Schoenberg <evands@pidgin.im>
parents:
14686
diff
changeset
|
415 | |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
416 | yahoo_buddy_icon_build_packet(d); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
417 | purple_http_request_set_contents(req, d->picture_data->str, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
418 | d->picture_data->len); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
419 | g_string_free(d->picture_data, TRUE); |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
420 | d->picture_data = NULL; |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
421 | |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
422 | yd->picture_upload_hc = purple_http_request(gc, req, |
|
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
423 | yahoo_buddy_icon_upload_done, d); |
| 9306 | 424 | } |
| 425 | ||
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
426 | static int yahoo_buddy_icon_calculate_checksum(const guchar *data, gsize len) |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
427 | { |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
428 | /* This code is borrowed from Kopete, which seems to be managing to calculate |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
429 | checksums in such a manner that Yahoo!'s servers are happy */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
430 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
431 | const guchar *p = data; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
432 | int checksum = 0, g, i = len; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
433 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
434 | while(i--) { |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
435 | checksum = (checksum << 4) + *p++; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
436 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
437 | if((g = (checksum & 0xf0000000)) != 0) |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
438 | checksum ^= g >> 23; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
439 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
440 | checksum &= ~g; |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
441 | } |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
442 | |
|
25895
ab35a3dda3c5
Add a newline to this log message
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
443 | purple_debug_misc("yahoo", "Calculated buddy icon checksum: %d\n", checksum); |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
444 | |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
445 | return checksum; |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
27052
diff
changeset
|
446 | } |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
447 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
448 | void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) |
| 9306 | 449 | { |
|
32280
704f84f692f6
Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
Andrew Victor <andrew.victor@mxit.com>
parents:
27959
diff
changeset
|
450 | YahooData *yd = purple_connection_get_protocol_data(gc); |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32596
diff
changeset
|
451 | PurpleAccount *account = purple_connection_get_account(gc); |
| 9306 | 452 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
453 | if (img == NULL) { |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
454 | g_free(yd->picture_url); |
| 9306 | 455 | yd->picture_url = NULL; |
| 456 | ||
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
457 | /* TODO: don't we have to clear it on the server too?! */ |
|
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
458 | |
| 15884 | 459 | purple_account_set_string(account, YAHOO_PICURL_SETTING, NULL); |
| 460 | purple_account_set_int(account, YAHOO_PICCKSUM_SETTING, 0); | |
| 461 | purple_account_set_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 9310 | 462 | if (yd->logged_in) |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
463 | /* Tell everyone we ain't got one no more */ |
| 9310 | 464 | yahoo_send_picture_update(gc, 0); |
| 9306 | 465 | |
|
16538
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
466 | } else { |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
467 | gconstpointer data = purple_imgstore_get_data(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
468 | size_t len = purple_imgstore_get_size(img); |
|
c7e61e2917c9
Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents:
16534
diff
changeset
|
469 | GString *s = g_string_new_len(data, len); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
470 | struct yahoo_buddy_icon_upload_data *d; |
| 15884 | 471 | int oldcksum = purple_account_get_int(account, YAHOO_PICCKSUM_SETTING, 0); |
| 472 | int expire = purple_account_get_int(account, YAHOO_PICEXPIRE_SETTING, 0); | |
| 473 | const char *oldurl = purple_account_get_string(account, YAHOO_PICURL_SETTING, NULL); | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
474 | |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
475 | yd->picture_checksum = yahoo_buddy_icon_calculate_checksum(data, len); |
| 9306 | 476 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
477 | if ((yd->picture_checksum == oldcksum) && |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
478 | (expire > (time(NULL) + 60*60*24)) && oldurl) |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
479 | { |
| 15884 | 480 | purple_debug_misc("yahoo", "buddy icon is up to date. Not reuploading.\n"); |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
481 | g_string_free(s, TRUE); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
482 | g_free(yd->picture_url); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
483 | yd->picture_url = g_strdup(oldurl); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
484 | return; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
485 | } |
| 9306 | 486 | |
|
16757
aae5c0ced2da
Update the comments about yahoo buddy icons. Only send the filename and not the whole path.
Tim Ringenbach <marv@pidgin.im>
parents:
16606
diff
changeset
|
487 | /* We use this solely for sending a filename to the server */ |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
488 | d = g_new0(struct yahoo_buddy_icon_upload_data, 1); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
489 | d->gc = gc; |
|
34285
bae262cc5585
HTTP: removing extra yahoo HTTP implementations - buddy icon uploading
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
490 | d->picture_data = s; |
|
23170
456cbed76e54
applied changes from c7504bbbe35f5bef52032c0cdf6bc7182128a469
Daniel Atallah <datallah@pidgin.im>
parents:
23156
diff
changeset
|
491 | d->filename = g_strdup(purple_imgstore_get_filename(img)); |
| 9306 | 492 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
493 | if (!yd->logged_in) { |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
494 | yd->picture_upload_todo = d; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
495 | return; |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
496 | } |
| 9306 | 497 | |
|
15239
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
498 | yahoo_buddy_icon_upload(gc, d); |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
499 | |
|
f31e2c11334e
[gaim-migrate @ 17964]
Mark Doliner <markdoliner@pidgin.im>
parents:
15042
diff
changeset
|
500 | } |
|
15245
3abed8bd82fb
[gaim-migrate @ 17972]
Mark Doliner <markdoliner@pidgin.im>
parents:
15239
diff
changeset
|
501 | } |