From: <the...@us...> - 2006-06-22 06:27:43
|
Revision: 16307 Author: thekingant Date: 2006-06-21 23:27:35 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16307&view=rev Log Message: ----------- Backport revision r16306 to the v2_0_0 branch. Original commit message: Keep track of the Yahoo! IMVironment specified by the people we're IMing with. When we reply to their IMs, we now send the same IMVironment instead of always sending an empty IMVironment because sending an empty IMVironment would reset their IMVironment back to nothing. This shouldn't negatively affect the Doodle stuff... but it didn't work for me when I tested it, so it's hard to tell. This is a change I made while at Meebo Modified Paths: -------------- branches/v2_0_0/src/protocols/yahoo/yahoo.c branches/v2_0_0/src/protocols/yahoo/yahoo.h branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-06-22 06:26:38 UTC (rev 16306) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-06-22 06:27:35 UTC (rev 16307) @@ -670,6 +670,7 @@ static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) { + struct yahoo_data *yd = gc->proto_data; GSList *l = pkt->hash; GSList *list = NULL; struct _yahoo_im *im = NULL; @@ -712,24 +713,29 @@ /** TODO: It seems that this check should be per IM, not global */ /* Check for the Doodle IMV */ - if(im != NULL && imv != NULL && !strcmp(imv, "doodle;11")) + if (im != NULL && imv!= NULL && im->from != NULL) { - GaimWhiteboard *wb; + g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv)); - if (!yahoo_privacy_check(gc, im->from)) { - gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from); - return; - } + if (strcmp(imv, "doodle;11") == 0) + { + GaimWhiteboard *wb; - wb = gaim_whiteboard_get_session(gc->account, im->from); + if (!yahoo_privacy_check(gc, im->from)) { + gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from); + return; + } - /* If a Doodle session doesn't exist between this user */ - if(wb == NULL) - { - wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED); + wb = gaim_whiteboard_get_session(gc->account, im->from); - yahoo_doodle_command_send_request(gc, im->from); - yahoo_doodle_command_send_ready(gc, im->from); + /* If a Doodle session doesn't exist between this user */ + if(wb == NULL) + { + wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED); + + yahoo_doodle_command_send_request(gc, im->from); + yahoo_doodle_command_send_ready(gc, im->from); + } } } @@ -2576,6 +2582,7 @@ /* TODO: Is there a good grow size for the buffer? */ yd->txbuf = gaim_circ_buffer_new(0); yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); + yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); yd->confs = NULL; yd->conf_id = 2; @@ -2628,6 +2635,7 @@ yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */ g_hash_table_destroy(yd->friends); + g_hash_table_destroy(yd->imvironments); g_free(yd->chat_name); g_free(yd->cookie_y); @@ -3101,14 +3109,30 @@ yahoo_packet_hash_str(pkt, 97, "1"); yahoo_packet_hash_str(pkt, 14, msg2); - /* If this message is to a user who is also Doodling with the local user, + /* + * IMVironment. + * + * If this message is to a user who is also Doodling with the local user, * format the chat packet with the correct IMV information (thanks Yahoo!) - */ - wb = gaim_whiteboard_get_session(gc->account, (char*)who); + * + * Otherwise attempt to use the same IMVironment as the remote user, + * just so that we don't inadvertantly reset their IMVironment back + * to nothing. + * + * If they have no set an IMVironment, then use the default. + */ + wb = gaim_whiteboard_get_session(gc->account, who); if (wb) - yahoo_packet_hash_str(pkt, 63, "doodle;11"); + yahoo_packet_hash_str(pkt, 63, "doodle;11"); else - yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */ + { + const char *imv; + imv = g_hash_table_lookup(yd->imvironments, who); + if (imv != NULL) + yahoo_packet_hash_str(pkt, 63, imv); + else + yahoo_packet_hash_str(pkt, 63, ";0"); + } 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 */ Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.h =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.h 2006-06-22 06:26:38 UTC (rev 16306) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.h 2006-06-22 06:27:35 UTC (rev 16307) @@ -105,6 +105,16 @@ GaimCircBuffer *txbuf; guint txhandler; GHashTable *friends; + + /** + * This is used to keep track of the IMVironment chosen + * by people you talk to. We don't do very much with + * this right now... but at least now if the remote user + * selects an IMVironment we won't reset it back to the + * default of nothing. + */ + GHashTable *imvironments; + int current_status; gboolean logged_in; GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist; Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-06-22 06:26:38 UTC (rev 16306) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-06-22 06:27:35 UTC (rev 16307) @@ -481,14 +481,18 @@ char *to = NULL; char *msg = NULL; char *url = NULL; + char *imv = NULL; long expires = 0; GaimXfer *xfer; + struct yahoo_data *yd; struct yahoo_xfer_data *xfer_data; char *service = NULL; char *filename = NULL; unsigned long filesize = 0L; GSList *l; + yd = gc->proto_data; + for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; @@ -508,8 +512,19 @@ filesize = atol(pair->value); if (pair->key == 49) service = pair->value; + if (pair->key == 63) + imv = pair->value; } + /* + * The remote user has changed their IMVironment. We + * record it for later use. + */ + if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) { + g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv)); + return; + } + if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) { if (service && (strcmp("FILEXFER", service) != 0)) { gaim_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-05 05:44:41
|
Revision: 16637 Author: thekingant Date: 2006-08-04 22:44:34 -0700 (Fri, 04 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16637&view=rev Log Message: ----------- Backport SVN revisions 16635 and 16636 from HEAD to v2_0_0 Original commit message: Make Yahoo! packet parsing not allocate stuff twice. Who wrote this?? Modified Paths: -------------- branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c branches/v2_0_0/src/protocols/yahoo/yahoo_packet.h Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c 2006-08-05 05:42:28 UTC (rev 16636) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_packet.c 2006-08-05 05:44:34 UTC (rev 16637) @@ -43,7 +43,7 @@ struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); pair->key = key; pair->value = g_strdup(value); - pkt->hash = g_slist_append(pkt->hash, pair); + pkt->hash = g_slist_prepend(pkt->hash, pair); } void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) @@ -52,7 +52,7 @@ pair->key = key; pair->value = g_strdup_printf("%d", value); - pkt->hash = g_slist_append(pkt->hash, pair); + pkt->hash = g_slist_prepend(pkt->hash, pair); } void yahoo_packet_hash(struct yahoo_packet *pkt, const char *fmt, ...) @@ -105,17 +105,16 @@ return len; } -void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) +void yahoo_packet_read(struct yahoo_packet *pkt, const guchar *data, int len) { int pos = 0; + char key[64], *delimiter, *esc; + gboolean accept; + int x; + struct yahoo_pair *pair; - while (pos + 1 < len) { - char key[64], *value = NULL, *esc; - int accept; - int x; - - struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); - + while (pos + 1 < len) + { /* this is weird, and in one of the chat packets, and causes us * think all the values are keys and all the keys are values after * this point if we don't handle it */ @@ -126,10 +125,11 @@ pos++; } pos += 2; - g_free(pair); continue; } + pair = g_new0(struct yahoo_pair, 1); + x = 0; while (pos + 1 < len) { if (data[pos] == 0xc0 && data[pos + 1] == 0x80) @@ -151,25 +151,29 @@ if (len - pos + 1 <= 0) { /* Truncated. Garbage or something. */ - accept = 0; + accept = FALSE; } if (accept) { - value = g_malloc(len - pos + 1); - x = 0; - while (pos + 1 < len) { - if (data[pos] == 0xc0 && data[pos + 1] == 0x80) - break; - value[x++] = data[pos++]; + delimiter = strstr((char *)&data[pos], "\xc0\x80"); + if (delimiter == NULL) + { + /* Malformed packet! (it doesn't end in 0xc0 0x80) */ + g_free(pair); + pos = len; + continue; } - value[x] = 0; - pair->value = g_strdup(value); - g_free(value); - pkt->hash = g_slist_append(pkt->hash, pair); + x = (guint64)delimiter - (guint64)data; + pair->value = g_strndup((const gchar *)&data[pos], x - pos); + pos = x; + pkt->hash = g_slist_prepend(pkt->hash, pair); + +#ifdef DEBUG esc = g_strescape(pair->value, NULL); gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Key: %d \tValue: %s\n", pair->key, esc); g_free(esc); +#endif } else { g_free(pair); } @@ -179,6 +183,16 @@ if (data[0] == '9' && data[pos] == 0x01) pos++; } + + /* + * Originally this function used g_slist_append(). I changed + * it to use g_slist_prepend() for improved performance. + * Ideally the Yahoo! PRPL code would be indifferent to the + * order of the key/value pairs, but I don't know if this is + * the case for all incoming messages. To be on the safe side + * we reverse the list. + */ + pkt->hash = g_slist_reverse(pkt->hash); } void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_packet.h =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_packet.h 2006-08-05 05:42:28 UTC (rev 16636) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_packet.h 2006-08-05 05:44:34 UTC (rev 16637) @@ -127,7 +127,7 @@ int yahoo_packet_send_and_free(struct yahoo_packet *pkt, struct yahoo_data *yd); size_t yahoo_packet_build(struct yahoo_packet *pkt, int pad, gboolean wm, guchar **buf); -void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len); +void yahoo_packet_read(struct yahoo_packet *pkt, const guchar *data, int len); void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data); void yahoo_packet_dump(guchar *data, int len); size_t yahoo_packet_length(struct yahoo_packet *pkt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |