Mercurial > pidgin
changeset 28728: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 | 6ebacc1710b2 |
children | cfcf5076b73f |
files | ChangeLog libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/jutil.c libpurple/protocols/jabber/jutil.h |
diffstat | 4 files changed, 45 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Dec 01 04:56:47 2009 +0000 +++ b/ChangeLog Tue Dec 01 21:26:58 2009 +0000 @@ -1,6 +1,10 @@ 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:
--- 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); }
--- a/libpurple/protocols/jabber/jutil.c Tue Dec 01 04:56:47 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.c Tue Dec 01 21:26:58 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 04:56:47 2009 +0000 +++ b/libpurple/protocols/jabber/jutil.h Tue Dec 01 21:26:58 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. */