From 8bea44a44ceb919fc0b249548e3494b4fe3e2ebc Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Tue, 18 Mar 2014 05:16:42 -0400 Subject: [PATCH] properly handle invalid statuses --- src/chat.c | 6 +++++- src/friendlist.c | 3 +++ src/prompt.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/chat.c b/src/chat.c index d95c3b8..bee1028 100644 --- a/src/chat.c +++ b/src/chat.c @@ -714,7 +714,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) /* Draw name, status and note in statusbar */ if (statusbar->is_online) { - char *status_text = "Unknown"; + const char *status_text = "Unknown"; int colour = WHITE; TOX_USERSTATUS status = statusbar->status; @@ -732,6 +732,10 @@ static void chat_onDraw(ToxWindow *self, Tox *m) status_text = "Busy"; colour = RED; break; + case TOX_USERSTATUS_INVALID: + status_text = "ERROR"; + colour = MAGENTA; + break; } wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); diff --git a/src/friendlist.c b/src/friendlist.c index d8d41bb..5426bcc 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -428,6 +428,9 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m) case TOX_USERSTATUS_BUSY: colour = RED; break; + case TOX_USERSTATUS_INVALID: + colour = MAGENTA; + break; } wattron(self->window, COLOR_PAIR(colour) | A_BOLD); diff --git a/src/prompt.c b/src/prompt.c index 950fb2c..2b76826 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -325,7 +325,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) if (statusbar->is_online) { int colour = WHITE; - char *status_text = "Unknown"; + const char *status_text = "Unknown"; switch (statusbar->status) { case TOX_USERSTATUS_NONE: @@ -340,6 +340,10 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) status_text = "Busy"; colour = RED; break; + case TOX_USERSTATUS_INVALID: + status_text = "ERROR"; + colour = MAGENTA; + break; } wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD); wprintw(statusbar->topline, " [%s]", status_text);