changeset 28421:1a9e56e2097a

merge of '5d9456311f879116a0aa9a4e39d9262030f2f79e' and 'e2c65b46e0e67251bcbbcb45a18222aca71132bc'
author Paul Aurich <paul@darkrain42.org>
date Sat, 22 Aug 2009 23:33:44 +0000
parents 7cebd7602c6e (diff) 7921a53b94b3 (current diff)
children 74ce58c7bc30 fd2dd4039cb4
files
diffstat 2 files changed, 47 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Sat Aug 22 23:32:38 2009 +0000
+++ b/libpurple/protocols/msn/msn.c	Sat Aug 22 23:33:44 2009 +0000
@@ -265,6 +265,7 @@
 	MsnSession *session;
 	MsnCmdProc *cmdproc;
 	MsnPage *page;
+	MsnMessage *msg;
 	MsnUser *user;
 	char *payload = NULL;
 	const char *mobile_number = NULL;
@@ -295,6 +296,9 @@
 	msn_transaction_set_payload(trans, payload, payload_len);
 	g_free(payload);
 
+	msg = msn_message_new_plain(entry);
+	msn_transaction_set_data(trans, msg);
+
 	msn_page_destroy(page);
 
 	msn_cmdproc_send_trans(cmdproc, trans);
--- a/libpurple/protocols/msn/notification.c	Sat Aug 22 23:32:38 2009 +0000
+++ b/libpurple/protocols/msn/notification.c	Sat Aug 22 23:33:44 2009 +0000
@@ -599,6 +599,8 @@
 		/* Decrement the count for unknown results so that we'll continue login.
 		   Also, need to finish the login process here as well, because ADL OK
 		   will not be called. */
+		if (purple_debug_is_verbose())
+			purple_debug_info("msn", "ADL/FQY count is %d\n", session->adl_fqy);
 		if (--session->adl_fqy == 0)
 			msn_session_finish_login(session);
 		return;
@@ -680,6 +682,9 @@
 
 				/* ADL's are returned all-together */
 				session->adl_fqy++;
+				if (purple_debug_is_verbose())
+					purple_debug_info("msn", "Posting ADL, count is %d\n",
+					                  session->adl_fqy);
 
 				msn_notification_post_adl(session->notification->cmdproc,
 					payload, payload_len);
@@ -694,6 +699,9 @@
 		} else {
 			/* FQY's are returned one-at-a-time */
 			session->adl_fqy++;
+			if (purple_debug_is_verbose())
+				purple_debug_info("msn", "Adding FQY address, count is %d\n",
+				                  session->adl_fqy);
 
 			msn_add_contact_xml(session, fqy_node, user->passport,
 				0, user->networkid);
@@ -718,6 +726,9 @@
 
 		/* ADL's are returned all-together */
 		session->adl_fqy++;
+		if (purple_debug_is_verbose())
+			purple_debug_info("msn", "Posting ADL, count is %d\n",
+			                  session->adl_fqy);
 
 		msn_notification_post_adl(session->notification->cmdproc, payload, payload_len);
 
@@ -809,6 +820,9 @@
 
 	if (!strcmp(cmd->params[1], "OK")) {
 		/* ADL ack */
+		if (purple_debug_is_verbose())
+			purple_debug_info("msn", "ADL ACK, count is %d\n",
+			                  session->adl_fqy);
 		if (--session->adl_fqy == 0)
 			msn_session_finish_login(session);
 	} else {
@@ -1178,14 +1192,36 @@
 	id = xmlnode_get_attrib(msg, "id");
 
 	if (id && !strcmp(id, "407")) {
-		/* TODO: Use this to NAK the transaction, maybe print the text, too.
-		unsigned int trId;
-		id = xmlnode_get_attrib(payloadNode, "id");
-		trId = atol(id);
-		*/
-		purple_conv_present_error(who, gc->account,
-			_("Mobile message was not sent because it was too long."));
+		PurpleConversation *conv
+			= purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
+			                                        who, gc->account);
+		if (conv != NULL) {
+			purple_conversation_write(conv, NULL,
+			                          _("Mobile message was not sent because it was too long."),
+			                          PURPLE_MESSAGE_ERROR, time(NULL));
+
+			if ((id = xmlnode_get_attrib(payloadNode, "id")) != NULL) {
+				unsigned int trId = atol(id);
+				MsnTransaction *trans;
+				MsnMessage *msg;
 
+				trans = msn_history_find(cmdproc->history, trId);
+				msg = (MsnMessage *)trans->data;
+
+				if (msg) {
+					char *body_str = msn_message_to_string(msg);
+					char *body_enc = g_markup_escape_text(body_str, -1);
+
+					purple_conversation_write(conv, NULL, body_enc,
+					                          PURPLE_MESSAGE_RAW, time(NULL));
+
+					g_free(body_str);
+					g_free(body_enc);
+					msn_message_destroy(msg);
+					trans->data = NULL;
+				}
+			}
+		}
 	} else {
 		serv_got_im(gc, who, text, 0, time(NULL));
 	}