Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/state.c @ 29368:746bf7d8b34e
Combine the CurrentMedia and MsnUserPhoneInfo structs. This makes
MsnUser smaller by the size of one pointer.
Since both of these structs are used only rarely, this ends up saving
memory for most people.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 05 Feb 2010 02:19:22 +0000 |
parents | 99d1b433dba0 |
children | 462cb893521b 1830fa548302 |
comparison
equal
deleted
inserted
replaced
29367:e137c1fc216a | 29368:746bf7d8b34e |
---|---|
82 xmlnode_insert_child(dataNode, guidNode); | 82 xmlnode_insert_child(dataNode, guidNode); |
83 | 83 |
84 result = xmlnode_to_str(dataNode, &length); | 84 result = xmlnode_to_str(dataNode, &length); |
85 xmlnode_free(dataNode); | 85 xmlnode_free(dataNode); |
86 return result; | 86 return result; |
87 } | |
88 | |
89 CurrentMedia *msn_parse_currentmedia(const char *cmedia) | |
90 { | |
91 char **cmedia_array; | |
92 int strings = 0; | |
93 CurrentMedia *media = NULL; | |
94 | |
95 if (!cmedia || cmedia[0] == '\0') { | |
96 purple_debug_info("msn", "No currentmedia string\n"); | |
97 return NULL; | |
98 } | |
99 | |
100 purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia); | |
101 | |
102 cmedia_array = g_strsplit(cmedia, "\\0", 0); | |
103 | |
104 /* | |
105 * 0: Application | |
106 * 1: 'Music'/'Games'/'Office' | |
107 * 2: '1' if enabled, '0' if not | |
108 * 3: Format (eg. {0} by {1}) | |
109 * 4: Title | |
110 * If 'Music': | |
111 * 5: Artist | |
112 * 6: Album | |
113 * 7: ? | |
114 */ | |
115 #if GLIB_CHECK_VERSION(2,6,0) | |
116 strings = g_strv_length(cmedia_array); | |
117 #else | |
118 while (cmedia_array[++strings] != NULL); | |
119 #endif | |
120 | |
121 if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { | |
122 media = g_new(CurrentMedia, 1); | |
123 | |
124 if (!strcmp(cmedia_array[1], "Music")) | |
125 media->type = CURRENT_MEDIA_MUSIC; | |
126 else if (!strcmp(cmedia_array[1], "Games")) | |
127 media->type = CURRENT_MEDIA_GAMES; | |
128 else if (!strcmp(cmedia_array[1], "Office")) | |
129 media->type = CURRENT_MEDIA_OFFICE; | |
130 else | |
131 media->type = CURRENT_MEDIA_UNKNOWN; | |
132 | |
133 media->title = g_strdup(cmedia_array[strings == 4 ? 3 : 4]); | |
134 media->artist = strings > 5 ? g_strdup(cmedia_array[5]) : NULL; | |
135 media->album = strings > 6 ? g_strdup(cmedia_array[6]) : NULL; | |
136 } | |
137 | |
138 g_strfreev(cmedia_array); | |
139 | |
140 return media; | |
141 } | 87 } |
142 | 88 |
143 /* get the CurrentMedia info from the XML string */ | 89 /* get the CurrentMedia info from the XML string */ |
144 char * | 90 char * |
145 msn_get_currentmedia(char *xml_str, gsize len) | 91 msn_get_currentmedia(char *xml_str, gsize len) |