From e922568770532e6fda63bf1865832fc7fd7f00ee Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 10 Feb 2013 17:13:19 +0000 Subject: Added resource_presence_t and contact_presence_t --- src/ui/titlebar.c | 38 +++++++++++++++++++++++--------------- src/ui/ui.h | 2 +- src/ui/windows.c | 24 +++--------------------- 3 files changed, 27 insertions(+), 37 deletions(-) (limited to 'src/ui') diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index edeb79fd..5c8cee83 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -32,7 +32,7 @@ static char *current_title = NULL; static char *recipient = NULL; static GTimer *typing_elapsed; static int dirty; -static presence_t current_status; +static contact_presence_t current_status; static void _title_bar_draw_title(void); static void _title_bar_draw_status(void); @@ -45,7 +45,7 @@ create_title_bar(void) title_bar = newwin(1, cols, 0, 0); wbkgd(title_bar, COLOUR_TITLE_TEXT); title_bar_title(); - title_bar_set_status(PRESENCE_OFFLINE); + title_bar_set_status(CONTACT_OFFLINE); dirty = TRUE; } @@ -119,7 +119,7 @@ title_bar_show(const char * const title) } void -title_bar_set_status(presence_t status) +title_bar_set_status(contact_presence_t status) { current_status = status; _title_bar_draw_status(); @@ -187,18 +187,26 @@ _title_bar_draw_status(void) mvwaddch(title_bar, 0, cols - 14, '['); wattroff(title_bar, COLOUR_TITLE_BRACKET); - if (current_status == PRESENCE_ONLINE) { - mvwprintw(title_bar, 0, cols - 13, " ...online "); - } else if (current_status == PRESENCE_AWAY) { - mvwprintw(title_bar, 0, cols - 13, " .....away "); - } else if (current_status == PRESENCE_DND) { - mvwprintw(title_bar, 0, cols - 13, " ......dnd "); - } else if (current_status == PRESENCE_CHAT) { - mvwprintw(title_bar, 0, cols - 13, " .....chat "); - } else if (current_status == PRESENCE_XA) { - mvwprintw(title_bar, 0, cols - 13, " .......xa "); - } else { - mvwprintw(title_bar, 0, cols - 13, " ..offline "); + switch (current_status) + { + case CONTACT_ONLINE: + mvwprintw(title_bar, 0, cols - 13, " ...online "); + break; + case CONTACT_AWAY: + mvwprintw(title_bar, 0, cols - 13, " .....away "); + break; + case CONTACT_DND: + mvwprintw(title_bar, 0, cols - 13, " ......dnd "); + break; + case CONTACT_CHAT: + mvwprintw(title_bar, 0, cols - 13, " .....chat "); + break; + case CONTACT_XA: + mvwprintw(title_bar, 0, cols - 13, " .......xa "); + break; + case CONTACT_OFFLINE: + mvwprintw(title_bar, 0, cols - 13, " ..offline "); + break; } wattron(title_bar, COLOUR_TITLE_BRACKET); diff --git a/src/ui/ui.h b/src/ui/ui.h index d317ce41..6686acb7 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -92,7 +92,7 @@ void title_bar_refresh(void); void title_bar_resize(void); void title_bar_show(const char * const title); void title_bar_title(void); -void title_bar_set_status(presence_t status); +void title_bar_set_status(contact_presence_t status); void title_bar_set_recipient(char *from); void title_bar_set_typing(gboolean is_typing); void title_bar_draw(void); diff --git a/src/ui/windows.c b/src/ui/windows.c index a7fc6a24..d764755b 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -506,7 +506,7 @@ ui_disconnected(void) } } - title_bar_set_status(PRESENCE_OFFLINE); + title_bar_set_status(CONTACT_OFFLINE); status_bar_clear_message(); status_bar_refresh(); } @@ -1094,26 +1094,8 @@ cons_show_login_success(ProfAccount *account) _win_show_time(console->win, '-'); wprintw(console->win, "%s logged in successfully, ", account->jid); - presence_t presence = accounts_get_login_presence(account->name); - char *presence_str; - switch(presence) - { - case PRESENCE_CHAT: - presence_str = "chat"; - break; - case PRESENCE_AWAY: - presence_str = "away"; - break; - case PRESENCE_XA: - presence_str = "xa"; - break; - case PRESENCE_DND: - presence_str = "dnd"; - break; - default: - presence_str = "online"; - break; - } + resource_presence_t presence = accounts_get_login_presence(account->name); + const char *presence_str = string_from_resource_presence(presence); _presence_colour_on(console->win, presence_str); wprintw(console->win, "%s", presence_str); -- cgit 1.4.1-2-gfad0