Mercurial > pidgin.yaz
comparison src/protocols/msn/msn.c @ 10621:fe919915fceb
[gaim-migrate @ 12090]
This should fix the MSN problems with having multiple
switchboards associated with the same conversation / buddy.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Tue, 22 Feb 2005 15:16:38 +0000 |
parents | f52ab405f1ab |
children | 6a618db0a404 |
comparison
equal
deleted
inserted
replaced
10620:17daac7cea91 | 10621:fe919915fceb |
---|---|
336 msn_switchboard_request_add_user(swboard, buddy->name); | 336 msn_switchboard_request_add_user(swboard, buddy->name); |
337 | 337 |
338 /* TODO: This might move somewhere else, after USR might be */ | 338 /* TODO: This might move somewhere else, after USR might be */ |
339 swboard->chat_id = session->conv_seq++; | 339 swboard->chat_id = session->conv_seq++; |
340 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); | 340 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); |
341 swboard->flag = MSN_SB_FLAG_IM; | |
342 | 341 |
343 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), | 342 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
344 gaim_account_get_username(buddy->account), NULL, GAIM_CBFLAGS_NONE, TRUE); | 343 gaim_account_get_username(buddy->account), NULL, GAIM_CBFLAGS_NONE, TRUE); |
345 } | 344 } |
346 | 345 |
737 { | 736 { |
738 MsnSession *session; | 737 MsnSession *session; |
739 MsnSwitchBoard *swboard; | 738 MsnSwitchBoard *swboard; |
740 | 739 |
741 session = gc->proto_data; | 740 session = gc->proto_data; |
742 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | 741 swboard = msn_session_get_swboard(session, who); |
743 | 742 |
744 msn_switchboard_send_msg(swboard, msg, TRUE); | 743 msn_switchboard_send_msg(swboard, msg, TRUE); |
745 } | 744 } |
746 else | 745 else |
747 { | 746 { |
793 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, GAIM_TYPING); | 792 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, GAIM_TYPING); |
794 | 793 |
795 return MSN_TYPING_SEND_TIMEOUT; | 794 return MSN_TYPING_SEND_TIMEOUT; |
796 } | 795 } |
797 | 796 |
798 swboard = msn_session_find_swboard(session, who, MSN_SB_FLAG_IM); | 797 swboard = msn_session_find_swboard(session, who); |
799 | 798 |
800 if (swboard == NULL || !msn_switchboard_can_send(swboard)) | 799 if (swboard == NULL || !msn_switchboard_can_send(swboard)) |
801 return 0; | 800 return 0; |
802 | 801 |
803 msg = msn_message_new(MSN_MSG_TYPING); | 802 msg = msn_message_new(MSN_MSG_TYPING); |
1080 MsnSession *session; | 1079 MsnSession *session; |
1081 MsnSwitchBoard *swboard; | 1080 MsnSwitchBoard *swboard; |
1082 | 1081 |
1083 session = gc->proto_data; | 1082 session = gc->proto_data; |
1084 | 1083 |
1085 swboard = msn_session_find_swboard_with_id(session, id, MSN_SB_FLAG_IM); | 1084 swboard = msn_session_find_swboard_with_id(session, id); |
1086 | 1085 |
1087 if (swboard == NULL) | 1086 if (swboard == NULL) |
1088 { | 1087 { |
1089 /* if we have no switchboard, everyone else left the chat already */ | 1088 /* if we have no switchboard, everyone else left the chat already */ |
1090 swboard = msn_switchboard_new(session); | 1089 swboard = msn_switchboard_new(session); |
1091 msn_switchboard_request(swboard); | 1090 msn_switchboard_request(swboard); |
1092 swboard->chat_id = id; | 1091 swboard->chat_id = id; |
1093 swboard->conv = gaim_find_chat(gc, id); | 1092 swboard->conv = gaim_find_chat(gc, id); |
1094 swboard->flag = MSN_SB_FLAG_IM; | |
1095 } | 1093 } |
1096 | 1094 |
1097 msn_switchboard_request_add_user(swboard, who); | 1095 msn_switchboard_request_add_user(swboard, who); |
1098 } | 1096 } |
1099 | 1097 |
1100 static void | 1098 static void |
1101 msn_chat_leave(GaimConnection *gc, int id) | 1099 msn_chat_leave(GaimConnection *gc, int id) |
1102 { | 1100 { |
1103 MsnSession *session; | 1101 MsnSession *session; |
1104 MsnSwitchBoard *swboard; | 1102 MsnSwitchBoard *swboard; |
1105 | 1103 GaimConversation *conv; |
1106 session = gc->proto_data; | 1104 |
1107 | 1105 session = gc->proto_data; |
1108 swboard = msn_session_find_swboard_with_id(session, id, MSN_SB_FLAG_IM); | 1106 |
1107 swboard = msn_session_find_swboard_with_id(session, id); | |
1109 | 1108 |
1110 /* if swboard is NULL we were the only person left anyway */ | 1109 /* if swboard is NULL we were the only person left anyway */ |
1111 if (swboard == NULL) | 1110 if (swboard == NULL) |
1112 return; | 1111 return; |
1113 | 1112 |
1113 conv = swboard->conv; | |
1114 | |
1114 msn_switchboard_close(swboard); | 1115 msn_switchboard_close(swboard); |
1116 | |
1117 /* If other switchboards managed to associate themselves with this | |
1118 * conv, make sure they know it's gone! */ | |
1119 if (conv != NULL) | |
1120 { | |
1121 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1122 swboard->conv = NULL; | |
1123 } | |
1115 } | 1124 } |
1116 | 1125 |
1117 static int | 1126 static int |
1118 msn_chat_send(GaimConnection *gc, int id, const char *message) | 1127 msn_chat_send(GaimConnection *gc, int id, const char *message) |
1119 { | 1128 { |
1124 char *msgformat; | 1133 char *msgformat; |
1125 char *msgtext; | 1134 char *msgtext; |
1126 | 1135 |
1127 account = gaim_connection_get_account(gc); | 1136 account = gaim_connection_get_account(gc); |
1128 session = gc->proto_data; | 1137 session = gc->proto_data; |
1129 swboard = msn_session_find_swboard_with_id(session, id, MSN_SB_FLAG_IM); | 1138 swboard = msn_session_find_swboard_with_id(session, id); |
1130 | 1139 |
1131 if (swboard == NULL) | 1140 if (swboard == NULL) |
1132 return -EINVAL; | 1141 return -EINVAL; |
1133 | 1142 |
1134 if (!swboard->ready) | 1143 if (!swboard->ready) |
1217 static void | 1226 static void |
1218 msn_convo_closed(GaimConnection *gc, const char *who) | 1227 msn_convo_closed(GaimConnection *gc, const char *who) |
1219 { | 1228 { |
1220 MsnSession *session; | 1229 MsnSession *session; |
1221 MsnSwitchBoard *swboard; | 1230 MsnSwitchBoard *swboard; |
1222 | 1231 GaimConversation *conv; |
1223 session = gc->proto_data; | 1232 |
1224 | 1233 session = gc->proto_data; |
1225 swboard = msn_session_find_swboard(session, who, MSN_SB_FLAG_IM); | 1234 |
1235 swboard = msn_session_find_swboard(session, who); | |
1226 | 1236 |
1227 /* | 1237 /* |
1228 * Don't perform an assertion here. If swboard is NULL, then the | 1238 * Don't perform an assertion here. If swboard is NULL, then the |
1229 * switchboard was either closed by the other party, or the person | 1239 * switchboard was either closed by the other party, or the person |
1230 * is talking to himself. | 1240 * is talking to himself. |
1231 */ | 1241 */ |
1232 if (swboard == NULL) | 1242 if (swboard == NULL) |
1233 return; | 1243 return; |
1234 | 1244 |
1245 conv = swboard->conv; | |
1246 | |
1235 if (!(swboard->flag & MSN_SB_FLAG_FT)) | 1247 if (!(swboard->flag & MSN_SB_FLAG_FT)) |
1236 msn_switchboard_close(swboard); | 1248 msn_switchboard_close(swboard); |
1237 else | 1249 else |
1238 swboard->conv = NULL; | 1250 swboard->conv = NULL; |
1251 | |
1252 /* If other switchboards managed to associate themselves with this | |
1253 * conv, make sure they know it's gone! */ | |
1254 if (conv != NULL) | |
1255 { | |
1256 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1257 swboard->conv = NULL; | |
1258 } | |
1239 } | 1259 } |
1240 | 1260 |
1241 static void | 1261 static void |
1242 msn_set_buddy_icon(GaimConnection *gc, const char *filename) | 1262 msn_set_buddy_icon(GaimConnection *gc, const char *filename) |
1243 { | 1263 { |