comparison libpurple/protocols/yahoo/yahoo_picture.c @ 27306:b2465d7fdeac

Some more fixes for when unsetting buddy picture, for both when sending and receiving updates.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 01 Jul 2009 00:12:39 +0000
parents f57904a95fbb
children ef5f0cde8d74
comparison
equal deleted inserted replaced
27305:a337d7a5cd0c 27306:b2465d7fdeac
151 } else if (who && send_icon_info) { 151 } else if (who && send_icon_info) {
152 yahoo_send_picture_info(gc, who); 152 yahoo_send_picture_info(gc, who);
153 } 153 }
154 } 154 }
155 155
156 void yahoo_process_picture_update(PurpleConnection *gc, struct yahoo_packet *pkt)
157 {
158 GSList *l = pkt->hash;
159 char *who = NULL;
160 int icon = 0;
161
162 while (l) {
163 struct yahoo_pair *pair = l->data;
164
165 switch (pair->key) {
166 case 4:
167 who = pair->value;
168 break;
169 case 5:
170 /* us */
171 break;
172 /* NOTE: currently the server seems to only send 213; 206 was used
173 * in older versions. Check whether it's still needed. */
174 case 206:
175 case 213:
176 icon = strtol(pair->value, NULL, 10);
177 break;
178 }
179 l = l->next;
180 }
181
182 if (who) {
183 if (icon == 2)
184 yahoo_send_picture_request(gc, who);
185 else if ((icon == 0) || (icon == 1)) {
186 YahooFriend *f;
187 purple_buddy_icons_set_for_user(gc->account, who, NULL, 0, NULL);
188 if ((f = yahoo_friend_find(gc, who)))
189 yahoo_friend_set_buddy_icon_need_request(f, TRUE);
190 purple_debug_misc("yahoo", "Setting user %s's icon to NULL.\n", who);
191 }
192 }
193 }
194
195 void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt) 156 void yahoo_process_picture_checksum(PurpleConnection *gc, struct yahoo_packet *pkt)
196 { 157 {
197 GSList *l = pkt->hash; 158 GSList *l = pkt->hash;
198 char *who = NULL; 159 char *who = NULL;
199 int checksum = 0; 160 int checksum = 0;
277 who = pair->value; 238 who = pair->value;
278 break; 239 break;
279 case 5: 240 case 5:
280 /* us */ 241 /* us */
281 break; 242 break;
282 case 206: 243 case 206: /* Older versions. Still needed? */
244 case 213: /* Newer versions */
283 /* 245 /*
284 * 0 - No icon or avatar 246 * 0 - No icon or avatar
285 * 1 - Using an avatar 247 * 1 - Using an avatar
286 * 2 - Using an icon 248 * 2 - Using an icon
287 */ 249 */
347 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)
348 { 310 {
349 struct yahoo_data *yd = gc->proto_data; 311 struct yahoo_data *yd = gc->proto_data;
350 struct yahoo_packet *pkt; 312 struct yahoo_packet *pkt;
351 313
352 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);
353 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);
354 yahoo_packet_send_and_free(pkt, yd); 316 yahoo_packet_send_and_free(pkt, yd);
355 } 317 }
356 318
357 struct yspufe { 319 struct yspufe {
358 PurpleConnection *gc; 320 PurpleConnection *gc;