diff --git a/Makefile.am b/Makefile.am index 9da258eb..88bed76f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,7 @@ core_sources = \ src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ src/ui/console.c src/ui/notifier.c src/ui/notifier.h \ src/ui/windows.c src/ui/windows.h \ + src/ui/muc_window.c src/ui/muc_window.h \ src/command/command.h src/command/command.c src/command/history.c \ src/command/history.h src/tools/parser.c \ src/tools/parser.h \ diff --git a/src/ui/muc_window.c b/src/ui/muc_window.c new file mode 100644 index 00000000..ef4e1c9b --- /dev/null +++ b/src/ui/muc_window.c @@ -0,0 +1,39 @@ +/* + * muc_window.c + * + * Copyright (C) 2012, 2013 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + */ + +#include + +#include "ui/window.h" + +gboolean +muc_handle_error_message(ProfWin *self, const char * const from, + const char * const err_msg) +{ + gboolean handled = FALSE; + if (g_strcmp0(err_msg, "conflict") == 0) { + win_print_line(self, "Nickname already in use."); + win_refresh(self); + handled = TRUE; + } + + return handled; +} diff --git a/src/ui/muc_window.h b/src/ui/muc_window.h new file mode 100644 index 00000000..e67954a7 --- /dev/null +++ b/src/ui/muc_window.h @@ -0,0 +1,33 @@ +/* + * muc_window.h + * + * Copyright (C) 2012, 2013 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + */ + +#ifndef MUC_WINDOW_H +#define MUC_WINDOW_H + +#include + +#include "ui/window.h" + +gboolean muc_handle_error_message(ProfWin *self, const char * const from, + const char * const err_msg); + +#endif diff --git a/src/ui/window.c b/src/ui/window.c index 13956b22..a1d5a0fc 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -34,14 +34,11 @@ #include "config/theme.h" #include "ui/window.h" +#include "ui/muc_window.h" -static gboolean _muc_handle_error_message(ProfWin *self, const char * const from, - const char * const err_msg); static gboolean _default_handle_error_message(ProfWin *self, const char * const from, const char * const err_msg); static void _win_print_time(ProfWin *self, char show_char); -static void _win_print_line(ProfWin *self, const char * const msg, ...); -static void _win_refresh(ProfWin *self); static void _win_presence_colour_on(ProfWin *self, const char * const presence); static void _win_presence_colour_off(ProfWin *self, const char * const presence); static void _win_show_contact(ProfWin *self, PContact contact); @@ -60,8 +57,8 @@ win_create(const char * const title, int cols, win_type_t type) new_win->type = type; new_win->print_time = _win_print_time; - new_win->print_line = _win_print_line; - new_win->refresh_win = _win_refresh; + new_win->print_line = win_print_line; + new_win->refresh_win = win_refresh; new_win->presence_colour_on = _win_presence_colour_on; new_win->presence_colour_off = _win_presence_colour_off; new_win->show_contact = _win_show_contact; @@ -69,7 +66,7 @@ win_create(const char * const title, int cols, win_type_t type) switch (new_win->type) { case WIN_MUC: - new_win->handle_error_message = _muc_handle_error_message; + new_win->handle_error_message = muc_handle_error_message; break; default: new_win->handle_error_message = _default_handle_error_message; @@ -102,8 +99,8 @@ _win_print_time(ProfWin* self, char show_char) g_free(date_fmt); } -static void -_win_print_line(ProfWin *self, const char * const msg, ...) +void +win_print_line(ProfWin *self, const char * const msg, ...) { va_list arg; va_start(arg, msg); @@ -115,8 +112,8 @@ _win_print_line(ProfWin *self, const char * const msg, ...) va_end(arg); } -static void -_win_refresh(ProfWin *self) +void +win_refresh(ProfWin *self) { int rows, cols; getmaxyx(stdscr, rows, cols); @@ -207,20 +204,6 @@ _win_show_contact(ProfWin *self, PContact contact) _win_presence_colour_off(self, presence); } -static gboolean -_muc_handle_error_message(ProfWin *self, const char * const from, - const char * const err_msg) -{ - gboolean handled = FALSE; - if (g_strcmp0(err_msg, "conflict") == 0) { - _win_print_line(self, "Nickname already in use."); - _win_refresh(self); - handled = TRUE; - } - - return handled; -} - static gboolean _default_handle_error_message(ProfWin *self, const char * const from, const char * const err_msg) diff --git a/src/ui/window.h b/src/ui/window.h index 2eec3b01..5f8a0e36 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -64,5 +64,7 @@ typedef struct prof_win_t { ProfWin* win_create(const char * const title, int cols, win_type_t type); void win_free(ProfWin *window); +void win_print_line(ProfWin *self, const char * const msg, ...); +void win_refresh(ProfWin *self); #endif