changeset 28733:cfcf5076b73f

merge of '1cebb8e5585732c30dcfb31a6700dcb78ae47b44' and '9e66a21277bce5b8be225115269300903be335ea'
author Marcus Lundblad <ml@update.uu.se>
date Tue, 01 Dec 2009 21:36:55 +0000
parents 1bb466ce21b8 (current diff) bc1eb4dacd00 (diff)
children 6c5deb5d04bd
files ChangeLog libpurple/protocols/jabber/buddy.c
diffstat 4 files changed, 45 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 01 21:24:11 2009 +0000
+++ b/ChangeLog	Tue Dec 01 21:36:55 2009 +0000
@@ -1,8 +1,10 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
 version 2.6.5 (??/??/20??):
-	XMPP:
-	* Do not crash when attempting to register for a new account on Windows.
+	libpurple:
+	* XMPP: when getting info on a domain-only (server) JID, show uptime
+	  (when given by the result of the "last query") and don't show status as
+	  offline.
 
 version 2.6.4 (11/29/2009):
 	libpurple:
--- a/libpurple/protocols/jabber/buddy.c	Tue Dec 01 21:24:11 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Dec 01 21:36:55 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);
 	}
 
--- a/libpurple/protocols/jabber/jutil.c	Tue Dec 01 21:24:11 2009 +0000
+++ b/libpurple/protocols/jabber/jutil.c	Tue Dec 01 21:36:55 2009 +0000
@@ -473,6 +473,19 @@
 	}
 }
 
+char *jabber_get_domain(const char *in)
+{
+	JabberID *jid = jabber_id_new(in);
+	char *out;
+
+	if (!jid)
+		return NULL;
+
+	out = g_strdup(jid->domain);
+	jabber_id_free(jid);
+
+	return out;
+}
 
 char *jabber_get_resource(const char *in)
 {
@@ -513,6 +526,17 @@
 	                   NULL);
 }
 
+gboolean
+jabber_jid_is_domain(const char *jid)
+{
+	char *domain = jabber_get_domain(jid);
+	gboolean is_domain = purple_strequal(jid, domain);
+
+	g_free(domain);
+	return is_domain;
+}
+
+
 JabberID *
 jabber_id_new(const char *str)
 {
--- a/libpurple/protocols/jabber/jutil.h	Tue Dec 01 21:24:11 2009 +0000
+++ b/libpurple/protocols/jabber/jutil.h	Tue Dec 01 21:36:55 2009 +0000
@@ -35,10 +35,13 @@
 JabberID* jabber_id_new(const char *str);
 void jabber_id_free(JabberID *jid);
 
+char *jabber_get_domain(const char *jid);
 char *jabber_get_resource(const char *jid);
 char *jabber_get_bare_jid(const char *jid);
 char *jabber_id_get_bare_jid(const JabberID *jid);
 
+gboolean jabber_jid_is_domain(const char *jid);
+
 const char *jabber_normalize(const PurpleAccount *account, const char *in);
 
 /* Returns true if JID is the bare JID of our server. */