cpw.qulogic.msnp16: c49e294a: Avoid calling xmlnode_from_str twice whe...

qulogic at pidgin.im qulogic at pidgin.im
Mon Dec 14 02:28:10 EST 2009


-----------------------------------------------------------------
Revision: c49e294a6748adc8bdaeeebf4b42b0548bb03eac
Ancestor: 760b5358091ace33cde641239ad64aa3223a1ce6
Author: qulogic at pidgin.im
Date: 2009-12-09T21:32:33
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/c49e294a6748adc8bdaeeebf4b42b0548bb03eac

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

ChangeLog: 

Avoid calling xmlnode_from_str twice when parsing the UBX data.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	734713fb84ee43b988ed59df30b1c236eadf7427
+++ libpurple/protocols/msn/notification.c	59cefed3c0434ef41752ed9f3c56fbedbacf9837
@@ -1625,6 +1625,7 @@ ubx_cmd_post(MsnCmdProc *cmdproc, MsnCom
 	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 @@ ubx_cmd_post(MsnCmdProc *cmdproc, MsnCom
 	}
 
 	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
============================================================
--- libpurple/protocols/msn/state.c	f65daa3592c8658318bb9216fb733d197446e24d
+++ libpurple/protocols/msn/state.c	0853f9bde58310f799b07ccba51ba4bce7995fcb
@@ -161,19 +161,14 @@ msn_parse_currentmedia(const char *cmedi
 	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 @@ msn_get_currentmedia(char *xml_str, gsiz
 	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");
============================================================
--- libpurple/protocols/msn/state.h	1a3f5281105e5370207665f8ca5c19794fe7e952
+++ libpurple/protocols/msn/state.h	7480506e2b7a9b7d3191f5eee3e85407fa6265ee
@@ -64,11 +64,11 @@ gboolean msn_parse_currentmedia(const ch
 /* 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);
 


More information about the Commits mailing list