# HG changeset patch # User Elliott Sales de Andrade # Date 1217311960 0 # Node ID 7f4b697c694778ca4a61511511fc581866d106b8 # Parent b2609fca4943d19756cd5c69fbaa724dc0d1c78e Use a URL to open MSN Hotmail inbox instead of a temporary file. Based on work by felipec in msn-pecan. Fixes #5762. diff -r b2609fca4943 -r 7f4b697c6947 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Mon Jul 28 05:10:48 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Tue Jul 29 06:12:40 2008 +0000 @@ -435,7 +435,8 @@ } /** apparently the correct value is 777, use 750 as a failsafe */ - if (time (NULL) - session->passport_info.mail_timestamp >= 750) { + if ((session->passport_info.mail_url == NULL) + || (time (NULL) - session->passport_info.mail_timestamp >= 750)) { MsnTransaction *trans; MsnCmdProc *cmdproc; @@ -446,9 +447,8 @@ msn_cmdproc_send_trans(cmdproc, trans); - } else if (session->passport_info.file != NULL) { - purple_notify_uri(gc, session->passport_info.file); - } + } else + purple_notify_uri(gc, session->passport_info.mail_url); } static void diff -r b2609fca4943 -r 7f4b697c6947 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Mon Jul 28 05:10:48 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Tue Jul 29 06:12:40 2008 +0000 @@ -1289,7 +1289,6 @@ const char *url; PurpleCipherContext *cipher; gchar digest[33]; - FILE *fd; char *buf; gulong tmp_timestamp; @@ -1316,111 +1315,19 @@ g_free(buf); - if (session->passport_info.file != NULL) - { - g_unlink(session->passport_info.file); - g_free(session->passport_info.file); - } - - if ((fd = purple_mkstemp(&session->passport_info.file, FALSE)) == NULL) - { - purple_debug_error("msn", - "Error opening temp passport file: %s\n", - g_strerror(errno)); - /* The user wanted to check his or her email */ - if (cmd->trans && cmd->trans->data) - /* TODO: This error might be a bit technical... */ - purple_notify_error(gc, NULL, - _("Error opening temporary passport file."), NULL); - } - else - { -#ifdef _WIN32 - fputs("\n", fd); -#endif - fputs("\n" - "\n" - "\n" - "\n\n", - fd); + g_free(session->passport_info.mail_url); + session->passport_info.mail_url = g_strdup_printf("%s&auth=%s&creds=%s&sl=%ld&username=%s&mode=ttl&sid=%s&id=2&rru=%ssvc_mail&js=yes", + url, + session->passport_info.mspauth ? session->passport_info.mspauth : "BOGUS", + buf, + tmp_timestamp, + msn_user_get_passport(session->user), + session->passport_info.sid, + rru); - fprintf(fd, "\n"); - fprintf(fd, "
\n\n", - url); - fprintf(fd, "\n"); - fprintf(fd, "\n", - purple_account_get_username(account)); - fprintf(fd, "\n", - purple_account_get_username(account)); - if (session->passport_info.sid != NULL) - fprintf(fd, "\n", - session->passport_info.sid); - if (session->passport_info.kv != NULL) - fprintf(fd, "\n", - session->passport_info.kv); - fprintf(fd, "\n"); - fprintf(fd, "\n", - tmp_timestamp); - fprintf(fd, "\n", - rru); - if (session->passport_info.mspauth != NULL) - fprintf(fd, "\n", - session->passport_info.mspauth); - fprintf(fd, "\n", - digest); /* TODO Digest me (huh? -- ChipX86) */ - fprintf(fd, "\n"); - fprintf(fd, "\n"); - fprintf(fd, "
\n"); - fprintf(fd, "\n"); - - if (fclose(fd)) - { - purple_debug_error("msn", - "Error closing temp passport file: %s\n", - g_strerror(errno)); - - /* The user wanted to check his or her email */ - if (cmd->trans && cmd->trans->data) - /* TODO: This error might be a bit technical... */ - purple_notify_error(gc, NULL, - _("Error closing temporary passport file."), NULL); - - g_unlink(session->passport_info.file); - g_free(session->passport_info.file); - session->passport_info.file = NULL; - } -#ifdef _WIN32 - else - { - /* - * Renaming file with .html extension, so that the - * win32 open_url will work. - */ - char *tmp; - - if ((tmp = - g_strdup_printf("%s.html", - session->passport_info.file)) != NULL) - { - if (g_rename(session->passport_info.file, - tmp) == 0) - { - g_free(session->passport_info.file); - session->passport_info.file = tmp; - } - else - g_free(tmp); - } - } -#endif - - /* The user wants to check his or her email */ - if (cmd->trans && cmd->trans->data) - purple_notify_uri(purple_account_get_connection(account), session->passport_info.file); - } + /* The user wants to check his or her email */ + if (cmd->trans && cmd->trans->data) + purple_notify_uri(purple_account_get_connection(account), session->passport_info.mail_url); } /************************************************************************** * Switchboards @@ -1699,7 +1606,7 @@ /* This isn't an official message. */ return; - if (session->passport_info.file == NULL) + if (session->passport_info.mail_url == NULL) { MsnTransaction *trans; trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); @@ -1727,7 +1634,7 @@ const char *url; passport = msn_user_get_passport(session->user); - url = session->passport_info.file; + url = session->passport_info.mail_url; purple_notify_emails(gc, count, FALSE, NULL, NULL, &passport, &url, NULL, NULL); @@ -1766,7 +1673,7 @@ return; } - if (session->passport_info.file == NULL) + if (session->passport_info.mail_url == NULL) { MsnTransaction *trans; trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); @@ -1796,7 +1703,7 @@ const char *url; passport = msn_user_get_passport(session->user); - url = session->passport_info.file; + url = session->passport_info.mail_url; purple_notify_emails(gc, count, FALSE, NULL, NULL, &passport, &url, NULL, NULL); @@ -1828,7 +1735,7 @@ /* This isn't an official message. */ return; - if (session->passport_info.file == NULL) + if (session->passport_info.mail_url == NULL) { MsnTransaction *trans; trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); @@ -1858,7 +1765,7 @@ (subject != NULL ? subject : ""), (from != NULL ? from : ""), msn_user_get_passport(session->user), - session->passport_info.file, NULL, NULL); + session->passport_info.mail_url, NULL, NULL); g_free(from); g_free(subject); diff -r b2609fca4943 -r 7f4b697c6947 libpurple/protocols/msn/oim.c --- a/libpurple/protocols/msn/oim.c Mon Jul 28 05:10:48 2008 +0000 +++ b/libpurple/protocols/msn/oim.c Tue Jul 29 06:12:40 2008 +0000 @@ -692,7 +692,7 @@ { char *unread = xmlnode_get_data(iu_node); const char *passport = msn_user_get_passport(session->user); - const char *url = session->passport_info.file; + const char *url = session->passport_info.mail_url; int count = atoi(unread); /* XXX/khc: pretty sure this is wrong */ diff -r b2609fca4943 -r 7f4b697c6947 libpurple/protocols/msn/session.c --- a/libpurple/protocols/msn/session.c Mon Jul 28 05:10:48 2008 +0000 +++ b/libpurple/protocols/msn/session.c Tue Jul 29 06:12:40 2008 +0000 @@ -80,11 +80,7 @@ g_free(session->passport_info.mspauth); g_free(session->passport_info.client_ip); - if (session->passport_info.file != NULL) - { - g_unlink(session->passport_info.file); - g_free(session->passport_info.file); - } + g_free(session->passport_info.mail_url); if (session->sync != NULL) msn_sync_destroy(session->sync); diff -r b2609fca4943 -r 7f4b697c6947 libpurple/protocols/msn/session.h --- a/libpurple/protocols/msn/session.h Mon Jul 28 05:10:48 2008 +0000 +++ b/libpurple/protocols/msn/session.h Tue Jul 29 06:12:40 2008 +0000 @@ -115,9 +115,9 @@ char *sid; char *mspauth; unsigned long sl; - char *file; char *client_ip; int client_port; + char *mail_url; gulong mail_timestamp; gboolean email_enabled; } passport_info;