Mercurial > pidgin
comparison src/conversation.c @ 8373:7a58f6f9fc3e
[gaim-migrate @ 9100]
Another great patch by Tim Ringenbach. This one fixes some rejoining
and parting bugs in chats. It also includes some tiny code cleanups I had
sitting here.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 01 Mar 2004 01:00:08 +0000 |
parents | 9f11f793c19e |
children | 143d0b29ba82 |
comparison
equal
deleted
inserted
replaced
8372:bd16ed85cfc2 | 8373:7a58f6f9fc3e |
---|---|
748 static void | 748 static void |
749 gaim_conversation_chat_cleanup_for_rejoin(GaimConversation *conv) | 749 gaim_conversation_chat_cleanup_for_rejoin(GaimConversation *conv) |
750 { | 750 { |
751 const char *disp; | 751 const char *disp; |
752 GaimAccount *account; | 752 GaimAccount *account; |
753 GaimConnection *gc; | |
753 | 754 |
754 account = gaim_conversation_get_account(conv); | 755 account = gaim_conversation_get_account(conv); |
755 | 756 |
756 if ((disp = gaim_connection_get_display_name(gaim_account_get_connection(account)))) { | 757 gaim_log_free(conv->log); |
757 gaim_conv_chat_set_nick(conv->u.chat, disp); | 758 conv->log = gaim_log_new(GAIM_LOG_CHAT, gaim_conversation_get_name(conv), |
758 } else { | 759 account, time(NULL)); |
759 gaim_conv_chat_set_nick(conv->u.chat, gaim_account_get_username(account)); | 760 |
760 } | 761 gc = gaim_account_get_connection(account); |
761 | 762 |
762 gaim_conv_chat_clear_users(conv->u.chat); | 763 if ((disp = gaim_connection_get_display_name(gc)) != NULL) |
763 gaim_conv_chat_set_topic(conv->u.chat, NULL, NULL); | 764 gaim_conv_chat_set_nick(GAIM_CONV_CHAT(conv), disp); |
764 conv->u.chat->left = FALSE; | 765 else |
766 { | |
767 gaim_conv_chat_set_nick(GAIM_CONV_CHAT(conv), | |
768 gaim_account_get_username(account)); | |
769 } | |
770 | |
771 gaim_conv_chat_clear_users(GAIM_CONV_CHAT(conv)); | |
772 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(conv), NULL, NULL); | |
773 GAIM_CONV_CHAT(conv)->left = FALSE; | |
765 | 774 |
766 gaim_conversation_update(conv, GAIM_CONV_UPDATE_CHATLEFT); | 775 gaim_conversation_update(conv, GAIM_CONV_UPDATE_CHATLEFT); |
767 } | 776 } |
768 | 777 |
769 GaimConversation * | 778 GaimConversation * |
841 | 850 |
842 /* | 851 /* |
843 * Create a window if one does not exist. If it does, use the last | 852 * Create a window if one does not exist. If it does, use the last |
844 * created window. | 853 * created window. |
845 */ | 854 */ |
846 if (windows == NULL) { | 855 if (windows == NULL) |
856 { | |
847 GaimConvWindow *win; | 857 GaimConvWindow *win; |
848 | 858 |
849 win = gaim_conv_window_new(); | 859 win = gaim_conv_window_new(); |
850 gaim_conv_window_add_conversation(win, conv); | 860 gaim_conv_window_add_conversation(win, conv); |
851 | 861 |
852 /* Ensure the window is visible. */ | 862 /* Ensure the window is visible. */ |
853 gaim_conv_window_show(win); | 863 gaim_conv_window_show(win); |
854 } | 864 } |
855 else { | 865 else |
866 { | |
856 if (place_conv == NULL) | 867 if (place_conv == NULL) |
857 { | 868 { |
858 ensure_default_funcs(); | 869 ensure_default_funcs(); |
859 | 870 |
860 place_conv = conv_placement_last_created_win; | 871 place_conv = conv_placement_last_created_win; |
888 win = gaim_conversation_get_window(conv); | 899 win = gaim_conversation_get_window(conv); |
889 ops = gaim_conversation_get_ui_ops(conv); | 900 ops = gaim_conversation_get_ui_ops(conv); |
890 gc = gaim_conversation_get_gc(conv); | 901 gc = gaim_conversation_get_gc(conv); |
891 name = gaim_conversation_get_name(conv); | 902 name = gaim_conversation_get_name(conv); |
892 | 903 |
893 if (gc != NULL) { | 904 if (gc != NULL) |
905 { | |
894 /* Still connected */ | 906 /* Still connected */ |
895 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | 907 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
896 | 908 |
897 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | 909 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
910 { | |
898 if (gaim_prefs_get_bool("/core/conversations/im/send_typing")) | 911 if (gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
899 serv_send_typing(gc, name, GAIM_NOT_TYPING); | 912 serv_send_typing(gc, name, GAIM_NOT_TYPING); |
900 | 913 |
901 if (gc && prpl_info->convo_closed != NULL) | 914 if (gc && prpl_info->convo_closed != NULL) |
902 prpl_info->convo_closed(gc, name); | 915 prpl_info->convo_closed(gc, name); |
903 } | 916 } |
904 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | 917 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
918 { | |
919 int chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
905 #if 0 | 920 #if 0 |
906 /* | 921 /* |
907 * This is unfortunately necessary, because calling | 922 * This is unfortunately necessary, because calling |
908 * serv_chat_leave() calls this gaim_conversation_destroy(), | 923 * serv_chat_leave() calls this gaim_conversation_destroy(), |
909 * which leads to two calls here.. We can't just return after | 924 * which leads to two calls here.. We can't just return after |
920 * | 935 * |
921 * -- ChipX86 | 936 * -- ChipX86 |
922 */ | 937 */ |
923 | 938 |
924 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) { | 939 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) { |
925 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | 940 serv_chat_leave(gc, chat_id); |
926 | 941 |
927 return; | 942 return; |
928 } | 943 } |
929 #endif | 944 #endif |
930 /* | 945 /* |
931 * Instead of all of that, lets just close the window when the user tells | 946 * Instead of all of that, lets just close the window when |
932 * us to, and let the prpl deal with the internals on it's own time. | 947 * the user tells us to, and let the prpl deal with the |
933 */ | 948 * internals on it's own time. Don't do this if the prpl already |
934 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | 949 * knows it left the chat. |
950 */ | |
951 if (!gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) | |
952 serv_chat_leave(gc, chat_id); | |
953 | |
954 /* | |
955 * If they didn't call serv_got_chat_left by now, it's too late. | |
956 * So we better do it for them before we destroy the thing. | |
957 */ | |
958 if (!gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) | |
959 serv_got_chat_left(gc, chat_id); | |
935 } | 960 } |
936 } | 961 } |
937 | 962 |
938 gaim_signal_emit(gaim_conversations_get_handle(), | 963 gaim_signal_emit(gaim_conversations_get_handle(), |
939 "deleting-conversation", conv); | 964 "deleting-conversation", conv); |