changeset 9220:f0488214826f

[gaim-migrate @ 10016] wing made yahoo profiles even better. They now include all the tooltip info, and also include a link to the profile, so you can open it in your browser with just a click. He also says: Note: I added _() to some "<b>%s:</b> %s" sort of strings, because otherwise the display would be very ugly. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 06 Jun 2004 18:01:32 +0000
parents ec2a51abcc71
children 8054855f2bb9
files src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo.h src/protocols/yahoo/yahoo_profile.c src/util.c
diffstat 4 files changed, 41 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Sun Jun 06 17:43:37 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sun Jun 06 18:01:32 2004 +0000
@@ -2474,7 +2474,7 @@
  	}
 }
 
-static char *yahoo_tooltip_text(GaimBuddy *b)
+char *yahoo_tooltip_text(GaimBuddy *b)
 {
 	struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data;
 	struct yahoo_friend *f;
--- a/src/protocols/yahoo/yahoo.h	Sun Jun 06 17:43:37 2004 +0000
+++ b/src/protocols/yahoo/yahoo.h	Sun Jun 06 18:01:32 2004 +0000
@@ -233,6 +233,9 @@
  */
 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8);
 
+/* previously-static functions, now needed for yahoo_profile.c */
+char *yahoo_tooltip_text(GaimBuddy *b);
+
 /* yahoo_profile.c */
 void yahoo_get_info(GaimConnection *gc, const char *name);
 
--- a/src/protocols/yahoo/yahoo_profile.c	Sun Jun 06 17:43:37 2004 +0000
+++ b/src/protocols/yahoo/yahoo_profile.c	Sun Jun 06 18:01:32 2004 +0000
@@ -625,10 +625,11 @@
 	const char *last_updated_string = NULL;
 	char *last_updated_utf8_string;
 	int lang, strid;
+	GaimBuddy *b;
 
 	gaim_debug_info("yahoo", "In yahoo_got_info\n");
 
-	/* we failed to grab the profile URL */
+	/* we failed to grab the profile URL. this should never happen */
 	if (url_text == NULL || strcmp(url_text, "") == 0) {
 		gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
 			_("<html><body><b>Error retrieving profile</b></body></html>"),
@@ -677,15 +678,15 @@
 		gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang);
 	}
 
-	/* At the moment we don't support profile pages with languages other than
-	 * English. The problem is, that every user may choose his/her own profile
-	 * language. This language has nothing to do with the preferences of the
-	 * user which looks at the profile
+	/* Every user may choose his/her own profile language, and this language
+	 * has nothing to do with the preferences of the user which looks at the
+	 * profile. We try to support all languages, but nothing is guaranteed.
 	 */
 	if (!p || profile_strings[strid].lang == XX) {
 		if (strstr(url_text, "was not found on this server.") == NULL && strstr(url_text, "Yahoo! Member Directory - User not found") == NULL) {
 			g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>",
-					_("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n"),
+					_("<b>Sorry, this profile seems to be in a language "
+					  "that is not supported at this time.</b><br><br>\n"),
 					_("If you wish to view this profile, you will need to visit this link in your web browser<br>"),
 					YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name);
 		} else {
@@ -759,8 +760,27 @@
 	 * true, since the Yahoo! ID will always be there */
 	if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].yahoo_id_string, 2, "\n", 0,
 			NULL, _("Yahoo! ID"), 0, NULL))
-		g_string_append_printf(s, "<b>%s:</b> %s<br>", _("Yahoo! ID"), info_data->name);
+		g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Yahoo! ID"), info_data->name);
 
+	/* Display the alias, idle time, and status message below the Yahoo! ID */
+	b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), info_data->name);
+	if (b) {
+		char *statustext = yahoo_tooltip_text(b);
+		if(b->alias && b->alias[0]) {
+			char *aliastext = g_markup_escape_text(b->alias, -1);
+			g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext);
+			g_free(aliastext);
+		}
+		if (b->idle > 0) {
+			char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle);
+			g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"), idletime);
+			g_free(idletime);
+		}
+		if (statustext) {
+			g_string_append_printf(s, "%s<br>", statustext);
+			g_free(statustext);
+		}
+	}
 
 	/* extract their Email address and put it in */
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].my_email_string, 5, "\n", 0,
@@ -845,9 +865,9 @@
 	}
 
 	/* Cool Link {1,2,3} is also different.  If "No cool link specified" exists,
-	 * then we have none.  If we have one however, we'll need to check and see if
-	 * we have a second one.  If we have a second one, we have to check to see if
-	 * we have a third one.
+	 * then we have none.  If we have one however, we'll need to check and see
+	 * if we have a second one.  If we have a second one, we have to check to
+	 * see if we have a third one.
 	 */
 	p = !profile_strings[strid].no_cool_link_specified_string? NULL:
 		strstr(stripped,profile_strings[strid].no_cool_link_specified_string);
@@ -872,6 +892,12 @@
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, s, last_updated_utf8_string, 0, "\n", '\n', NULL,
 			_("Last Updated"), 0, NULL);
 
+	/* put a link to the actual profile URL */
+	g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL"));
+	g_string_append_printf(s, "<a href=\"%s%s\">%s%s</a><br>",
+			YAHOO_PROFILE_URL, info_data->name,
+			YAHOO_PROFILE_URL, info_data->name);
+
 	/* finish off the html */
 	g_string_append(s, "</body></html>\n");
 	g_free(stripped);
--- a/src/util.c	Sun Jun 06 17:43:37 2004 +0000
+++ b/src/util.c	Sun Jun 06 18:01:32 2004 +0000
@@ -786,9 +786,7 @@
 					  (no_value_token && strncmp(p, no_value_token,
 												 strlen(no_value_token)))))
 	{
-		g_string_append(dest, "<b>");
-		g_string_append(dest, display_name);
-		g_string_append(dest, ":</b> ");
+		g_string_append_printf(dest, _("<b>%s:</b> "), display_name);
 
 		if (is_link)
 		{