diff options
author | James Booth <boothj5@gmail.com> | 2014-11-11 00:00:10 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-11-11 00:00:10 +0000 |
commit | eace543da5620ca4c1d94d74ddd5342be4c66f47 (patch) | |
tree | f1bdbe539ce9606554f8a648f358f41c75e45522 | |
parent | f715c0580c904caababf980e0fef72ae28944424 (diff) | |
download | profani-tty-eace543da5620ca4c1d94d74ddd5342be4c66f47.tar.gz |
Added /roster show|hide resource
-rw-r--r-- | src/command/command.c | 25 | ||||
-rw-r--r-- | src/command/commands.c | 10 | ||||
-rw-r--r-- | src/ui/console.c | 10 | ||||
-rw-r--r-- | src/ui/core.c | 56 |
4 files changed, 63 insertions, 38 deletions
diff --git a/src/command/command.c b/src/command/command.c index e441656d..953128a8 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -169,19 +169,21 @@ static struct cmd_t command_defs[] = { "/roster", cmd_roster, parse_args_with_freetext, 0, 3, NULL, - { "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]", "Manage your roster.", - { "/roster [show|hide|add|remove|nick|clearnick] [offline] [jid] [nickname]", - "------------------------------------------------------------------------", + { "/roster [show|hide|add|remove|nick|clearnick] [offline|resource] [jid] [nickname]", "Manage your roster.", + { "/roster [show|hide|add|remove|nick|clearnick] [offline|resource] [jid] [nickname]", + "---------------------------------------------------------------------------------", "View, add to, and remove from your roster.", "Passing no arguments lists all contacts in your roster.", - "show - Show the roster panel in the console window.", - "hide - Hide the roster panel.", - "show offline - Show offline contacts in the roster panel.", - "hide offline - Hide offline contacts in the roster panel.", - "add - Add a new item, jid is required, nickname is optional.", - "remove - Removes a contact, jid is required.", - "nick - Changes a contacts nickname, both jid and nickname are required,", - "clearnick - Removes the current nickname, jid is required.", + "show - Show the roster panel in the console window.", + "hide - Hide the roster panel.", + "show offline - Show offline contacts in the roster panel.", + "hide offline - Hide offline contacts in the roster panel.", + "show resource - Show contact's connected resources in the roster panel.", + "hide resource - Hide contact's connected resources in the roster panel.", + "add - Add a new item, jid is required, nickname is optional.", + "remove - Removes a contact, jid is required.", + "nick - Changes a contacts nickname, both jid and nickname are required,", + "clearnick - Removes the current nickname, jid is required.", "", "Example : /roster (show your roster)", "Example : /roster add someone@contacts.org (add the contact)", @@ -1240,6 +1242,7 @@ cmd_init(void) roster_option_ac = autocomplete_new(); autocomplete_add(roster_option_ac, "offline"); + autocomplete_add(roster_option_ac, "resource"); group_ac = autocomplete_new(); autocomplete_add(group_ac, "show"); diff --git a/src/command/commands.c b/src/command/commands.c index 568cd352..30e317bd 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1342,6 +1342,11 @@ cmd_roster(gchar **args, struct cmd_help_t help) prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE); ui_roster(); return TRUE; + } else if (g_strcmp0(args[1], "resource") == 0) { + cons_show("Roster resource enabled"); + prefs_set_boolean(PREF_ROSTER_RESOURCE, TRUE); + ui_roster(); + return TRUE; } else { cons_show("Usage: %s", help.usage); return TRUE; @@ -1357,6 +1362,11 @@ cmd_roster(gchar **args, struct cmd_help_t help) prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE); ui_roster(); return TRUE; + } else if (g_strcmp0(args[1], "resource") == 0) { + cons_show("Roster resource disabled"); + prefs_set_boolean(PREF_ROSTER_RESOURCE, FALSE); + ui_roster(); + return TRUE; } else { cons_show("Usage: %s", help.usage); return TRUE; diff --git a/src/ui/console.c b/src/ui/console.c index 831b1b7d..d4f6bcc9 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -948,6 +948,16 @@ _cons_roster_setting(void) cons_show("Roster (/roster) : show"); else cons_show("Roster (/roster) : hide"); + + if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) + cons_show("Roster offline (/roster) : show"); + else + cons_show("Roster offline (/roster) : hide"); + + if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) + cons_show("Roster resource (/roster) : show"); + else + cons_show("Roster resource (/roster) : hide"); } static void diff --git a/src/ui/core.c b/src/ui/core.c index e2beae04..c5e3711f 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2835,34 +2835,36 @@ _ui_roster(void) 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); + if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) { + 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(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); } } curr_contact = g_slist_next(curr_contact); |