changeset 23614:c1e23b9d9cf5

merge of '006d5deacf5a5a7ed5e6410903c3815794845ce9' and 'c6f48a020334f1614d2363fdc8f52c3ea71a0018'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 29 Jul 2008 07:02:18 +0000
parents 3bc912c3874a (current diff) 860e5e210fc9 (diff)
children f4001a130765
files
diffstat 9 files changed, 81 insertions(+), 151 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/contact.c	Tue Jul 29 07:02:18 2008 +0000
@@ -228,8 +228,8 @@
 	msn_soap_message_send(session,
 		msn_soap_message_new(MSN_ADD_ADDRESSBOOK_SOAP_ACTION,
 			xmlnode_from_str(body, -1)),
-		MSN_CONTACT_SERVER, MSN_ADDRESS_BOOK_POST_URL, msn_create_address_cb,
-		session);
+		MSN_CONTACT_SERVER, MSN_ADDRESS_BOOK_POST_URL, FALSE,
+		msn_create_address_cb, session);
 
 	g_free(body);
 }
@@ -415,7 +415,7 @@
 	msn_soap_message_send(session,
 		msn_soap_message_new(MSN_GET_CONTACT_SOAP_ACTION,
 			xmlnode_from_str(body, -1)),
-		MSN_CONTACT_SERVER, MSN_GET_CONTACT_POST_URL,
+		MSN_CONTACT_SERVER, MSN_GET_CONTACT_POST_URL, FALSE,
 		msn_get_contact_list_cb, g_memdup(&cb_data, sizeof(cb_data)));
 
 	g_free(update_str);
@@ -815,8 +815,8 @@
 	msn_soap_message_send(session,
 		msn_soap_message_new(MSN_GET_ADDRESS_SOAP_ACTION,
 			xmlnode_from_str(body, -1)),
-		MSN_CONTACT_SERVER, MSN_ADDRESS_BOOK_POST_URL, msn_get_address_cb,
-		session);
+		MSN_CONTACT_SERVER, MSN_ADDRESS_BOOK_POST_URL, FALSE,
+		msn_get_address_cb, session);
 
 	g_free(update_str);
 	g_free(body);
@@ -917,7 +917,8 @@
 		msn_nexus_get_token_str(state->session->nexus, MSN_AUTH_CONTACTS), -1);
 	msn_soap_message_send(state->session,
 		msn_soap_message_new(state->post_action, xmlnode_copy(state->body)),
-		MSN_CONTACT_SERVER, state->post_url, msn_contact_request_cb, state);
+		MSN_CONTACT_SERVER, state->post_url, FALSE,
+		msn_contact_request_cb, state);
 	return FALSE;
 }
 
--- a/libpurple/protocols/msn/msn.c	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Tue Jul 29 07:02:18 2008 +0000
@@ -428,25 +428,27 @@
 	gc = (PurpleConnection *) action->context;
 	session = gc->proto_data;
 
+	if (!session->passport_info.email_enabled) {
+		purple_notify_error(gc, NULL,
+						  _("This account does not have email enabled."), NULL);
+		return;
+	}
+
 	/** 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;
 
 		cmdproc = session->notification->cmdproc;
 
 		trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX");
-		msn_transaction_set_data(trans, GUINT_TO_POINTER (TRUE));
+		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);
-	}
+	} else
+		purple_notify_uri(gc, session->passport_info.mail_url);
 }
 
 static void
@@ -582,16 +584,23 @@
 {
 	PurpleAccount *account;
 	char *normal;
+	MsnSession *session;
+	MsnUser *user;
 	gboolean ret;
 
 	account = purple_connection_get_account(gc);
 
 	normal = g_strdup(msn_normalize(account, purple_account_get_username(account)));
-
 	ret = strcmp(normal, msn_normalize(account, who));
-
 	g_free(normal);
 
+	if (ret) {
+		session = gc->proto_data;
+		user = msn_userlist_find_user(session->userlist, who);
+		ret = (user->clientid & MSN_CLIENT_CAP_WEBMSGR) == 0;
+		/* Include these too: MSN_CLIENT_CAP_MSNMOBILE|MSN_CLIENT_CAP_MSNDIRECT ? */
+	}
+
 	return ret;
 }
 
@@ -614,14 +623,14 @@
 		if (user->clientid & MSN_CLIENT_CAP_BOT)
 			return "bot";
 		if (user->clientid & MSN_CLIENT_CAP_WIN_MOBILE)
-			return "hiptop"; /* XXX: Rename to Mobile / Use different icon? */
+			return "mobile";
 #if 0
 		/* XXX: Since we don't support this, there's no point in showing it just yet */
 		if (user->clientid & MSN_CLIENT_CAP_SCHANNEL)
 			return "secure";
 #endif
 		if (user->clientid & MSN_CLIENT_CAP_WEBMSGR)
-			return "web";
+			return "external";
 		if (user->networkid == MSN_NETWORK_YAHOO)
 			return "yahoo";
 	}
--- a/libpurple/protocols/msn/nexus.c	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/nexus.c	Tue Jul 29 07:02:18 2008 +0000
@@ -411,7 +411,7 @@
 
 	soap = msn_soap_message_new(NULL, xmlnode_from_str(request, -1));
 	g_free(request);
-	msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL,
+	msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL, TRUE,
 	                      nexus_got_response_cb, nexus);
 }
 
@@ -597,7 +597,7 @@
 
 	soap = msn_soap_message_new(NULL, xmlnode_from_str(request, -1));
 	g_free(request);
-	msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL,
+	msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL, TRUE,
 	                      nexus_got_update_cb, ud);
 }
 
--- a/libpurple/protocols/msn/notification.c	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/notification.c	Tue Jul 29 07:02:18 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
@@ -1666,6 +1573,9 @@
 	if ((value = msn_message_get_attr(msg, "LoginTime")) != NULL)
 		session->passport_info.sl = atol(value);
 
+	if ((value = msn_message_get_attr(msg, "EmailEnabled")) != NULL)
+		session->passport_info.email_enabled = (gboolean)atol(value);
+
 	/*starting retrieve the contact list*/
 	clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL);
 #ifdef MSN_PARTIAL_LISTS
@@ -1696,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");
@@ -1724,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);
@@ -1763,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");
@@ -1793,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);
@@ -1825,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");
@@ -1855,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	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/oim.c	Tue Jul 29 07:02:18 2008 +0000
@@ -219,7 +219,8 @@
 
 	msn_soap_message_send(session,
 		msn_soap_message_new(data->action, xmlnode_copy(data->body)),
-		data->host, data->url, msn_oim_request_cb, data);
+		data->host, data->url, FALSE,
+		msn_oim_request_cb, data);
 }
 
 
@@ -692,7 +693,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	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/session.c	Tue Jul 29 07:02:18 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	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/session.h	Tue Jul 29 07:02:18 2008 +0000
@@ -115,10 +115,11 @@
 		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;
 
 	GHashTable *soap_table;
--- a/libpurple/protocols/msn/soap.c	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/soap.c	Tue Jul 29 07:02:18 2008 +0000
@@ -42,6 +42,7 @@
 typedef struct _MsnSoapRequest {
 	char *path;
 	MsnSoapMessage *message;
+	gboolean secure;
 	MsnSoapCallback cb;
 	gpointer cb_data;
 } MsnSoapRequest;
@@ -76,8 +77,8 @@
 static void msn_soap_connection_handle_next(MsnSoapConnection *conn);
 static void msn_soap_connection_destroy(MsnSoapConnection *conn);
 
-static void msn_soap_message_send_internal(MsnSession *session,
-	MsnSoapMessage *message, const char *host, const char *path,
+static void msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message,
+	const char *host, const char *path, gboolean secure,
 	MsnSoapCallback cb, gpointer cb_data, gboolean first);
 
 static void msn_soap_request_destroy(MsnSoapRequest *req, gboolean keep_message);
@@ -187,8 +188,8 @@
 	char *path;
 
 	if (purple_url_parse(url, &host, NULL, &path, NULL, NULL)) {
-		msn_soap_message_send_internal(conn->session,
-			conn->current_request->message,	host, path,
+		msn_soap_message_send_internal(conn->session, conn->current_request->message,
+			host, path, conn->current_request->secure,
 			conn->current_request->cb, conn->current_request->cb_data, TRUE);
 
 		msn_soap_request_destroy(conn->current_request, TRUE);
@@ -309,6 +310,11 @@
 	char *cursor;
 	char *linebreak;
 
+#ifndef MSN_UNSAFE_DEBUG
+	if (conn->current_request->secure)
+		purple_debug_info("soap", "Received secure request.\n");
+	else
+#endif
 	purple_debug_info("soap", "current %s\n", conn->buf->str);
 
 	cursor = conn->buf->str + conn->handled_len;
@@ -506,6 +512,11 @@
 			g_string_append(conn->buf, "\r\n");
 			g_string_append(conn->buf, body);
 
+#ifndef MSN_UNSAFE_DEBUG
+			if (req->secure)
+				purple_debug_info("soap", "Sending secure request.\n");
+			else
+#endif
 			purple_debug_info("soap", "%s\n", conn->buf->str);
 
 			conn->handled_len = 0;
@@ -534,16 +545,16 @@
 
 void
 msn_soap_message_send(MsnSession *session, MsnSoapMessage *message,
-	const char *host, const char *path,
+	const char *host, const char *path, gboolean secure,
 	MsnSoapCallback cb, gpointer cb_data)
 {
-	msn_soap_message_send_internal(session, message, host, path, cb, cb_data,
-		FALSE);
+	msn_soap_message_send_internal(session, message, host, path, secure,
+		cb, cb_data, FALSE);
 }
 
 static void
-msn_soap_message_send_internal(MsnSession *session,
-	MsnSoapMessage *message, const char *host, const char *path,
+msn_soap_message_send_internal(MsnSession *session, MsnSoapMessage *message,
+	const char *host, const char *path, gboolean secure,
 	MsnSoapCallback cb, gpointer cb_data, gboolean first)
 {
 	MsnSoapConnection *conn = msn_soap_get_connection(session, host);
@@ -551,6 +562,7 @@
 
 	req->path = g_strdup(path);
 	req->message = message;
+	req->secure = secure;
 	req->cb = cb;
 	req->cb_data = cb_data;
 
--- a/libpurple/protocols/msn/soap.h	Tue Jul 29 06:08:58 2008 +0000
+++ b/libpurple/protocols/msn/soap.h	Tue Jul 29 07:02:18 2008 +0000
@@ -47,8 +47,8 @@
 void msn_soap_message_add_header(MsnSoapMessage *req,
 	const char *name, const char *value);
 
-void msn_soap_message_send(MsnSession *session,
-	MsnSoapMessage *message, const char *host, const char *path,
+void msn_soap_message_send(MsnSession *session, MsnSoapMessage *message,
+	const char *host, const char *path, gboolean secure,
 	MsnSoapCallback cb, gpointer cb_data);
 
 void msn_soap_message_destroy(MsnSoapMessage *message);