cpw.malu.xmpp.idle: fabd9ad2: Always show the top resource first in th...
malu at pidgin.im
malu at pidgin.im
Fri Feb 6 17:50:28 EST 2009
-----------------------------------------------------------------
Revision: fabd9ad23e9fb900097d73b3de731f9464c1211a
Ancestor: 63bee7b380d8a99f45a86cc2216752f224c94ced
Author: malu at pidgin.im
Date: 2009-02-06T22:45:52
Branch: im.pidgin.cpw.malu.xmpp.idle
URL: http://d.pidgin.im/viewmtn/revision/info/fabd9ad23e9fb900097d73b3de731f9464c1211a
Modified files:
libpurple/protocols/jabber/jabber.c
ChangeLog:
Always show the top resource first in the tooltip
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c 88cb18b3672b3ccd1fa88d8707c7d45df57143e4
+++ libpurple/protocols/jabber/jabber.c e7fb5d6ba88f52b78328d730d1ac45beec5f81cb
@@ -1683,6 +1683,56 @@ char *jabber_status_text(PurpleBuddy *b)
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", "<br />\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 @@ void jabber_tooltip_text(PurpleBuddy *b,
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", "<br />\n");
- tmp = purple_markup_strip_html(text);
- g_free(text);
- text = g_markup_escape_text(tmp, -1);
- g_free(tmp);
+ /* the remaining resources */
+ if (jbr != top_jbr) {
+ jabber_tooltip_add_resource_text(jbr, user_info,
+ multiple_resources);
}
-
- 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);
}
if (full) {
More information about the Commits
mailing list