comparison libpurple/protocols/yahoo/yahoo_picture.c @ 31998:fcf841ffd620

Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
author andrew.victor@mxit.com
date Tue, 30 Aug 2011 20:03:11 +0000
parents 908be3822215
children 513b8ec76077
comparison
equal deleted inserted replaced
31997:1a3723704543 31998:fcf841ffd620
50 { 50 {
51 struct yahoo_fetch_picture_data *d; 51 struct yahoo_fetch_picture_data *d;
52 YahooData *yd; 52 YahooData *yd;
53 53
54 d = user_data; 54 d = user_data;
55 yd = d->gc->proto_data; 55 yd = purple_connection_get_protocol_data(d->gc);
56 yd->url_datas = g_slist_remove(yd->url_datas, url_data); 56 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
57 57
58 if (error_message != NULL) { 58 if (error_message != NULL) {
59 purple_debug_error("yahoo", "Fetching buddy icon failed: %s\n", error_message); 59 purple_debug_error("yahoo", "Fetching buddy icon failed: %s\n", error_message);
60 } else if (len == 0) { 60 } else if (len == 0) {
140 /* TODO: Does this need to be MSIE 5.0? */ 140 /* TODO: Does this need to be MSIE 5.0? */
141 url_data = purple_util_fetch_url(url, use_whole_url, 141 url_data = purple_util_fetch_url(url, use_whole_url,
142 "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE, 142 "Mozilla/4.0 (compatible; MSIE 5.5)", FALSE,
143 yahoo_fetch_picture_cb, data); 143 yahoo_fetch_picture_cb, data);
144 if (url_data != NULL) { 144 if (url_data != NULL) {
145 yd = gc->proto_data; 145 yd = purple_connection_get_protocol_data(gc);
146 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); 146 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
147 } else { 147 } else {
148 g_free(data->who); 148 g_free(data->who);
149 g_free(data); 149 g_free(data);
150 } 150 }
190 } 190 }
191 191
192 void yahoo_process_picture_upload(PurpleConnection *gc, struct yahoo_packet *pkt) 192 void yahoo_process_picture_upload(PurpleConnection *gc, struct yahoo_packet *pkt)
193 { 193 {
194 PurpleAccount *account = purple_connection_get_account(gc); 194 PurpleAccount *account = purple_connection_get_account(gc);
195 YahooData *yd = gc->proto_data; 195 YahooData *yd = purple_connection_get_protocol_data(gc);
196 GSList *l = pkt->hash; 196 GSList *l = pkt->hash;
197 char *url = NULL; 197 char *url = NULL;
198 198
199 while (l) { 199 while (l) {
200 struct yahoo_pair *pair = l->data; 200 struct yahoo_pair *pair = l->data;
266 } 266 }
267 } 267 }
268 268
269 void yahoo_send_picture_info(PurpleConnection *gc, const char *who) 269 void yahoo_send_picture_info(PurpleConnection *gc, const char *who)
270 { 270 {
271 YahooData *yd = gc->proto_data; 271 YahooData *yd = purple_connection_get_protocol_data(gc);
272 struct yahoo_packet *pkt; 272 struct yahoo_packet *pkt;
273 273
274 if (!yd->picture_url) { 274 if (!yd->picture_url) {
275 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");
276 return; 276 return;
283 yahoo_packet_send_and_free(pkt, yd); 283 yahoo_packet_send_and_free(pkt, yd);
284 } 284 }
285 285
286 void yahoo_send_picture_request(PurpleConnection *gc, const char *who) 286 void yahoo_send_picture_request(PurpleConnection *gc, const char *who)
287 { 287 {
288 YahooData *yd = gc->proto_data; 288 YahooData *yd = purple_connection_get_protocol_data(gc);
289 struct yahoo_packet *pkt; 289 struct yahoo_packet *pkt;
290 290
291 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id); 291 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, yd->session_id);
292 yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); /* me */ 292 yahoo_packet_hash_str(pkt, 1, purple_connection_get_display_name(gc)); /* me */
293 yahoo_packet_hash_str(pkt, 5, who); /* the other guy */ 293 yahoo_packet_hash_str(pkt, 5, who); /* the other guy */
295 yahoo_packet_send_and_free(pkt, yd); 295 yahoo_packet_send_and_free(pkt, yd);
296 } 296 }
297 297
298 void yahoo_send_picture_checksum(PurpleConnection *gc) 298 void yahoo_send_picture_checksum(PurpleConnection *gc)
299 { 299 {
300 YahooData *yd = gc->proto_data; 300 YahooData *yd = purple_connection_get_protocol_data(gc);
301 struct yahoo_packet *pkt; 301 struct yahoo_packet *pkt;
302 302
303 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, yd->session_id); 303 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, yd->session_id);
304 yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc), 304 yahoo_packet_hash(pkt, "ssi", 1, purple_connection_get_display_name(gc),
305 212, "1", 192, yd->picture_checksum); 305 212, "1", 192, yd->picture_checksum);
306 yahoo_packet_send_and_free(pkt, yd); 306 yahoo_packet_send_and_free(pkt, yd);
307 } 307 }
308 308
309 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)
310 { 310 {
311 YahooData *yd = gc->proto_data; 311 YahooData *yd = purple_connection_get_protocol_data(gc);
312 struct yahoo_packet *pkt; 312 struct yahoo_packet *pkt;
313 313
314 pkt = yahoo_packet_new(YAHOO_SERVICE_AVATAR_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); 314 pkt = yahoo_packet_new(YAHOO_SERVICE_AVATAR_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id);
315 yahoo_packet_hash(pkt, "si", 3, who, 213, type); 315 yahoo_packet_hash(pkt, "si", 3, who, 213, type);
316 yahoo_packet_send_and_free(pkt, yd); 316 yahoo_packet_send_and_free(pkt, yd);
331 yahoo_send_picture_update_to_user(d->gc, who, d->type); 331 yahoo_send_picture_update_to_user(d->gc, who, d->type);
332 } 332 }
333 333
334 void yahoo_send_picture_update(PurpleConnection *gc, int type) 334 void yahoo_send_picture_update(PurpleConnection *gc, int type)
335 { 335 {
336 YahooData *yd = gc->proto_data; 336 YahooData *yd = purple_connection_get_protocol_data(gc);
337 struct yspufe data; 337 struct yspufe data;
338 338
339 data.gc = gc; 339 data.gc = gc;
340 data.type = type; 340 data.type = type;
341 341
430 YahooData *yd; 430 YahooData *yd;
431 /* use whole URL if using HTTP Proxy */ 431 /* use whole URL if using HTTP Proxy */
432 gboolean use_whole_url = yahoo_account_use_http_proxy(gc); 432 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
433 433
434 account = purple_connection_get_account(gc); 434 account = purple_connection_get_account(gc);
435 yd = gc->proto_data; 435 yd = purple_connection_get_protocol_data(gc);
436 436
437 /* Buddy icon connect is now complete; clear the PurpleProxyConnectData */ 437 /* Buddy icon connect is now complete; clear the PurpleProxyConnectData */
438 yd->buddy_icon_connect_data = NULL; 438 yd->buddy_icon_connect_data = NULL;
439 439
440 if (source < 0) { 440 if (source < 0) {
495 } 495 }
496 496
497 void yahoo_buddy_icon_upload(PurpleConnection *gc, struct yahoo_buddy_icon_upload_data *d) 497 void yahoo_buddy_icon_upload(PurpleConnection *gc, struct yahoo_buddy_icon_upload_data *d)
498 { 498 {
499 PurpleAccount *account = purple_connection_get_account(gc); 499 PurpleAccount *account = purple_connection_get_account(gc);
500 YahooData *yd = gc->proto_data; 500 YahooData *yd = purple_connection_get_protocol_data(gc);
501 501
502 if (yd->buddy_icon_connect_data != NULL) { 502 if (yd->buddy_icon_connect_data != NULL) {
503 /* Cancel any in-progress buddy icon upload */ 503 /* Cancel any in-progress buddy icon upload */
504 purple_proxy_connect_cancel(yd->buddy_icon_connect_data); 504 purple_proxy_connect_cancel(yd->buddy_icon_connect_data);
505 yd->buddy_icon_connect_data = NULL; 505 yd->buddy_icon_connect_data = NULL;
540 return checksum; 540 return checksum;
541 } 541 }
542 542
543 void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) 543 void yahoo_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
544 { 544 {
545 YahooData *yd = gc->proto_data; 545 YahooData *yd = purple_connection_get_protocol_data(gc);
546 PurpleAccount *account = gc->account; 546 PurpleAccount *account = gc->account;
547 547
548 if (img == NULL) { 548 if (img == NULL) {
549 g_free(yd->picture_url); 549 g_free(yd->picture_url);
550 yd->picture_url = NULL; 550 yd->picture_url = NULL;