# HG changeset patch # User Marcus Lundblad # Date 1233960352 0 # Node ID e3f2b16f75da096e497071ac46d55bfe5ff24850 # Parent b955681d9597a733dbf4c45e81e3532c1e80ef1d Always show the top resource first in the tooltip diff -r b955681d9597 -r e3f2b16f75da libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Fri Feb 06 22:07:57 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Fri Feb 06 22:45:52 2009 +0000 @@ -1683,6 +1683,56 @@ return ret; } +static void +jabber_tooltip_add_resource_text(JabberBuddyResource *jbr, + PurpleNotifyUserInfo *user_info, gboolean multiple_resources) +{ + char *text = NULL; + char *res = NULL; + char *label, *value; + const char *state; + + if(jbr->status) { + char *tmp; + text = purple_strreplace(jbr->status, "\n", "
\n"); + tmp = purple_markup_strip_html(text); + g_free(text); + text = g_markup_escape_text(tmp, -1); + g_free(tmp); + } + + if(jbr->name) + res = g_strdup_printf(" (%s)", jbr->name); + + state = jabber_buddy_state_get_name(jbr->state); + if (text != NULL && !purple_utf8_strcasecmp(state, text)) { + g_free(text); + text = NULL; + } + + label = g_strdup_printf("%s%s", _("Status"), (res ? res : "")); + value = g_strdup_printf("%s%s%s", state, (text ? ": " : ""), (text ? text : "")); + + purple_notify_user_info_add_pair(user_info, label, value); + g_free(label); + g_free(value); + g_free(text); + + /* if the resource is idle, show that */ + /* only show it if there is more than one resource available for + the buddy, since the "general" idleness will be shown anyway, + this way we can see see the idleness of lower-priority resources */ + if (jbr->idle && multiple_resources) { + gchar *idle_str = + purple_str_seconds_to_string(time(NULL) - jbr->idle); + label = g_strdup_printf("%s%s", _("Idle"), (res ? res : "")); + purple_notify_user_info_add_pair(user_info, label, idle_str); + g_free(idle_str); + g_free(label); + } + g_free(res); +} + void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { JabberBuddy *jb; @@ -1703,60 +1753,22 @@ const char *mood; gboolean multiple_resources = jb->resources && g_list_next(jb->resources); - + JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); + + /* resource-specific info for the top resource */ + jabber_tooltip_add_resource_text(top_jbr, user_info, + multiple_resources); + for(l=jb->resources; l; l = l->next) { - char *text = NULL; char *res = NULL; - char *label, *value; - const char *state; + char *label; jbr = l->data; - - if(jbr->status) { - char *tmp; - text = purple_strreplace(jbr->status, "\n", "
\n"); - tmp = purple_markup_strip_html(text); - g_free(text); - text = g_markup_escape_text(tmp, -1); - g_free(tmp); - } - - if(jbr->name) - res = g_strdup_printf(" (%s)", jbr->name); - - state = jabber_buddy_state_get_name(jbr->state); - if (text != NULL && !purple_utf8_strcasecmp(state, text)) { - g_free(text); - text = NULL; + /* the remaining resources */ + if (jbr != top_jbr) { + jabber_tooltip_add_resource_text(jbr, user_info, + multiple_resources); } - - label = g_strdup_printf("%s%s", - _("Status"), (res ? res : "")); - value = g_strdup_printf("%s%s%s", - state, - (text ? ": " : ""), - (text ? text : "")); - - purple_notify_user_info_add_pair(user_info, label, value); - g_free(label); - g_free(value); - g_free(text); - - /* if the resource is idle, show that */ - /* only show it if there is more than one resource available for - the buddy, since the "general" idleness will be shown anyway, - this way we can see see the idleness of lower-priority resources */ - if (jbr->idle && multiple_resources) { - gchar *idle_str = - purple_str_seconds_to_string(time(NULL) - jbr->idle); - label = g_strdup_printf("%s%s", - _("Idle"), (res ? res : "")); - purple_notify_user_info_add_pair(user_info, label, idle_str); - g_free(idle_str); - g_free(label); - } - - g_free(res); } if (full) {