libpurple/protocols/msn/state.c

branch
cpw.khc.msnp14
changeset 20590
633c12c90fd7
parent 20589
312d830f7169
child 20591
8469ac3acbec
equal deleted inserted replaced
20589:312d830f7169 20590:633c12c90fd7
86 char * 86 char *
87 msn_parse_currentmedia(const char *cmedia) 87 msn_parse_currentmedia(const char *cmedia)
88 { 88 {
89 char **cmedia_array; 89 char **cmedia_array;
90 char *inptr, *tmpptr; 90 char *inptr, *tmpptr;
91 GString *buffer; 91 GString *buffer = NULL;
92 int strings, tmp; 92 int strings, tmp;
93 93
94 if ((cmedia == NULL) || (*cmedia == '\0')) { 94 if ((cmedia == NULL) || (*cmedia == '\0')) {
95 purple_debug_info("msn", "No currentmedia string\n"); 95 purple_debug_info("msn", "No currentmedia string\n");
96 return NULL; 96 return NULL;
101 cmedia_array = g_strsplit(cmedia, "\\0", 0); 101 cmedia_array = g_strsplit(cmedia, "\\0", 0);
102 102
103 strings = 0; 103 strings = 0;
104 while (strcmp(cmedia_array[++strings], "")); /* Yes, we want to skip the first empty string, apparently */ 104 while (strcmp(cmedia_array[++strings], "")); /* Yes, we want to skip the first empty string, apparently */
105 105
106 buffer = g_string_new(NULL);
107
108 if ((strings > 3) && (!strcmp(cmedia_array[2], "1"))) { /* Check if enabled */ 106 if ((strings > 3) && (!strcmp(cmedia_array[2], "1"))) { /* Check if enabled */
107 buffer = g_string_new(NULL);
109 inptr = cmedia_array[3]; 108 inptr = cmedia_array[3];
110 109
111 #if 0 110 #if 0
112 if(!strcmp(cmedia_array[1], "Music")) { 111 if(!strcmp(cmedia_array[1], "Music")) {
113 /* The music string seems to be of 'Title - Artist' form. */ 112 /* The music string seems to be of 'Title - Artist' form. */
136 } else { 135 } else {
137 purple_debug_info("msn", "Current media marked disabled, not parsing\n"); 136 purple_debug_info("msn", "Current media marked disabled, not parsing\n");
138 } 137 }
139 138
140 g_strfreev(cmedia_array); 139 g_strfreev(cmedia_array);
141 return g_string_free(buffer, FALSE); 140 return buffer ? g_string_free(buffer, FALSE) : NULL;
142 } 141 }
143 142
144 /* get the CurrentMedia info from the XML string */ 143 /* get the CurrentMedia info from the XML string */
145 char * 144 char *
146 msn_get_currentmedia(char *xml_str, gsize len) 145 msn_get_currentmedia(char *xml_str, gsize len)

mercurial