Mercurial > pidgin
changeset 9510:2aed8d5cda1b
[gaim-migrate @ 10337]
wing did some stuff to make get info on yahoo and msn look better,
and provide more info on why it can't fetch the profile when it can't.
See patch #987609 for a fuller description.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 11 Jul 2004 20:26:02 +0000 |
parents | aecabbe495db |
children | 3ed6001d5de8 |
files | src/protocols/msn/msn.c src/protocols/yahoo/yahoo_profile.c |
diffstat | 2 files changed, 149 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/msn.c Sun Jul 11 19:57:31 2004 +0000 +++ b/src/protocols/msn/msn.c Sun Jul 11 20:26:02 2004 +0000 @@ -72,7 +72,7 @@ GString *s; char *photo_url_text; char *tooltip_text; - gboolean has_info; + const char *title; } MsnGetInfoStepTwoData; @@ -1142,9 +1142,21 @@ static char * msn_tooltip_info_text(MsnGetInfoData *info_data) { GString *s = g_string_sized_new(80); /* wild guess */ + GString *name; GaimBuddy *b; + const char *p; - g_string_printf(s, _("<b>%s:</b> %s<br>"), _("MSN ID"), info_data->name); + /* Try to not display the MSN screen name as an email address */ + p = strrchr(info_data->name, '@'); + if (p) { + name = g_string_new_len(info_data->name, p - info_data->name); + g_string_append_printf(name, "@%s", p + 1); + } else { /* This should never happen */ + name = g_string_new(info_data->name); + } + g_string_printf(s, "<span style=\"font-size: larger\"><b>%s</b></span><br>", + name->str); + g_string_free(name, TRUE); b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), info_data->name); @@ -1157,7 +1169,8 @@ } if(b->server_alias) { char *nicktext = g_markup_escape_text(b->server_alias, -1); - g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Nickname"), + g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); + g_string_append_printf(s, _("<font sml=\"msn\">%s</font><br>"), nicktext); g_free(nicktext); } @@ -1214,6 +1227,7 @@ char *user_url = NULL; gboolean found; gboolean has_info = FALSE; + const char* title = NULL; char *url_buffer; GString *s; int stripped_len; @@ -1225,6 +1239,7 @@ gaim_debug_info("msn", "In msn_got_info\n"); tooltip_text = msn_tooltip_info_text(info_data); + title = _("MSN Profile"); if (url_text == NULL || strcmp(url_text, "") == 0) { @@ -1232,7 +1247,7 @@ tooltip_text, _("Error retrieving profile")); gaim_notify_formatted(info_data->gc, NULL, - _("Buddy Information"), NULL, buf, NULL, NULL); + title, NULL, buf, NULL, NULL); g_free(tooltip_text); return; @@ -1470,13 +1485,34 @@ has_info = TRUE; } - if (found) { - /* put a link to the actual profile URL */ - g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); - g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", - PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); + if (!has_info) + { + /* MSN doesn't actually distinguish between "unknown member" and + * a known member with an empty profile. Try to explain this fact. + * Note that if we have a nonempty tooltip_text, we know the user + * exists. + */ + char *p = strstr(url_buffer, "Unknown Member </TITLE>"); + GaimBuddy *b = gaim_find_buddy + (gaim_connection_get_account(info_data->gc), info_data->name); + g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>", + _("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."): + _("Gaim 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 */ + g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); + g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", + PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); + /* Finish it off, and show it to them */ g_string_append(s, "</body></html>\n"); @@ -1490,7 +1526,7 @@ info2_data->s = s; info2_data->photo_url_text = photo_url_text; info2_data->tooltip_text = tooltip_text; - info2_data->has_info = has_info; + info2_data->title = title; /* Try to put the photo in there too, if there's one */ photo_url_text = msn_get_photo_url(url_text); @@ -1515,7 +1551,7 @@ GString *s = info2_data->s; char *photo_url_text = info2_data->photo_url_text; char *tooltip_text = info2_data->tooltip_text; - gboolean has_info = info2_data->has_info; + const char *title = info2_data->title; /* Try to put the photo in there too, if there's one and is readable */ if (data && url_text && len != 0) { @@ -1537,28 +1573,9 @@ /* We continue here from msn_got_info, as if nothing has happened */ #endif - if (has_info) - { - g_string_prepend(s, tooltip_text); - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), - NULL, s->str, NULL, NULL); - } - else - { - char *p = strstr(url_buffer, "Unknown Member </TITLE>"); - - /* MSN doesn't actually distinguish between "unknown member" and - * a known member with an empty profile. But if we say unknown - * member, it is at least not worse than reading the actual page. - */ - g_string_printf(s, "<html><body>%s<b>%s</b><br></body></html>", - tooltip_text, - (p ? _("Error retrieving profile") - : _("The user's profile is empty."))); - - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - s->str, NULL, NULL); - } + g_string_prepend(s, tooltip_text); + gaim_notify_formatted(info_data->gc, NULL, title, + NULL, s->str, NULL, NULL); g_free(stripped); g_free(url_buffer);
--- a/src/protocols/yahoo/yahoo_profile.c Sun Jul 11 19:57:31 2004 +0000 +++ b/src/protocols/yahoo/yahoo_profile.c Sun Jul 11 20:26:02 2004 +0000 @@ -34,6 +34,7 @@ #include "yahoo.h" #include "yahoo_friend.h" + typedef struct { GaimConnection *gc; char *name; @@ -83,6 +84,13 @@ } profile_strings_node_t; +typedef enum profile_state { + PROFILE_STATE_DEFAULT, + PROFILE_STATE_NOT_FOUND, + PROFILE_STATE_UNKNOWN_LANGUAGE +} profile_state_t; + + typedef struct { YahooGetInfoData *info_data; char *url_buffer; @@ -92,6 +100,8 @@ char *tooltip_text; const profile_strings_node_t *strings; const char *last_updated_string; + const char *title; + profile_state_t profile_state; } YahooGetInfoStepTwoData; @@ -637,7 +647,8 @@ GaimBuddy *b; YahooFriend *f; - g_string_printf(s, _("<b>%s:</b> %s<br>"), _("Yahoo! ID"), info_data->name); + g_string_printf(s, "<span style=\"font-size: larger\"><b>%s</b></span><br>", + info_data->name); b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), info_data->name); @@ -723,6 +734,8 @@ int lang, strid; struct yahoo_data *yd; const profile_strings_node_t *strings = NULL; + const char *title; + profile_state_t profile_state = PROFILE_STATE_DEFAULT; if (!GAIM_CONNECTION_IS_VALID(info_data->gc)) { g_free(info_data->name); @@ -733,6 +746,8 @@ gaim_debug_info("yahoo", "In yahoo_got_info\n"); yd = info_data->gc->proto_data; + title = (yd->jp? _("Yahoo! Japan Profile") : + _("Yahoo! Profile")); /* Get the tooltip info string */ tooltip_text = yahoo_tooltip_info_text(info_data); @@ -745,7 +760,7 @@ g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", tooltip_text, _("Error retrieving profile")); - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, + gaim_notify_formatted(info_data->gc, NULL, title, NULL, buf, NULL, NULL); g_free(profile_url_text); @@ -782,7 +797,7 @@ "you will need to visit this link in your web browser"), profile_url_text, profile_url_text); - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, + gaim_notify_formatted(info_data->gc, NULL, title, NULL, buf, NULL, NULL); g_free(profile_url_text); @@ -821,27 +836,10 @@ if (!strstr(url_text, "Yahoo! Member Directory - User not found") && !strstr(url_text, "was not found on this server.") && !strstr(url_text, "\xb8\xf8\xb3\xab\xa5\xd7\xa5\xed\xa5\xd5\xa5\xa3\xa1\xbc\xa5\xeb\xa4\xac\xb8\xab\xa4\xc4\xa4\xab\xa4\xea\xa4\xde\xa4\xbb\xa4\xf3")) { - g_snprintf(buf, 1024, "<html><body>%s<b>%s</b><br><br>\n" - "%s<br><a href=\"%s\">%s</a></body></html>", - tooltip_text, - _("Sorry, this profile seems to be in a language " - "that is not supported at this time."), - _("If you wish to view this profile, " - "you will need to visit this link in your web browser"), - profile_url_text, profile_url_text); + profile_state = PROFILE_STATE_UNKNOWN_LANGUAGE; } else { - g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", - tooltip_text, _("Error retrieving profile")); + profile_state = PROFILE_STATE_NOT_FOUND; } - - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - buf, NULL, NULL); - - g_free(profile_url_text); - g_free(tooltip_text); - g_free(info_data->name); - g_free(info_data); - return; } #if PHOTO_SUPPORT @@ -877,6 +875,8 @@ info2_data->tooltip_text = tooltip_text; info2_data->strings = strings; info2_data->last_updated_string = last_updated_string; + info2_data->title = title; + info2_data->profile_state = profile_state; /* Try to put the photo in there too, if there's one */ if (photo_url_text) { @@ -913,6 +913,8 @@ char *tooltip_text = info2_data->tooltip_text; const profile_strings_node_t *strings = info2_data->strings; const char *last_updated_string = info2_data->last_updated_string; + const char *title = info2_data->title; + profile_state_t profile_state = info2_data->profile_state; /* We continue here from yahoo_got_info, as if nothing has happened */ #endif /* PHOTO_SUPPORT */ @@ -925,33 +927,39 @@ gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); /* convert to utf8 */ - p = g_convert(stripped, -1, "utf-8", strings->charset, NULL, NULL, NULL); - if (!p) { - p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL); + if (strings && strings->charset != XX) { + p = g_convert(stripped, -1, "utf-8", strings->charset, + NULL, NULL, NULL); if (!p) { - p = g_convert(stripped, -1, "utf-8", "windows-1252", NULL, NULL, NULL); + p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL); + if (!p) { + p = g_convert(stripped, -1, "utf-8", "windows-1252", + NULL, NULL, NULL); + } + } + if (p) { + g_free(stripped); + stripped = gaim_utf8_ncr_decode(p); + stripped_len = strlen(stripped); + g_free(p); } } - if (p) { - g_free(stripped); - stripped = gaim_utf8_ncr_decode(p); - stripped_len = strlen(stripped); - g_free(p); - p = stripped; - } - /* FIXME need error dialog here */ + p = NULL; /* "Last updated" should also be converted to utf8 and with killed */ - last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", - strings->charset, NULL, NULL, NULL); - yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); + if (strings && strings->charset != XX) { + last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", + strings->charset, NULL, NULL, NULL); + yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); - gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); + gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); + } /* gonna re-use the memory we've already got for url_buffer */ /* no we're not */ s = g_string_sized_new(strlen(url_buffer)); - g_string_append(s, "<html><body>\n"); + + if (profile_state == PROFILE_STATE_DEFAULT) { #if 0 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as @@ -962,9 +970,6 @@ ; #endif - /* Put the Yahoo! ID, nickname, idle time, and status message in */ - g_string_append(s, tooltip_text); - #if PHOTO_SUPPORT /* Try to put the photo in there too, if there's one and is readable */ @@ -1117,29 +1122,66 @@ last_updated_utf8_string, 0, "\n", '\n', NULL, _("Last Updated"), 0, NULL); + } /* if (profile_state == PROFILE_STATE_DEFAULT) */ + + if(!found) + { + g_string_append_printf(s, "<br><b>"); + g_string_append_printf(s, _("User information for %s unavailable"), + info_data->name); + g_string_append_printf(s, "</b><br>"); + + if (profile_state == PROFILE_STATE_UNKNOWN_LANGUAGE) { + g_string_append_printf(s, "%s<br><br>", + _("Sorry, this profile seems to be in a language " + "that is not supported at this time.")); + + } else if (profile_state == PROFILE_STATE_NOT_FOUND) { + GaimBuddy *b = gaim_find_buddy + (gaim_connection_get_account(info_data->gc), + info_data->name); + YahooFriend *f = NULL; + if (b) { + /* Someone on the buddy list can be "not on server list", + * in which case the user may or may not actually exist. + * Hence this extra step. + */ + f = yahoo_friend_find(b->account->gc, b->name); + } + g_string_append_printf(s, "%s<br><br>", + f? _("Could not retrieve the user's profile. " + "This most likely is a temporary server-side problem. " + "Please try again later."): + _("Could not retrieve the user's profile. " + "This most likely means that the user does not exist; " + "however, Yahoo! sometimes does fail to find a user's " + "profile. If you know that the user exists, " + "please try again later.")); + + } else { + g_string_append_printf(s, "%s<br><br>", + _("The user's profile is empty.")); + } + } + /* put a link to the actual profile URL */ g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); g_string_append_printf(s, "<br><a href=\"%s\">%s</a><br>", profile_url_text, profile_url_text); - /* finish off the html */ + /* finish off the html at the end */ g_string_append(s, "</body></html>\n"); g_free(stripped); - if(found) - { - /* show it to the user */ - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - s->str, NULL, NULL); - } - else - { - char *primary; - primary = g_strdup_printf(_("User information for %s unavailable"), info_data->name); - gaim_notify_error(info_data->gc, NULL, primary, - _("The user's profile is empty.")); - g_free(primary); - } + /* Put the Yahoo! ID, nickname, idle time, and status message in */ + g_string_prepend(s, tooltip_text); + + /* finish off the html at the beginning */ + g_string_prepend(s, "<html><body>\n"); + + /* show it to the user */ + gaim_notify_formatted(info_data->gc, NULL, title, NULL, + s->str, NULL, NULL); g_free(last_updated_utf8_string); g_free(url_buffer);