Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_picture.c @ 27590:a08e84032814
merge of '2348ff22f0ff3453774b8b25b36238465580c609'
and 'e76f11543c2a4aa05bdf584f087cbe3439029661'
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 12 Jul 2009 05:43:38 +0000 |
parents | ef5f0cde8d74 |
children | 4bfaf18fcb13 |
comparison
equal
deleted
inserted
replaced
27104:048bcf41deef | 27590:a08e84032814 |
---|---|
30 #include "privacy.h" | 30 #include "privacy.h" |
31 #include "prpl.h" | 31 #include "prpl.h" |
32 #include "proxy.h" | 32 #include "proxy.h" |
33 #include "util.h" | 33 #include "util.h" |
34 | 34 |
35 #include "yahoo.h" | 35 #include "libymsg.h" |
36 #include "yahoo_packet.h" | 36 #include "yahoo_packet.h" |
37 #include "yahoo_friend.h" | 37 #include "yahoo_friend.h" |
38 #include "yahoo_picture.h" | 38 #include "yahoo_picture.h" |
39 | 39 |
40 | 40 |
108 } | 108 } |
109 | 109 |
110 l = l->next; | 110 l = l->next; |
111 } | 111 } |
112 | 112 |
113 if (!who) | |
114 return; | |
115 | |
113 if (!purple_privacy_check(purple_connection_get_account(gc), who)) { | 116 if (!purple_privacy_check(purple_connection_get_account(gc), who)) { |
114 purple_debug_info("yahoo", "Picture packet from %s dropped.\n", who); | 117 purple_debug_info("yahoo", "Picture packet from %s dropped.\n", who); |
115 return; | 118 return; |
116 } | 119 } |
117 | 120 |
124 const char *locksum = NULL; | 127 const char *locksum = NULL; |
125 /* use whole URL if using HTTP Proxy */ | 128 /* use whole URL if using HTTP Proxy */ |
126 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); | 129 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); |
127 | 130 |
128 /* FIXME: Cleanup this strtol() stuff if possible. */ | 131 /* FIXME: Cleanup this strtol() stuff if possible. */ |
129 if (b && (locksum = purple_buddy_icons_get_checksum_for_user(b)) != NULL && | 132 if (b && (locksum = purple_buddy_icons_get_checksum_for_user(b)) != NULL && |
130 (checksum == strtol(locksum, NULL, 10))) | 133 (checksum == strtol(locksum, NULL, 10))) |
131 return; | 134 return; |
132 | 135 |
133 data = g_new0(struct yahoo_fetch_picture_data, 1); | 136 data = g_new0(struct yahoo_fetch_picture_data, 1); |
134 data->gc = gc; | 137 data->gc = gc; |
135 data->who = g_strdup(who); | 138 data->who = g_strdup(who); |
136 data->checksum = checksum; | 139 data->checksum = checksum; |
137 /* TODO: Does this need to be MSIE 5.0? */ | 140 /* TODO: Does this need to be MSIE 5.0? */ |
138 url_data = purple_util_fetch_url(url, use_whole_url, | 141 url_data = purple_util_fetch_url(url, use_whole_url, |
139 "Mozilla/4.0 (compatible; MSIE 5.0)", FALSE, | 142 "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, |
140 yahoo_fetch_picture_cb, data); | 143 yahoo_fetch_picture_cb, data); |
141 if (url_data != NULL) { | 144 if (url_data != NULL) { |
142 yd = gc->proto_data; | 145 yd = gc->proto_data; |
143 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); | 146 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
144 } else { | 147 } else { |
148 } else if (who && send_icon_info) { | 151 } else if (who && send_icon_info) { |
149 yahoo_send_picture_info(gc, who); | 152 yahoo_send_picture_info(gc, who); |
150 } | 153 } |
151 } | 154 } |
152 | 155 |
153 void yahoo_process_picture_update(PurpleConnection *gc, struct yahoo_packet *pkt) | |
154 { | |
155 GSList *l = pkt->hash; | |
156 char *who = NULL; | |
157 int icon = 0; | |
158 | |
159 while (l) { | |
160 struct yahoo_pair *pair = l->data; | |
161 | |
162 switch (pair->key) { | |
163 case 4: | |
164 who = pair->value; | |
165 break; | |
166 case 5: | |
167 /* us */ | |
168 break; | |
169 /* NOTE: currently the server seems to only send 213; 206 was used | |
170 * in older versions. Check whether it's still needed. */ | |
171 case 206: | |
172 case 213: | |
173 icon = strtol(pair->value, NULL, 10); | |
174 break; | |
175 } | |
176 l = l->next; | |
177 } | |
178 | |
179 if (who) { | |
180 if (icon == 2) | |
181 yahoo_send_picture_request(gc, who); | |
182 else if ((icon == 0) || (icon == 1)) { | |
183 YahooFriend *f; | |
184 purple_buddy_icons_set_for_user(gc->account, who, NULL, 0, NULL); | |
185 if ((f = yahoo_friend_find(gc, who))) | |
186 yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
187 purple_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who); | |
188 } | |
189 } | |
190 } | |
191 | |
192 void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) | 156 void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) |
193 { | 157 { |
194 GSList *l = pkt->hash; | 158 GSList *l = pkt->hash; |
195 char *who = NULL; | 159 char *who = NULL; |
196 int checksum = 0; | 160 int checksum = 0; |
274 who = pair->value; | 238 who = pair->value; |
275 break; | 239 break; |
276 case 5: | 240 case 5: |
277 /* us */ | 241 /* us */ |
278 break; | 242 break; |
279 case 206: | 243 case 206: /* Older versions. Still needed? */ |
244 case 213: /* Newer versions */ | |
280 /* | 245 /* |
281 * 0 - No icon or avatar | 246 * 0 - No icon or avatar |
282 * 1 - Using an avatar | 247 * 1 - Using an avatar |
283 * 2 - Using an icon | 248 * 2 - Using an icon |
284 */ | 249 */ |
310 purple_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); | 275 purple_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); |
311 return; | 276 return; |
312 } | 277 } |
313 | 278 |
314 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); | 279 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); |
315 yahoo_packet_hash(pkt, "sssssi", 1, purple_connection_get_display_name(gc), | 280 yahoo_packet_hash(pkt, "ssssi", 1, purple_connection_get_display_name(gc), |
316 4, purple_connection_get_display_name(gc), 5, who, | 281 5, who, |
317 13, "2", 20, yd->picture_url, 192, yd->picture_checksum); | 282 13, "2", 20, yd->picture_url, 192, yd->picture_checksum); |
318 yahoo_packet_send_and_free(pkt, yd); | 283 yahoo_packet_send_and_free(pkt, yd); |
319 } | 284 } |
320 | 285 |
321 void yahoo_send_picture_request(PurpleConnection *gc, const char *who) | 286 void yahoo_send_picture_request(PurpleConnection *gc, const char *who) |
322 { | 287 { |
323 struct yahoo_data *yd = gc->proto_data; | 288 struct yahoo_data *yd = gc->proto_data; |
324 struct yahoo_packet *pkt; | 289 struct yahoo_packet *pkt; |
325 | 290 |
326 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); | 291 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); |
327 yahoo_packet_hash_str(pkt, 4, purple_connection_get_display_name(gc)); /* me */ | 292 yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); /* me */ |
328 yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ | 293 yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ |
329 yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */ | 294 yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */ |
330 yahoo_packet_send_and_free(pkt, yd); | 295 yahoo_packet_send_and_free(pkt, yd); |
331 } | 296 } |
332 | 297 |
344 void yahoo_send_picture_update_to_user(PurpleConnection *gc, const char *who, int type) | 309 void yahoo_send_picture_update_to_user(PurpleConnection *gc, const char *who, int type) |
345 { | 310 { |
346 struct yahoo_data *yd = gc->proto_data; | 311 struct yahoo_data *yd = gc->proto_data; |
347 struct yahoo_packet *pkt; | 312 struct yahoo_packet *pkt; |
348 | 313 |
349 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 314 pkt = yahoo_packet_new(YAHOO_SERVICE_AVATAR_UPDATE, YAHOO_STATUS_AVAILABLE, 0); |
350 yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), 5, who, 206, type); | 315 yahoo_packet_hash(pkt, "si", 3, who, 213, type); |
351 yahoo_packet_send_and_free(pkt, yd); | 316 yahoo_packet_send_and_free(pkt, yd); |
352 } | 317 } |
353 | 318 |
354 struct yspufe { | 319 struct yspufe { |
355 PurpleConnection *gc; | 320 PurpleConnection *gc; |
504 "Cookie: T=%s; Y=%s\r\n" | 469 "Cookie: T=%s; Y=%s\r\n" |
505 "Host: %s\r\n" | 470 "Host: %s\r\n" |
506 "Content-Length: %" G_GSIZE_FORMAT "\r\n" | 471 "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
507 "Cache-Control: no-cache\r\n\r\n", | 472 "Cache-Control: no-cache\r\n\r\n", |
508 use_whole_url ? "http://" : "", use_whole_url ? tmp : "", | 473 use_whole_url ? "http://" : "", use_whole_url ? tmp : "", |
509 yd->cookie_t, yd->cookie_y, | 474 yd->cookie_t, yd->cookie_y, |
510 tmp, | 475 tmp, |
511 pkt_buf_len + 4 + d->str->len); | 476 pkt_buf_len + 4 + d->str->len); |
512 g_free(tmp); | 477 g_free(tmp); |
513 | 478 |
514 /* There's no magic here, we just need to prepend in reverse order */ | 479 /* There's no magic here, we just need to prepend in reverse order */ |
571 } | 536 } |
572 | 537 |
573 purple_debug_misc("yahoo", "Calculated buddy icon checksum: %d\n", checksum); | 538 purple_debug_misc("yahoo", "Calculated buddy icon checksum: %d\n", checksum); |
574 | 539 |
575 return checksum; | 540 return checksum; |
576 } | 541 } |
577 | 542 |
578 void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) | 543 void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) |
579 { | 544 { |
580 struct yahoo_data *yd = gc->proto_data; | 545 struct yahoo_data *yd = gc->proto_data; |
581 PurpleAccount *account = gc->account; | 546 PurpleAccount *account = gc->account; |