changeset 9092:9e5a709c30a8

[gaim-migrate @ 9869] More patches by shx. These prevent disconnects with message lengths that are past the allowed MSN message length, fixes pager messages, and provides a better error dialog stuff for MSN errors. I hope I got that all right. :) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 27 May 2004 08:19:29 +0000
parents 97a1fb329cd2
children 6dd02df922b4
files ChangeLog src/protocols/msn/msg.c src/protocols/msn/msn.c src/protocols/msn/page.c src/protocols/msn/page.h src/protocols/msn/servconn.c
diffstat 6 files changed, 49 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 27 08:04:11 2004 +0000
+++ b/ChangeLog	Thu May 27 08:19:29 2004 +0000
@@ -37,6 +37,8 @@
 	  which was due to case-sensitive string comparisons (Gudmundur Olafsson)
 	* Fixed an MSN HTTP method bug where MSN would queue data indefinitely.
 	  (Andrew Wellington)
+	* Overly long messages and paging cell phones in MSN no longer cause
+	  disconnects (Felipe Contreras)
 	* Several bug fixes for MSN's MSNSLP and MSNObject support (Finlay Dobbie)
 	* ALT-F works correctly in the System Log Viewer (Stu Tomlinson)
 	* New tabs should scroll correctly again (Tim Ringenbach)
--- a/src/protocols/msn/msg.c	Thu May 27 08:04:11 2004 +0000
+++ b/src/protocols/msn/msg.c	Thu May 27 08:19:29 2004 +0000
@@ -474,8 +474,13 @@
 	}
 
 	if (ret_size != NULL)
+	{
 		*ret_size = len - 1;
 
+		if (*ret_size > 1664)
+			*ret_size = 1664;
+	}
+
 	return str;
 }
 
--- a/src/protocols/msn/msn.c	Thu May 27 08:04:11 2004 +0000
+++ b/src/protocols/msn/msn.c	Thu May 27 08:19:29 2004 +0000
@@ -159,9 +159,9 @@
 	page = msn_page_new();
 	msn_page_set_body(page, entry);
 
-	trans = msn_transaction_new("PGD", "%s 1 %d", who, page->size);
+	payload = msn_page_gen_payload(page, &payload_len);
 
-	payload = msn_page_gen_payload(page, &payload_len);
+	trans = msn_transaction_new("PGD", "%s 1 %d", who, payload_len);
 
 	msn_transaction_set_payload(trans, payload, payload_len);
 
--- a/src/protocols/msn/page.c	Thu May 27 08:04:11 2004 +0000
+++ b/src/protocols/msn/page.c	Thu May 27 08:19:29 2004 +0000
@@ -22,28 +22,6 @@
 #include "msn.h"
 #include "page.h"
 
-#define GET_NEXT(tmp) \
-	while (*(tmp) && *(tmp) != ' ' && *(tmp) != '\r') \
-		(tmp)++; \
-	if (*(tmp) != '\0') *(tmp)++ = '\0'; \
-	if (*(tmp) == '\n') *(tmp)++; \
-	while (*(tmp) && *(tmp) == ' ') \
-		(tmp)++
-
-#define GET_NEXT_LINE(tmp) \
-	while (*(tmp) && *(tmp) != '\r') \
-		(tmp)++; \
-	if (*(tmp) != '\0') *(tmp)++ = '\0'; \
-	if (*(tmp) == '\n') *(tmp)++
-
-/*
- * <TEXT xml:space="preserve" enc="utf-8"> == 39
- * </TEXT>                                 ==  7
- *                                           ----
- *                                            46
- */
-#define MSN_PAGE_BASE_SIZE 46
-
 MsnPage *
 msn_page_new(void)
 {
@@ -51,8 +29,6 @@
 
 	page = g_new0(MsnPage, 1);
 
-	page->size = MSN_PAGE_BASE_SIZE;
-
 	return page;
 }
 
@@ -84,15 +60,8 @@
 		g_strdup_printf("<TEXT xml:space=\"preserve\" enc=\"utf-8\">%s</TEXT>",
 						msn_page_get_body(page));
 
-	if (page->size != strlen(str))
-	{
-		gaim_debug(GAIM_DEBUG_ERROR, "msn",
-				   "Outgoing page size (%d) and string length (%d) "
-				   "do not match!\n", page->size, strlen(str));
-	}
-
 	if (ret_size != NULL)
-		*ret_size = page->size - 1;
+		*ret_size = strlen(str);
 
 	return str;
 }
@@ -104,14 +73,9 @@
 	g_return_if_fail(body != NULL);
 
 	if (page->body != NULL)
-	{
-		page->size -= strlen(page->body);
 		g_free(page->body);
-	}
 
 	page->body = g_strdup(body);
-
-	page->size += strlen(body);
 }
 
 const char *
@@ -121,4 +85,3 @@
 
 	return page->body;
 }
-
--- a/src/protocols/msn/page.h	Thu May 27 08:04:11 2004 +0000
+++ b/src/protocols/msn/page.h	Thu May 27 08:19:29 2004 +0000
@@ -35,8 +35,6 @@
 	char *from_location;
 	char *from_phone;
 
-	size_t size;
-
 	char *body;
 };
 
--- a/src/protocols/msn/servconn.c	Thu May 27 08:04:11 2004 +0000
+++ b/src/protocols/msn/servconn.c	Thu May 27 08:19:29 2004 +0000
@@ -26,6 +26,43 @@
 static void read_cb(gpointer data, gint source, GaimInputCondition cond);
 
 static void
+show_error(MsnServConn *servconn)
+{
+	GaimConnection *gc;
+	char *tmp;
+	char *cmd;
+
+	const char *names[] = { "Notification", "Switchboard" };
+	const char *name;
+	
+	gc = gaim_account_get_connection(servconn->session->account);
+	name = names[servconn->type];
+
+	switch (servconn->cmdproc->error)
+	{
+		case MSN_ERROR_CONNECT:
+			tmp = g_strdup_printf(_("Unable to connect to %s server"),
+								  name);
+			break;
+		case MSN_ERROR_WRITE:
+			tmp = g_strdup_printf(_("Error writing to %s server"), name);
+			break;
+		case MSN_ERROR_READ:
+			cmd = servconn->cmdproc->last_trans;
+			tmp = g_strdup_printf(_("Error reading from %s server"), name);
+			gaim_debug_info("msn", "Last command was: %s\n", cmd);
+			break;
+		default:
+			tmp = g_strdup_printf(_("Unknown error from %s server"), name);
+			break;
+	}
+
+	gaim_connection_error(gc, tmp);
+	
+	g_free(tmp);
+}
+
+static void
 connect_cb(gpointer data, gint source, GaimInputCondition cond)
 {
 	MsnServConn *servconn = data;
@@ -43,8 +80,8 @@
 	}
 	else
 	{
-		GaimConnection *gc = servconn->session->account->gc;
-		gaim_connection_error(gc, _("Unable to connect."));
+		servconn->cmdproc->error = MSN_ERROR_CONNECT;
+		show_error(servconn);
 	}
 }
 
@@ -192,46 +229,6 @@
 }
 
 static void
-show_error(MsnServConn *servconn)
-{
-	GaimConnection *gc;
-	char *tmp;
-	char *cmd;
-
-	const char *names[] = { "Notification", "Switchboard" };
-	const char *name;
-
-	gc = gaim_account_get_connection(servconn->session->account);
-	name = names[servconn->type];
-
-	switch (servconn->cmdproc->error)
-	{
-		case MSN_ERROR_CONNECT:
-			tmp = g_strdup_printf(_("Unable to connect to %s server"),
-								  name);
-			break;
-		case MSN_ERROR_WRITE:
-			tmp = g_strdup_printf(_("Error writing to %s server"), name);
-			break;
-		case MSN_ERROR_READ:
-			cmd = servconn->cmdproc->last_trans;
-			tmp = g_strdup_printf(_("Error reading from %s server. Last"
-									"command was:\n %s"), name, cmd);
-			break;
-		default:
-			tmp = g_strdup_printf(_("Unknown error from %s server"), name);
-			break;
-	}
-
-	if (servconn->type != MSN_SERVER_SB)
-		gaim_connection_error(gc, tmp);
-	else
-		gaim_notify_error(gc, NULL, tmp, NULL);
-
-	g_free(tmp);
-}
-
-static void
 failed_io(MsnServConn *servconn)
 {
 	show_error(servconn);