cpw.qulogic.msn: 5cfe3cd2: Properly parse (most of) the MSN GCF com...

qulogic at pidgin.im qulogic at pidgin.im
Sun Jun 15 04:25:57 EDT 2008


-----------------------------------------------------------------
Revision: 5cfe3cd23d4a1eb60980e0ad2098d8bf2ba831ce
Ancestor: 74d8e44ec0c60b1e362ada585e3b24dd17f404bd
Author: qulogic at pidgin.im
Date: 2008-06-15T06:55:21
Branch: im.pidgin.cpw.qulogic.msn
URL: http://d.pidgin.im/viewmtn/revision/info/5cfe3cd23d4a1eb60980e0ad2098d8bf2ba831ce

Modified files:
        libpurple/protocols/msn/msn.c
        libpurple/protocols/msn/notification.c
        libpurple/protocols/msn/session.c
        libpurple/protocols/msn/session.h

ChangeLog: 

Properly parse (most of) the MSN GCF command. Provides a 
<Account>->"View Blocked Text" dialog showing the regular expressions 
that the MSN servers are currently blocking. For the people who were 
wondering why their messages were never received.


-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c	4c5f76548f0af42ceb8051f49452b716e0b439ab
+++ libpurple/protocols/msn/msn.c	6f867b546f5a27b833af0dc6c2f2e323271f0157
@@ -394,6 +394,29 @@ static void
 }
 
 static void
+msn_show_blocked_text(PurplePluginAction *action)
+{
+	PurpleConnection *pc = (PurpleConnection *) action->context;
+	MsnSession *session;
+	char *title;
+
+	session = pc->proto_data;
+
+	title = g_strdup_printf(_("Blocked Text for %s"), session->account->username);
+	if (session->blocked_text == NULL) {
+		purple_notify_formatted(pc, title, title, NULL, _("No text is blocked for this account."), NULL, NULL);
+	} else {
+		char *blocked_text;
+		blocked_text = g_strdup_printf(_("MSN servers are currently blocking the following regular expressions:<br/>%s"),
+		                               session->blocked_text);
+		
+		purple_notify_formatted(pc, title, title, NULL, blocked_text, NULL, NULL);
+		g_free(blocked_text);
+	}
+	g_free(title);
+}
+
+static void
 msn_show_hotmail_inbox(PurplePluginAction *action)
 {
 	PurpleConnection *gc;
@@ -809,6 +832,11 @@ msn_actions(PurplePlugin *plugin, gpoint
 			msn_show_set_mobile_pages);
 	m = g_list_append(m, act);
 
+	m = g_list_append(m, NULL);
+	act = purple_plugin_action_new(_("View Blocked Text..."),
+			msn_show_blocked_text);
+	m = g_list_append(m, act);
+
 	account = purple_connection_get_account(gc);
 	user = msn_normalize(account, purple_account_get_username(account));
 
============================================================
--- libpurple/protocols/msn/notification.c	0ae15e6cee7acf9ab5f5fc0c1d35c567cde5d12d
+++ libpurple/protocols/msn/notification.c	5a6bfc91beddb8580feb738650620654ba90db2b
@@ -1612,9 +1612,8 @@ gcf_cmd_post(MsnCmdProc *cmdproc, MsnCom
 gcf_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload,
 			 size_t len)
 {
-	xmlnode * root;
-	gchar * buf;
-	int xmllen;
+	xmlnode *root;
+	xmlnode *policy;
 
 	g_return_if_fail(cmd->payload != NULL);
 
@@ -1624,12 +1623,32 @@ gcf_cmd_post(MsnCmdProc *cmdproc, MsnCom
 		return;
 	}
 
-	buf = xmlnode_to_formatted_str(root, &xmllen);
 
-	/* get the payload content */
-	purple_debug_info("MSNP14","GCF command payload:\n%.*s\n", xmllen, buf);
+	g_free(cmdproc->session->blocked_text);
+	cmdproc->session->blocked_text = NULL;
 
-	g_free(buf);
+	/* We need a get_child with attrib... */
+	policy = xmlnode_get_child(root, "Policy");
+	while (policy) {
+		if (g_str_equal(xmlnode_get_attrib(policy, "type"), "SHIELDS"))
+			break;
+		policy = xmlnode_get_next_twin(policy);
+	}
+
+	if (policy) {
+		GString *blocked = g_string_new(NULL);
+		xmlnode *imtext = xmlnode_get_child(policy,
+		                                    "config/block/regexp/imtext");
+		while (imtext) {
+			const char *value = xmlnode_get_attrib(imtext, "value");
+			g_string_append_printf(blocked, "%s<br/>\n",
+			                       purple_base64_decode(value, NULL));
+			imtext = xmlnode_get_next_twin(imtext);
+		}
+
+		cmdproc->session->blocked_text = g_string_free(blocked, FALSE);
+	}
+
 	xmlnode_free(root);
 }
 
============================================================
--- libpurple/protocols/msn/session.c	d86a70b8a2f5ece8e1034cfdc2a40428ff7ee05d
+++ libpurple/protocols/msn/session.c	10c3fed6ef04dcee45980dffe6a2368e4ea1c1d4
@@ -72,6 +72,9 @@ msn_session_destroy(MsnSession *session)
 	msn_userlist_destroy(session->userlist);
 
 	g_free(session->psm);
+
+	g_free(session->blocked_text);
+
 	g_free(session->passport_info.kv);
 	g_free(session->passport_info.sid);
 	g_free(session->passport_info.mspauth);
============================================================
--- libpurple/protocols/msn/session.h	263228d16feb6c6c745c88a08591408771dd127d
+++ libpurple/protocols/msn/session.h	4d3267f1a7f69fc6bbde267857c35df84daa981e
@@ -107,6 +107,8 @@ struct _MsnSession
 	/*psm info*/
 	char *psm;
 
+	char *blocked_text;
+
 	struct
 	{
 		char *kv;


More information about the Commits mailing list