# HG changeset patch # User Elliott Sales de Andrade # Date 1260394353 0 # Node ID 3140627b93e7acd1eddf155a137559d7eecbad8b # Parent 0a22d67651ce23272d4b04830bbccfb451b0a6d2 Avoid calling xmlnode_from_str twice when parsing the UBX data. diff -r 0a22d67651ce -r 3140627b93e7 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Wed Dec 09 21:29:29 2009 +0000 +++ b/libpurple/protocols/msn/notification.c Wed Dec 09 21:32:33 2009 +0000 @@ -1625,6 +1625,7 @@ PurpleAccount *account; MsnUser *user; const char *passport; + xmlnode *payloadNode; char *psm_str, *str; CurrentMedia media = {CURRENT_MEDIA_UNKNOWN, NULL, NULL, NULL}; @@ -1642,11 +1643,22 @@ } if (len != 0) { - psm_str = msn_get_psm(cmd->payload,len); + payloadNode = xmlnode_from_str(payload, len); + if (!payloadNode) { + purple_debug_error("msn", "UBX XML parse Error!\n"); + + msn_user_set_statusline(user, NULL); + msn_user_set_currentmedia(user, NULL); + + msn_user_update(user); + return; + } + + psm_str = msn_get_psm(payloadNode); msn_user_set_statusline(user, psm_str); g_free(psm_str); - str = msn_get_currentmedia(cmd->payload, len); + str = msn_get_currentmedia(payloadNode); if (msn_parse_currentmedia(str, &media)) msn_user_set_currentmedia(user, &media); else diff -r 0a22d67651ce -r 3140627b93e7 libpurple/protocols/msn/state.c --- a/libpurple/protocols/msn/state.c Wed Dec 09 21:29:29 2009 +0000 +++ b/libpurple/protocols/msn/state.c Wed Dec 09 21:32:33 2009 +0000 @@ -161,19 +161,14 @@ return parsed; } -/* get the CurrentMedia info from the XML string */ +/* get the CurrentMedia info from the XML node */ char * -msn_get_currentmedia(char *xml_str, gsize len) +msn_get_currentmedia(xmlnode *payloadNode) { - xmlnode *payloadNode, *currentmediaNode; + xmlnode *currentmediaNode; char *currentmedia; purple_debug_info("msn", "Get CurrentMedia\n"); - payloadNode = xmlnode_from_str(xml_str, len); - if (!payloadNode) { - purple_debug_error("msn", "PSM XML parse Error!\n"); - return NULL; - } currentmediaNode = xmlnode_get_child(payloadNode, "CurrentMedia"); if (currentmediaNode == NULL) { purple_debug_info("msn", "No CurrentMedia Node\n"); @@ -187,19 +182,14 @@ return currentmedia; } -/*get the PSM info from the XML string*/ +/* Get the PSM info from the XML node */ char * -msn_get_psm(char *xml_str, gsize len) +msn_get_psm(xmlnode *payloadNode) { - xmlnode *payloadNode, *psmNode; + xmlnode *psmNode; char *psm; purple_debug_info("msn", "msn get PSM\n"); - payloadNode = xmlnode_from_str(xml_str, len); - if (!payloadNode) { - purple_debug_error("msn", "PSM XML parse Error!\n"); - return NULL; - } psmNode = xmlnode_get_child(payloadNode, "PSM"); if (psmNode == NULL) { purple_debug_info("msn", "No PSM status Node\n"); diff -r 0a22d67651ce -r 3140627b93e7 libpurple/protocols/msn/state.h --- a/libpurple/protocols/msn/state.h Wed Dec 09 21:29:29 2009 +0000 +++ b/libpurple/protocols/msn/state.h Wed Dec 09 21:32:33 2009 +0000 @@ -64,11 +64,11 @@ /* Parse CurrentMedia string */ gboolean msn_parse_currentmedia(const char *cmedia, CurrentMedia *media); -/* Get the CurrentMedia info from the XML string */ -char * msn_get_currentmedia(char *xml_str,gsize len); +/* Get the CurrentMedia info from the XML node */ +char * msn_get_currentmedia(xmlnode *payloadNode); -/*get the PSM info from the XML string*/ -char * msn_get_psm(char *xml_str,gsize len); +/* Get the PSM info from the XML node */ +char * msn_get_psm(xmlnode *payloadNode); MsnAwayType msn_state_from_account(PurpleAccount *account);