Mercurial > pidgin
diff src/protocols/msn/session.c @ 10481:bcfea6c3d5c9
[gaim-migrate @ 11769]
Patch 1093958 from Felipe Contreras. It fixes stuff.
I also made some tweaks to make valgrind a bit happier.
committer: Tailor Script <tailor@pidgin.im>
| author | Stu Tomlinson <stu@nosnilmot.com> |
|---|---|
| date | Fri, 07 Jan 2005 02:48:33 +0000 |
| parents | 9bed28273ec7 |
| children | 1a97d5e88d12 |
line wrap: on
line diff
--- a/src/protocols/msn/session.c Thu Jan 06 23:11:12 2005 +0000 +++ b/src/protocols/msn/session.c Fri Jan 07 02:48:33 2005 +0000 @@ -28,8 +28,7 @@ #include "dialog.h" MsnSession * -msn_session_new(GaimAccount *account, const char *host, int port, - gboolean http_method) +msn_session_new(GaimAccount *account) { MsnSession *session; @@ -37,15 +36,14 @@ session = g_new0(MsnSession, 1); - session->account = account; - session->dispatch_host = g_strdup(host); - session->dispatch_port = port; - session->http_method = http_method; - + session->account = account; session->notification = msn_notification_new(session); session->userlist = msn_userlist_new(session); session->sync_userlist = msn_userlist_new(session); + session->user = msn_user_new(session->userlist, + gaim_account_get_username(account), NULL); + session->protocol_ver = 9; return session; @@ -61,9 +59,6 @@ if (session->connected) msn_session_disconnect(session); - if (session->dispatch_host != NULL) - g_free(session->dispatch_host); - if (session->notification != NULL) msn_notification_destroy(session->notification); @@ -102,16 +97,21 @@ if (session->nexus != NULL) msn_nexus_destroy(session->nexus); + if (session->user != NULL) + msn_user_destroy(session->user); + g_free(session); } gboolean -msn_session_connect(MsnSession *session) +msn_session_connect(MsnSession *session, const char *host, int port, + gboolean http_method) { g_return_val_if_fail(session != NULL, FALSE); g_return_val_if_fail(!session->connected, TRUE); session->connected = TRUE; + session->http_method = http_method; if (session->notification == NULL) { @@ -119,9 +119,7 @@ g_return_val_if_reached(FALSE); } - if (msn_notification_connect(session->notification, - session->dispatch_host, - session->dispatch_port)) + if (msn_notification_connect(session->notification, host, port)) { return TRUE; } @@ -135,13 +133,13 @@ g_return_if_fail(session != NULL); g_return_if_fail(session->connected); + session->connected = FALSE; + while (session->switches != NULL) msn_switchboard_close(session->switches->data); if (session->notification != NULL) msn_notification_close(session->notification); - - session->connected = FALSE; } /* TODO: This must go away when conversation is redesigned */ @@ -278,6 +276,86 @@ } void +msn_session_set_error(MsnSession *session, MsnErrorType error, + const char *info) +{ + GaimConnection *gc; + char *msg; + + gc = session->account->gc; + + switch (error) + { + case MSN_ERROR_SERVCONN: + msg = g_strdup(info); + break; + case MSN_ERROR_UNSUPORTED_PROTOCOL: + msg = g_strdup(_("Our protocol is not supported by the " + "server.")); + break; + case MSN_ERROR_HTTP_MALFORMED: + msg = g_strdup(_("Error parsing HTTP.")); + break; + case MSN_ERROR_SIGN_OTHER: + gc->wants_to_die = TRUE; + msg = g_strdup(_("You have signed on from another location.")); + break; + case MSN_ERROR_SERV_DOWN: + msg = g_strdup(_("The MSN servers are going down " + "temporarily.")); + break; + case MSN_ERROR_AUTH: + msg = g_strdup_printf(_("Unable to authenticate: %s"), + (info == NULL ) ? + _("Unknown error") : info); + break; + case MSN_ERROR_BAD_BLIST: + msg = g_strdup(_("Your MSN buddy list is temporarily " + "unavailable. Please wait and try " + "again.")); + break; + default: + msg = g_strdup(_("Unknown error.")); + break; + } + + msn_session_disconnect(session); + gaim_connection_error(gc, msg); + + g_free(msg); +} + +static const char * +get_login_step_text(MsnSession *session) +{ + const char *steps_text[] = { + _("Connecting"), + _("Handshaking"), + _("Transfering"), + _("Starting authentication"), + _("Getting cookie"), + _("Authenticating"), + _("Sending cookie"), + _("Retrieving buddy list") + }; + + return steps_text[session->login_step]; +} + +void +msn_session_set_login_step(MsnSession *session, MsnLoginStep step) +{ + GaimConnection *gc; + + gc = session->account->gc; + + session->login_step = step; + + gaim_connection_update_progress(gc, get_login_step_text(session), step, + MSN_LOGIN_STEPS); +} + +void msn_session_finish_login(MsnSession *session) { GaimAccount *account;
