Added /roster show|hide offline

This commit is contained in:
James Booth
2014-11-10 23:51:13 +00:00
parent 497b07c1c3
commit f715c0580c
3 changed files with 88 additions and 49 deletions

View File

@@ -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);
GList *resources = p_contact_get_available_resources(contact);
GList *ordered_resources = NULL;
// 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);
}
g_list_free(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);
GString *msg = g_string_new(" ");
g_string_append(msg, resource->name);
GString *msg = g_string_new(" ");
g_string_append(msg, name);
win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE);
wattroff(window->subwin, resource_presence_colour);
wattroff(window->subwin, presence_colour);
ordered_resources = g_list_next(ordered_resources);
GList *resources = p_contact_get_available_resources(contact);
GList *ordered_resources = NULL;
// 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);
}
g_list_free(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);
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);
ordered_resources = g_list_next(ordered_resources);
}
g_list_free(ordered_resources);
}
g_list_free(ordered_resources);
}
curr_contact = g_slist_next(curr_contact);
}