comparison src/conversation.c @ 8256:1d86096ae0f4

[gaim-migrate @ 8979] Tim Ringenbach says this shouldn't have gotten into 0.76, because 0.76 should have been release two weeks ago. He also doesn't have a good description, so I'll just say it fixed a bunch of idiot mistakes and ugly hacks on my part regarding the removing of users from the chat lists and parting chats/channels. Thanks Tim. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 14 Feb 2004 21:07:29 +0000
parents e283be34aadf
children 5c9cd9c97727
comparison
equal deleted inserted replaced
8255:4de49af535b3 8256:1d86096ae0f4
743 } 743 }
744 744
745 /************************************************************************** 745 /**************************************************************************
746 * Conversation API 746 * Conversation API
747 **************************************************************************/ 747 **************************************************************************/
748 static void
749 gaim_conversation_chat_cleanup_for_rejoin(GaimConversation *conv)
750 {
751 const char *disp;
752 GaimAccount *account;
753
754 account = gaim_conversation_get_account(conv);
755
756 if ((disp = gaim_connection_get_display_name(gaim_account_get_connection(account)))) {
757 gaim_conv_chat_set_nick(conv->u.chat, disp);
758 } else {
759 gaim_conv_chat_set_nick(conv->u.chat, gaim_account_get_username(account));
760 }
761
762 gaim_conv_chat_clear_users(conv->u.chat);
763 gaim_conv_chat_set_topic(conv->u.chat, NULL, NULL);
764 conv->u.chat->left = FALSE;
765
766 gaim_conversation_update(conv, GAIM_CONV_UPDATE_CHATLEFT);
767 }
768
748 GaimConversation * 769 GaimConversation *
749 gaim_conversation_new(GaimConversationType type, GaimAccount *account, 770 gaim_conversation_new(GaimConversationType type, GaimAccount *account,
750 const char *name) 771 const char *name)
751 { 772 {
752 GaimConversation *conv; 773 GaimConversation *conv;
754 g_return_val_if_fail(type != GAIM_CONV_UNKNOWN, NULL); 775 g_return_val_if_fail(type != GAIM_CONV_UNKNOWN, NULL);
755 g_return_val_if_fail(account != NULL, NULL); 776 g_return_val_if_fail(account != NULL, NULL);
756 g_return_val_if_fail(name != NULL, NULL); 777 g_return_val_if_fail(name != NULL, NULL);
757 778
758 /* Check if this conversation already exists. */ 779 /* Check if this conversation already exists. */
759 if ((conv = gaim_find_conversation_with_account(name, account)) != NULL) 780 if (((conv = gaim_find_conversation_with_account(name, account)) != NULL) &&
760 return conv; 781 (gaim_conversation_get_type(conv) == type)) {
782
783 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT ||
784 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) {
785 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)
786 gaim_conversation_chat_cleanup_for_rejoin(conv);
787
788 return conv;
789 }
790 }
761 791
762 conv = g_new0(GaimConversation, 1); 792 conv = g_new0(GaimConversation, 1);
763 793
764 conv->type = type; 794 conv->type = type;
765 conv->account = account; 795 conv->account = account;
867 897
868 if (gc && prpl_info->convo_closed != NULL) 898 if (gc && prpl_info->convo_closed != NULL)
869 prpl_info->convo_closed(gc, name); 899 prpl_info->convo_closed(gc, name);
870 } 900 }
871 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { 901 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) {
902 #if 0
872 /* 903 /*
873 * This is unfortunately necessary, because calling 904 * This is unfortunately necessary, because calling
874 * serv_chat_leave() calls this gaim_conversation_destroy(), 905 * serv_chat_leave() calls this gaim_conversation_destroy(),
875 * which leads to two calls here.. We can't just return after 906 * which leads to two calls here.. We can't just return after
876 * this, because then it'll return on the next pass. So, since 907 * this, because then it'll return on the next pass. So, since
890 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) { 921 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) {
891 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); 922 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)));
892 923
893 return; 924 return;
894 } 925 }
926 #endif
927 /*
928 * Instead of all of that, lets just close the window when the user tells
929 * us to, and let the prpl deal with the internals on it's own time.
930 */
931 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)));
895 } 932 }
896 } 933 }
897 934
898 gaim_signal_emit(gaim_conversations_get_handle(), 935 gaim_signal_emit(gaim_conversations_get_handle(),
899 "deleting-conversation", conv); 936 "deleting-conversation", conv);
1404 if (b != NULL) 1441 if (b != NULL)
1405 who = gaim_get_buddy_alias(b); 1442 who = gaim_get_buddy_alias(b);
1406 } 1443 }
1407 } 1444 }
1408 } 1445 }
1409 1446
1410 if (gaim_conversation_is_logging(conv)) 1447 if (gaim_conversation_is_logging(conv))
1411 gaim_log_write(conv->log, flags, who, mtime, message); 1448 gaim_log_write(conv->log, flags, who, mtime, message);
1412 ops->write_conv(conv, who, message, flags, mtime); 1449 ops->write_conv(conv, who, message, flags, mtime);
1413 1450
1414 win = gaim_conversation_get_window(conv); 1451 win = gaim_conversation_get_window(conv);
1455 if (ops != NULL && ops->update_progress != NULL) 1492 if (ops != NULL && ops->update_progress != NULL)
1456 ops->update_progress(conv, percent); 1493 ops->update_progress(conv, percent);
1457 } 1494 }
1458 1495
1459 /* 1496 /*
1460 * TODO: Need to make sure calls to this function happen in the core 1497 * TODO: Need to make sure calls to this function happen in the core
1461 * instead of the UI. That way UIs have less work to do, and the 1498 * instead of the UI. That way UIs have less work to do, and the
1462 * core/UI split is cleaner. Also need to make sure this is called 1499 * core/UI split is cleaner. Also need to make sure this is called
1463 * when chats are added/removed from the blist. 1500 * when chats are added/removed from the blist.
1464 */ 1501 */
1465 void 1502 void
1466 gaim_conversation_update(GaimConversation *conv, GaimConvUpdateType type) 1503 gaim_conversation_update(GaimConversation *conv, GaimConvUpdateType type)
1467 { 1504 {
2176 gaim_conversation_get_gc(conv) == gc) 2213 gaim_conversation_get_gc(conv) == gc)
2177 return conv; 2214 return conv;
2178 } 2215 }
2179 2216
2180 return NULL; 2217 return NULL;
2218 }
2219
2220 void
2221 gaim_conv_chat_left(GaimConvChat *chat)
2222 {
2223 g_return_if_fail(chat != NULL);
2224
2225 chat->left = TRUE;
2226 gaim_conversation_update(chat->conv, GAIM_CONV_UPDATE_CHATLEFT);
2227 }
2228
2229 gboolean
2230 gaim_conv_chat_has_left(GaimConvChat *chat)
2231 {
2232 g_return_val_if_fail(chat != NULL, TRUE);
2233
2234 return chat->left;
2181 } 2235 }
2182 2236
2183 /************************************************************************** 2237 /**************************************************************************
2184 * Conversation placement functions 2238 * Conversation placement functions
2185 **************************************************************************/ 2239 **************************************************************************/