From f715c0580c904caababf980e0fef72ae28944424 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 10 Nov 2014 23:51:13 +0000 Subject: Added /roster show|hide offline --- src/ui/core.c | 60 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'src/ui') diff --git a/src/ui/core.c b/src/ui/core.c index 66b5fa2b..e2beae04 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2821,45 +2821,49 @@ _ui_roster(void) if (p_contact_subscribed(contact)) { const char *name = p_contact_name_or_jid(contact); const char *presence = p_contact_presence(contact); - int presence_colour = win_presence_colour(presence); - wattron(window->subwin, presence_colour); + if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) && + (prefs_get_boolean(PREF_ROSTER_OFFLINE)))) { + int presence_colour = win_presence_colour(presence); - GString *msg = g_string_new(" "); - g_string_append(msg, name); - win_printline_nowrap(window->subwin, msg->str); - g_string_free(msg, TRUE); + wattron(window->subwin, presence_colour); - wattroff(window->subwin, presence_colour); + GString *msg = g_string_new(" "); + g_string_append(msg, name); + win_printline_nowrap(window->subwin, msg->str); + g_string_free(msg, TRUE); - GList *resources = p_contact_get_available_resources(contact); - GList *ordered_resources = NULL; + wattroff(window->subwin, presence_colour); - // sort in order of availabiltiy - while (resources != NULL) { - Resource *resource = resources->data; - ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability); - resources = g_list_next(resources); - } + GList *resources = p_contact_get_available_resources(contact); + GList *ordered_resources = NULL; - g_list_free(resources); + // sort in order of availabiltiy + while (resources != NULL) { + Resource *resource = resources->data; + ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability); + resources = g_list_next(resources); + } - while (ordered_resources) { - Resource *resource = ordered_resources->data; - const char *resource_presence = string_from_resource_presence(resource->presence); - int resource_presence_colour = win_presence_colour(resource_presence); - wattron(window->subwin, resource_presence_colour); + g_list_free(resources); - GString *msg = g_string_new(" "); - g_string_append(msg, resource->name); - win_printline_nowrap(window->subwin, msg->str); - g_string_free(msg, TRUE); + while (ordered_resources) { + Resource *resource = ordered_resources->data; + const char *resource_presence = string_from_resource_presence(resource->presence); + int resource_presence_colour = win_presence_colour(resource_presence); + wattron(window->subwin, resource_presence_colour); + + GString *msg = g_string_new(" "); + g_string_append(msg, resource->name); + win_printline_nowrap(window->subwin, msg->str); + g_string_free(msg, TRUE); - wattroff(window->subwin, resource_presence_colour); + wattroff(window->subwin, resource_presence_colour); - ordered_resources = g_list_next(ordered_resources); + ordered_resources = g_list_next(ordered_resources); + } + g_list_free(ordered_resources); } - g_list_free(ordered_resources); } curr_contact = g_slist_next(curr_contact); } -- cgit 1.4.1-2-gfad0