about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-10 23:51:13 +0000
committerJames Booth <boothj5@gmail.com>2014-11-10 23:51:13 +0000
commitf715c0580c904caababf980e0fef72ae28944424 (patch)
treee90477a22657838c4435422a235c095f922e0933 /src/ui
parent497b07c1c3563efdfc147b22bd8afd094caf619a (diff)
downloadprofani-tty-f715c0580c904caababf980e0fef72ae28944424.tar.gz
Added /roster show|hide offline
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c60
1 files changed, 32 insertions, 28 deletions
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);
             }