diff libpurple/protocols/jabber/buddy.c @ 29110:bc1eb4dacd00

jabber: When getting info on a "bare" domain JID, interpret the value of "last" as the server's uptime. Don't show status (as offline).
author Marcus Lundblad <ml@update.uu.se>
date Tue, 01 Dec 2009 21:26:58 +0000
parents 9ae3e70a327b
children cfcf5076b73f
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Tue Dec 01 04:56:47 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Dec 01 21:26:58 2009 +0000
@@ -815,19 +815,29 @@
 
 	if (!jbi->jb->resources) {
 		/* the buddy is offline */
+		gboolean is_domain = jabber_jid_is_domain(jbi->jid);
 		gchar *status =
 			g_strdup_printf("%s%s%s",	_("Offline"),
 			                jbi->last_message ? ": " : "",
 			                jbi->last_message ? jbi->last_message : "");
 		if (jbi->last_seconds > 0) {
 			char *last = purple_str_seconds_to_string(jbi->last_seconds);
-			gchar *message = g_strdup_printf(_("%s ago"), last);
-			purple_notify_user_info_prepend_pair(user_info,
-				_("Logged Off"), message);
+			gchar *message = NULL;
+			const gchar *title = NULL;
+			if (is_domain) {
+				title = _("Uptime");
+				message = g_strdup_printf(_("%s"), last);
+			} else {
+				title = _("Logged Off");
+				message = g_strdup_printf(_("%s ago"), last);
+			}
+			purple_notify_user_info_prepend_pair(user_info, title, message);
 			g_free(last);
 			g_free(message);
 		}
-		purple_notify_user_info_prepend_pair(user_info, _("Status"), status);
+
+		if (!is_domain)
+			purple_notify_user_info_prepend_pair(user_info, _("Status"), status);
 		g_free(status);
 	}