diff 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
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo_picture.c	Thu Dec 16 21:57:58 2004 +0000
+++ b/src/protocols/yahoo/yahoo_picture.c	Fri Dec 17 00:05:32 2004 +0000
@@ -232,7 +232,6 @@
 {
 	struct yahoo_data *yd = gc->proto_data;
 	struct yahoo_packet *pkt;
-	char *buf;
 
 	if (!yd->picture_url) {
 		gaim_debug_warning("yahoo", "Attempted to send picture info without a picture\n");
@@ -240,16 +239,10 @@
 	}
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 5, who);
-	yahoo_packet_hash(pkt, 13, "2");
-	yahoo_packet_hash(pkt, 20, yd->picture_url);
-	buf = g_strdup_printf("%d", yd->picture_checksum);
-	yahoo_packet_hash(pkt, 192, buf);
-
+	yahoo_packet_hash(pkt, "sssssi", 1, gaim_connection_get_display_name(gc),
+	                  4, gaim_connection_get_display_name(gc), 5, who,
+	                  13, "2", 20, yd->picture_url, 192, yd->picture_checksum);
 	yahoo_packet_send_and_free(pkt, yd);
-	g_free(buf);
 }
 
 void yahoo_send_picture_request(GaimConnection *gc, const char *who)
@@ -258,9 +251,9 @@
 	struct yahoo_packet *pkt;
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, 4, gaim_connection_get_display_name(gc)); /* me */
-	yahoo_packet_hash(pkt, 5, who); /* the other guy */
-	yahoo_packet_hash(pkt, 13, "1"); /* 1 = request, 2 = reply */
+	yahoo_packet_hash_str(pkt, 4, gaim_connection_get_display_name(gc)); /* me */
+	yahoo_packet_hash_str(pkt, 5, who); /* the other guy */
+	yahoo_packet_hash_str(pkt, 13, "1"); /* 1 = request, 2 = reply */
 	yahoo_packet_send_and_free(pkt, yd);
 }
 
@@ -268,29 +261,21 @@
 {
 	struct yahoo_data *yd = gc->proto_data;
 	struct yahoo_packet *pkt;
-	char *cksum = g_strdup_printf("%d", yd->picture_checksum);
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 212, "1");
-	yahoo_packet_hash(pkt, 192, cksum);
+	yahoo_packet_hash(pkt, "ssd", 1, gaim_connection_get_display_name(gc),
+			  212, "1", 192, yd->picture_checksum);
 	yahoo_packet_send_and_free(pkt, yd);
-	g_free(cksum);
 }
 
 void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type)
 {
 	struct yahoo_data *yd = gc->proto_data;
 	struct yahoo_packet *pkt;
-	char *typestr = g_strdup_printf("%d", type);
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 5, who);
-	yahoo_packet_hash(pkt, 206, typestr);
+	yahoo_packet_hash(pkt, "ssd", 1, gaim_connection_get_display_name(gc), 5, who, 206, type);
 	yahoo_packet_send_and_free(pkt, yd);
-
-	g_free(typestr);
 }
 
 struct yspufe {
@@ -406,13 +391,13 @@
 
 	size = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len);
 	/* 1 = me, 38 = expire time(?), 0 = me, 28 = size, 27 = filename, 14 = NULL, 29 = data */
-	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 38, "604800"); /* time til expire */
+	yahoo_packet_hash_str(pkt, 1, gaim_connection_get_display_name(gc));
+	yahoo_packet_hash_str(pkt, 38, "604800"); /* time til expire */
 	gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, time(NULL) + 604800);
-	yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc));
-	yahoo_packet_hash(pkt, 28, size);
-	yahoo_packet_hash(pkt, 27, d->filename);
-	yahoo_packet_hash(pkt, 14, "");
+	yahoo_packet_hash_str(pkt, 0, gaim_connection_get_display_name(gc));
+	yahoo_packet_hash_str(pkt, 28, size);
+	yahoo_packet_hash_str(pkt, 27, d->filename);
+	yahoo_packet_hash_str(pkt, 14, "");
 
 	content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);