comparison src/protocols/yahoo/yahoo.c @ 13849:8d1c55309e3c

[gaim-migrate @ 16306] 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 committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 22 Jun 2006 06:26:38 +0000
parents a9ff4499d9ce
children b5ff22440a5b
comparison
equal deleted inserted replaced
13848:b43971b34053 13849:8d1c55309e3c
668 char *msg; 668 char *msg;
669 }; 669 };
670 670
671 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) 671 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt)
672 { 672 {
673 struct yahoo_data *yd = gc->proto_data;
673 GSList *l = pkt->hash; 674 GSList *l = pkt->hash;
674 GSList *list = NULL; 675 GSList *list = NULL;
675 struct _yahoo_im *im = NULL; 676 struct _yahoo_im *im = NULL;
676 677
677 const char *imv = NULL; 678 const char *imv = NULL;
710 _("Your Yahoo! message did not get sent."), NULL); 711 _("Your Yahoo! message did not get sent."), NULL);
711 } 712 }
712 713
713 /** TODO: It seems that this check should be per IM, not global */ 714 /** TODO: It seems that this check should be per IM, not global */
714 /* Check for the Doodle IMV */ 715 /* Check for the Doodle IMV */
715 if(im != NULL && imv != NULL && !strcmp(imv, "doodle;11")) 716 if (im != NULL && imv!= NULL && im->from != NULL)
716 { 717 {
717 GaimWhiteboard *wb; 718 g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv));
718 719
719 if (!yahoo_privacy_check(gc, im->from)) { 720 if (strcmp(imv, "doodle;11") == 0)
720 gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from);
721 return;
722 }
723
724 wb = gaim_whiteboard_get_session(gc->account, im->from);
725
726 /* If a Doodle session doesn't exist between this user */
727 if(wb == NULL)
728 { 721 {
729 wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED); 722 GaimWhiteboard *wb;
730 723
731 yahoo_doodle_command_send_request(gc, im->from); 724 if (!yahoo_privacy_check(gc, im->from)) {
732 yahoo_doodle_command_send_ready(gc, im->from); 725 gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from);
726 return;
727 }
728
729 wb = gaim_whiteboard_get_session(gc->account, im->from);
730
731 /* If a Doodle session doesn't exist between this user */
732 if(wb == NULL)
733 {
734 wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED);
735
736 yahoo_doodle_command_send_request(gc, im->from);
737 yahoo_doodle_command_send_ready(gc, im->from);
738 }
733 } 739 }
734 } 740 }
735 741
736 for (l = list; l; l = l->next) { 742 for (l = list; l; l = l->next) {
737 YahooFriend *f; 743 YahooFriend *f;
2574 yd->fd = -1; 2580 yd->fd = -1;
2575 yd->txhandler = -1; 2581 yd->txhandler = -1;
2576 /* TODO: Is there a good grow size for the buffer? */ 2582 /* TODO: Is there a good grow size for the buffer? */
2577 yd->txbuf = gaim_circ_buffer_new(0); 2583 yd->txbuf = gaim_circ_buffer_new(0);
2578 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); 2584 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free);
2585 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
2579 yd->confs = NULL; 2586 yd->confs = NULL;
2580 yd->conf_id = 2; 2587 yd->conf_id = 2;
2581 2588
2582 yd->current_status = get_yahoo_status_from_gaim_status(status); 2589 yd->current_status = get_yahoo_status_from_gaim_status(status);
2583 2590
2626 yd->chat_online = 0; 2633 yd->chat_online = 0;
2627 if (yd->in_chat) 2634 if (yd->in_chat)
2628 yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */ 2635 yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */
2629 2636
2630 g_hash_table_destroy(yd->friends); 2637 g_hash_table_destroy(yd->friends);
2638 g_hash_table_destroy(yd->imvironments);
2631 g_free(yd->chat_name); 2639 g_free(yd->chat_name);
2632 2640
2633 g_free(yd->cookie_y); 2641 g_free(yd->cookie_y);
2634 g_free(yd->cookie_t); 2642 g_free(yd->cookie_t);
2635 2643
3099 yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who); 3107 yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who);
3100 if (utf8) 3108 if (utf8)
3101 yahoo_packet_hash_str(pkt, 97, "1"); 3109 yahoo_packet_hash_str(pkt, 97, "1");
3102 yahoo_packet_hash_str(pkt, 14, msg2); 3110 yahoo_packet_hash_str(pkt, 14, msg2);
3103 3111
3104 /* If this message is to a user who is also Doodling with the local user, 3112 /*
3113 * IMVironment.
3114 *
3115 * If this message is to a user who is also Doodling with the local user,
3105 * format the chat packet with the correct IMV information (thanks Yahoo!) 3116 * format the chat packet with the correct IMV information (thanks Yahoo!)
3106 */ 3117 *
3107 wb = gaim_whiteboard_get_session(gc->account, (char*)who); 3118 * Otherwise attempt to use the same IMVironment as the remote user,
3119 * just so that we don't inadvertantly reset their IMVironment back
3120 * to nothing.
3121 *
3122 * If they have no set an IMVironment, then use the default.
3123 */
3124 wb = gaim_whiteboard_get_session(gc->account, who);
3108 if (wb) 3125 if (wb)
3109 yahoo_packet_hash_str(pkt, 63, "doodle;11"); 3126 yahoo_packet_hash_str(pkt, 63, "doodle;11");
3110 else 3127 else
3111 yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */ 3128 {
3129 const char *imv;
3130 imv = g_hash_table_lookup(yd->imvironments, who);
3131 if (imv != NULL)
3132 yahoo_packet_hash_str(pkt, 63, imv);
3133 else
3134 yahoo_packet_hash_str(pkt, 63, ";0");
3135 }
3112 3136
3113 yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */ 3137 yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */
3114 yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ 3138 yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */
3115 if (!yd->picture_url) 3139 if (!yd->picture_url)
3116 yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ 3140 yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */