comparison src/protocols/msn/switchboard.c @ 10533:ace8cd0de6ea

[gaim-migrate @ 11862] Some minor MSN reorganization from Felipe and a bunch of MSN chat related fixes and improvements from me. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Thu, 20 Jan 2005 16:37:14 +0000
parents 1a97d5e88d12
children fed2a7c2471d
comparison
equal deleted inserted replaced
10532:8f2b74c5aa24 10533:ace8cd0de6ea
225 gaim_conversation_get_type(swboard->conv) != GAIM_CONV_CHAT) 225 gaim_conversation_get_type(swboard->conv) != GAIM_CONV_CHAT)
226 { 226 {
227 GList *l; 227 GList *l;
228 228
229 /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */ 229 /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */
230 230 #if 0
231 /* this is bad - it causes msn_switchboard_close to be called on the
232 * switchboard we're in the middle of using :( */
231 if (swboard->conv != NULL) 233 if (swboard->conv != NULL)
232 gaim_conversation_destroy(swboard->conv); 234 gaim_conversation_destroy(swboard->conv);
235 #endif
233 236
234 cmdproc->session->conv_seq++; 237 cmdproc->session->conv_seq++;
235 swboard->chat_id = cmdproc->session->conv_seq; 238 swboard->chat_id = cmdproc->session->conv_seq;
236 239
237 swboard->conv = serv_got_joined_chat(account->gc, 240 swboard->conv = serv_got_joined_chat(account->gc,
312 { 315 {
313 g_return_if_fail(swboard != NULL); 316 g_return_if_fail(swboard != NULL);
314 317
315 gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); 318 gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport);
316 319
317 if (swboard->total_users == 0) 320 /* TODO: if current_users > 0, this is probably a chat and an invite failed,
321 * we should report that in the chat or something */
322 if (swboard->current_users == 0)
318 { 323 {
319 swboard->error = reason; 324 swboard->error = reason;
320 msn_switchboard_close(swboard); 325 msn_switchboard_close(swboard);
321 } 326 }
322 } 327 }
610 if (swboard->conv == NULL) 615 if (swboard->conv == NULL)
611 { 616 {
612 /* This is a helper switchboard */ 617 /* This is a helper switchboard */
613 msn_switchboard_destroy(swboard); 618 msn_switchboard_destroy(swboard);
614 } 619 }
615 else if (swboard->current_users > 1) 620 else if ((swboard->current_users > 1) ||
621 (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
616 { 622 {
617 /* This is a switchboard used for a chat */ 623 /* This is a switchboard used for a chat */
618 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); 624 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL);
625 swboard->current_users--;
626 if (swboard->current_users == 0)
627 msn_switchboard_destroy(swboard);
619 } 628 }
620 else 629 else
621 { 630 {
622 /* This is a switchboard used for a im session */ 631 /* This is a switchboard used for a im session */
623 632
834 else 843 else
835 { 844 {
836 body_final = body_enc; 845 body_final = body_enc;
837 } 846 }
838 847
839 if (swboard->current_users > 1) 848 if (swboard->current_users > 1 ||
849 ((swboard->conv != NULL) &&
850 gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
840 { 851 {
841 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, 852 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
842 time(NULL)); 853 time(NULL));
854 if (swboard->conv == NULL)
855 swboard->conv = gaim_find_chat(gc, swboard->chat_id);
843 } 856 }
844 else 857 else
858 {
845 serv_got_im(gc, passport, body_final, 0, time(NULL)); 859 serv_got_im(gc, passport, body_final, 0, time(NULL));
860 if (swboard->conv == NULL)
861 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_IM,
862 passport, gaim_connection_get_account(gc));
863 }
846 864
847 g_free(body_final); 865 g_free(body_final);
848 } 866 }
849 867
850 static void 868 static void
1077 1095
1078 void 1096 void
1079 msn_switchboard_close(MsnSwitchBoard *swboard) 1097 msn_switchboard_close(MsnSwitchBoard *swboard)
1080 { 1098 {
1081 g_return_if_fail(swboard != NULL); 1099 g_return_if_fail(swboard != NULL);
1100
1101 /* forget any conversation that used to be associated with this swboard */
1102 swboard->conv = NULL;
1082 1103
1083 if (swboard->error != MSN_SB_ERROR_NONE) 1104 if (swboard->error != MSN_SB_ERROR_NONE)
1084 { 1105 {
1085 msn_switchboard_destroy(swboard); 1106 msn_switchboard_destroy(swboard);
1086 } 1107 }