pidgin: ac4ea8dd: Use a URL to open MSN Hotmail inbox inst...

qulogic at pidgin.im qulogic at pidgin.im
Tue Jul 29 03:11:12 EDT 2008


-----------------------------------------------------------------
Revision: ac4ea8dd7d88b80021aa72a43b686f2bdc5514d3
Ancestor: 337eed6a3abf681c14acf327e6f8f5cc088cbd4b
Author: qulogic at pidgin.im
Date: 2008-07-29T06:12:40
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ac4ea8dd7d88b80021aa72a43b686f2bdc5514d3

Modified 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

ChangeLog: 

Use a URL to open MSN Hotmail inbox instead of a temporary file. 
Based on work by felipec in msn-pecan.

Fixes #5762.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c	99e56dce8cb2b491566c20b85eb8a555e29be921
+++ libpurple/protocols/msn/msn.c	d71a9dfa8d95d62426e5698bb2dfbcb685062bf2
@@ -435,7 +435,8 @@ msn_show_hotmail_inbox(PurplePluginActio
 	}
 
 	/** 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_show_hotmail_inbox(PurplePluginActio
 
 		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
============================================================
--- libpurple/protocols/msn/notification.c	6eec2269e47806d8ed8f38c52787ff8268ac75cd
+++ libpurple/protocols/msn/notification.c	d4fc00410685ecc86b267b309d0782c89e12b351
@@ -1289,7 +1289,6 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	const char *url;
 	PurpleCipherContext *cipher;
 	gchar digest[33];
-	FILE *fd;
 	char *buf;
 
 	gulong tmp_timestamp;
@@ -1316,111 +1315,19 @@ url_cmd(MsnCmdProc *cmdproc, MsnCommand 
 
 	g_free(buf);
 
-	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);
+	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);
 
-	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);
-
-		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 @@ initial_email_msg(MsnCmdProc *cmdproc, M
 		/* 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 @@ initial_email_msg(MsnCmdProc *cmdproc, M
 			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 @@ initial_mdata_msg(MsnCmdProc *cmdproc, M
 		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 @@ initial_mdata_msg(MsnCmdProc *cmdproc, M
 			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 @@ email_msg(MsnCmdProc *cmdproc, MsnMessag
 		/* 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 @@ email_msg(MsnCmdProc *cmdproc, MsnMessag
 					  (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);
============================================================
--- libpurple/protocols/msn/oim.c	7b95d2fbe39abdeeb2e7925239a3c139f6bfb3ee
+++ libpurple/protocols/msn/oim.c	e9de21ec6181704104a6655a93a184e2056fc3e8
@@ -692,7 +692,7 @@ msn_parse_oim_xml(MsnOim *oim, xmlnode *
 	{
 		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 */
============================================================
--- libpurple/protocols/msn/session.c	c03702e8345fe1dbd39a1199b18f8ed29c52924a
+++ libpurple/protocols/msn/session.c	c68589a526c0a381bcf3e58ace8e5346ad92de2c
@@ -80,11 +80,7 @@ msn_session_destroy(MsnSession *session)
 	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);
============================================================
--- libpurple/protocols/msn/session.h	21c879b9bd5cf7afcad6b1d18b2bc23a10334bb2
+++ libpurple/protocols/msn/session.h	c6739ea3b5f9eb838e0601f341a9a1ac99c06783
@@ -115,9 +115,9 @@ struct _MsnSession
 		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;


More information about the Commits mailing list