Mercurial > pidgin.yaz
diff libpurple/protocols/msn/notification.c @ 23522:fd124c21ebb7
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.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 15 Jun 2008 06:55:21 +0000 |
parents | f85450504940 |
children | 31b5a1334e7e |
line wrap: on
line diff
--- 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<br/>\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); }