From f1693278cb906a75effca482fb9bf4080df1f037 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 18 Feb 2013 22:07:17 +0000 Subject: [PATCH] Colour connected account in "/account list" according ot presence --- src/command/command.c | 15 ++------------- src/ui/ui.h | 1 + src/ui/windows.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 13eec811..0b6f5312 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1081,19 +1081,8 @@ _cmd_account(gchar **args, struct cmd_help_t help) if (strcmp(command, "list") == 0) { gchar **accounts = accounts_get_list(); - int size = g_strv_length(accounts); - - if (size > 0) { - cons_show("Accounts:"); - int i = 0; - for (i = 0; i < size; i++) { - cons_show(accounts[i]); - } - cons_show(""); - } else { - cons_show("No accounts created yet."); - cons_show(""); - } + cons_show_account_list(accounts); + g_strfreev(accounts); } else if (strcmp(command, "show") == 0) { char *account_name = args[1]; if (account_name == NULL) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 4ff10679..11c32b8f 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -171,6 +171,7 @@ void cons_show_login_success(ProfAccount *account); void cons_show_software_version(const char * const jid, const char * const presence, const char * const name, const char * const version, const char * const os); +void cons_show_account_list(gchar **accounts); // status bar actions void status_bar_refresh(void); diff --git a/src/ui/windows.c b/src/ui/windows.c index aecba904..a7d82a6e 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -1305,6 +1305,32 @@ cons_show_status(const char * const contact) } } +void +cons_show_account_list(gchar **accounts) +{ + int size = g_strv_length(accounts); + if (size > 0) { + cons_show("Accounts:"); + int i = 0; + for (i = 0; i < size; i++) { + if ((jabber_get_connection_status() == JABBER_CONNECTED) && + (g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) { + resource_presence_t presence = accounts_get_last_presence(accounts[i]); + _win_show_time(console->win, '-'); + _presence_colour_on(console->win, string_from_resource_presence(presence)); + wprintw(console->win, "%s\n", accounts[i]); + _presence_colour_off(console->win, string_from_resource_presence(presence)); + } else { + cons_show(accounts[i]); + } + } + cons_show(""); + } else { + cons_show("No accounts created yet."); + cons_show(""); + } +} + void win_show_status(void) {