# HG changeset patch # User Elliott Sales de Andrade # Date 1216272348 0 # Node ID ab70eae012f5abe1f3ca431477ef5db1ecba0a50 # Parent 2a4341e3d2da8a0b8b383d1172f37d687c73f2fb Fixup MSN mailbox handling based on a patch from Felipe, plus various other things that I cleaned up in the URL command handler. Updates are now made after at least 750 seconds because Felipe found that to be the magic value, and updating every time we receive a QNG is totally unreliable. They aren't even received when using the HTTP method, for example. Opening the inbox is now always available. I'm not sure why it was limited to just @hotmail.com and @msn.com, but I certainly haven't been testing with either of those. I think the correct way to determine if an inbox exists is to just use the URL command and see, but I don't have one of those no-inbox accounts. The initial email notification is no longer called explicitly for @hotmail.com and @msn.com accounts. I, at least, get an initial mail notification, but the rest of Felipe's patch negates the need to do this, anyway. References #5762. diff -r 2a4341e3d2da -r ab70eae012f5 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Thu Jul 17 04:52:32 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Thu Jul 17 05:25:48 2008 +0000 @@ -428,14 +428,25 @@ gc = (PurpleConnection *) action->context; session = gc->proto_data; - if (session->passport_info.file == NULL) - { + /** apparently the correct value is 777, use 750 as a failsafe */ + if (time (NULL) - session->passport_info.mail_timestamp >= 750) { + MsnTransaction *trans; + MsnCmdProc *cmdproc; + + cmdproc = session->notification->cmdproc; + + trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); + msn_transaction_set_data(trans, GUINT_TO_POINTER (TRUE)); + + msn_cmdproc_send_trans(cmdproc, trans); + + } else if (session->passport_info.file != NULL) { + purple_notify_uri(gc, session->passport_info.file); + + } else { purple_notify_error(gc, NULL, _("This Hotmail account may not be active."), NULL); - return; } - - purple_notify_uri(gc, session->passport_info.file); } static void @@ -824,10 +835,6 @@ static GList * msn_actions(PurplePlugin *plugin, gpointer context) { - PurpleConnection *gc = (PurpleConnection *)context; - PurpleAccount *account; - const char *user; - GList *m = NULL; PurplePluginAction *act; @@ -867,17 +874,10 @@ m = g_list_append(m, act); #endif - account = purple_connection_get_account(gc); - user = msn_normalize(account, purple_account_get_username(account)); - - if ((strstr(user, "@hotmail.") != NULL) || - (strstr(user, "@msn.com") != NULL)) - { - m = g_list_append(m, NULL); - act = purple_plugin_action_new(_("Open Hotmail Inbox"), - msn_show_hotmail_inbox); - m = g_list_append(m, act); - } + m = g_list_append(m, NULL); + act = purple_plugin_action_new(_("Open Hotmail Inbox"), + msn_show_hotmail_inbox); + m = g_list_append(m, act); return m; } diff -r 2a4341e3d2da -r ab70eae012f5 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Thu Jul 17 04:52:32 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Thu Jul 17 05:25:48 2008 +0000 @@ -918,29 +918,7 @@ static void qng_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { - MsnSession *session; - static int count = 0; - const char *passport; - PurpleAccount *account; - - session = cmdproc->session; - account = session->account; - - if (session->passport_info.file == NULL) - return; - - passport = purple_normalize(account, purple_account_get_username(account)); - - if ((strstr(passport, "@hotmail.") == NULL) && - (strstr(passport, "@live.com") == NULL) && - (strstr(passport, "@msn.com") == NULL)) - return; - - if (count++ < 26) - return; - - count = 0; - msn_cmdproc_send(cmdproc, "URL", "%s", "INBOX"); + /* TODO: Call PNG after the timeout specified. */ } @@ -1273,46 +1251,39 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; + PurpleConnection *gc; PurpleAccount *account; const char *rru; const char *url; - PurpleCipher *cipher; - PurpleCipherContext *context; - guchar digest[16]; + PurpleCipherContext *cipher; + gchar digest[33]; FILE *fd; char *buf; - char buf2[3]; - char sendbuf[64]; - int i; + + gulong tmp_timestamp; session = cmdproc->session; account = session->account; + gc = account->gc; rru = cmd->params[1]; url = cmd->params[2]; + session->passport_info.mail_timestamp = time(NULL); + tmp_timestamp = session->passport_info.mail_timestamp - session->passport_info.sl; + buf = g_strdup_printf("%s%lu%s", session->passport_info.mspauth ? session->passport_info.mspauth : "BOGUS", - time(NULL) - session->passport_info.sl, - purple_connection_get_password(account->gc)); + tmp_timestamp, + purple_connection_get_password(gc)); - cipher = purple_ciphers_find_cipher("md5"); - context = purple_cipher_context_new(cipher, NULL); - - purple_cipher_context_append(context, (const guchar *)buf, strlen(buf)); - purple_cipher_context_digest(context, sizeof(digest), digest, NULL); - purple_cipher_context_destroy(context); + cipher = purple_cipher_context_new_by_name("md5", NULL); + purple_cipher_context_append(cipher, (const guchar *)buf, strlen(buf)); + purple_cipher_context_digest_to_str(cipher, sizeof(digest), digest, NULL); + purple_cipher_context_destroy(cipher); g_free(buf); - memset(sendbuf, 0, sizeof(sendbuf)); - - for (i = 0; i < 16; i++) - { - g_snprintf(buf2, sizeof(buf2), "%02x", digest[i]); - strcat(sendbuf, buf2); - } - if (session->passport_info.file != NULL) { g_unlink(session->passport_info.file); @@ -1324,6 +1295,11 @@ 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 { @@ -1355,14 +1331,14 @@ session->passport_info.kv); fprintf(fd, "\n"); fprintf(fd, "\n", - time(NULL) - session->passport_info.sl); + tmp_timestamp); fprintf(fd, "\n", rru); if (session->passport_info.mspauth != NULL) fprintf(fd, "\n", session->passport_info.mspauth); fprintf(fd, "\n", - sendbuf); /* TODO Digest me (huh? -- ChipX86) */ + digest); /* TODO Digest me (huh? -- ChipX86) */ fprintf(fd, "\n"); fprintf(fd, "\n"); fprintf(fd, "\n"); @@ -1374,6 +1350,12 @@ "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; @@ -1402,6 +1384,10 @@ } } #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); } } /************************************************************************** diff -r 2a4341e3d2da -r ab70eae012f5 libpurple/protocols/msn/session.c --- a/libpurple/protocols/msn/session.c Thu Jul 17 04:52:32 2008 +0000 +++ b/libpurple/protocols/msn/session.c Thu Jul 17 05:25:48 2008 +0000 @@ -454,7 +454,6 @@ PurpleAccount *account; PurpleConnection *gc; PurpleStoredImage *img; - const char *passport; if (session->logged_in) return; @@ -474,17 +473,5 @@ /* Sync users */ msn_session_sync_users(session); - /* It seems that some accounts that haven't accessed hotmail for a while - * and @msn.com accounts don't automatically get the initial email - * notification so we always request it on login - */ - - passport = purple_normalize(account, purple_account_get_username(account)); - - if ((strstr(passport, "@hotmail.") != NULL) || - (strstr(passport, "@msn.com") != NULL)) - { - msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX"); - } } diff -r 2a4341e3d2da -r ab70eae012f5 libpurple/protocols/msn/session.h --- a/libpurple/protocols/msn/session.h Thu Jul 17 04:52:32 2008 +0000 +++ b/libpurple/protocols/msn/session.h Thu Jul 17 05:25:48 2008 +0000 @@ -118,6 +118,7 @@ char *file; char *client_ip; int client_port; + gulong mail_timestamp; } passport_info; GHashTable *soap_table;