Mercurial > pidgin
diff libpurple/protocols/msn/msn.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 | f3950234b164 |
children | 68f4edb42f39 3e39e4652c36 ca01403251f1 9ea6842536ba |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c Sat Nov 29 18:46:49 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Sun Dec 21 18:32:37 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); @@ -1389,6 +1418,7 @@ MsnSession *session; MsnUserList *userlist; const char *who; + MsnUser *user; session = gc->proto_data; userlist = session->userlist; @@ -1414,21 +1444,19 @@ purple_debug_info("msn", "msn_add_buddy: %s\n", who); #endif -#if 0 - /* Which is the max? */ - if (session->fl_users_count >= 150) - { - purple_debug_info("msn", "Too many buddies\n"); - /* Buddy list full */ - /* TODO: purple should be notified of this */ - return; - } -#endif - /* XXX - Would group ever be NULL here? I don't think so... * shx: Yes it should; MSN handles non-grouped buddies, and this is only * internal. */ - msn_userlist_add_buddy(userlist, who, group ? group->name : NULL); + user = msn_userlist_find_user(userlist, who); + if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) { + /* We already know this buddy and their network. This function knows + what to do with users already in the list and stuff... */ + msn_userlist_add_buddy(userlist, who, group ? group->name : NULL); + } else { + /* We need to check the network for this buddy first */ + msn_userlist_save_pending_buddy(userlist, who, group ? group->name : NULL); + msn_notification_send_fqy(session, who); + } } static void @@ -1811,7 +1839,7 @@ if (b->server_alias) { char *nicktext = g_markup_escape_text(b->server_alias, -1); - tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); + tmp = g_strdup_printf("<font sml=\"msn\">%s</font>", nicktext); purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); g_free(tmp); g_free(nicktext); @@ -1917,9 +1945,8 @@ if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) { - tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); - purple_notify_user_info_add_pair(user_info, NULL, tmp); - g_free(tmp); + purple_notify_user_info_add_pair(user_info, + _("Error retrieving profile"), NULL); purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); @@ -2260,21 +2287,24 @@ char *p = strstr(url_buffer, "<form id=\"profile_form\" name=\"profile_form\" action=\"http://spaces.live.com/profile.aspx?cid=0\""); PurpleBuddy *b = purple_find_buddy (purple_connection_get_account(info_data->gc), info_data->name); - purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"), - ((p && b) ? _("The user has not created a public profile.") : - (p ? _("MSN reported not being able to find the user's profile. " - "This either means that the user does not exist, " - "or that the user exists " - "but has not created a public profile.") : - _("Could not find " /* This should never happen */ - "any information in the user's profile. " - "The user most likely does not exist.")))); + purple_notify_user_info_add_pair(user_info, + _("Error retrieving profile"), NULL); + purple_notify_user_info_add_pair(user_info, NULL, + ((p && b) ? _("The user has not created a public profile.") : + (p ? _("MSN reported not being able to find the user's profile. " + "This either means that the user does not exist, " + "or that the user exists " + "but has not created a public profile.") : + _("Could not find " /* This should never happen */ + "any information in the user's profile. " + "The user most likely does not exist.")))); } /* put a link to the actual profile URL */ - tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", - PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); - purple_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); + purple_notify_user_info_add_section_break(user_info); + tmp = g_strdup_printf("<a href=\"%s%s\">%s</a>", + PROFILE_URL, info_data->name, _("View web profile")); + purple_notify_user_info_add_pair(user_info, NULL, tmp); g_free(tmp); #if PHOTO_SUPPORT