comparison libpurple/protocols/msn/switchboard.c @ 17441:83f10ac192d9

Handle problems initiating or joining a switchboard session more gracefully. Don't display obnoxious meaningless "MSN Authentication Error" dialogs when the MSN servers are having kittens and inviting us to join a switchboard session but then refusing to accept the auth key they gave us. Fixes #1424
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 02 Jun 2007 16:37:22 +0000
parents e058328dc954
children 8502b0b42436 4403cecc7cd6
comparison
equal deleted inserted replaced
17440:b65d0cc85419 17441:83f10ac192d9
417 "because a connection error occurred:"); 417 "because a connection error occurred:");
418 break; 418 break;
419 case MSN_SB_ERROR_TOO_FAST: 419 case MSN_SB_ERROR_TOO_FAST:
420 str_reason = _("Message could not be sent " 420 str_reason = _("Message could not be sent "
421 "because we are sending too quickly:"); 421 "because we are sending too quickly:");
422 break; 422 break;
423 case MSN_SB_ERROR_AUTHFAILED:
424 str_reason = _("Message could not be sent "
425 "because we wer unable to establish a "
426 "session with the server. This is "
427 "likely a server problem, try again in "
428 "a few minutes:");
429 break;
423 default: 430 default:
424 str_reason = _("Message could not be sent " 431 str_reason = _("Message could not be sent "
425 "because an error with " 432 "because an error with "
426 "the switchboard occurred:"); 433 "the switchboard occurred:");
427 break; 434 break;
961 968
962 /************************************************************************** 969 /**************************************************************************
963 * Connect stuff 970 * Connect stuff
964 **************************************************************************/ 971 **************************************************************************/
965 static void 972 static void
973 ans_usr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error);
974
975 static void
966 connect_cb(MsnServConn *servconn) 976 connect_cb(MsnServConn *servconn)
967 { 977 {
968 MsnSwitchBoard *swboard; 978 MsnSwitchBoard *swboard;
979 MsnTransaction *trans;
969 MsnCmdProc *cmdproc; 980 MsnCmdProc *cmdproc;
970 PurpleAccount *account; 981 PurpleAccount *account;
971 982
972 cmdproc = servconn->cmdproc; 983 cmdproc = servconn->cmdproc;
973 g_return_if_fail(cmdproc != NULL); 984 g_return_if_fail(cmdproc != NULL);
978 989
979 if (msn_switchboard_is_invited(swboard)) 990 if (msn_switchboard_is_invited(swboard))
980 { 991 {
981 swboard->empty = FALSE; 992 swboard->empty = FALSE;
982 993
983 msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", 994 trans = msn_transaction_new(cmdproc, "ANS", "%s %s %s",
984 purple_account_get_username(account), 995 purple_account_get_username(account),
985 swboard->auth_key, swboard->session_id); 996 swboard->auth_key, swboard->session_id);
986 } 997 }
987 else 998 else
988 { 999 {
989 msn_cmdproc_send(cmdproc, "USR", "%s %s", 1000 trans = msn_transaction_new(cmdproc, "USR", "%s %s",
990 purple_account_get_username(account), 1001 purple_account_get_username(account),
991 swboard->auth_key); 1002 swboard->auth_key);
992 } 1003 }
1004
1005 msn_transaction_set_error_cb(trans, ans_usr_error);
1006 msn_transaction_set_data(trans, swboard);
1007 msn_cmdproc_send_trans(cmdproc, trans);
1008 }
1009
1010 static void
1011 ans_usr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error)
1012 {
1013 MsnSwitchBoard *swboard;
1014 char **params;
1015 char *passport;
1016 int reason = MSN_SB_ERROR_UNKNOWN;
1017
1018 if (error == 911)
1019 {
1020 reason = MSN_SB_ERROR_AUTHFAILED;
1021 }
1022
1023 purple_debug_warning("msn", "ans_usr_error: command %s gave error %i\n", trans->command, error);
1024
1025 params = g_strsplit(trans->params, " ", 0);
1026 passport = params[0];
1027 swboard = trans->data;
1028
1029 swboard_error_helper(swboard, reason, passport);
1030
1031 g_strfreev(params);
993 } 1032 }
994 1033
995 static void 1034 static void
996 disconnect_cb(MsnServConn *servconn) 1035 disconnect_cb(MsnServConn *servconn)
997 { 1036 {