Removed handle error message function from ProfWin
This commit is contained in:
@@ -35,12 +35,12 @@
|
||||
|
||||
#include "config/theme.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/muc_window.h"
|
||||
|
||||
static gboolean _default_handle_error_message(ProfWin *self, const char * const from,
|
||||
const char * const err_msg);
|
||||
static void _win_chat_print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
|
||||
static void _win_chat_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
|
||||
const char * const from, const char * const message);
|
||||
static gboolean
|
||||
_muc_handle_error_message(ProfWin *window, const char * const from,
|
||||
const char * const err_msg);
|
||||
|
||||
ProfWin*
|
||||
win_create(const char * const title, int cols, win_type_t type)
|
||||
@@ -54,29 +54,6 @@ win_create(const char * const title, int cols, win_type_t type)
|
||||
new_win->unread = 0;
|
||||
new_win->history_shown = 0;
|
||||
new_win->type = type;
|
||||
|
||||
switch (new_win->type)
|
||||
{
|
||||
case WIN_CONSOLE:
|
||||
new_win->handle_error_message = _default_handle_error_message;
|
||||
break;
|
||||
case WIN_CHAT:
|
||||
new_win->handle_error_message = _default_handle_error_message;
|
||||
break;
|
||||
case WIN_MUC:
|
||||
new_win->handle_error_message = muc_handle_error_message;
|
||||
break;
|
||||
case WIN_PRIVATE:
|
||||
new_win->handle_error_message = _default_handle_error_message;
|
||||
break;
|
||||
case WIN_DUCK:
|
||||
new_win->handle_error_message = _default_handle_error_message;
|
||||
break;
|
||||
default:
|
||||
new_win->handle_error_message = _default_handle_error_message;
|
||||
break;
|
||||
}
|
||||
|
||||
scrollok(new_win->win, TRUE);
|
||||
|
||||
return new_win;
|
||||
@@ -319,49 +296,75 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
|
||||
case WIN_PRIVATE:
|
||||
_win_chat_print_incoming_message(window, tv_stamp, from, message);
|
||||
break;
|
||||
case WIN_DUCK:
|
||||
case WIN_CONSOLE:
|
||||
case WIN_MUC:
|
||||
default:
|
||||
assert(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_default_handle_error_message(ProfWin *self, const char * const from,
|
||||
gboolean
|
||||
win_handle_error_message(ProfWin *window, const char * const from,
|
||||
const char * const err_msg)
|
||||
{
|
||||
return FALSE;
|
||||
gboolean handled = FALSE;
|
||||
switch (window->type)
|
||||
{
|
||||
case WIN_CHAT:
|
||||
case WIN_PRIVATE:
|
||||
case WIN_DUCK:
|
||||
case WIN_CONSOLE:
|
||||
handled = FALSE;
|
||||
case WIN_MUC:
|
||||
handled = _muc_handle_error_message(window, from, err_msg);
|
||||
default:
|
||||
assert(FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_muc_handle_error_message(ProfWin *window, const char * const from,
|
||||
const char * const err_msg)
|
||||
{
|
||||
gboolean handled = FALSE;
|
||||
if (g_strcmp0(err_msg, "conflict") == 0) {
|
||||
win_print_line(window, '-', 0, "Nickname already in use.");
|
||||
win_refresh(window);
|
||||
handled = TRUE;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static void
|
||||
_win_chat_print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
|
||||
_win_chat_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
|
||||
const char * const from, const char * const message)
|
||||
{
|
||||
if (tv_stamp == NULL) {
|
||||
win_print_time(self, '-');
|
||||
win_print_time(window, '-');
|
||||
} else {
|
||||
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
||||
gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
|
||||
wattron(self->win, COLOUR_TIME);
|
||||
wprintw(self->win, "%s - ", date_fmt);
|
||||
wattroff(self->win, COLOUR_TIME);
|
||||
wattron(window->win, COLOUR_TIME);
|
||||
wprintw(window->win, "%s - ", date_fmt);
|
||||
wattroff(window->win, COLOUR_TIME);
|
||||
g_date_time_unref(time);
|
||||
g_free(date_fmt);
|
||||
}
|
||||
|
||||
if (strncmp(message, "/me ", 4) == 0) {
|
||||
wattron(self->win, COLOUR_THEM);
|
||||
wprintw(self->win, "*%s ", from);
|
||||
waddstr(self->win, message + 4);
|
||||
wprintw(self->win, "\n");
|
||||
wattroff(self->win, COLOUR_THEM);
|
||||
wattron(window->win, COLOUR_THEM);
|
||||
wprintw(window->win, "*%s ", from);
|
||||
waddstr(window->win, message + 4);
|
||||
wprintw(window->win, "\n");
|
||||
wattroff(window->win, COLOUR_THEM);
|
||||
} else {
|
||||
wattron(self->win, COLOUR_THEM);
|
||||
wprintw(self->win, "%s: ", from);
|
||||
wattroff(self->win, COLOUR_THEM);
|
||||
waddstr(self->win, message);
|
||||
wprintw(self->win, "\n");
|
||||
wattron(window->win, COLOUR_THEM);
|
||||
wprintw(window->win, "%s: ", from);
|
||||
wattroff(window->win, COLOUR_THEM);
|
||||
waddstr(window->win, message);
|
||||
wprintw(window->win, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user