about summary refs log tree commit diff stats
path: root/src/roster_list.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-18 00:25:35 +0000
committerJames Booth <boothj5@gmail.com>2015-11-18 00:25:35 +0000
commitb373cbcfc0688c80314b40024a8a9d596bcc9856 (patch)
tree343707ede12d423a5226c6a107410f4873f5ea56 /src/roster_list.c
parent2260e3bd6f7e99fd16f05372c7545b8e2379ff6e (diff)
downloadprofani-tty-b373cbcfc0688c80314b40024a8a9d596bcc9856.tar.gz
Pass offline filter to roster list functions
Diffstat (limited to 'src/roster_list.c')
-rw-r--r--src/roster_list.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/roster_list.c b/src/roster_list.c
index 2f1a0b55..4b2662ad 100644
--- a/src/roster_list.c
+++ b/src/roster_list.c
@@ -455,7 +455,7 @@ roster_fulljid_autocomplete(const char *const search_str)
 }
 
 GSList*
-roster_get_nogroup(roster_ord_t order)
+roster_get_nogroup(roster_ord_t order, gboolean include_offline)
 {
     GSList *result = NULL;
     GHashTableIter iter;
@@ -471,6 +471,12 @@ roster_get_nogroup(roster_ord_t order)
 
     g_hash_table_iter_init(&iter, contacts);
     while (g_hash_table_iter_next(&iter, &key, &value)) {
+        PContact contact = value;
+        const char *presence = p_contact_presence(contact);
+        if (!include_offline && (g_strcmp0(presence, "offline") == 0)) {
+            continue;
+        }
+
         GSList *groups = p_contact_groups(value);
         if (groups == NULL) {
             result = g_slist_insert_sorted(result, value, cmp_func);
@@ -482,7 +488,7 @@ roster_get_nogroup(roster_ord_t order)
 }
 
 GSList*
-roster_get_group(const char *const group, roster_ord_t order)
+roster_get_group(const char *const group, roster_ord_t order, gboolean include_offline)
 {
     GSList *result = NULL;
     GHashTableIter iter;
@@ -498,6 +504,12 @@ roster_get_group(const char *const group, roster_ord_t order)
 
     g_hash_table_iter_init(&iter, contacts);
     while (g_hash_table_iter_next(&iter, &key, &value)) {
+        PContact contact = value;
+        const char *presence = p_contact_presence(contact);
+        if (!include_offline && (g_strcmp0(presence, "offline") == 0)) {
+            continue;
+        }
+
         GSList *groups = p_contact_groups(value);
         while (groups) {
             if (strcmp(groups->data, group) == 0) {