Mercurial > pidgin.yaz
comparison src/protocols/yahoo/yahoochat.c @ 7186:0da869011d8a
[gaim-migrate @ 7754]
" This fixes issues some people in Linux, FreeBSD,
Solaris:1 reported to me, where gaim would reopen the
chat window after leaving if someone else joined before
the server decided to stop sending us stuff.
It also fixes a bug where it would say you left the
chat upon joining a chat while having another chat open.
Finally, it attempts to do a better job logging out of
chat, and fixes the bugs introduced by this change."
--Tim Ringenbach (marv_sf)
it doesn't appear to change any strings, and it fixes some bugs, so i'm
going to go ahead and commit this.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 07 Oct 2003 15:55:26 +0000 |
parents | bf630f7dfdcd |
children | ee32e030c9be |
comparison
equal
deleted
inserted
replaced
7185:780604587f46 | 7186:0da869011d8a |
---|---|
38 #include "yahoo.h" | 38 #include "yahoo.h" |
39 #include "yahoochat.h" | 39 #include "yahoochat.h" |
40 | 40 |
41 #define YAHOO_CHAT_ID (1) | 41 #define YAHOO_CHAT_ID (1) |
42 | 42 |
43 /* prototype(s) */ | |
44 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout); | |
45 | |
43 /* special function to log us on to the yahoo chat service */ | 46 /* special function to log us on to the yahoo chat service */ |
44 static void yahoo_chat_online(GaimConnection *gc) | 47 static void yahoo_chat_online(GaimConnection *gc) |
45 { | 48 { |
46 struct yahoo_data *yd = gc->proto_data; | 49 struct yahoo_data *yd = gc->proto_data; |
47 struct yahoo_packet *pkt; | 50 struct yahoo_packet *pkt; |
296 | 299 |
297 /* this is basicly the opposite of chat_online */ | 300 /* this is basicly the opposite of chat_online */ |
298 void yahoo_process_chat_logout(GaimConnection *gc, struct yahoo_packet *pkt) | 301 void yahoo_process_chat_logout(GaimConnection *gc, struct yahoo_packet *pkt) |
299 { | 302 { |
300 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; | 303 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; |
301 | 304 GSList *l; |
302 if (pkt->status == 1) | 305 |
306 for (l = pkt->hash; l; l = l->next) { | |
307 struct yahoo_pair *pair = l->data; | |
308 | |
309 if (pair->key == 1) | |
310 if (g_ascii_strcasecmp(pair->value, | |
311 gaim_connection_get_display_name(gc))) | |
312 return; | |
313 } | |
314 | |
315 if (pkt->status == 1) { | |
303 yd->chat_online = 0; | 316 yd->chat_online = 0; |
317 if (yd->in_chat) | |
318 yahoo_c_leave(gc, YAHOO_CHAT_ID); | |
319 } | |
304 } | 320 } |
305 | 321 |
306 void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) | 322 void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) |
307 { | 323 { |
308 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; | 324 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; |
367 | 383 |
368 if (!room) | 384 if (!room) |
369 return; | 385 return; |
370 | 386 |
371 if (yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) | 387 if (yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) |
372 yahoo_c_leave(gc, YAHOO_CHAT_ID); | 388 yahoo_chat_leave(gc, room, |
389 gaim_connection_get_display_name(gc), FALSE); | |
373 | 390 |
374 c = gaim_find_chat(gc, YAHOO_CHAT_ID); | 391 c = gaim_find_chat(gc, YAHOO_CHAT_ID); |
375 | 392 |
376 if (!c) { | 393 if (!c && members && ((g_list_length(members) > 1) || |
394 !g_ascii_strcasecmp(members->data, | |
395 gaim_connection_get_display_name(gc)))) { | |
377 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); | 396 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); |
378 if (topic) | 397 if (topic) |
379 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); | 398 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); |
380 yd->in_chat = 1; | 399 yd->in_chat = 1; |
381 yd->chat_name = g_strdup(room); | 400 yd->chat_name = g_strdup(room); |
382 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members); | 401 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members); |
383 } else { | 402 } else if (c) { |
384 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); | 403 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); |
385 } | 404 } |
386 | 405 |
387 g_list_free(members); | 406 g_list_free(members); |
388 } | 407 } |
389 | 408 |
390 void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt) | 409 void yahoo_process_chat_exit(GaimConnection *gc, struct yahoo_packet *pkt) |
391 { | 410 { |
392 char *who = NULL; | 411 char *who = NULL; |
412 char *room = NULL; | |
393 GSList *l; | 413 GSList *l; |
394 struct yahoo_data *yd; | 414 struct yahoo_data *yd; |
395 | 415 |
396 yd = gc->proto_data; | 416 yd = gc->proto_data; |
397 | 417 |
398 for (l = pkt->hash; l; l = l->next) { | 418 for (l = pkt->hash; l; l = l->next) { |
399 struct yahoo_pair *pair = l->data; | 419 struct yahoo_pair *pair = l->data; |
400 | 420 |
421 if (pair->key == 104) | |
422 room = pair->value; | |
401 if (pair->key == 109) | 423 if (pair->key == 109) |
402 who = pair->value; | 424 who = pair->value; |
403 } | 425 } |
404 | 426 |
405 | 427 |
406 if (who) { | 428 if (who && room) { |
407 GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID); | 429 GaimConversation *c = gaim_find_chat(gc, YAHOO_CHAT_ID); |
408 if (c) | 430 if (c && !gaim_utf8_strcasecmp(gaim_conversation_get_name(c), room)) |
409 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); | 431 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), who, NULL); |
410 | 432 |
411 } | 433 } |
412 } | 434 } |
413 | 435 |
621 | 643 |
622 /* | 644 /* |
623 * Functions dealing with chats | 645 * Functions dealing with chats |
624 */ | 646 */ |
625 | 647 |
626 static void yahoo_chat_leave(struct yahoo_data *yd, const char *room, const char *dn) | 648 static void yahoo_chat_leave(GaimConnection *gc, const char *room, const char *dn, gboolean logout) |
627 { | 649 { |
650 struct yahoo_data *yd = gc->proto_data; | |
628 struct yahoo_packet *pkt; | 651 struct yahoo_packet *pkt; |
652 GaimConversation *c; | |
629 | 653 |
630 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); | 654 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); |
631 | 655 |
632 yahoo_packet_hash(pkt, 104, room); | 656 yahoo_packet_hash(pkt, 104, room); |
633 yahoo_packet_hash(pkt, 109, dn); | 657 yahoo_packet_hash(pkt, 109, dn); |
642 if (yd->chat_name) { | 666 if (yd->chat_name) { |
643 g_free(yd->chat_name); | 667 g_free(yd->chat_name); |
644 yd->chat_name = NULL; | 668 yd->chat_name = NULL; |
645 } | 669 } |
646 | 670 |
671 if ((c = gaim_find_chat(gc, YAHOO_CHAT_ID))) | |
672 serv_got_chat_left(gc, YAHOO_CHAT_ID); | |
673 | |
674 if (!logout) | |
675 return; | |
676 | |
677 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, | |
678 YAHOO_STATUS_AVAILABLE, 0); | |
679 yahoo_packet_hash(pkt, 1, dn); | |
680 yahoo_send_packet(yd, pkt); | |
681 yahoo_packet_free(pkt); | |
682 | |
683 yd->chat_online = 0; | |
647 } | 684 } |
648 | 685 |
649 /* borrowed from gtkconv.c */ | 686 /* borrowed from gtkconv.c */ |
650 static gboolean | 687 static gboolean |
651 meify(char *message, size_t len) | 688 meify(char *message, size_t len) |
789 if (id != YAHOO_CHAT_ID) { | 826 if (id != YAHOO_CHAT_ID) { |
790 yahoo_conf_leave(yd, gaim_conversation_get_name(c), | 827 yahoo_conf_leave(yd, gaim_conversation_get_name(c), |
791 gaim_connection_get_display_name(gc), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c))); | 828 gaim_connection_get_display_name(gc), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c))); |
792 yd->confs = g_slist_remove(yd->confs, c); | 829 yd->confs = g_slist_remove(yd->confs, c); |
793 } else { | 830 } else { |
794 yahoo_chat_leave(yd, gaim_conversation_get_name(c), gaim_connection_get_display_name(gc)); | 831 yahoo_chat_leave(gc, gaim_conversation_get_name(c), gaim_connection_get_display_name(gc), TRUE); |
795 } | 832 } |
796 | 833 |
797 serv_got_chat_left(gc, id); | 834 serv_got_chat_left(gc, id); |
798 } | 835 } |
799 | 836 |
866 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), gaim_connection_get_display_name(gc), topic); | 903 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), gaim_connection_get_display_name(gc), topic); |
867 yahoo_conf_join(yd, c, gaim_connection_get_display_name(gc), room, topic, members); | 904 yahoo_conf_join(yd, c, gaim_connection_get_display_name(gc), room, topic, members); |
868 return; | 905 return; |
869 } else { | 906 } else { |
870 if (yd->in_chat) | 907 if (yd->in_chat) |
871 yahoo_c_leave(gc, YAHOO_CHAT_ID); | 908 yahoo_chat_leave(gc, room, |
909 gaim_connection_get_display_name(gc), | |
910 FALSE); | |
872 if (!yd->chat_online) | 911 if (!yd->chat_online) |
873 yahoo_chat_online(gc); | 912 yahoo_chat_online(gc); |
874 yahoo_chat_join(yd, gaim_connection_get_display_name(gc), room, topic); | 913 yahoo_chat_join(yd, gaim_connection_get_display_name(gc), room, topic); |
875 return; | 914 return; |
876 } | 915 } |