# HG changeset patch # User Elliott Sales de Andrade # Date 1213512921 0 # Node ID fd124c21ebb7e1014246daf3c18a1e0215e3f904 # Parent 9fdf0accd4aa3fac67788cc13801561997fbdfe7 Properly parse (most of) the MSN GCF command. Provides a ->"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. diff -r 9fdf0accd4aa -r fd124c21ebb7 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Sun Jun 15 06:22:25 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Sun Jun 15 06:55:21 2008 +0000 @@ -394,6 +394,29 @@ } 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:
%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_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)); diff -r 9fdf0accd4aa -r fd124c21ebb7 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Sun Jun 15 06:22:25 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Sun Jun 15 06:55:21 2008 +0000 @@ -1612,9 +1612,8 @@ 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 @@ return; } - buf = xmlnode_to_formatted_str(root, &xmllen); + + g_free(cmdproc->session->blocked_text); + cmdproc->session->blocked_text = NULL; + + /* 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); + } - /* get the payload content */ - purple_debug_info("MSNP14","GCF command payload:\n%.*s\n", xmllen, buf); + 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
\n", + purple_base64_decode(value, NULL)); + imtext = xmlnode_get_next_twin(imtext); + } - g_free(buf); + cmdproc->session->blocked_text = g_string_free(blocked, FALSE); + } + xmlnode_free(root); } diff -r 9fdf0accd4aa -r fd124c21ebb7 libpurple/protocols/msn/session.c --- a/libpurple/protocols/msn/session.c Sun Jun 15 06:22:25 2008 +0000 +++ b/libpurple/protocols/msn/session.c Sun Jun 15 06:55:21 2008 +0000 @@ -72,6 +72,9 @@ 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); diff -r 9fdf0accd4aa -r fd124c21ebb7 libpurple/protocols/msn/session.h --- a/libpurple/protocols/msn/session.h Sun Jun 15 06:22:25 2008 +0000 +++ b/libpurple/protocols/msn/session.h Sun Jun 15 06:55:21 2008 +0000 @@ -107,6 +107,8 @@ /*psm info*/ char *psm; + char *blocked_text; + struct { char *kv;