diff src/protocols/msn/notification.c @ 8646:1e211dde3cae

[gaim-migrate @ 9398] Added a patch by shx to clean up the message-handling code and split the command stuff from it, among a few other things. Also, I fixed a crash in message parsing, which I think may close a couple bug reports. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 13 Apr 2004 04:08:22 +0000
parents 563d47350c7e
children 5747e3fac25a
line wrap: on
line diff
--- a/src/protocols/msn/notification.c	Tue Apr 13 03:53:37 2004 +0000
+++ b/src/protocols/msn/notification.c	Tue Apr 13 04:08:22 2004 +0000
@@ -199,7 +199,7 @@
 			size_t param_count)
 {
 	int errnum = 0;
-	
+
 	if (isdigit(*command)) {
 		errnum = atoi(command);
 
@@ -212,7 +212,7 @@
 			return TRUE;
 		}
 	}
-	
+
 	msn_error_handle(servconn->session, errnum);
 
 	return TRUE;
@@ -451,18 +451,30 @@
 /**************************************************************************
  * Messages
  **************************************************************************/
+static void
+msg_cmd_post(MsnServConn *servconn, char *payload, size_t len)
+{
+	MsnMessage *msg = msn_message_new();
+
+	msg->passport = servconn->msg_passport;
+
+	msn_message_parse_payload(msg, payload, len);
+
+	msn_servconn_process_message(servconn, msg);
+
+	msn_message_destroy(msg);
+}
+
 static gboolean
 msg_cmd(MsnServConn *servconn, const char *command, const char **params,
 		size_t param_count)
 {
 	gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n");
 
-	servconn->parsing_multiline = TRUE;
-	servconn->multiline_type    = MSN_MULTILINE_MSG;
-	servconn->multiline_len     = atoi(params[2]);
+	servconn->payload_cb  = msg_cmd_post;
+	servconn->payload_len = atoi(params[2]);
 
 	servconn->msg_passport = g_strdup(params[0]);
-	servconn->msg_friendly = g_strdup(params[1]);
 
 	return TRUE;
 }
@@ -746,14 +758,8 @@
 ipg_cmd(MsnServConn *servconn, const char *command, const char **params,
 		size_t param_count)
 {
-	/* GaimConnection *gc = servconn->session->account->gc; */
-
-	servconn->parsing_multiline = TRUE;
-	servconn->multiline_type    = MSN_MULTILINE_IPG;
-	servconn->multiline_len     = atoi(params[0]);
-
-	servconn->msg_passport = NULL;
-	servconn->msg_friendly = NULL;
+	servconn->payload_cb  = NULL;
+	servconn->payload_len = atoi(params[2]);
 
 	return TRUE;
 }
@@ -1167,14 +1173,8 @@
 not_cmd(MsnServConn *servconn, const char *command, const char **params,
 		size_t param_count)
 {
-	/* GaimConnection *gc = servconn->session->account->gc; */
-
-	servconn->parsing_multiline = TRUE;
-	servconn->multiline_type    = MSN_MULTILINE_NOT;
-	servconn->multiline_len     = atoi(params[0]);
-
-	servconn->msg_passport = NULL;
-	servconn->msg_friendly = NULL;
+	servconn->payload_cb  = NULL;
+	servconn->payload_len = atoi(params[2]);
 
 	return TRUE;
 }
@@ -1604,7 +1604,9 @@
 									  port))
 		{
 			gaim_connection_error(gc, _("Unable to transfer to "
-									  "notification server"));
+										"notification server"));
+
+			g_free(host);
 
 			return FALSE;
 		}
@@ -1624,7 +1626,7 @@
 	MsnSession *session = servconn->session;
 	const char *value;
 
-	if (strcmp(servconn->msg_passport, "Hotmail")) {
+	if (strcmp(msg->passport, "Hotmail")) {
 		/* This isn't an official message. */
 		return TRUE;
 	}
@@ -1655,7 +1657,7 @@
 	GHashTable *table;
 	const char *unread;
 
-	if (strcmp(servconn->msg_passport, "Hotmail")) {
+	if (strcmp(msg->passport, "Hotmail")) {
 		/* This isn't an official message. */
 		return TRUE;
 	}
@@ -1705,7 +1707,7 @@
 	GHashTable *table;
 	char *from, *subject;
 
-	if (strcmp(servconn->msg_passport, "Hotmail")) {
+	if (strcmp(msg->passport, "Hotmail")) {
 		/* This isn't an official message. */
 		return TRUE;
 	}
@@ -1743,7 +1745,7 @@
 	GHashTable *table;
 	const char *type_s;
 
-	if (strcmp(servconn->msg_passport, "Hotmail")) {
+	if (strcmp(msg->passport, "Hotmail")) {
 		/* This isn't an official message. */
 		return TRUE;
 	}