Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/state.c @ 22793:6b182ab4bc05
Leak plug in parsing MSN currentmedia.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 02 May 2008 21:09:59 +0000 |
parents | c80d0732fa40 |
children | 05cb3f04c01e |
comparison
equal
deleted
inserted
replaced
22792:dec78ddd46aa | 22793:6b182ab4bc05 |
---|---|
85 /* parse CurrentMedia string */ | 85 /* parse CurrentMedia string */ |
86 gboolean | 86 gboolean |
87 msn_parse_currentmedia(const char *cmedia, CurrentMedia *media) | 87 msn_parse_currentmedia(const char *cmedia, CurrentMedia *media) |
88 { | 88 { |
89 char **cmedia_array; | 89 char **cmedia_array; |
90 int strings; | 90 int strings = 0; |
91 gboolean parsed = FALSE; | |
91 | 92 |
92 if ((cmedia == NULL) || (*cmedia == '\0')) { | 93 if ((cmedia == NULL) || (*cmedia == '\0')) { |
93 purple_debug_info("msn", "No currentmedia string\n"); | 94 purple_debug_info("msn", "No currentmedia string\n"); |
94 return FALSE; | 95 return FALSE; |
95 } | 96 } |
106 * 4: Title | 107 * 4: Title |
107 * 5: Artist | 108 * 5: Artist |
108 * 6: Album | 109 * 6: Album |
109 * 7: ? | 110 * 7: ? |
110 */ | 111 */ |
111 strings = 0; | 112 #if GLIB_CHECK_VERSION(2,6,0) |
113 strings = g_strv_length(cmedia_array); | |
114 #else | |
112 while (cmedia_array[++strings] != NULL); | 115 while (cmedia_array[++strings] != NULL); |
113 | 116 #endif |
114 if (strings < 4) | 117 |
115 return FALSE; | 118 if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { |
116 if (strcmp(cmedia_array[2], "1")) | 119 parsed = TRUE; |
117 return FALSE; | 120 |
118 | 121 g_free(media->title); |
119 if (strings == 4) { | 122 if (strings == 4) { |
120 media->title = g_strdup(cmedia_array[3]); | 123 media->title = g_strdup(cmedia_array[3]); |
121 } else { | 124 } else { |
122 media->title = g_strdup(cmedia_array[4]); | 125 media->title = g_strdup(cmedia_array[4]); |
123 } | 126 } |
124 | 127 |
125 if (strings > 5) | 128 g_free(media->artist); |
126 media->artist = g_strdup(cmedia_array[5]); | 129 if (strings > 5) |
127 else | 130 media->artist = g_strdup(cmedia_array[5]); |
128 media->artist = NULL; | 131 else |
129 | 132 media->artist = NULL; |
130 if (strings > 6) | 133 |
131 media->album = g_strdup(cmedia_array[6]); | 134 g_free(media->album); |
132 else | 135 if (strings > 6) |
133 media->album = NULL; | 136 media->album = g_strdup(cmedia_array[6]); |
134 | 137 else |
135 return TRUE; | 138 media->album = NULL; |
139 | |
140 } | |
141 | |
142 g_strfreev(cmedia_array); | |
143 | |
144 return parsed; | |
136 } | 145 } |
137 | 146 |
138 /* get the CurrentMedia info from the XML string */ | 147 /* get the CurrentMedia info from the XML string */ |
139 char * | 148 char * |
140 msn_get_currentmedia(char *xml_str, gsize len) | 149 msn_get_currentmedia(char *xml_str, gsize len) |