Mercurial > pidgin
comparison libpurple/protocols/msn/state.c @ 25237:401f548e3544
propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f)
to branch 'org.darkrain42.pidgin.buddy-add' (head 6831808999a270f8c1a128c7430a73d3dc0bfae2)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 21 Dec 2008 18:32:37 +0000 |
parents | 7a5f6ddd11b1 |
children | 4ea0f3edd973 d971b6a6be2c |
comparison
equal
deleted
inserted
replaced
25172:125cac3e24ee | 25237:401f548e3544 |
---|---|
98 purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia); | 98 purple_debug_info("msn", "Parsing currentmedia string: \"%s\"\n", cmedia); |
99 | 99 |
100 cmedia_array = g_strsplit(cmedia, "\\0", 0); | 100 cmedia_array = g_strsplit(cmedia, "\\0", 0); |
101 | 101 |
102 /* | 102 /* |
103 * 0: Media Player | 103 * 0: Application |
104 * 1: 'Music' | 104 * 1: 'Music'/'Games'/'Office' |
105 * 2: '1' if enabled, '0' if not | 105 * 2: '1' if enabled, '0' if not |
106 * 3: Format (eg. {0} by {1}) | 106 * 3: Format (eg. {0} by {1}) |
107 * 4: Title | 107 * 4: Title |
108 * 5: Artist | 108 * If 'Music': |
109 * 6: Album | 109 * 5: Artist |
110 * 7: ? | 110 * 6: Album |
111 * 7: ? | |
111 */ | 112 */ |
112 #if GLIB_CHECK_VERSION(2,6,0) | 113 #if GLIB_CHECK_VERSION(2,6,0) |
113 strings = g_strv_length(cmedia_array); | 114 strings = g_strv_length(cmedia_array); |
114 #else | 115 #else |
115 while (cmedia_array[++strings] != NULL); | 116 while (cmedia_array[++strings] != NULL); |
116 #endif | 117 #endif |
117 | 118 |
118 if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { | 119 if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { |
119 parsed = TRUE; | 120 parsed = TRUE; |
120 | 121 |
122 if (!strcmp(cmedia_array[1], "Music")) | |
123 media->type = CURRENT_MEDIA_MUSIC; | |
124 else if (!strcmp(cmedia_array[1], "Games")) | |
125 media->type = CURRENT_MEDIA_GAMES; | |
126 else if (!strcmp(cmedia_array[1], "Office")) | |
127 media->type = CURRENT_MEDIA_OFFICE; | |
128 else | |
129 media->type = CURRENT_MEDIA_UNKNOWN; | |
130 | |
121 g_free(media->title); | 131 g_free(media->title); |
122 if (strings == 4) { | 132 if (strings == 4) { |
123 media->title = g_strdup(cmedia_array[3]); | 133 media->title = g_strdup(cmedia_array[3]); |
124 } else { | 134 } else { |
125 media->title = g_strdup(cmedia_array[4]); | 135 media->title = g_strdup(cmedia_array[4]); |
197 } | 207 } |
198 | 208 |
199 static char * | 209 static char * |
200 create_media_string(PurplePresence *presence) | 210 create_media_string(PurplePresence *presence) |
201 { | 211 { |
202 const char *artist, *title, *album; | 212 const char *title, *game, *office; |
203 char *ret; | 213 char *ret; |
204 PurpleStatus *status = purple_presence_get_status(presence, "tune"); | 214 PurpleStatus *status = purple_presence_get_status(presence, "tune"); |
205 if (!status || !purple_status_is_active(status)) | 215 if (!status || !purple_status_is_active(status)) |
206 return g_strdup_printf("WMP\\0Music\\00\\0{0} - {1}\\0\\0\\0\\0\\0"); | 216 return g_strdup_printf("\\0Music\\00\\0\\0"); |
207 | 217 |
208 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); | |
209 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); | 218 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); |
210 album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); | 219 game = purple_status_get_attr_string(status, "game"); |
211 | 220 office = purple_status_get_attr_string(status, "office"); |
212 ret = g_strdup_printf("WMP\\0Music\\0%c\\0{0} - {1}\\0%s\\0%s\\0%s\\0\\0", | 221 |
213 (title && *title) ? '1' : '0', | 222 if (title && *title) { |
214 title ? title : "", | 223 const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); |
215 artist ? artist : "", | 224 const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); |
216 album ? album : ""); | 225 ret = g_strdup_printf("WMP\\0Music\\01\\0{0}%s%s\\0%s\\0%s\\0%s\\0", |
226 artist ? " - {1}" : "", | |
227 album ? " ({2})" : "", | |
228 title, | |
229 artist ? artist : "", | |
230 album ? album : ""); | |
231 } | |
232 else if (game && *game) | |
233 ret = g_strdup_printf("\\0Games\\01\\0Playing {0}\\0%s\\0", game); | |
234 else if (office && *office) | |
235 ret = g_strdup_printf("\\0Office\\01\\0Editing {0}\\0%s\\0", office); | |
236 else | |
237 ret = g_strdup_printf("\\0Music\\00\\0\\0"); | |
238 | |
217 return ret; | 239 return ret; |
218 } | 240 } |
219 | 241 |
220 /* set the MSN's PSM info,Currently Read from the status Line | 242 /* set the MSN's PSM info,Currently Read from the status Line |
221 * Thanks for Cris Code | 243 * Thanks for Cris Code |