Mercurial > pidgin.yaz
changeset 23657:7f4b697c6947
Use a URL to open MSN Hotmail inbox instead of a temporary file.
Based on work by felipec in msn-pecan.
Fixes #5762.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Tue, 29 Jul 2008 06:12:40 +0000 |
parents | b2609fca4943 |
children | 860e5e210fc9 |
files | libpurple/protocols/msn/msn.c libpurple/protocols/msn/notification.c libpurple/protocols/msn/oim.c libpurple/protocols/msn/session.c libpurple/protocols/msn/session.h |
diffstat | 5 files changed, 25 insertions(+), 122 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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("<!-- saved from url=(0013)about:internet -->\n", fd); -#endif - fputs("<html>\n" - "<head>\n" - "<noscript>\n" - "<meta http-equiv=\"Refresh\" content=\"0; " - "url=http://www.hotmail.com\">\n" - "</noscript>\n" - "</head>\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, "<body onload=\"document.pform.submit(); \">\n"); - fprintf(fd, "<form name=\"pform\" action=\"%s\" method=\"POST\">\n\n", - url); - fprintf(fd, "<input type=\"hidden\" name=\"mode\" value=\"ttl\">\n"); - fprintf(fd, "<input type=\"hidden\" name=\"login\" value=\"%s\">\n", - purple_account_get_username(account)); - fprintf(fd, "<input type=\"hidden\" name=\"username\" value=\"%s\">\n", - purple_account_get_username(account)); - if (session->passport_info.sid != NULL) - fprintf(fd, "<input type=\"hidden\" name=\"sid\" value=\"%s\">\n", - session->passport_info.sid); - if (session->passport_info.kv != NULL) - fprintf(fd, "<input type=\"hidden\" name=\"kv\" value=\"%s\">\n", - session->passport_info.kv); - fprintf(fd, "<input type=\"hidden\" name=\"id\" value=\"2\">\n"); - fprintf(fd, "<input type=\"hidden\" name=\"sl\" value=\"%ld\">\n", - tmp_timestamp); - fprintf(fd, "<input type=\"hidden\" name=\"rru\" value=\"%s\">\n", - rru); - if (session->passport_info.mspauth != NULL) - fprintf(fd, "<input type=\"hidden\" name=\"auth\" value=\"%s\">\n", - session->passport_info.mspauth); - fprintf(fd, "<input type=\"hidden\" name=\"creds\" value=\"%s\">\n", - digest); /* TODO Digest me (huh? -- ChipX86) */ - fprintf(fd, "<input type=\"hidden\" name=\"svc\" value=\"mail\">\n"); - fprintf(fd, "<input type=\"hidden\" name=\"js\" value=\"yes\">\n"); - fprintf(fd, "</form></body>\n"); - fprintf(fd, "</html>\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);
--- 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 */
--- 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);
--- 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;