Mercurial > pidgin
changeset 24705:6f41450584a7
merge of '5f86c51d96715086ed0790a769fd222be570c8ac'
and '68a2ccd3df34ca17e6d788cfcbaf96a605bea2e5'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 08 Dec 2008 17:53:46 +0000 |
parents | acd98ea6c6f9 (current diff) f1936abe1616 (diff) |
children | 8d1ff9c7b889 367b3ddcf5c3 |
files | ChangeLog pidgin/gtkblist.c pidgin/pixmaps/protocols/16/facebook.png pidgin/pixmaps/protocols/22/facebook.png pidgin/pixmaps/protocols/48/facebook.png pidgin/pixmaps/status/48/rtl/login.png pidgin/pixmaps/status/48/rtl/logout.png |
diffstat | 8 files changed, 162 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Dec 08 17:19:52 2008 +0000 +++ b/ChangeLog Mon Dec 08 17:53:46 2008 +0000 @@ -20,6 +20,9 @@ connected (Paul Aurich) * Fix a crash in purple_accounts_delete that happens when this function is called before the buddy list is initialized (Florian Quèze) + * On MSN, the Games and Office media can now be set and displayed (in + addition to the previous Music media). The Media status text now shows + the album, if possible. Gadu-Gadu: * Fix some problems with Gadu-Gadu buddy icons (Adam Strzelecki)
--- a/libpurple/protocols/msn/contact.c Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/contact.c Mon Dec 08 17:53:46 2008 +0000 @@ -176,28 +176,6 @@ return 0; } -/* get Network */ -/* QuLogic: These names don't really refer to the MsnNetwork, - * but I haven't yet written the code to properly use them. - */ -static MsnNetwork -msn_get_network(char *type) -{ - g_return_val_if_fail(type != NULL, 0); - - if (!strcmp(type,"Regular")) { - return MSN_NETWORK_PASSPORT; - } - if (!strcmp(type,"Live")) { - return MSN_NETWORK_PASSPORT; - } - if (!strcmp(type,"LivePending")) { - return MSN_NETWORK_PASSPORT; - } - - return MSN_NETWORK_UNKNOWN; -} - /* Create the AddressBook in the server, if we don't have one */ static void msn_create_address_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data) @@ -245,9 +223,26 @@ char *type = xmlnode_get_data(xmlnode_get_child(member, "Type")); char *member_id = xmlnode_get_data(xmlnode_get_child(member, "MembershipId")); MsnUser *user = msn_userlist_find_add_user(session->userlist, passport, NULL); + xmlnode *annotation; + guint nid = MSN_NETWORK_PASSPORT; - purple_debug_info("msn", "CL: %s name: %s, Type: %s, MembershipID: %s\n", - node, passport, type, member_id == NULL ? "(null)" : member_id); + for (annotation = xmlnode_get_child(member, "Annotations/Annotation"); + annotation; + annotation = xmlnode_get_next_twin(annotation)) { + char *name = xmlnode_get_data(xmlnode_get_child(annotation, "Name")); + if (name && !strcmp(name, "MSN.IM.BuddyType")) { + char *value = xmlnode_get_data(xmlnode_get_child(annotation, "Value")); + if (value != NULL) + nid = strtoul(value, NULL, 10); + g_free(value); + } + g_free(name); + } + + purple_debug_info("msn", "CL: %s name: %s, Type: %s, MembershipID: %s, NetworkID: %u\n", + node, passport, type, member_id == NULL ? "(null)" : member_id, nid); + + msn_user_set_network(user, nid); if (member_id) { user->membership_id[list] = atoi(member_id); @@ -445,16 +440,16 @@ if ((groupInfo = xmlnode_get_child(group, "groupInfo")) && (groupname = xmlnode_get_child(groupInfo, "name"))) group_name = xmlnode_get_data(groupname); - msn_group_new(session->userlist, group_id, group_name); - - if (group_id == NULL){ + if (group_id == NULL) { /* Group of ungroupped buddies */ g_free(group_name); continue; } + msn_group_new(session->userlist, group_id, group_name); + purple_debug_info("msn", "AB group_id: %s, name: %s\n", group_id, group_name ? group_name : "(null)"); - if ((purple_find_group(group_name)) == NULL){ + if ((purple_find_group(group_name)) == NULL) { PurpleGroup *g = purple_group_new(group_name); purple_blist_add_group(g, NULL); } @@ -528,7 +523,6 @@ xmlnode *contactId, *contactInfo, *contactType, *passportName, *displayName, *guid, *groupIds, *messenger_user; xmlnode *annotation; MsnUser *user; - MsnNetwork networkId; if (!(contactId = xmlnode_get_child(contactNode,"contactId")) || !(contactInfo = xmlnode_get_child(contactNode, "contactInfo")) @@ -569,7 +563,6 @@ g_free(is_messenger_user); } - networkId = msn_get_network(type); passportName = xmlnode_get_child(contactInfo, "passportName"); if (passportName == NULL) { xmlnode *emailsNode, *contactEmailNode, *emailNode; @@ -600,7 +593,6 @@ if (msnEnabled && !strcmp(msnEnabled, "true")) { /*Messenger enabled, Get the Passport*/ purple_debug_info("msn", "AB Yahoo User %s\n", passport ? passport : "(null)"); - networkId = MSN_NETWORK_YAHOO; g_free(msnEnabled); break; } else { @@ -628,6 +620,15 @@ name = xmlnode_get_data(xmlnode_get_child(annotation, "Name")); if (!strcmp(name, "AB.NickName")) alias = xmlnode_get_data(xmlnode_get_child(annotation, "Value")); + else if (!strcmp(name, "MSN.IM.HasSharedFolder")) + ; /* Do nothing yet... */ + else if (!strcmp(name, "AB.Spouse")) + ; /* Do nothing yet... */ + else if (!strcmp(name, "MSN.Mobile.ContactId")) + ; /* Do nothing yet... */ + else + purple_debug_info("msn", + "Unknown AB contact annotation: %s\n", name); g_free(name); } @@ -639,7 +640,6 @@ user = msn_userlist_find_add_user(session->userlist, passport, Name); msn_user_set_uid(user, uid); - msn_user_set_network(user, networkId); msn_user_set_mobile_phone(user, mobile_number); groupIds = xmlnode_get_child(contactInfo, "groupIds");
--- a/libpurple/protocols/msn/msn.c Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Mon Dec 08 17:53:46 2008 +0000 @@ -647,25 +647,41 @@ presence = purple_buddy_get_presence(buddy); status = purple_presence_get_active_status(presence); - /* I think status message should take precedence over media */ - msg = purple_status_get_attr_string(status, "message"); - if (msg && *msg) - return g_markup_escape_text(msg, -1); - if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { - const char *title, *artist; + const char *title, *game, *office; char *media, *esc; status = purple_presence_get_status(presence, "tune"); title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); - artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); - - media = g_strdup_printf("%s%s%s", title, artist ? " - " : "", - artist ? artist : ""); + + game = purple_status_get_attr_string(status, "game"); + office = purple_status_get_attr_string(status, "office"); + + if (title && *title) { + const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); + const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); + media = g_strdup_printf("%s%s%s%s%s%s", title, + (artist && *artist) ? " - " : "", + (artist && *artist) ? artist : "", + (album && *album) ? " (" : "", + (album && *album) ? album : "", + (album && *album) ? ")" : ""); + } + else if (game && *game) + media = g_strdup_printf("Playing %s", game); + else if (office && *office) + media = g_strdup_printf("Editing %s", office); + else + return NULL; esc = g_markup_escape_text(media, -1); g_free(media); return esc; } + /* Official client says media takes precedence over message */ + msg = purple_status_get_attr_string(status, "message"); + if (msg && *msg) + return g_markup_escape_text(msg, -1); + return NULL; } @@ -681,6 +697,7 @@ if (purple_presence_is_online(presence)) { const char *psm, *name; + const char *mediatype = NULL; char *currentmedia = NULL; char *tmp; @@ -688,10 +705,20 @@ if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { PurpleStatus *tune = purple_presence_get_status(presence, "tune"); const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); - const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); - const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); - currentmedia = purple_util_format_song_info(title, artist, album, NULL); - /* We could probably just use user->media.title etc. here */ + const char *game = purple_status_get_attr_string(tune, "game"); + const char *office = purple_status_get_attr_string(tune, "office"); + if (title && *title) { + const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); + const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); + mediatype = _("Now Listening"); + currentmedia = purple_util_format_song_info(title, artist, album, NULL); + } else if (game && *game) { + mediatype = _("Playing a game"); + currentmedia = g_strdup(game); + } else if (office && *office) { + mediatype = _("Working"); + currentmedia = g_strdup(office); + } } if (!purple_status_is_available(status)) { @@ -745,7 +772,7 @@ } if (currentmedia) { - purple_notify_user_info_add_pair(user_info, _("Now Listening"), currentmedia); + purple_notify_user_info_add_pair(user_info, mediatype, currentmedia); g_free(currentmedia); } } @@ -840,6 +867,8 @@ PURPLE_TUNE_ARTIST, _("Artist"), purple_value_new(PURPLE_TYPE_STRING), PURPLE_TUNE_ALBUM, _("Album"), purple_value_new(PURPLE_TYPE_STRING), PURPLE_TUNE_TITLE, _("Title"), purple_value_new(PURPLE_TYPE_STRING), + "game", _("Game Title"), purple_value_new(PURPLE_TYPE_STRING), + "office", _("Office Title"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, status);
--- a/libpurple/protocols/msn/notification.c Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Mon Dec 08 17:53:46 2008 +0000 @@ -1578,7 +1578,7 @@ MsnUser *user; const char *passport; char *psm_str, *str; - CurrentMedia media = {NULL, NULL, NULL}; + CurrentMedia media = {CURRENT_MEDIA_UNKNOWN, NULL, NULL, NULL}; session = cmdproc->session; account = session->account;
--- a/libpurple/protocols/msn/state.c Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/state.c Mon Dec 08 17:53:46 2008 +0000 @@ -100,14 +100,15 @@ cmedia_array = g_strsplit(cmedia, "\\0", 0); /* - * 0: Media Player - * 1: 'Music' + * 0: Application + * 1: 'Music'/'Games'/'Office' * 2: '1' if enabled, '0' if not * 3: Format (eg. {0} by {1}) * 4: Title - * 5: Artist - * 6: Album - * 7: ? + * If 'Music': + * 5: Artist + * 6: Album + * 7: ? */ #if GLIB_CHECK_VERSION(2,6,0) strings = g_strv_length(cmedia_array); @@ -118,6 +119,15 @@ if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { parsed = TRUE; + if (!strcmp(cmedia_array[1], "Music")) + media->type = CURRENT_MEDIA_MUSIC; + else if (!strcmp(cmedia_array[1], "Games")) + media->type = CURRENT_MEDIA_GAMES; + else if (!strcmp(cmedia_array[1], "Office")) + media->type = CURRENT_MEDIA_OFFICE; + else + media->type = CURRENT_MEDIA_UNKNOWN; + g_free(media->title); if (strings == 4) { media->title = g_strdup(cmedia_array[3]); @@ -199,21 +209,33 @@ static char * create_media_string(PurplePresence *presence) { - const char *artist, *title, *album; + const char *title, *game, *office; char *ret; PurpleStatus *status = purple_presence_get_status(presence, "tune"); if (!status || !purple_status_is_active(status)) - return g_strdup_printf("WMP\\0Music\\00\\0{0} - {1}\\0\\0\\0\\0\\0"); + return g_strdup_printf("\\0Music\\00\\0\\0"); - artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); - album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); + game = purple_status_get_attr_string(status, "game"); + office = purple_status_get_attr_string(status, "office"); - ret = g_strdup_printf("WMP\\0Music\\0%c\\0{0} - {1}\\0%s\\0%s\\0%s\\0\\0", - (title && *title) ? '1' : '0', - title ? title : "", - artist ? artist : "", - album ? album : ""); + if (title && *title) { + const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); + const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM); + ret = g_strdup_printf("WMP\\0Music\\01\\0{0}%s%s\\0%s\\0%s\\0%s\\0", + artist ? " - {1}" : "", + album ? " ({2})" : "", + title, + artist ? artist : "", + album ? album : ""); + } + else if (game && *game) + ret = g_strdup_printf("\\0Games\\01\\0Playing {0}\\0%s\\0", game); + else if (office && *office) + ret = g_strdup_printf("\\0Office\\01\\0Editing {0}\\0%s\\0", office); + else + ret = g_strdup_printf("\\0Music\\00\\0\\0"); + return ret; }
--- a/libpurple/protocols/msn/user.c Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/user.c Mon Dec 08 17:53:46 2008 +0000 @@ -106,12 +106,25 @@ purple_prpl_got_user_status_deactive(account, user->passport, "mobile"); } - if (!offline && user->media.title) { - purple_prpl_got_user_status(account, user->passport, "tune", - PURPLE_TUNE_ARTIST, user->media.artist, - PURPLE_TUNE_ALBUM, user->media.album, - PURPLE_TUNE_TITLE, user->media.title, - NULL); + if (!offline && user->media.type != CURRENT_MEDIA_UNKNOWN) { + if (user->media.type == CURRENT_MEDIA_MUSIC) { + purple_prpl_got_user_status(account, user->passport, "tune", + PURPLE_TUNE_ARTIST, user->media.artist, + PURPLE_TUNE_ALBUM, user->media.album, + PURPLE_TUNE_TITLE, user->media.title, + NULL); + } else if (user->media.type == CURRENT_MEDIA_GAMES) { + purple_prpl_got_user_status(account, user->passport, "tune", + "game", user->media.title, + NULL); + } else if (user->media.type == CURRENT_MEDIA_OFFICE) { + purple_prpl_got_user_status(account, user->passport, "tune", + "office", user->media.title, + NULL); + } else { + purple_debug_warning("msn", "Got CurrentMedia with unknown type %d.\n", + user->media.type); + } } else { purple_prpl_got_user_status_deactive(account, user->passport, "tune"); } @@ -191,6 +204,7 @@ g_free(user->media.album); g_free(user->media.artist); + user->media.type = media ? media->type : CURRENT_MEDIA_UNKNOWN; user->media.title = media ? g_strdup(media->title) : NULL; user->media.artist = media ? g_strdup(media->artist) : NULL; user->media.album = media ? g_strdup(media->album) : NULL;
--- a/libpurple/protocols/msn/user.h Mon Dec 08 17:19:52 2008 +0000 +++ b/libpurple/protocols/msn/user.h Mon Dec 08 17:53:46 2008 +0000 @@ -45,11 +45,20 @@ /** * Current media. */ +typedef enum +{ + CURRENT_MEDIA_UNKNOWN, + CURRENT_MEDIA_MUSIC, + CURRENT_MEDIA_GAMES, + CURRENT_MEDIA_OFFICE +} CurrentMediaType; + typedef struct _CurrentMedia { + CurrentMediaType type; /**< Type. */ + char *title; /**< Title. */ char *artist; /**< Artist. */ char *album; /**< Album. */ - char *title; /**< Title. */ } CurrentMedia; /**
--- a/pidgin/gtkblist.c Mon Dec 08 17:19:52 2008 +0000 +++ b/pidgin/gtkblist.c Mon Dec 08 17:53:46 2008 +0000 @@ -3630,6 +3630,7 @@ const char *name = NULL; char *filename, *path; PurplePresence *p; + PurpleStatus *tune; if(PURPLE_BLIST_NODE_IS_CONTACT(node)) { if(!gtknode->contact_expanded) { @@ -3668,7 +3669,21 @@ return _pidgin_blist_get_cached_emblem(path); } - if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_TUNE)) { + tune = purple_presence_get_status(p, "tune"); + if (tune && purple_status_is_active(tune)) { + /* Only in MSN. + * TODO: Replace "Tune" with generalized "Media" in 3.0. */ + if (purple_status_get_attr_string(tune, "game") != NULL) { + path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "game.png", NULL); + return _pidgin_blist_get_cached_emblem(path); + } + /* Only in MSN. + * TODO: Replace "Tune" with generalized "Media" in 3.0. */ + if (purple_status_get_attr_string(tune, "office") != NULL) { + path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "office.png", NULL); + return _pidgin_blist_get_cached_emblem(path); + } + /* Regular old "tune" is the only one in all protocols. */ path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emblems", "16", "music.png", NULL); return _pidgin_blist_get_cached_emblem(path); }