pidgin: 9e66a212: jabber: When getting info on a "bare" do...

malu at pidgin.im malu at pidgin.im
Tue Dec 1 16:30:41 EST 2009


-----------------------------------------------------------------
Revision: 9e66a21277bce5b8be225115269300903be335ea
Ancestor: 5c0b873fe3c22c45d708e6455514edac31619055
Author: malu at pidgin.im
Date: 2009-12-01T21:26:58
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9e66a21277bce5b8be225115269300903be335ea

Modified files:
        ChangeLog libpurple/protocols/jabber/buddy.c
        libpurple/protocols/jabber/jutil.c
        libpurple/protocols/jabber/jutil.h

ChangeLog: 

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).

-------------- next part --------------
============================================================
--- ChangeLog	3a61592c95edbf2ffe43183e7702cba8a7dda54f
+++ ChangeLog	6b19c6f54e1addf304d1f57729a503d6f9054335
@@ -1,6 +1,10 @@ version 2.6.5 (??/??/20??):
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
 version 2.6.5 (??/??/20??):
+	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:
============================================================
--- libpurple/protocols/jabber/buddy.c	04bc7984bb02176cfd7fbf99dc3b00e27d50ff8f
+++ libpurple/protocols/jabber/buddy.c	38829175d35d5e216320f1308c151eb2a35c9cb3
@@ -815,19 +815,29 @@ static void jabber_buddy_info_show_if_re
 
 	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);
 	}
 
============================================================
--- libpurple/protocols/jabber/jutil.c	603120abe6629d5e8f9e79d5198134bb252b0875
+++ libpurple/protocols/jabber/jutil.c	5c683984eca9746c1ac51fc9ad1bb99d161e76ca
@@ -473,7 +473,20 @@ jabber_id_free(JabberID *jid)
 	}
 }
 
+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)
 {
 	JabberID *jid = jabber_id_new(in);
@@ -513,6 +526,17 @@ jabber_id_get_bare_jid(const JabberID *j
 	                   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)
 {
============================================================
--- libpurple/protocols/jabber/jutil.h	02b6b2dd78e434bf836d385baa5748633b7885d3
+++ libpurple/protocols/jabber/jutil.h	66403796aa287a70c638463ccbc24a85d2344c37
@@ -35,10 +35,13 @@ void jabber_id_free(JabberID *jid);
 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. */


More information about the Commits mailing list