Mercurial > pidgin.yaz
changeset 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 | a7a2c27248af |
children | b4b9dabdd7c7 |
files | src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo_filexfer.c src/protocols/yahoo/yahoo_packet.c src/protocols/yahoo/yahoo_packet.h src/protocols/yahoo/yahoo_picture.c src/protocols/yahoo/yahoochat.c |
diffstat | 6 files changed, 133 insertions(+), 167 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoo.c Fri Dec 17 00:05:32 2004 +0000 @@ -1015,11 +1015,7 @@ to_y64(result96, result, 16); pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pack, 0, name); - yahoo_packet_hash(pack, 6, result6); - yahoo_packet_hash(pack, 96, result96); - yahoo_packet_hash(pack, 1, name); - + yahoo_packet_hash(pack, "ssss", 0, name, 6, result6, 96, result96, 1, name); yahoo_packet_send_and_free(pack, yd); g_free(hash_string_p); @@ -1470,16 +1466,11 @@ } pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pack, 0, name); - yahoo_packet_hash(pack, 6, resp_6); - yahoo_packet_hash(pack, 96, resp_96); - yahoo_packet_hash(pack, 1, name); - yahoo_packet_hash(pack, 135, "6,0,0,1710"); - if (yd->picture_checksum) { - char *cksum = g_strdup_printf("%d", yd->picture_checksum); - yahoo_packet_hash(pack, 192, cksum); - g_free(cksum); - } + yahoo_packet_hash(pack, "sssss", 0, name, 6, resp_6, 96, resp_96, 1, + name, 135, "6,0,0,1710"); + if (yd->picture_checksum) + yahoo_packet_hash_int(pack, 192, yd->picture_checksum); + yahoo_packet_send_and_free(pack, yd); g_free(password_hash); @@ -2022,7 +2013,7 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); + yahoo_packet_hash_str(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); yahoo_packet_send_and_free(pkt, yd); gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); @@ -2049,9 +2040,10 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); - yahoo_packet_hash(pkt, 0, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); - yahoo_packet_hash(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); - yahoo_packet_hash(pkt, 6, yd->auth); + yahoo_packet_hash(pkt, "sss", 0, + gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), + 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), + 6, yd->auth); yahoo_packet_send_and_free(pkt, yd); g_free(yd->auth); @@ -2610,7 +2602,7 @@ struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 3, entry); + yahoo_packet_hash_str(pkt, 3, entry); yahoo_packet_send_and_free(pkt, yd); gaim_connection_set_display_name(gc, entry); @@ -2660,19 +2652,18 @@ msg2 = yahoo_string_encode(gc, msg, &utf8); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 5, who); + yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who); if (utf8) - yahoo_packet_hash(pkt, 97, "1"); - yahoo_packet_hash(pkt, 14, msg2); - - yahoo_packet_hash(pkt, 63, ";0"); /* IMvironment */ - yahoo_packet_hash(pkt, 64, "0"); /* no idea */ - yahoo_packet_hash(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ + yahoo_packet_hash_str(pkt, 97, "1"); + yahoo_packet_hash_str(pkt, 14, msg2); + + yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */ + yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */ + yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ if (!yd->picture_url) - yahoo_packet_hash(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ + yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ else - yahoo_packet_hash(pkt, 206, "2"); + yahoo_packet_hash_str(pkt, 206, "2"); /* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */ if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) @@ -2692,12 +2683,9 @@ { struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); - yahoo_packet_hash(pkt, 49, "TYPING"); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 14, " "); - yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0"); - yahoo_packet_hash(pkt, 5, who); - yahoo_packet_hash(pkt, 1002, "1"); + yahoo_packet_hash(pkt, "ssssss", 49, "TYPING", 1, gaim_connection_get_display_name(gc), + 14, " ", 13, typ == GAIM_TYPING ? "1" : "0", + 5, who, 1002, "1"); yahoo_packet_send_and_free(pkt, yd); @@ -2710,7 +2698,6 @@ struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; struct yahoo_packet *pkt; int old_status = yd->current_status; - char s[4]; const char *id; char *conv_msg = NULL; char *conv_msg2 = NULL; @@ -2752,15 +2739,14 @@ if (yd->current_status == YAHOO_STATUS_INVISIBLE) { pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 13, "2"); + yahoo_packet_hash_str(pkt, 13, "2"); yahoo_packet_send_and_free(pkt, yd); return; } pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); - g_snprintf(s, sizeof(s), "%d", yd->current_status); - yahoo_packet_hash(pkt, 10, s); + yahoo_packet_hash_int(pkt, 10, yd->current_status); if (yd->current_status == YAHOO_STATUS_CUSTOM) { const char *msg = gaim_status_get_attr_string(status, "message"); @@ -2772,16 +2758,16 @@ conv_msg = yahoo_string_encode(gc, msg, NULL); conv_msg2 = gaim_markup_strip_html(conv_msg); - yahoo_packet_hash(pkt, 19, conv_msg2); + yahoo_packet_hash_str(pkt, 19, conv_msg2); } else { - yahoo_packet_hash(pkt, 19, ""); + yahoo_packet_hash_str(pkt, 19, ""); } if (gc->is_idle) - yahoo_packet_hash(pkt, 47, "2"); + yahoo_packet_hash_str(pkt, 47, "2"); else if (!gaim_status_type_is_available(gaim_status_get_type(status))) - yahoo_packet_hash(pkt, 47, "1"); + yahoo_packet_hash_str(pkt, 47, "1"); yahoo_packet_send_and_free(pkt, yd); @@ -2790,7 +2776,7 @@ if (old_status == YAHOO_STATUS_INVISIBLE) { pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 13, "1"); + yahoo_packet_hash_str(pkt, 13, "1"); yahoo_packet_send_and_free(pkt, yd); } } @@ -2800,7 +2786,6 @@ struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt = NULL; char *msg = NULL, *msg2 = NULL; - char buf[4]; if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) yd->current_status = YAHOO_STATUS_IDLE; @@ -2810,22 +2795,20 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); - - g_snprintf(buf, sizeof(buf), "%d", yd->current_status); - yahoo_packet_hash(pkt, 10, buf); + yahoo_packet_hash_int(pkt, 10, yd->current_status); if (yd->current_status == YAHOO_STATUS_CUSTOM) { GaimStatus *status = gaim_presence_get_active_status(gaim_account_get_presence(gaim_connection_get_account(gc))); msg = yahoo_string_encode(gc, gaim_status_get_attr_string(status, "message"), NULL); //this line crashes, fix it msg2 = gaim_unescape_html(msg); - yahoo_packet_hash(pkt, 19, msg2); + yahoo_packet_hash_str(pkt, 19, msg2); } else { - yahoo_packet_hash(pkt, 19, ""); + yahoo_packet_hash_str(pkt, 19, ""); } if (idle) - yahoo_packet_hash(pkt, 47, "2"); + yahoo_packet_hash_str(pkt, 47, "2"); else if (!gaim_presence_is_available(gaim_account_get_presence(gaim_connection_get_account(gc)))) - yahoo_packet_hash(pkt, 47, "1"); + yahoo_packet_hash_str(pkt, 47, "1"); yahoo_packet_send_and_free(pkt, yd); @@ -2916,8 +2899,8 @@ } pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); - yahoo_packet_send_and_free(yd, pkt); + yahoo_packet_hash_str(pkt, 109, gaim_connection_get_display_name(gc)); + yahoo_packet_send_and_free(pkt, yd); } /* XXX - What's the deal with GaimGroup *foo? */ @@ -2944,10 +2927,8 @@ group2 = yahoo_string_encode(gc, group, NULL); pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, buddy->name); - yahoo_packet_hash(pkt, 65, group2); - yahoo_packet_hash(pkt, 14, ""); + yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), + 7, buddy->name, 65, group2, 14, ""); yahoo_packet_send_and_free(pkt, yd); g_free(group2); } @@ -2981,9 +2962,8 @@ cg = yahoo_string_encode(gc, group->name, NULL); pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, buddy->name); - yahoo_packet_hash(pkt, 65, cg); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), + 7, buddy->name, 65, cg); yahoo_packet_send_and_free(pkt, yd); g_free(cg); } @@ -3003,9 +2983,8 @@ return; pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); - yahoo_packet_hash(pkt, 13, "1"); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), + 7, who, 13, "1"); yahoo_packet_send_and_free(pkt, yd); } @@ -3020,9 +2999,7 @@ return; pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); - yahoo_packet_hash(pkt, 13, "2"); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 13, "2"); yahoo_packet_send_and_free(pkt, yd); } @@ -3090,17 +3067,13 @@ /* Step 1: Add buddy to new group. */ pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); - yahoo_packet_hash(pkt, 65, gpn); - yahoo_packet_hash(pkt, 14, ""); + yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), + 7, who, 65, gpn, 14, ""); yahoo_packet_send_and_free(pkt, yd); /* Step 2: Remove buddy from old group */ pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); - yahoo_packet_hash(pkt, 65, gpo); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 65, gpo); yahoo_packet_send_and_free(pkt, yd); g_free(gpn); g_free(gpo); @@ -3122,9 +3095,8 @@ } pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 65, gpo); - yahoo_packet_hash(pkt, 67, gpn); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), + 65, gpo, 67, gpn); yahoo_packet_send_and_free(pkt, yd); g_free(gpn); g_free(gpo);
--- a/src/protocols/yahoo/yahoo_filexfer.c Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoo_filexfer.c Fri Dec 17 00:05:32 2004 +0000 @@ -119,13 +119,10 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, YAHOO_STATUS_AVAILABLE, yd->session_id); size = g_strdup_printf("%" G_GSIZE_FORMAT, gaim_xfer_get_size(xfer)); - - yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 5, xfer->who); - yahoo_packet_hash(pkt, 14, ""); filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer)); - yahoo_packet_hash(pkt, 27, filename); - yahoo_packet_hash(pkt, 28, size); + + yahoo_packet_hash(pkt, "sssss", 0, gaim_connection_get_display_name(gc), + 5, xfer->who, 14, "", 27, filename, 28, size); content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
--- a/src/protocols/yahoo/yahoo_packet.c Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoo_packet.c Fri Dec 17 00:05:32 2004 +0000 @@ -38,7 +38,7 @@ return pkt; } -void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) +void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) { struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); pair->key = key; @@ -46,6 +46,42 @@ pkt->hash = g_slist_append(pkt->hash, pair); } +void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) +{ + struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); + + pair->key = key; + pair->value = g_strdup_printf("%d", value); + pkt->hash = g_slist_append(pkt->hash, pair); +} + +void yahoo_packet_hash(struct yahoo_packet *pkt, const char *fmt, ...) +{ + char *strval; + int key, intval; + const char *cur; + va_list ap; + + va_start(ap, fmt); + for (cur = fmt; *cur; cur++) { + key = va_arg(ap, int); + switch (*cur) { + case 'i': + intval = va_arg(ap, int); + yahoo_packet_hash_int(pkt, key, intval); + break; + case 's': + strval = va_arg(ap, char *); + yahoo_packet_hash_str(pkt, key, strval); + break; + default: + gaim_debug_error("yahoo", "Invalid format character '%c'\n", *cur); + break; + } + } + va_end(ap); +} + int yahoo_packet_length(struct yahoo_packet *pkt) { GSList *l;
--- a/src/protocols/yahoo/yahoo_packet.h Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoo_packet.h Fri Dec 17 00:05:32 2004 +0000 @@ -119,7 +119,9 @@ struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id); -void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value); +void yahoo_packet_hash(struct yahoo_packet *pkt, const char *fmt, ...); +void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value); +void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value); int yahoo_packet_send(struct yahoo_packet *pkt, struct yahoo_data *yd); int yahoo_packet_send_and_free(struct yahoo_packet *pkt, struct yahoo_data *yd); int yahoo_packet_send_special(struct yahoo_packet *pkt, int fd, int pad);
--- 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);
--- a/src/protocols/yahoo/yahoochat.c Thu Dec 16 21:57:58 2004 +0000 +++ b/src/protocols/yahoo/yahoochat.c Fri Dec 17 00:05:32 2004 +0000 @@ -60,9 +60,8 @@ } pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 6, "abcde"); + yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), + 109, gaim_connection_get_display_name(gc), 6, "abcde"); yahoo_packet_send_and_free(pkt, yd); } @@ -593,13 +592,13 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); + yahoo_packet_hash_str(pkt, 1, dn); for (w = who; w; w = w->next) { const char *name = gaim_conv_chat_cb_get_name(w->data); - yahoo_packet_hash(pkt, 3, name); + yahoo_packet_hash_str(pkt, 3, name); } - yahoo_packet_hash(pkt, 57, room); + yahoo_packet_hash_str(pkt, 57, room); yahoo_packet_send_and_free(pkt, yd); } @@ -619,15 +618,14 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); + yahoo_packet_hash_str(pkt, 1, dn); for (who = members; who; who = who->next) { const char *name = gaim_conv_chat_cb_get_name(who->data); - yahoo_packet_hash(pkt, 53, name); + yahoo_packet_hash_str(pkt, 53, name); } - yahoo_packet_hash(pkt, 57, room); - yahoo_packet_hash(pkt, 14, msg2); + yahoo_packet_hash(pkt, "ss", 57, room, 14, msg2); if (utf8) - yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ + yahoo_packet_hash_str(pkt, 97, "1"); /* utf-8 */ yahoo_packet_send_and_free(pkt, yd); g_free(msg); @@ -649,14 +647,12 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); - yahoo_packet_hash(pkt, 3, dn); - yahoo_packet_hash(pkt, 57, room); + yahoo_packet_hash(pkt, "sss", 1, dn, 3, dn, 57, room); if (memarr) { for(i = 0 ; memarr[i]; i++) { if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn)) continue; - yahoo_packet_hash(pkt, 3, memarr[i]); + yahoo_packet_hash_str(pkt, 3, memarr[i]); gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE); } } @@ -681,17 +677,12 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); - yahoo_packet_hash(pkt, 51, buddy); - yahoo_packet_hash(pkt, 57, room); - yahoo_packet_hash(pkt, 58, msg?msg2:""); - yahoo_packet_hash(pkt, 13, "0"); + yahoo_packet_hash(pkt, "sssss", 1, dn, 51, buddy, 57, room, 58, msg?msg2:"", 13, "0"); for(; members; members = members->next) { const char *name = gaim_conv_chat_cb_get_name(members->data); if (!strcmp(name, dn)) continue; - yahoo_packet_hash(pkt, 52, name); - yahoo_packet_hash(pkt, 53, name); + yahoo_packet_hash(pkt, "ss", 52, name, 53, name); } yahoo_packet_send_and_free(pkt, yd); @@ -721,10 +712,8 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 104, eroom); - yahoo_packet_hash(pkt, 109, dn); - yahoo_packet_hash(pkt, 108, "1"); - yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */ + yahoo_packet_hash(pkt, "sss", 104, eroom, 109, dn, 108, "1"); + yahoo_packet_hash_str(pkt, 112, "0"); /* what does this one mean? */ yahoo_packet_send_and_free(pkt, yd); @@ -742,7 +731,7 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); + yahoo_packet_hash_str(pkt, 1, dn); yahoo_packet_send_and_free(pkt, yd); yd->chat_online = 0; @@ -815,16 +804,14 @@ pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0); - yahoo_packet_hash(pkt, 1, dn); - yahoo_packet_hash(pkt, 104, room2); - yahoo_packet_hash(pkt, 117, msg1); + yahoo_packet_hash(pkt, "sss", 1, dn, 104, room2, 117, msg1); if (me) - yahoo_packet_hash(pkt, 124, "2"); + yahoo_packet_hash_str(pkt, 124, "2"); else - yahoo_packet_hash(pkt, 124, "1"); + yahoo_packet_hash_str(pkt, 124, "1"); /* fixme: what about /think? (124=3) */ if (utf8) - yahoo_packet_hash(pkt, 97, "1"); + yahoo_packet_hash_str(pkt, 97, "1"); yahoo_packet_send_and_free(pkt, yd); g_free(msg1); @@ -852,12 +839,8 @@ room2 = yahoo_string_encode(gc, room, &utf8); pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0); - - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 62, "2"); - yahoo_packet_hash(pkt, 104, room2); - yahoo_packet_hash(pkt, 129, "0"); - + yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), + 62, "2", 104, room2, 129, "0"); yahoo_packet_send_and_free(pkt, yd); g_free(room2); } @@ -880,14 +863,9 @@ room2 = yahoo_string_encode(gc, room, &utf8); if (msg) msg2 = yahoo_string_encode(gc, msg, NULL); + pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0); - - yahoo_packet_hash(pkt, 1, dn); - yahoo_packet_hash(pkt, 118, buddy); - yahoo_packet_hash(pkt, 104, room2); - yahoo_packet_hash(pkt, 117, (msg2?msg2:"")); - yahoo_packet_hash(pkt, 129, "0"); - + yahoo_packet_hash(pkt, "sssss", 1, dn, 118, buddy, 104, room2, 117, (msg2?msg2:""), 129, "0"); yahoo_packet_send_and_free(pkt, yd); g_free(room2); @@ -912,11 +890,7 @@ yahoo_chat_online(gc); pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, 0); - - yahoo_packet_hash(pkt, 109, name); - yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 62, "2"); - + yahoo_packet_hash(pkt, "sss", 109, name, 1, gaim_connection_get_display_name(gc), 62, "2"); yahoo_packet_send_and_free(pkt, yd); } /*