comparison src/protocols/yahoo/yahoo_picture.c @ 10394:45a0a07e8b25

[gaim-migrate @ 11623] Renamed yahoo_packet_hash to yahoo_packet_hash_str, added yahoo_packet_hash_int, and a new variable arg yahoo_packet_hash that calls either of them. I was going to add some more format chars to yahoo_packet_hash, and may yet. Stuff like automaticly converting strings' character sets or html to yahoo codes, etc. But first I want to look at how yahoo 6 handles character sets and see if it's any different. Feel free to give opinions on if these changes are actually better, assuming you actually look at them, as opposed to running away like a girly man when you see yahoo protocol code. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Fri, 17 Dec 2004 00:05:32 +0000
parents a8f9e5ce4f92
children 6c6772d3ea31
comparison
equal deleted inserted replaced
10393:a7a2c27248af 10394:45a0a07e8b25
230 230
231 void yahoo_send_picture_info(GaimConnection *gc, const char *who) 231 void yahoo_send_picture_info(GaimConnection *gc, const char *who)
232 { 232 {
233 struct yahoo_data *yd = gc->proto_data; 233 struct yahoo_data *yd = gc->proto_data;
234 struct yahoo_packet *pkt; 234 struct yahoo_packet *pkt;
235 char *buf;
236 235
237 if (!yd->picture_url) { 236 if (!yd->picture_url) {
238 gaim_debug_warning("yahoo", "Attempted to send picture info without a picture\n"); 237 gaim_debug_warning("yahoo", "Attempted to send picture info without a picture\n");
239 return; 238 return;
240 } 239 }
241 240
242 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 241 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
243 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 242 yahoo_packet_hash(pkt, "sssssi", 1, gaim_connection_get_display_name(gc),
244 yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc)); 243 4, gaim_connection_get_display_name(gc), 5, who,
245 yahoo_packet_hash(pkt, 5, who); 244 13, "2", 20, yd->picture_url, 192, yd->picture_checksum);
246 yahoo_packet_hash(pkt, 13, "2");
247 yahoo_packet_hash(pkt, 20, yd->picture_url);
248 buf = g_strdup_printf("%d", yd->picture_checksum);
249 yahoo_packet_hash(pkt, 192, buf);
250
251 yahoo_packet_send_and_free(pkt, yd); 245 yahoo_packet_send_and_free(pkt, yd);
252 g_free(buf);
253 } 246 }
254 247
255 void yahoo_send_picture_request(GaimConnection *gc, const char *who) 248 void yahoo_send_picture_request(GaimConnection *gc, const char *who)
256 { 249 {
257 struct yahoo_data *yd = gc->proto_data; 250 struct yahoo_data *yd = gc->proto_data;
258 struct yahoo_packet *pkt; 251 struct yahoo_packet *pkt;
259 252
260 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 253 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
261 yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc)); /* me */ 254 yahoo_packet_hash_str(pkt, 4, gaim_connection_get_display_name(gc)); /* me */
262 yahoo_packet_hash(pkt, 5, who); /* the other guy */ 255 yahoo_packet_hash_str(pkt, 5, who); /* the other guy */
263 yahoo_packet_hash(pkt, 13, "1"); /* 1 = request, 2 = reply */ 256 yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */
264 yahoo_packet_send_and_free(pkt, yd); 257 yahoo_packet_send_and_free(pkt, yd);
265 } 258 }
266 259
267 void yahoo_send_picture_checksum(GaimConnection *gc) 260 void yahoo_send_picture_checksum(GaimConnection *gc)
268 { 261 {
269 struct yahoo_data *yd = gc->proto_data; 262 struct yahoo_data *yd = gc->proto_data;
270 struct yahoo_packet *pkt; 263 struct yahoo_packet *pkt;
271 char *cksum = g_strdup_printf("%d", yd->picture_checksum);
272 264
273 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); 265 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
274 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 266 yahoo_packet_hash(pkt, "ssd", 1, gaim_connection_get_display_name(gc),
275 yahoo_packet_hash(pkt, 212, "1"); 267 212, "1", 192, yd->picture_checksum);
276 yahoo_packet_hash(pkt, 192, cksum);
277 yahoo_packet_send_and_free(pkt, yd); 268 yahoo_packet_send_and_free(pkt, yd);
278 g_free(cksum);
279 } 269 }
280 270
281 void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type) 271 void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type)
282 { 272 {
283 struct yahoo_data *yd = gc->proto_data; 273 struct yahoo_data *yd = gc->proto_data;
284 struct yahoo_packet *pkt; 274 struct yahoo_packet *pkt;
285 char *typestr = g_strdup_printf("%d", type);
286 275
287 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); 276 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
288 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 277 yahoo_packet_hash(pkt, "ssd", 1, gaim_connection_get_display_name(gc), 5, who, 206, type);
289 yahoo_packet_hash(pkt, 5, who);
290 yahoo_packet_hash(pkt, 206, typestr);
291 yahoo_packet_send_and_free(pkt, yd); 278 yahoo_packet_send_and_free(pkt, yd);
292
293 g_free(typestr);
294 } 279 }
295 280
296 struct yspufe { 281 struct yspufe {
297 GaimConnection *gc; 282 GaimConnection *gc;
298 int type; 283 int type;
404 389
405 pkt = yahoo_packet_new(0xc2, YAHOO_STATUS_AVAILABLE, yd->session_id); 390 pkt = yahoo_packet_new(0xc2, YAHOO_STATUS_AVAILABLE, yd->session_id);
406 391
407 size = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len); 392 size = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len);
408 /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */ 393 /* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */
409 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 394 yahoo_packet_hash_str(pkt, 1, gaim_connection_get_display_name(gc));
410 yahoo_packet_hash(pkt, 38, "604800"); /* time til expire */ 395 yahoo_packet_hash_str(pkt, 38, "604800"); /* time til expire */
411 gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800); 396 gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800);
412 yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc)); 397 yahoo_packet_hash_str(pkt, 0, gaim_connection_get_display_name(gc));
413 yahoo_packet_hash(pkt, 28, size); 398 yahoo_packet_hash_str(pkt, 28, size);
414 yahoo_packet_hash(pkt, 27, d->filename); 399 yahoo_packet_hash_str(pkt, 27, d->filename);
415 yahoo_packet_hash(pkt, 14, ""); 400 yahoo_packet_hash_str(pkt, 14, "");
416 401
417 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 402 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
418 403
419 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 404 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
420 405