From d56f6dc39b002e16966354b0ad98cf7801260e0c Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 19 Dec 2013 21:05:39 +0000 Subject: Added mocks and stubs for cons_show --- src/ui/ui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/ui.h') diff --git a/src/ui/ui.h b/src/ui/ui.h index f6bb98ac..539146b7 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -149,7 +149,7 @@ void title_bar_set_typing(gboolean is_typing); void title_bar_draw(void); // console window actions -void cons_show(const char * const msg, ...); +void (*cons_show)(const char * const msg, ...); void cons_about(void); void cons_help(void); void cons_basic_help(void); -- cgit 1.4.1-2-gfad0 From 5a5b1340aa799ee1d56961123a4770ebadb287bc Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 22 Dec 2013 22:14:15 +0000 Subject: Dynamically load UI functions, fixed tests --- src/command/command.c | 44 +++--- src/command/commands.h | 2 +- src/ui/console.c | 303 ++++++++++++++++++++++++---------------- src/ui/core.c | 352 +++++++++++++++++++++++++++++------------------ src/ui/inputwin.c | 45 +++--- src/ui/notifier.c | 42 +++--- src/ui/statusbar.c | 60 ++++---- src/ui/titlebar.c | 45 +++--- src/ui/ui.h | 341 ++++++++++++++++++++++----------------------- tests/test_cmd_account.c | 9 +- tests/test_cmd_connect.c | 18 ++- tests/ui/mock_ui.c | 324 ++++++++----------------------------------- tests/ui/mock_ui.h | 13 ++ 13 files changed, 793 insertions(+), 805 deletions(-) (limited to 'src/ui/ui.h') diff --git a/src/command/command.c b/src/command/command.c index a13687a3..e37331ce 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -435,7 +435,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/beep", - cmd_beep, parse_args, 1, 1, cons_beep_setting, + cmd_beep, parse_args, 1, 1, &cons_beep_setting, { "/beep on|off", "Terminal beep on new messages.", { "/beep on|off", "------------", @@ -445,7 +445,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/notify", - cmd_notify, parse_args, 2, 2, cons_notify_setting, + cmd_notify, parse_args, 2, 2, &cons_notify_setting, { "/notify type value", "Control various desktop noficiations.", { "/notify type value", "------------------", @@ -470,7 +470,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/flash", - cmd_flash, parse_args, 1, 1, cons_flash_setting, + cmd_flash, parse_args, 1, 1, &cons_flash_setting, { "/flash on|off", "Terminal flash on new messages.", { "/flash on|off", "-------------", @@ -480,7 +480,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/intype", - cmd_intype, parse_args, 1, 1, cons_intype_setting, + cmd_intype, parse_args, 1, 1, &cons_intype_setting, { "/intype on|off", "Show when contact is typing.", { "/intype on|off", "--------------", @@ -488,7 +488,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/splash", - cmd_splash, parse_args, 1, 1, cons_splash_setting, + cmd_splash, parse_args, 1, 1, &cons_splash_setting, { "/splash on|off", "Splash logo on startup and /about command.", { "/splash on|off", "--------------", @@ -496,7 +496,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/autoconnect", - cmd_autoconnect, parse_args, 1, 2, cons_autoconnect_setting, + cmd_autoconnect, parse_args, 1, 2, &cons_autoconnect_setting, { "/autoconnect set|off [account]", "Set account to autoconnect with.", { "/autoconnect set|off [account]", "------------------------------", @@ -517,7 +517,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/titlebar", - cmd_titlebar, parse_args, 2, 2, cons_titlebar_setting, + cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting, { "/titlebar property on|off", "Show various properties in the window title bar.", { "/titlebar property on|off", "-------------------------", @@ -526,7 +526,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/mouse", - cmd_mouse, parse_args, 1, 1, cons_mouse_setting, + cmd_mouse, parse_args, 1, 1, &cons_mouse_setting, { "/mouse on|off", "Use profanity mouse handling.", { "/mouse on|off", "-------------", @@ -539,7 +539,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/chlog", - cmd_chlog, parse_args, 1, 1, cons_chlog_setting, + cmd_chlog, parse_args, 1, 1, &cons_chlog_setting, { "/chlog on|off", "Chat logging to file", { "/chlog on|off", "-------------", @@ -550,7 +550,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/grlog", - cmd_grlog, parse_args, 1, 1, cons_grlog_setting, + cmd_grlog, parse_args, 1, 1, &cons_grlog_setting, { "/grlog on|off", "Chat logging of chat rooms to file", { "/grlog on|off", "-------------", @@ -559,7 +559,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/states", - cmd_states, parse_args, 1, 1, cons_states_setting, + cmd_states, parse_args, 1, 1, &cons_states_setting, { "/states on|off", "Send chat states during a chat session.", { "/states on|off", "--------------", @@ -568,7 +568,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/outtype", - cmd_outtype, parse_args, 1, 1, cons_outtype_setting, + cmd_outtype, parse_args, 1, 1, &cons_outtype_setting, { "/outtype on|off", "Send typing notification to recipient.", { "/outtype on|off", "---------------", @@ -577,7 +577,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/gone", - cmd_gone, parse_args, 1, 1, cons_gone_setting, + cmd_gone, parse_args, 1, 1, &cons_gone_setting, { "/gone minutes", "Send 'gone' state to recipient after a period.", { "/gone minutes", "-------------", @@ -588,7 +588,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/history", - cmd_history, parse_args, 1, 1, cons_history_setting, + cmd_history, parse_args, 1, 1, &cons_history_setting, { "/history on|off", "Chat history in message windows.", { "/history on|off", "---------------", @@ -597,7 +597,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/log", - cmd_log, parse_args, 2, 2, cons_log_setting, + cmd_log, parse_args, 2, 2, &cons_log_setting, { "/log maxsize value", "Manage system logging settings.", { "/log maxsize value", "------------------", @@ -606,7 +606,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/reconnect", - cmd_reconnect, parse_args, 1, 1, cons_reconnect_setting, + cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting, { "/reconnect seconds", "Set reconnect interval.", { "/reconnect seconds", "------------------", @@ -615,7 +615,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/autoping", - cmd_autoping, parse_args, 1, 1, cons_autoping_setting, + cmd_autoping, parse_args, 1, 1, &cons_autoping_setting, { "/autoping seconds", "Server ping interval.", { "/autoping seconds", "-----------------", @@ -624,7 +624,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/autoaway", - cmd_autoaway, parse_args_with_freetext, 2, 2, cons_autoaway_setting, + cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting, { "/autoaway setting value", "Set auto idle/away properties.", { "/autoaway setting value", "-----------------------", @@ -645,7 +645,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/priority", - cmd_priority, parse_args, 1, 1, cons_priority_setting, + cmd_priority, parse_args, 1, 1, &cons_priority_setting, { "/priority value", "Set priority for the current account.", { "/priority value", "---------------", @@ -714,7 +714,7 @@ static struct cmd_t command_defs[] = NULL } } }, { "/theme", - cmd_theme, parse_args, 1, 2, cons_theme_setting, + cmd_theme, parse_args, 1, 2, &cons_theme_setting, { "/theme command [theme-name]", "Change colour theme.", { "/theme command [theme-name]", "---------------------------", @@ -730,7 +730,7 @@ static struct cmd_t command_defs[] = { "/statuses", - cmd_statuses, parse_args, 1, 1, cons_statuses_setting, + cmd_statuses, parse_args, 1, 1, &cons_statuses_setting, { "/statuses on|off", "Set notifications for status messages.", { "/statuses on|off", "----------------", @@ -1086,7 +1086,7 @@ cmd_execute(const char * const command, const char * const inp) gchar **args = cmd->parser(inp, cmd->min_args, cmd->max_args); if ((args == NULL) && (cmd->setting_func != NULL)) { cons_show(""); - cmd->setting_func(); + (*cmd->setting_func)(); cons_show("Usage: %s", cmd->help.usage); return TRUE; } else if (args == NULL) { diff --git a/src/command/commands.h b/src/command/commands.h index aee74849..27a02249 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -46,7 +46,7 @@ typedef struct cmd_t { gchar** (*parser)(const char * const inp, int min, int max); int min_args; int max_args; - void (*setting_func)(void); + void (**setting_func)(void); CommandHelp help; } Command; diff --git a/src/ui/console.c b/src/ui/console.c index 43313dd1..57e5eb73 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -47,24 +47,26 @@ static void _cons_splash_logo(void); void _show_roster_contacts(GSList *list, gboolean show_groups); -void -cons_show_time(void) +static void +_cons_show_time(void) { ProfWin *console = wins_get_console(); win_print_time(console, '-'); wins_refresh_console(); } +void (*cons_show_time)(void) = _cons_show_time; -void -cons_show_word(const char * const word) +static void +_cons_show_word(const char * const word) { ProfWin *console = wins_get_console(); wprintw(console->win, "%s", word); wins_refresh_console(); } +void (*cons_show_word)(const char * const) = _cons_show_word; -void -cons_debug(const char * const msg, ...) +static void +_cons_debug(const char * const msg, ...) { ProfWin *console = wins_get_console(); if (strcmp(PACKAGE_STATUS, "development") == 0) { @@ -84,6 +86,7 @@ cons_debug(const char * const msg, ...) ui_refresh(); } } +void (*cons_debug)(const char * const, ...) = _cons_debug; static void _cons_show(const char * const msg, ...) @@ -101,8 +104,8 @@ _cons_show(const char * const msg, ...) } void (*cons_show)(const char * const, ...) = _cons_show; -void -cons_show_error(const char * const msg, ...) +static void +_cons_show_error(const char * const msg, ...) { ProfWin *console = wins_get_console(); va_list arg; @@ -119,9 +122,10 @@ cons_show_error(const char * const msg, ...) wins_refresh_console(); cons_alert(); } +void (*cons_show_error)(const char * const, ...) = _cons_show_error; -void -cons_show_typing(const char * const barejid) +static void +_cons_show_typing(const char * const barejid) { ProfWin *console = wins_get_console(); PContact contact = roster_get_contact(barejid); @@ -137,9 +141,10 @@ cons_show_typing(const char * const barejid) wins_refresh_console(); cons_alert(); } +void (*cons_show_typing)(const char * const) = _cons_show_typing; -void -cons_show_incoming_message(const char * const short_from, const int win_index) +static void +_cons_show_incoming_message(const char * const short_from, const int win_index) { ProfWin *console = wins_get_console(); @@ -155,9 +160,10 @@ cons_show_incoming_message(const char * const short_from, const int win_index) wins_refresh_console(); cons_alert(); } +void (*cons_show_incoming_message)(const char * const, const int) = _cons_show_incoming_message; -void -cons_about(void) +static void +_cons_about(void) { ProfWin *console = wins_get_console(); int rows, cols; @@ -207,9 +213,10 @@ cons_about(void) wins_refresh_console(); cons_alert(); } +void (*cons_about)(void) = _cons_about; -void -cons_check_version(gboolean not_available_msg) +static void +_cons_check_version(gboolean not_available_msg) { ProfWin *console = wins_get_console(); char *latest_release = release_get_latest(); @@ -238,9 +245,10 @@ cons_check_version(gboolean not_available_msg) } } } +void (*cons_check_version)(gboolean) = _cons_check_version; -void -cons_show_login_success(ProfAccount *account) +static void +_cons_show_login_success(ProfAccount *account) { ProfWin *console = wins_get_console(); win_print_time(console, '-'); @@ -258,9 +266,10 @@ cons_show_login_success(ProfAccount *account) wins_refresh_console(); cons_alert(); } +void (*cons_show_login_success)(ProfAccount*) = _cons_show_login_success; -void -cons_show_wins(void) +static void +_cons_show_wins(void) { ProfWin *console = wins_get_console(); cons_show(""); @@ -279,9 +288,10 @@ cons_show_wins(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_wins)(void) = _cons_show_wins; -void -cons_show_room_invites(GSList *invites) +static void +_cons_show_room_invites(GSList *invites) { cons_show(""); if (invites == NULL) { @@ -297,9 +307,10 @@ cons_show_room_invites(GSList *invites) wins_refresh_console(); cons_alert(); } +void (*cons_show_room_invites)(GSList*) = _cons_show_room_invites; -void -cons_show_info(PContact pcontact) +static void +_cons_show_info(PContact pcontact) { ProfWin *console = wins_get_console(); const char *barejid = p_contact_barejid(pcontact); @@ -430,9 +441,10 @@ cons_show_info(PContact pcontact) wins_refresh_console(); cons_alert(); } +void (*cons_show_info)(PContact) = _cons_show_info; -void -cons_show_caps(const char * const contact, Resource *resource) +static void +_cons_show_caps(const char * const contact, Resource *resource) { ProfWin *console = wins_get_console(); WINDOW *win = console->win; @@ -505,9 +517,10 @@ cons_show_caps(const char * const contact, Resource *resource) wins_refresh_console(); cons_alert(); } +void (*cons_show_caps)(const char * const, Resource*) = _cons_show_caps; -void -cons_show_software_version(const char * const jid, const char * const presence, +static 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) { ProfWin *console = wins_get_console(); @@ -532,9 +545,12 @@ cons_show_software_version(const char * const jid, const char * const presence, wins_refresh_console(); cons_alert(); } +void (*cons_show_software_version)(const char * const, const char * const, + const char * const, const char * const, + const char * const) = _cons_show_software_version; -void -cons_show_received_subs(void) +static void +_cons_show_received_subs(void) { GSList *received = presence_get_subscription_requests(); if (received == NULL) { @@ -552,9 +568,10 @@ cons_show_received_subs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_received_subs)(void) = _cons_show_received_subs; -void -cons_show_sent_subs(void) +static void +_cons_show_sent_subs(void) { if (roster_has_pending_subscriptions()) { GSList *contacts = roster_get_contacts(); @@ -574,9 +591,10 @@ cons_show_sent_subs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_sent_subs)(void) = _cons_show_sent_subs; -void -cons_show_room_list(GSList *rooms, const char * const conference_node) +static void +_cons_show_room_list(GSList *rooms, const char * const conference_node) { ProfWin *console = wins_get_console(); if ((rooms != NULL) && (g_slist_length(rooms) > 0)) { @@ -598,9 +616,10 @@ cons_show_room_list(GSList *rooms, const char * const conference_node) wins_refresh_console(); cons_alert(); } +void (*cons_show_room_list)(GSList*, const char * const) = _cons_show_room_list; -void -cons_show_bookmarks(const GList *list) +static void +_cons_show_bookmarks(const GList *list) { Bookmark *item; @@ -628,9 +647,10 @@ cons_show_bookmarks(const GList *list) wins_refresh_console(); cons_alert(); } +void (*cons_show_bookmarks)(const GList*) = _cons_show_bookmarks; -void -cons_show_disco_info(const char *jid, GSList *identities, GSList *features) +static void +_cons_show_disco_info(const char *jid, GSList *identities, GSList *features) { if (((identities != NULL) && (g_slist_length(identities) > 0)) || ((features != NULL) && (g_slist_length(features) > 0))) { @@ -671,9 +691,10 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) cons_alert(); } } +void (*cons_show_disco_info)(const char*, GSList*, GSList*) = _cons_show_disco_info; -void -cons_show_disco_items(GSList *items, const char * const jid) +static void +_cons_show_disco_items(GSList *items, const char * const jid) { ProfWin *console = wins_get_console(); if ((items != NULL) && (g_slist_length(items) > 0)) { @@ -696,9 +717,10 @@ cons_show_disco_items(GSList *items, const char * const jid) wins_refresh_console(); cons_alert(); } +void (*cons_show_disco_items)(GSList*, const char * const) = _cons_show_disco_items; -void -cons_show_status(const char * const barejid) +static void +_cons_show_status(const char * const barejid) { ProfWin *console = wins_get_console(); PContact pcontact = roster_get_contact(barejid); @@ -711,9 +733,10 @@ cons_show_status(const char * const barejid) wins_refresh_console(); cons_alert(); } +void (*cons_show_status)(const char * const) = _cons_show_status; -void -cons_show_room_invite(const char * const invitor, const char * const room, +static void +_cons_show_room_invite(const char * const invitor, const char * const room, const char * const reason) { char *display_from = NULL; @@ -748,9 +771,11 @@ cons_show_room_invite(const char * const invitor, const char * const room, wins_refresh_console(); cons_alert(); } +void (*cons_show_room_invite)(const char * const, const char * const, + const char * const) = _cons_show_room_invite; -void -cons_show_account_list(gchar **accounts) +static void +_cons_show_account_list(gchar **accounts) { ProfWin *console = wins_get_console(); int size = g_strv_length(accounts); @@ -778,9 +803,10 @@ cons_show_account_list(gchar **accounts) wins_refresh_console(); cons_alert(); } +void (*cons_show_account_list)(gchar**) = _cons_show_account_list; -void -cons_show_account(ProfAccount *account) +static void +_cons_show_account(ProfAccount *account) { ProfWin *console = wins_get_console(); cons_show(""); @@ -901,9 +927,10 @@ cons_show_account(ProfAccount *account) wins_refresh_console(); cons_alert(); } +void (*cons_show_account)(ProfAccount*) = _cons_show_account; -void -cons_theme_setting(void) +static void +_cons_theme_setting(void) { gchar *theme = prefs_get_string(PREF_THEME); if (theme == NULL) { @@ -912,72 +939,80 @@ cons_theme_setting(void) cons_show("Theme (/theme) : %s", theme); } } +void (*cons_theme_setting)(void) = _cons_theme_setting; -void -cons_beep_setting(void) +static void +_cons_beep_setting(void) { if (prefs_get_boolean(PREF_BEEP)) cons_show("Terminal beep (/beep) : ON"); else cons_show("Terminal beep (/beep) : OFF"); } +void (*cons_beep_setting)(void) = _cons_beep_setting; -void -cons_flash_setting(void) +static void +_cons_flash_setting(void) { if (prefs_get_boolean(PREF_FLASH)) cons_show("Terminal flash (/flash) : ON"); else cons_show("Terminal flash (/flash) : OFF"); } +void (*cons_flash_setting)(void) = _cons_flash_setting; -void -cons_splash_setting(void) +static void +_cons_splash_setting(void) { if (prefs_get_boolean(PREF_SPLASH)) cons_show("Splash screen (/splash) : ON"); else cons_show("Splash screen (/splash) : OFF"); } +void (*cons_splash_setting)(void) = _cons_splash_setting; -void -cons_autoconnect_setting(void) +static void +_cons_autoconnect_setting(void) { if (prefs_get_string(PREF_CONNECT_ACCOUNT) != NULL) cons_show("Autoconnect (/autoconnect) : %s", prefs_get_string(PREF_CONNECT_ACCOUNT)); else cons_show("Autoconnect (/autoconnect) : OFF"); } +void (*cons_autoconnect_setting)(void) = _cons_autoconnect_setting; -void -cons_vercheck_setting(void) +static void +_cons_vercheck_setting(void) { if (prefs_get_boolean(PREF_VERCHECK)) cons_show("Version checking (/vercheck) : ON"); else cons_show("Version checking (/vercheck) : OFF"); } +void (*cons_vercheck_setting)(void) = _cons_vercheck_setting; -void -cons_mouse_setting(void) +static void +_cons_mouse_setting(void) { if (prefs_get_boolean(PREF_MOUSE)) cons_show("Mouse handling (/mouse) : ON"); else cons_show("Mouse handling (/mouse) : OFF"); } +void (*cons_mouse_setting)(void) = _cons_mouse_setting; -void -cons_statuses_setting(void) +static void +_cons_statuses_setting(void) { if (prefs_get_boolean(PREF_STATUSES)) cons_show("Status (/statuses) : ON"); else cons_show("Status (/statuses) : OFF"); } +void (*cons_statuses_setting)(void) = _cons_statuses_setting; -void -cons_titlebar_setting(void) +static void +_cons_titlebar_setting(void) { if (prefs_get_boolean(PREF_TITLEBARVERSION)) { cons_show("Titlebar display (/titlebar) : version"); @@ -985,9 +1020,10 @@ cons_titlebar_setting(void) cons_show("Titlebar display (/titlebar) : NONE"); } } +void (*cons_titlebar_setting)(void) = _cons_titlebar_setting; -void -cons_show_ui_prefs(void) +static void +_cons_show_ui_prefs(void) { cons_show("UI preferences:"); cons_show(""); @@ -1003,9 +1039,10 @@ cons_show_ui_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_ui_prefs)(void) = _cons_show_ui_prefs; -void -cons_notify_setting(void) +static void +_cons_notify_setting(void) { if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) cons_show("Messages (/notify message) : ON"); @@ -1036,9 +1073,10 @@ cons_notify_setting(void) cons_show("Reminder period (/notify remind) : %d seconds", remind_period); } } +void (*cons_notify_setting)(void) = _cons_notify_setting; -void -cons_show_desktop_prefs(void) +static void +_cons_show_desktop_prefs(void) { cons_show("Desktop notification preferences:"); cons_show(""); @@ -1047,36 +1085,40 @@ cons_show_desktop_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_desktop_prefs)(void) = _cons_show_desktop_prefs; -void -cons_states_setting(void) +static void +_cons_states_setting(void) { if (prefs_get_boolean(PREF_STATES)) cons_show("Send chat states (/states) : ON"); else cons_show("Send chat states (/states) : OFF"); } +void (*cons_states_setting)(void) = _cons_states_setting; -void -cons_outtype_setting(void) +static void +_cons_outtype_setting(void) { if (prefs_get_boolean(PREF_OUTTYPE)) cons_show("Send composing (/outtype) : ON"); else cons_show("Send composing (/outtype) : OFF"); } +void (*cons_outtype_setting)(void) = _cons_outtype_setting; -void -cons_intype_setting(void) +static void +_cons_intype_setting(void) { if (prefs_get_boolean(PREF_INTYPE)) cons_show("Show typing (/intype) : ON"); else cons_show("Show typing (/intype) : OFF"); } +void (*cons_intype_setting)(void) = _cons_intype_setting; -void -cons_gone_setting(void) +static void +_cons_gone_setting(void) { gint gone_time = prefs_get_gone(); if (gone_time == 0) { @@ -1087,18 +1129,20 @@ cons_gone_setting(void) cons_show("Leave conversation (/gone) : %d minutes", gone_time); } } +void (*cons_gone_setting)(void) = _cons_gone_setting; -void -cons_history_setting(void) +static void +_cons_history_setting(void) { if (prefs_get_boolean(PREF_HISTORY)) cons_show("Chat history (/history) : ON"); else cons_show("Chat history (/history) : OFF"); } +void (*cons_history_setting)(void) = _cons_history_setting; -void -cons_show_chat_prefs(void) +static void +_cons_show_chat_prefs(void) { cons_show("Chat preferences:"); cons_show(""); @@ -1111,33 +1155,37 @@ cons_show_chat_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_chat_prefs)(void) = _cons_show_chat_prefs; -void -cons_log_setting(void) +static void +_cons_log_setting(void) { cons_show("Max log size (/log maxsize) : %d bytes", prefs_get_max_log_size()); } +void (*cons_log_setting)(void) = _cons_log_setting; -void -cons_chlog_setting(void) +static void +_cons_chlog_setting(void) { if (prefs_get_boolean(PREF_CHLOG)) cons_show("Chat logging (/chlog) : ON"); else cons_show("Chat logging (/chlog) : OFF"); } +void (*cons_chlog_setting)(void) = _cons_chlog_setting; -void -cons_grlog_setting(void) +static void +_cons_grlog_setting(void) { if (prefs_get_boolean(PREF_GRLOG)) cons_show("Groupchat logging (/grlog) : ON"); else cons_show("Groupchat logging (/grlog) : OFF"); } +void (*cons_grlog_setting)(void) = _cons_grlog_setting; -void -cons_show_log_prefs(void) +static void +_cons_show_log_prefs(void) { cons_show("Logging preferences:"); cons_show(""); @@ -1148,9 +1196,10 @@ cons_show_log_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_log_prefs)(void) = _cons_show_log_prefs; -void -cons_autoaway_setting(void) +static void +_cons_autoaway_setting(void) { if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "off") == 0) { cons_show("Autoaway (/autoaway mode) : OFF"); @@ -1173,9 +1222,10 @@ cons_autoaway_setting(void) cons_show("Autoaway check (/autoaway check) : OFF"); } } +void (*cons_autoaway_setting)(void) = _cons_autoaway_setting; -void -cons_show_presence_prefs(void) +static void +_cons_show_presence_prefs(void) { cons_show("Presence preferences:"); cons_show(""); @@ -1184,9 +1234,10 @@ cons_show_presence_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_presence_prefs)(void) = _cons_show_presence_prefs; -void -cons_reconnect_setting(void) +static void +_cons_reconnect_setting(void) { gint reconnect_interval = prefs_get_reconnect(); if (reconnect_interval == 0) { @@ -1197,9 +1248,10 @@ cons_reconnect_setting(void) cons_show("Reconnect interval (/reconnect) : %d seconds", reconnect_interval); } } +void (*cons_reconnect_setting)(void) = _cons_reconnect_setting; -void -cons_autoping_setting(void) +static void +_cons_autoping_setting(void) { gint autoping_interval = prefs_get_autoping(); if (autoping_interval == 0) { @@ -1210,16 +1262,18 @@ cons_autoping_setting(void) cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval); } } +void (*cons_autoping_setting)(void) = _cons_autoping_setting; -void -cons_priority_setting(void) +static void +_cons_priority_setting(void) { gint priority = prefs_get_priority(); cons_show("Priority (/priority) : %d", priority); } +void (*cons_priority_setting)(void) = _cons_priority_setting; -void -cons_show_connection_prefs(void) +static void +_cons_show_connection_prefs(void) { cons_show("Connection preferences:"); cons_show(""); @@ -1230,9 +1284,10 @@ cons_show_connection_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_show_connection_prefs)(void) = _cons_show_connection_prefs; -void -cons_show_themes(GSList *themes) +static void +_cons_show_themes(GSList *themes) { cons_show(""); @@ -1249,9 +1304,10 @@ cons_show_themes(GSList *themes) wins_refresh_console(); cons_alert(); } +void (*cons_show_themes)(GSList*) = _cons_show_themes; -void -cons_prefs(void) +static void +_cons_prefs(void) { cons_show(""); cons_show_ui_prefs(); @@ -1270,9 +1326,10 @@ cons_prefs(void) wins_refresh_console(); cons_alert(); } +void (*cons_prefs)(void) = _cons_prefs; -void -cons_help(void) +static void +_cons_help(void) { cons_show(""); cons_show("Choose a help option:"); @@ -1293,9 +1350,10 @@ cons_help(void) wins_refresh_console(); cons_alert(); } +void (*cons_help)(void) = _cons_help; -void -cons_navigation_help(void) +static void +_cons_navigation_help(void) { cons_show(""); cons_show("Navigation:"); @@ -1317,9 +1375,10 @@ cons_navigation_help(void) wins_refresh_console(); cons_alert(); } +void (*cons_navigation_help)(void) = _cons_navigation_help; -void -cons_show_roster_group(const char * const group, GSList *list) +static void +_cons_show_roster_group(const char * const group, GSList *list) { cons_show(""); @@ -1333,9 +1392,10 @@ cons_show_roster_group(const char * const group, GSList *list) wins_refresh_console(); cons_alert(); } +void (*cons_show_roster_group)(const char * const, GSList*) = _cons_show_roster_group; -void -cons_show_roster(GSList *list) +static void +_cons_show_roster(GSList *list) { cons_show(""); cons_show("Roster:"); @@ -1344,9 +1404,10 @@ cons_show_roster(GSList *list) wins_refresh_console(); cons_alert(); } +void (*cons_show_roster)(GSList*) = _cons_show_roster; -void -cons_show_contacts(GSList *list) +static void +_cons_show_contacts(GSList *list) { ProfWin *console = wins_get_console(); GSList *curr = list; @@ -1363,14 +1424,16 @@ cons_show_contacts(GSList *list) wins_refresh_console(); cons_alert(); } +void (*cons_show_contacts)(GSList*) = _cons_show_contacts; -void -cons_alert(void) +static void +_cons_alert(void) { if (ui_current_win_type() != WIN_CONSOLE) { status_bar_new(1); } } +void (*cons_alert)(void) = _cons_alert; static void _cons_splash_logo(void) diff --git a/src/ui/core.c b/src/ui/core.c index 1ff41b7d..b68d2edc 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -69,8 +69,8 @@ static void _win_show_history(WINDOW *win, int win_index, const char * const contact); static void _ui_draw_win_title(void); -void -ui_init(void) +static void +_ui_init(void) { log_info("Initialising UI"); initscr(); @@ -95,18 +95,20 @@ ui_init(void) ui_idle_time = g_timer_new(); wins_refresh_current(); } +void (*ui_init)(void) = _ui_init; -void -ui_refresh(void) +static void +_ui_refresh(void) { _ui_draw_win_title(); title_bar_refresh(); status_bar_refresh(); inp_put_back(); } +void (*ui_refresh)(void) = _ui_refresh; -unsigned long -ui_get_idle_time(void) +static unsigned long +_ui_get_idle_time(void) { // if compiled with libxss, get the x sessions idle time #ifdef HAVE_LIBXSS @@ -123,23 +125,26 @@ ui_get_idle_time(void) unsigned long ms_elapsed = seconds_elapsed * 1000.0; return ms_elapsed; } +unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time; -void -ui_reset_idle_time(void) +static void +_ui_reset_idle_time(void) { g_timer_start(ui_idle_time); } +void (*ui_reset_idle_time)(void) = _ui_reset_idle_time; -void -ui_close(void) +static void +_ui_close(void) { notifier_uninit(); wins_destroy(); endwin(); } +void (*ui_close)(void) = _ui_close; -void -ui_resize(const int ch, const char * const input, const int size) +static void +_ui_resize(const int ch, const char * const input, const int size) { log_info("Resizing UI"); title_bar_resize(); @@ -148,9 +153,10 @@ ui_resize(const int ch, const char * const input, const int size) inp_win_resize(input, size); wins_refresh_current(); } +void (*ui_resize)(const int, const char * const, const int) = _ui_resize; -void -ui_load_colours(void) +static void +_ui_load_colours(void) { if (has_colors()) { use_default_colors(); @@ -158,22 +164,25 @@ ui_load_colours(void) theme_init_colours(); } } +void (*ui_load_colours)(void) = _ui_load_colours; -gboolean -ui_win_exists(int index) +static gboolean +_ui_win_exists(int index) { ProfWin *window = wins_get_by_num(index); return (window != NULL); } +gboolean (*ui_win_exists)(int) = _ui_win_exists; -gboolean -ui_duck_exists(void) +static gboolean +_ui_duck_exists(void) { return wins_duck_exists(); } +gboolean (*ui_duck_exists)(void) = _ui_duck_exists; -void -ui_contact_typing(const char * const barejid) +static void +_ui_contact_typing(const char * const barejid) { ProfWin *window = wins_get_by_recipient(barejid); @@ -209,16 +218,18 @@ ui_contact_typing(const char * const barejid) notify_typing(display_usr); } } +void (*ui_contact_typing)(const char * const) = _ui_contact_typing; -GSList * -ui_get_recipients(void) +static GSList * +_ui_get_recipients(void) { GSList *recipients = wins_get_chat_recipients(); return recipients; } +GSList * (*ui_get_recipients)(void) = _ui_get_recipients; -void -ui_incoming_msg(const char * const from, const char * const message, +static void +_ui_incoming_msg(const char * const from, const char * const message, GTimeVal *tv_stamp, gboolean priv) { gboolean win_created = FALSE; @@ -293,9 +304,11 @@ ui_incoming_msg(const char * const from, const char * const message, free(display_from); } +void (*ui_incoming_msg)(const char * const, const char * const, + GTimeVal*, gboolean) = _ui_incoming_msg; -void -ui_roster_add(const char * const barejid, const char * const name) +static void +_ui_roster_add(const char * const barejid, const char * const name) { if (name != NULL) { cons_show("Roster item added: %s (%s)", barejid, name); @@ -303,39 +316,45 @@ ui_roster_add(const char * const barejid, const char * const name) cons_show("Roster item added: %s", barejid); } } +void (*ui_roster_add)(const char * const, const char * const) = _ui_roster_add; -void -ui_roster_remove(const char * const barejid) +static void +_ui_roster_remove(const char * const barejid) { cons_show("Roster item removed: %s", barejid); } +void (*ui_roster_remove)(const char * const) = _ui_roster_remove; -void -ui_contact_already_in_group(const char * const contact, const char * const group) +static void +_ui_contact_already_in_group(const char * const contact, const char * const group) { cons_show("%s already in group %s", contact, group); } +void (*ui_contact_already_in_group)(const char * const, const char * const) = _ui_contact_already_in_group; -void -ui_contact_not_in_group(const char * const contact, const char * const group) +static void +_ui_contact_not_in_group(const char * const contact, const char * const group) { cons_show("%s is not currently in group %s", contact, group); } +void (*ui_contact_not_in_group)(const char * const, const char * const) = _ui_contact_not_in_group; -void -ui_group_added(const char * const contact, const char * const group) +static void +_ui_group_added(const char * const contact, const char * const group) { cons_show("%s added to group %s", contact, group); } +void (*ui_group_added)(const char * const, const char * const) = _ui_group_added; -void -ui_group_removed(const char * const contact, const char * const group) +static void +_ui_group_removed(const char * const contact, const char * const group) { cons_show("%s removed from group %s", contact, group); } +void (*ui_group_removed)(const char * const, const char * const) = _ui_group_removed; -void -ui_handle_error_message(const char * const from, const char * const err_msg) +static void +_ui_handle_error_message(const char * const from, const char * const err_msg) { if (err_msg == NULL) { cons_show_error("Unknown error received from service."); @@ -349,9 +368,11 @@ ui_handle_error_message(const char * const from, const char * const err_msg) ui_print_error_from_recipient(from, err_msg); } +void (*ui_handle_error_message)(const char * const, + const char * const) = _ui_handle_error_message; -void -ui_contact_online(const char * const barejid, const char * const resource, +static void +_ui_contact_online(const char * const barejid, const char * const resource, const char * const show, const char * const status, GDateTime *last_activity) { PContact contact = roster_get_contact(barejid); @@ -375,9 +396,11 @@ ui_contact_online(const char * const barejid, const char * const resource, wins_refresh_current(); } } +void (*ui_contact_online)(const char * const, const char * const, + const char * const, const char * const, GDateTime*) = _ui_contact_online; -void -ui_contact_offline(const char * const from, const char * const show, +static void +_ui_contact_offline(const char * const from, const char * const show, const char * const status) { Jid *jidp = jid_create(from); @@ -403,18 +426,21 @@ ui_contact_offline(const char * const from, const char * const show, wins_refresh_current(); } } +void (*ui_contact_offline)(const char * const, const char * const, + const char * const) = _ui_contact_offline; -void -ui_disconnected(void) +static void +_ui_disconnected(void) { wins_lost_connection(); title_bar_set_status(CONTACT_OFFLINE); status_bar_clear_message(); status_bar_refresh(); } +void (*ui_disconnected)(void) = _ui_disconnected; -void -ui_handle_special_keys(const wint_t * const ch, const char * const inp, +static void +_ui_handle_special_keys(const wint_t * const ch, const char * const inp, const int size) { _win_handle_switch(ch); @@ -424,9 +450,11 @@ ui_handle_special_keys(const wint_t * const ch, const char * const inp, } } +void (*ui_handle_special_keys)(const wint_t * const, const char * const, + const int) = _ui_handle_special_keys; -void -ui_close_connected_win(int index) +static void +_ui_close_connected_win(int index) { win_type_t win_type = ui_win_type(index); if (win_type == WIN_MUC) { @@ -446,9 +474,10 @@ ui_close_connected_win(int index) } } } +void (*ui_close_connected_win)(int index) = _ui_close_connected_win; -int -ui_close_all_wins(void) +static int +_ui_close_all_wins(void) { int count = 0; jabber_conn_status_t conn_status = jabber_get_connection_status(); @@ -473,9 +502,10 @@ ui_close_all_wins(void) return count; } +int (*ui_close_all_wins)(void) = _ui_close_all_wins; -int -ui_close_read_wins(void) +static int +_ui_close_read_wins(void) { int count = 0; jabber_conn_status_t conn_status = jabber_get_connection_status(); @@ -500,9 +530,10 @@ ui_close_read_wins(void) return count; } +int (*ui_close_read_wins)(void) = _ui_close_read_wins; -void -ui_switch_win(const int i) +static void +_ui_switch_win(const int i) { ui_current_page_off(); ProfWin *new_current = wins_get_by_num(i); @@ -534,9 +565,10 @@ ui_switch_win(const int i) wins_refresh_current(); } } +void (*ui_switch_win)(const int) = _ui_switch_win; -void -ui_next_win(void) +static void +_ui_next_win(void) { ui_current_page_off(); ProfWin *new_current = wins_get_next(); @@ -567,9 +599,10 @@ ui_next_win(void) } wins_refresh_current(); } +void (*ui_next_win)(void) = _ui_next_win; -void -ui_previous_win(void) +static void +_ui_previous_win(void) { ui_current_page_off(); ProfWin *new_current = wins_get_previous(); @@ -600,15 +633,17 @@ ui_previous_win(void) } wins_refresh_current(); } +void (*ui_previous_win)(void) = _ui_previous_win; -void -ui_clear_current(void) +static void +_ui_clear_current(void) { wins_clear_current(); } +void (*ui_clear_current)(void) = _ui_clear_current; -void -ui_close_current(void) +static void +_ui_close_current(void) { int current_index = wins_get_current_num(); status_bar_inactive(current_index); @@ -617,9 +652,10 @@ ui_close_current(void) status_bar_active(1); title_bar_title(); } +void (*ui_close_current)(void) = _ui_close_current; -void -ui_close_win(int index) +static void +_ui_close_win(int index) { wins_close_by_num(index); status_bar_current(1); @@ -628,9 +664,10 @@ ui_close_win(int index) wins_refresh_current(); } +void (*ui_close_win)(int) = _ui_close_win; -void -ui_tidy_wins(void) +static void +_ui_tidy_wins(void) { gboolean tidied = wins_tidy(); @@ -640,9 +677,10 @@ ui_tidy_wins(void) cons_show("No tidy needed."); } } +void (*ui_tidy_wins)(void) = _ui_tidy_wins; -void -ui_prune_wins(void) +static void +_ui_prune_wins(void) { jabber_conn_status_t conn_status = jabber_get_connection_status(); gboolean pruned = FALSE; @@ -685,43 +723,49 @@ ui_prune_wins(void) cons_show("No prune needed."); } } +void (*ui_prune_wins)(void) = _ui_prune_wins; -win_type_t -ui_current_win_type(void) +static win_type_t +_ui_current_win_type(void) { ProfWin *current = wins_get_current(); return current->type; } +win_type_t (*ui_current_win_type)(void) = _ui_current_win_type; -int -ui_current_win_index(void) +static int +_ui_current_win_index(void) { return wins_get_current_num(); } +int (*ui_current_win_index)(void) = _ui_current_win_index; -win_type_t -ui_win_type(int index) +static win_type_t +_ui_win_type(int index) { ProfWin *window = wins_get_by_num(index); return window->type; } +win_type_t (*ui_win_type)(int index) = _ui_win_type; -char * -ui_recipient(int index) +static char * +_ui_recipient(int index) { ProfWin *window = wins_get_by_num(index); return window->from; } +char * (*ui_recipient)(int) = _ui_recipient; -char * -ui_current_recipient(void) +static char * +_ui_current_recipient(void) { ProfWin *current = wins_get_current(); return current->from; } +char* (*ui_current_recipient)(void) = _ui_current_recipient; -void -ui_current_print_line(const char * const msg, ...) +static void +_ui_current_print_line(const char * const msg, ...) { ProfWin *current = wins_get_current(); va_list arg; @@ -730,25 +774,28 @@ ui_current_print_line(const char * const msg, ...) va_end(arg); win_refresh(current); } +void (*ui_current_print_line)(const char * const, ...) = _ui_current_print_line; -void -ui_current_error_line(const char * const msg) +static void +_ui_current_error_line(const char * const msg) { ProfWin *current = wins_get_current(); win_print_line(current, '-', COLOUR_ERROR, msg); win_refresh(current); } +void (*ui_current_error_line)(const char * const) = _ui_current_error_line; -void -ui_current_page_off(void) +static void +_ui_current_page_off(void) { ProfWin *current = wins_get_current(); win_page_off(current); win_refresh(current); } +void (*ui_current_page_off)(void) = _ui_current_page_off; -void -ui_print_error_from_recipient(const char * const from, const char *err_msg) +static void +_ui_print_error_from_recipient(const char * const from, const char *err_msg) { if (from == NULL || err_msg == NULL) return; @@ -761,9 +808,10 @@ ui_print_error_from_recipient(const char * const from, const char *err_msg) } } } +void (*ui_print_error_from_recipient)(const char * const, const char *) = _ui_print_error_from_recipient; -void -ui_print_system_msg_from_recipient(const char * const from, const char *message) +static void +_ui_print_system_msg_from_recipient(const char * const from, const char *message) { int num = 0; char from_cpy[strlen(from) + 1]; @@ -796,9 +844,11 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message) wins_refresh_current(); } } +void (*ui_print_system_msg_from_recipient)(const char * const, + const char *) = _ui_print_system_msg_from_recipient; -void -ui_recipient_gone(const char * const barejid) +static void +_ui_recipient_gone(const char * const barejid) { if (barejid == NULL) return; @@ -819,9 +869,10 @@ ui_recipient_gone(const char * const barejid) } } } +void (*ui_recipient_gone)(const char * const) = _ui_recipient_gone; -void -ui_new_chat_win(const char * const to) +static void +_ui_new_chat_win(const char * const to) { // if the contact is offline, show a message PContact contact = roster_get_contact(to); @@ -858,18 +909,20 @@ ui_new_chat_win(const char * const to) ui_switch_win(num); } +void (*ui_new_chat_win)(const char * const) = _ui_new_chat_win; -void -ui_create_duck_win(void) +static void +_ui_create_duck_win(void) { ProfWin *window = wins_new("DuckDuckGo search", WIN_DUCK); int num = wins_get_num(window); ui_switch_win(num); win_print_line(window, '-', 0, "Type ':help' to find out more."); } +void (*ui_create_duck_win)(void) = _ui_create_duck_win; -void -ui_open_duck_win(void) +static void +_ui_open_duck_win(void) { ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); if (window != NULL) { @@ -877,9 +930,10 @@ ui_open_duck_win(void) ui_switch_win(num); } } +void (*ui_open_duck_win)(void) = _ui_open_duck_win; -void -ui_duck(const char * const query) +static void +_ui_duck(const char * const query) { ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); if (window != NULL) { @@ -893,9 +947,10 @@ ui_duck(const char * const query) wprintw(window->win, "\n"); } } +void (*ui_duck)(const char * const) = _ui_duck; -void -ui_duck_result(const char * const result) +static void +_ui_duck_result(const char * const result) { ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); @@ -926,9 +981,10 @@ ui_duck_result(const char * const result) wprintw(window->win, "\n"); } } +void (*ui_duck_result)(const char * const) = _ui_duck_result; -void -ui_outgoing_msg(const char * const from, const char * const to, +static void +_ui_outgoing_msg(const char * const from, const char * const to, const char * const message) { PContact contact = roster_get_contact(to); @@ -978,9 +1034,11 @@ ui_outgoing_msg(const char * const from, const char * const to, } ui_switch_win(num); } +void (*ui_outgoing_msg)(const char * const, const char * const, + const char * const) = _ui_outgoing_msg; -void -ui_room_join(Jid *jid) +static void +_ui_room_join(Jid *jid) { ProfWin *window = wins_get_by_recipient(jid->barejid); int num = 0; @@ -993,9 +1051,10 @@ ui_room_join(Jid *jid) num = wins_get_num(window); ui_switch_win(num); } +void (*ui_room_join)(Jid *) = _ui_room_join; -void -ui_room_roster(const char * const room, GList *roster, const char * const presence) +static void +_ui_room_roster(const char * const room, GList *roster, const char * const presence) { ProfWin *window = wins_get_by_recipient(room); @@ -1048,9 +1107,10 @@ ui_room_roster(const char * const room, GList *roster, const char * const presen wins_refresh_current(); } } +void (*ui_room_roster)(const char * const, GList*, const char * const) = _ui_room_roster; -void -ui_room_member_offline(const char * const room, const char * const nick) +static void +_ui_room_member_offline(const char * const room, const char * const nick) { ProfWin *window = wins_get_by_recipient(room); @@ -1063,9 +1123,10 @@ ui_room_member_offline(const char * const room, const char * const nick) wins_refresh_current(); } } +void (*ui_room_member_offline)(const char * const, const char * const) = _ui_room_member_offline; -void -ui_room_member_online(const char * const room, const char * const nick, +static void +_ui_room_member_online(const char * const room, const char * const nick, const char * const show, const char * const status) { ProfWin *window = wins_get_by_recipient(room); @@ -1079,9 +1140,11 @@ ui_room_member_online(const char * const room, const char * const nick, wins_refresh_current(); } } +void (*ui_room_member_online)(const char * const, const char * const, + const char * const, const char * const) = _ui_room_member_online; -void -ui_room_member_presence(const char * const room, const char * const nick, +static void +_ui_room_member_presence(const char * const room, const char * const nick, const char * const show, const char * const status) { ProfWin *window = wins_get_by_recipient(room); @@ -1094,9 +1157,11 @@ ui_room_member_presence(const char * const room, const char * const nick, wins_refresh_current(); } } +void (*ui_room_member_presence)(const char * const, const char * const, + const char * const, const char * const) = _ui_room_member_presence; -void -ui_room_member_nick_change(const char * const room, +static void +_ui_room_member_nick_change(const char * const room, const char * const old_nick, const char * const nick) { ProfWin *window = wins_get_by_recipient(room); @@ -1110,9 +1175,11 @@ ui_room_member_nick_change(const char * const room, wins_refresh_current(); } } +void (*ui_room_member_nick_change)(const char * const, + const char * const, const char * const) = _ui_room_member_nick_change; -void -ui_room_nick_change(const char * const room, const char * const nick) +static void +_ui_room_nick_change(const char * const room, const char * const nick) { ProfWin *window = wins_get_by_recipient(room); @@ -1125,9 +1192,10 @@ ui_room_nick_change(const char * const room, const char * const nick) wins_refresh_current(); } } +void (*ui_room_nick_change)(const char * const, const char * const) = _ui_room_nick_change; -void -ui_room_history(const char * const room_jid, const char * const nick, +static void +_ui_room_history(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message) { ProfWin *window = wins_get_by_recipient(room_jid); @@ -1151,9 +1219,11 @@ ui_room_history(const char * const room_jid, const char * const nick, wins_refresh_current(); } } +void (*ui_room_history)(const char * const, const char * const, + GTimeVal, const char * const) = _ui_room_history; -void -ui_room_message(const char * const room_jid, const char * const nick, +static void +_ui_room_message(const char * const room_jid, const char * const nick, const char * const message) { ProfWin *window = wins_get_by_recipient(room_jid); @@ -1223,9 +1293,11 @@ ui_room_message(const char * const room_jid, const char * const nick, } } } +void (*ui_room_message)(const char * const, const char * const, + const char * const) = _ui_room_message; -void -ui_room_subject(const char * const room_jid, const char * const subject) +static void +_ui_room_subject(const char * const room_jid, const char * const subject) { ProfWin *window = wins_get_by_recipient(room_jid); int num = wins_get_num(window); @@ -1246,9 +1318,10 @@ ui_room_subject(const char * const room_jid, const char * const subject) status_bar_new(num); } } +void (*ui_room_subject)(const char * const, const char * const) = _ui_room_subject; -void -ui_room_broadcast(const char * const room_jid, const char * const message) +static void +_ui_room_broadcast(const char * const room_jid, const char * const message) { ProfWin *window = wins_get_by_recipient(room_jid); int num = wins_get_num(window); @@ -1269,9 +1342,10 @@ ui_room_broadcast(const char * const room_jid, const char * const message) status_bar_new(num); } } +void (*ui_room_broadcast)(const char * const, const char * const) = _ui_room_broadcast; -void -ui_status(void) +static void +_ui_status(void) { char *recipient = ui_current_recipient(); PContact pcontact = roster_get_contact(recipient); @@ -1283,9 +1357,10 @@ ui_status(void) win_print_line(current, '-', 0, "Error getting contact info."); } } +void (*ui_status)(void) = _ui_status; -void -ui_status_private(void) +static void +_ui_status_private(void) { Jid *jid = jid_create(ui_current_recipient()); PContact pcontact = muc_get_participant(jid->barejid, jid->resourcepart); @@ -1299,9 +1374,10 @@ ui_status_private(void) jid_destroy(jid); } +void (*ui_status_private)(void) = _ui_status_private; -void -ui_status_room(const char * const contact) +static void +_ui_status_room(const char * const contact) { PContact pcontact = muc_get_participant(ui_current_recipient(), contact); ProfWin *current = wins_get_current(); @@ -1312,15 +1388,17 @@ ui_status_room(const char * const contact) win_print_line(current, '-', 0, "No such participant \"%s\" in room.", contact); } } +void (*ui_status_room)(const char * const) = _ui_status_room; -gint -ui_unread(void) +static gint +_ui_unread(void) { return wins_get_total_unread(); } +gint (*ui_unread)(void) = _ui_unread; -int -ui_win_unread(int index) +static int +_ui_win_unread(int index) { ProfWin *window = wins_get_by_num(index); if (window != NULL) { @@ -1329,9 +1407,10 @@ ui_win_unread(int index) return 0; } } +int (*ui_win_unread)(int) = _ui_win_unread; -char * -ui_ask_password(void) +static char * +_ui_ask_password(void) { char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1)); status_bar_get_password(); @@ -1342,6 +1421,7 @@ ui_ask_password(void) return passwd; } +char * (*ui_ask_password)(void) = _ui_ask_password; static void _ui_draw_win_title(void) diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 3306a246..040e87b2 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -58,8 +58,8 @@ static int _printable(const wint_t ch); static void _clear_input(void); static void _go_to_end(int display_size); -void -create_input_window(void) +static void +_create_input_window(void) { #ifdef NCURSES_REENTRANT set_escdelay(25); @@ -73,9 +73,10 @@ create_input_window(void) wmove(inp_win, 0, 0); _inp_win_refresh(); } +void (*create_input_window)(void) = _create_input_window; -void -inp_win_resize(const char * const input, const int size) +static void +_inp_win_resize(const char * const input, const int size) { int inp_x; getmaxyx(stdscr, rows, cols); @@ -91,21 +92,24 @@ inp_win_resize(const char * const input, const int size) _inp_win_refresh(); } +void (*inp_win_resize)(const char * const, const int) = _inp_win_resize; -void -inp_non_block(void) +static void +_inp_non_block(void) { wtimeout(inp_win, 20); } +void (*inp_non_block)(void) = _inp_non_block; -void -inp_block(void) +static void +_inp_block(void) { wtimeout(inp_win, -1); } +void (*inp_block)(void) = _inp_block; -wint_t -inp_get_char(char *input, int *size) +static wint_t +_inp_get_char(char *input, int *size) { int inp_x = 0; int i; @@ -202,9 +206,10 @@ inp_get_char(char *input, int *size) return ch; } +wint_t (*inp_get_char)(char*, int*) = _inp_get_char; -void -inp_get_password(char *passwd) +static void +_inp_get_password(char *passwd) { _clear_input(); _inp_win_refresh(); @@ -214,15 +219,17 @@ inp_get_password(char *passwd) echo(); status_bar_clear(); } +void (*inp_get_password)(char*) = _inp_get_password; -void -inp_put_back(void) +static void +_inp_put_back(void) { _inp_win_refresh(); } +void (*inp_put_back)(void) = _inp_put_back; -void -inp_replace_input(char *input, const char * const new_input, int *size) +static void +_inp_replace_input(char *input, const char * const new_input, int *size) { int display_size; strcpy(input, new_input); @@ -233,14 +240,16 @@ inp_replace_input(char *input, const char * const new_input, int *size) waddstr(inp_win, input); _go_to_end(display_size); } +void (*inp_replace_input)(char*, const char * const, int*) = _inp_replace_input; -void -inp_win_reset(void) +static void +_inp_win_reset(void) { _clear_input(); pad_start = 0; _inp_win_refresh(); } +void (*inp_win_reset)(void) = _inp_win_reset; static void _clear_input(void) diff --git a/src/ui/notifier.c b/src/ui/notifier.c index 403c215e..d0319cb9 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -39,16 +39,17 @@ static void _notify(const char * const message, int timeout, const char * const category); -void -notifier_init(void) +static void +_notifier_init(void) { #ifdef HAVE_LIBNOTIFY notify_init("Profanity"); #endif } +void (*notifier_init)(void) = _notifier_init; -void -notifier_uninit(void) +static void +_notifier_uninit(void) { #ifdef HAVE_LIBNOTIFY if (notify_is_initted()) { @@ -56,18 +57,20 @@ notifier_uninit(void) } #endif } +void (*notifier_uninit)(void) = _notifier_uninit; -void -notify_typing(const char * const handle) +static void +_notify_typing(const char * const handle) { char message[strlen(handle) + 1 + 11]; sprintf(message, "%s: typing...", handle); _notify(message, 10000, "Incoming message"); } +void (*notify_typing)(const char * const) = _notify_typing; -void -notify_invite(const char * const from, const char * const room, +static void +_notify_invite(const char * const from, const char * const room, const char * const reason) { GString *message = g_string_new("Room invite\nfrom: "); @@ -82,18 +85,21 @@ notify_invite(const char * const from, const char * const room, g_string_free(message, TRUE); } +void (*notify_invite)(const char * const, const char * const, + const char * const) = _notify_invite; -void -notify_message(const char * const handle, int win) +static void +_notify_message(const char * const handle, int win) { char message[strlen(handle) + 1 + 14]; sprintf(message, "%s: message (%d).", handle, win); _notify(message, 10000, "incoming message"); } +void (*notify_message)(const char * const, int) = _notify_message; -void -notify_room_message(const char * const handle, const char * const room, int win) +static void +_notify_room_message(const char * const handle, const char * const room, int win) { GString *text = g_string_new(""); @@ -104,18 +110,21 @@ notify_room_message(const char * const handle, const char * const room, int win) g_string_free(text, TRUE); } +void (*notify_room_message)(const char * const, const char * const, + int) = _notify_room_message; -void -notify_subscription(const char * const from) +static void +_notify_subscription(const char * const from) { GString *message = g_string_new("Subscription request: \n"); g_string_append(message, from); _notify(message->str, 10000, "Incomming message"); g_string_free(message, TRUE); } +void (*notify_subscription)(const char * const) = _notify_subscription; -void -notify_remind(void) +static void +_notify_remind(void) { gint unread = ui_unread(); gint open = muc_invite_count(); @@ -158,6 +167,7 @@ notify_remind(void) g_string_free(text, TRUE); } +void (*notify_remind)(void) = _notify_remind; static void _notify(const char * const message, int timeout, diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 16bd31c9..8a578a56 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -54,8 +54,8 @@ static void _mark_new(int num); static void _mark_active(int num); static void _mark_inactive(int num); -void -create_status_bar(void) +static void +_create_status_bar(void) { int rows, cols, i; getmaxyx(stdscr, rows, cols); @@ -83,9 +83,10 @@ create_status_bar(void) dirty = TRUE; } +void (*create_status_bar)(void) = _create_status_bar; -void -status_bar_refresh(void) +static void +_status_bar_refresh(void) { GDateTime *now_time = g_date_time_new_now_local(); GTimeSpan elapsed = g_date_time_difference(now_time, last_time); @@ -107,9 +108,10 @@ status_bar_refresh(void) g_date_time_unref(now_time); } +void (*status_bar_refresh)(void) = _status_bar_refresh; -void -status_bar_resize(void) +static void +_status_bar_resize(void) { int rows, cols; getmaxyx(stdscr, rows, cols); @@ -133,9 +135,10 @@ status_bar_resize(void) last_time = g_date_time_new_now_local(); dirty = TRUE; } +void (*status_bar_resize)(void) = _status_bar_resize; -void -status_bar_set_all_inactive(void) +static void +_status_bar_set_all_inactive(void) { int i = 0; for (i = 0; i < 12; i++) { @@ -147,9 +150,10 @@ status_bar_set_all_inactive(void) g_hash_table_remove_all(remaining_active); g_hash_table_remove_all(remaining_new); } +void (*status_bar_set_all_inactive)(void) = _status_bar_set_all_inactive; -void -status_bar_current(int i) +static void +_status_bar_current(int i) { if (i == 0) { current = 10; @@ -164,9 +168,10 @@ status_bar_current(int i) mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); } +void (*status_bar_current)(int) = _status_bar_current; -void -status_bar_inactive(const int win) +static void +_status_bar_inactive(const int win) { int true_win = win; if (true_win == 0) { @@ -204,9 +209,10 @@ status_bar_inactive(const int win) _mark_inactive(true_win); } } +void (*status_bar_inactive)(const int) = _status_bar_inactive; -void -status_bar_active(const int win) +static void +_status_bar_active(const int win) { int true_win = win; if (true_win == 0) { @@ -238,9 +244,10 @@ status_bar_active(const int win) _mark_active(true_win); } } +void (*status_bar_active)(const int) = _status_bar_active; -void -status_bar_new(const int win) +static void +_status_bar_new(const int win) { int true_win = win; if (true_win == 0) { @@ -261,16 +268,18 @@ status_bar_new(const int win) _mark_new(true_win); } } +void (*status_bar_new)(const int) = _status_bar_new; -void -status_bar_get_password(void) +static void +_status_bar_get_password(void) { status_bar_print_message("Enter password:"); dirty = TRUE; } +void (*status_bar_get_password)(void) = _status_bar_get_password; -void -status_bar_print_message(const char * const msg) +static void +_status_bar_print_message(const char * const msg) { werase(status_bar); @@ -291,9 +300,10 @@ status_bar_print_message(const char * const msg) _update_win_statuses(); dirty = TRUE; } +void (*status_bar_print_message)(const char * const) = _status_bar_print_message; -void -status_bar_clear(void) +static void +_status_bar_clear(void) { if (message != NULL) { free(message); @@ -319,9 +329,10 @@ status_bar_clear(void) dirty = TRUE; } +void (*status_bar_clear)(void) = _status_bar_clear; -void -status_bar_clear_message(void) +static void +_status_bar_clear_message(void) { if (message != NULL) { free(message); @@ -340,6 +351,7 @@ status_bar_clear_message(void) _update_win_statuses(); dirty = TRUE; } +void (*status_bar_clear_message)(void) = _status_bar_clear_message; static void _status_bar_update_time(void) diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 791a5fbe..79baae1d 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -37,8 +37,8 @@ static contact_presence_t current_status; static void _title_bar_draw_title(void); static void _title_bar_draw_status(void); -void -create_title_bar(void) +static void +_create_title_bar(void) { int cols = getmaxx(stdscr); @@ -48,9 +48,10 @@ create_title_bar(void) title_bar_set_status(CONTACT_OFFLINE); dirty = TRUE; } +void (*create_title_bar)(void) = _create_title_bar; -void -title_bar_title(void) +static void +_title_bar_title(void) { werase(title_bar); recipient = NULL; @@ -59,9 +60,10 @@ title_bar_title(void) _title_bar_draw_status(); dirty = TRUE; } +void (*title_bar_title)(void) = _title_bar_title; -void -title_bar_resize(void) +static void +_title_bar_resize(void) { int cols = getmaxx(stdscr); @@ -72,9 +74,10 @@ title_bar_resize(void) _title_bar_draw_status(); dirty = TRUE; } +void (*title_bar_resize)(void) = _title_bar_resize; -void -title_bar_refresh(void) +static void +_title_bar_refresh(void) { if (recipient != NULL) { @@ -106,9 +109,10 @@ title_bar_refresh(void) dirty = FALSE; } } +void (*title_bar_refresh)(void) = _title_bar_refresh; -void -title_bar_show(const char * const title) +static void +_title_bar_show(const char * const title) { if (current_title != NULL) free(current_title); @@ -117,16 +121,18 @@ title_bar_show(const char * const title) strcpy(current_title, title); _title_bar_draw_title(); } +void (*title_bar_show)(const char * const) = _title_bar_show; -void -title_bar_set_status(contact_presence_t status) +static void +_title_bar_set_status(contact_presence_t status) { current_status = status; _title_bar_draw_status(); } +void (*title_bar_set_status)(contact_presence_t) = _title_bar_set_status; -void -title_bar_set_recipient(const char * const from) +static void +_title_bar_set_recipient(const char * const from) { if (typing_elapsed != NULL) { g_timer_destroy(typing_elapsed); @@ -143,9 +149,10 @@ title_bar_set_recipient(const char * const from) dirty = TRUE; } +void (*title_bar_set_recipient)(const char * const) = _title_bar_set_recipient; -void -title_bar_set_typing(gboolean is_typing) +static void +_title_bar_set_typing(gboolean is_typing) { if (is_typing) { if (typing_elapsed != NULL) { @@ -169,14 +176,16 @@ title_bar_set_typing(gboolean is_typing) dirty = TRUE; } +void (*title_bar_set_typing)(gboolean) = _title_bar_set_typing; -void -title_bar_draw(void) +static void +_title_bar_draw(void) { werase(title_bar); _title_bar_draw_status(); _title_bar_draw_title(); } +void (*title_bar_draw)(void) = _title_bar_draw; static void _title_bar_draw_status(void) diff --git a/src/ui/ui.h b/src/ui/ui.h index 539146b7..482d8735 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -42,218 +42,213 @@ #define INP_WIN_MAX 1000 // ui startup and control -void ui_init(void); -void ui_load_colours(void); -void ui_refresh(void); -void ui_close(void); -void ui_resize(const int ch, const char * const input, +void (*ui_init)(void); +void (*ui_load_colours)(void); +void (*ui_refresh)(void); +void (*ui_close)(void); +void (*ui_resize)(const int ch, const char * const input, const int size); -GSList* ui_get_recipients(void); -void ui_handle_special_keys(const wint_t * const ch, const char * const inp, +GSList* (*ui_get_recipients)(void); +void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp, const int size); -void ui_switch_win(const int i); -void ui_next_win(void); -void ui_previous_win(void); -unsigned long ui_get_idle_time(void); -void ui_reset_idle_time(void); -void ui_new_chat_win(const char * const to); -void ui_print_error_from_recipient(const char * const from, const char *err_msg); -void ui_print_system_msg_from_recipient(const char * const from, const char *message); -void ui_handle_error_message(const char * const from, const char * const err_msg); -gint ui_unread(void); -void ui_close_connected_win(int index); -int ui_close_all_wins(void); -int ui_close_read_wins(void); +void (*ui_switch_win)(const int i); +void (*ui_next_win)(void); +void (*ui_previous_win)(void); +unsigned long (*ui_get_idle_time)(void); +void (*ui_reset_idle_time)(void); +void (*ui_new_chat_win)(const char * const to); +void (*ui_print_error_from_recipient)(const char * const from, const char *err_msg); +void (*ui_print_system_msg_from_recipient)(const char * const from, const char *message); +void (*ui_handle_error_message)(const char * const from, const char * const err_msg); +gint (*ui_unread)(void); +void (*ui_close_connected_win)(int index); +int (*ui_close_all_wins)(void); +int (*ui_close_read_wins)(void); // current window actions -void ui_close_current(void); -void ui_clear_current(void); -win_type_t ui_current_win_type(void); -int ui_current_win_index(void); -char* ui_current_recipient(void); -void ui_current_print_line(const char * const msg, ...); -void ui_current_error_line(const char * const msg); -void ui_current_page_off(void); - -win_type_t ui_win_type(int index); -char * ui_recipient(int index); -void ui_close_win(int index); -gboolean ui_win_exists(int index); -int ui_win_unread(int index); -char * ui_ask_password(void); +void (*ui_close_current)(void); +void (*ui_clear_current)(void); +win_type_t (*ui_current_win_type)(void); +int (*ui_current_win_index)(void); +char* (*ui_current_recipient)(void); +void (*ui_current_print_line)(const char * const msg, ...); +void (*ui_current_error_line)(const char * const msg); +void (*ui_current_page_off)(void); + +win_type_t (*ui_win_type)(int index); +char * (*ui_recipient)(int index); +void (*ui_close_win)(int index); +gboolean (*ui_win_exists)(int index); +int (*ui_win_unread)(int index); +char * (*ui_ask_password)(void); // ui events -void ui_contact_typing(const char * const from); -void ui_incoming_msg(const char * const from, const char * const message, +void (*ui_contact_typing)(const char * const from); +void (*ui_incoming_msg)(const char * const from, const char * const message, GTimeVal *tv_stamp, gboolean priv); -void ui_contact_online(const char * const barejid, const char * const resource, +void (*ui_contact_online)(const char * const barejid, const char * const resource, const char * const show, const char * const status, GDateTime *last_activity); -void ui_contact_offline(const char * const from, const char * const show, +void (*ui_contact_offline)(const char * const from, const char * const show, const char * const status); -void ui_disconnected(void); -void ui_recipient_gone(const char * const barejid); -void ui_outgoing_msg(const char * const from, const char * const to, +void (*ui_disconnected)(void); +void (*ui_recipient_gone)(const char * const barejid); +void (*ui_outgoing_msg)(const char * const from, const char * const to, const char * const message); -void ui_room_join(Jid *jid); -void ui_room_roster(const char * const room, GList *roster, const char * const presence); -void ui_room_history(const char * const room_jid, const char * const nick, +void (*ui_room_join)(Jid *jid); +void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence); +void (*ui_room_history)(const char * const room_jid, const char * const nick, GTimeVal tv_stamp, const char * const message); -void ui_room_message(const char * const room_jid, const char * const nick, +void (*ui_room_message)(const char * const room_jid, const char * const nick, const char * const message); -void ui_room_subject(const char * const room_jid, +void (*ui_room_subject)(const char * const room_jid, const char * const subject); -void ui_room_broadcast(const char * const room_jid, +void (*ui_room_broadcast)(const char * const room_jid, const char * const message); -void ui_room_member_offline(const char * const room, const char * const nick); -void ui_room_member_online(const char * const room, +void (*ui_room_member_offline)(const char * const room, const char * const nick); +void (*ui_room_member_online)(const char * const room, const char * const nick, const char * const show, const char * const status); -void ui_room_member_nick_change(const char * const room, +void (*ui_room_member_nick_change)(const char * const room, const char * const old_nick, const char * const nick); -void ui_room_nick_change(const char * const room, const char * const nick); -void ui_room_member_presence(const char * const room, +void (*ui_room_nick_change)(const char * const room, const char * const nick); +void (*ui_room_member_presence)(const char * const room, const char * const nick, const char * const show, const char * const status); -void ui_roster_add(const char * const barejid, const char * const name); -void ui_roster_remove(const char * const barejid); -void ui_contact_already_in_group(const char * const contact, const char * const group); -void ui_contact_not_in_group(const char * const contact, const char * const group); -void ui_group_added(const char * const contact, const char * const group); -void ui_group_removed(const char * const contact, const char * const group); +void (*ui_roster_add)(const char * const barejid, const char * const name); +void (*ui_roster_remove)(const char * const barejid); +void (*ui_contact_already_in_group)(const char * const contact, const char * const group); +void (*ui_contact_not_in_group)(const char * const contact, const char * const group); +void (*ui_group_added)(const char * const contact, const char * const group); +void (*ui_group_removed)(const char * const contact, const char * const group); // contact status functions -void ui_status_room(const char * const contact); -void ui_status(void); -void ui_status_private(void); +void (*ui_status_room)(const char * const contact); +void (*ui_status)(void); +void (*ui_status_private)(void); -void ui_create_duck_win(void); -void ui_open_duck_win(void); -void ui_duck(const char * const query); -void ui_duck_result(const char * const result); -gboolean ui_duck_exists(void); +void (*ui_create_duck_win)(void); +void (*ui_open_duck_win)(void); +void (*ui_duck)(const char * const query); +void (*ui_duck_result)(const char * const result); +gboolean (*ui_duck_exists)(void); -void ui_tidy_wins(void); -void ui_prune_wins(void); +void (*ui_tidy_wins)(void); +void (*ui_prune_wins)(void); // create windows -void create_title_bar(void); -void create_status_bar(void); -void create_input_window(void); +void (*create_title_bar)(void); +void (*create_status_bar)(void); +void (*create_input_window)(void); // title bar actions -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(contact_presence_t status); -void title_bar_set_recipient(const char * const from); -void title_bar_set_typing(gboolean is_typing); -void title_bar_draw(void); +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)(contact_presence_t status); +void (*title_bar_set_recipient)(const char * const from); +void (*title_bar_set_typing)(gboolean is_typing); +void (*title_bar_draw)(void); // console window actions void (*cons_show)(const char * const msg, ...); -void cons_about(void); -void cons_help(void); -void cons_basic_help(void); -void cons_settings_help(void); -void cons_presence_help(void); -void cons_navigation_help(void); -void cons_prefs(void); -void cons_show_ui_prefs(void); -void cons_show_desktop_prefs(void); -void cons_show_chat_prefs(void); -void cons_show_log_prefs(void); -void cons_show_presence_prefs(void); -void cons_show_connection_prefs(void); -void cons_show_account(ProfAccount *account); -void cons_debug(const char * const msg, ...); -void cons_show_time(void); -void cons_show_word(const char * const word); -void cons_show_error(const char * const cmd, ...); -void cons_highlight_show(const char * const cmd); -void cons_show_contacts(GSList * list); -void cons_show_roster(GSList * list); -void cons_show_roster_group(const char * const group, GSList * list); -void cons_show_wins(void); -void cons_show_status(const char * const barejid); -void cons_show_info(PContact pcontact); -void cons_show_caps(const char * const contact, Resource *resource); -void cons_show_themes(GSList *themes); -void cons_show_login_success(ProfAccount *account); -void cons_show_software_version(const char * const jid, +void (*cons_about)(void); +void (*cons_help)(void); +void (*cons_navigation_help)(void); +void (*cons_prefs)(void); +void (*cons_show_ui_prefs)(void); +void (*cons_show_desktop_prefs)(void); +void (*cons_show_chat_prefs)(void); +void (*cons_show_log_prefs)(void); +void (*cons_show_presence_prefs)(void); +void (*cons_show_connection_prefs)(void); +void (*cons_show_account)(ProfAccount *account); +void (*cons_debug)(const char * const msg, ...); +void (*cons_show_time)(void); +void (*cons_show_word)(const char * const word); +void (*cons_show_error)(const char * const cmd, ...); +void (*cons_show_contacts)(GSList * list); +void (*cons_show_roster)(GSList * list); +void (*cons_show_roster_group)(const char * const group, GSList * list); +void (*cons_show_wins)(void); +void (*cons_show_status)(const char * const barejid); +void (*cons_show_info)(PContact pcontact); +void (*cons_show_caps)(const char * const contact, Resource *resource); +void (*cons_show_themes)(GSList *themes); +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); -void cons_show_room_list(GSList *room, const char * const conference_node); -void cons_show_bookmarks(const GList *list); -void cons_show_disco_items(GSList *items, const char * const jid); -void cons_show_disco_info(const char *from, GSList *identities, GSList *features); -void cons_show_room_invite(const char * const invitor, const char * const room, +void (*cons_show_account_list)(gchar **accounts); +void (*cons_show_room_list)(GSList *room, const char * const conference_node); +void (*cons_show_bookmarks)(const GList *list); +void (*cons_show_disco_items)(GSList *items, const char * const jid); +void (*cons_show_disco_info)(const char *from, GSList *identities, GSList *features); +void (*cons_show_room_invite)(const char * const invitor, const char * const room, const char * const reason); -void cons_check_version(gboolean not_available_msg); -void cons_show_typing(const char * const barejid); -void cons_show_incoming_message(const char * const short_from, const int win_index); -void cons_show_room_invites(GSList *invites); -void cons_show_received_subs(void); -void cons_show_sent_subs(void); -void cons_alert(void); -void cons_theme_setting(void); -void cons_beep_setting(void); -void cons_flash_setting(void); -void cons_splash_setting(void); -void cons_vercheck_setting(void); -void cons_mouse_setting(void); -void cons_statuses_setting(void); -void cons_titlebar_setting(void); -void cons_notify_setting(void); -void cons_show_desktop_prefs(void); -void cons_states_setting(void); -void cons_outtype_setting(void); -void cons_intype_setting(void); -void cons_gone_setting(void); -void cons_history_setting(void); -void cons_log_setting(void); -void cons_chlog_setting(void); -void cons_grlog_setting(void); -void cons_autoaway_setting(void); -void cons_reconnect_setting(void); -void cons_autoping_setting(void); -void cons_priority_setting(void); -void cons_autoconnect_setting(void); +void (*cons_check_version)(gboolean not_available_msg); +void (*cons_show_typing)(const char * const barejid); +void (*cons_show_incoming_message)(const char * const short_from, const int win_index); +void (*cons_show_room_invites)(GSList *invites); +void (*cons_show_received_subs)(void); +void (*cons_show_sent_subs)(void); +void (*cons_alert)(void); +void (*cons_theme_setting)(void); +void (*cons_beep_setting)(void); +void (*cons_flash_setting)(void); +void (*cons_splash_setting)(void); +void (*cons_vercheck_setting)(void); +void (*cons_mouse_setting)(void); +void (*cons_statuses_setting)(void); +void (*cons_titlebar_setting)(void); +void (*cons_notify_setting)(void); +void (*cons_show_desktop_prefs)(void); +void (*cons_states_setting)(void); +void (*cons_outtype_setting)(void); +void (*cons_intype_setting)(void); +void (*cons_gone_setting)(void); +void (*cons_history_setting)(void); +void (*cons_log_setting)(void); +void (*cons_chlog_setting)(void); +void (*cons_grlog_setting)(void); +void (*cons_autoaway_setting)(void); +void (*cons_reconnect_setting)(void); +void (*cons_autoping_setting)(void); +void (*cons_priority_setting)(void); +void (*cons_autoconnect_setting)(void); // status bar actions -void status_bar_refresh(void); -void status_bar_resize(void); -void status_bar_clear(void); -void status_bar_clear_message(void); -void status_bar_get_password(void); -void status_bar_print_message(const char * const msg); -void status_bar_inactive(const int win); -void status_bar_active(const int win); -void status_bar_new(const int win); -void status_bar_update_time(void); -void status_bar_set_all_inactive(void); -void status_bar_current(int i); +void (*status_bar_refresh)(void); +void (*status_bar_resize)(void); +void (*status_bar_clear)(void); +void (*status_bar_clear_message)(void); +void (*status_bar_get_password)(void); +void (*status_bar_print_message)(const char * const msg); +void (*status_bar_inactive)(const int win); +void (*status_bar_active)(const int win); +void (*status_bar_new)(const int win); +void (*status_bar_set_all_inactive)(void); +void (*status_bar_current)(int i); // input window actions -wint_t inp_get_char(char *input, int *size); -void inp_win_reset(void); -void inp_win_resize(const char * input, const int size); -void inp_put_back(void); -void inp_non_block(void); -void inp_block(void); -void inp_get_password(char *passwd); -void inp_replace_input(char *input, const char * const new_input, int *size); +wint_t (*inp_get_char)(char *input, int *size); +void (*inp_win_reset)(void); +void (*inp_win_resize)(const char * input, const int size); +void (*inp_put_back)(void); +void (*inp_non_block)(void); +void (*inp_block)(void); +void (*inp_get_password)(char *passwd); +void (*inp_replace_input)(char *input, const char * const new_input, int *size); // desktop notifier actions -void notifier_init(void); -void notifier_uninit(void); +void (*notifier_init)(void); +void (*notifier_uninit)(void); -void notify_typing(const char * const handle); -void notify_message(const char * const handle, int win); -void notify_room_message(const char * const handle, const char * const room, +void (*notify_typing)(const char * const handle); +void (*notify_message)(const char * const handle, int win); +void (*notify_room_message)(const char * const handle, const char * const room, int win); -void notify_remind(void); -void notify_invite(const char * const from, const char * const room, +void (*notify_remind)(void); +void (*notify_invite)(const char * const from, const char * const room, const char * const reason); -void notify_subscription(const char * const from); +void (*notify_subscription)(const char * const from); #endif diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index 0ef3c0ee..b2650d8e 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -33,6 +33,7 @@ void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) void cmd_account_shows_account_when_connected_and_no_args(void **state) { + mock_cons_show_account(); CommandHelp *help = malloc(sizeof(CommandHelp)); ProfAccount *account = malloc(sizeof(ProfAccount)); gchar *args[] = { NULL }; @@ -43,7 +44,7 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state) expect_any(accounts_get_account, name); will_return(accounts_get_account, account); - expect_memory(cons_show_account, account, account, sizeof(ProfAccount)); + expect_cons_show_account(account); expect_any(accounts_free_account, account); @@ -56,6 +57,7 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state) void cmd_account_list_shows_accounts(void **state) { + mock_cons_show_account_list(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "list", NULL }; @@ -67,7 +69,7 @@ void cmd_account_list_shows_accounts(void **state) will_return(accounts_get_list, accounts); - expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts)); + expect_cons_show_account_list(accounts); gboolean result = cmd_account(args, *help); assert_true(result); @@ -110,6 +112,7 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state) void cmd_account_show_shows_account_when_exists(void **state) { + mock_cons_show_account(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "show", "account_name", NULL }; ProfAccount *account = malloc(sizeof(ProfAccount)); @@ -117,7 +120,7 @@ void cmd_account_show_shows_account_when_exists(void **state) expect_any(accounts_get_account, name); will_return(accounts_get_account, account); - expect_memory(cons_show_account, account, account, sizeof(ProfAccount)); + expect_cons_show_account(account); expect_any(accounts_free_account, account); diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c index f4545fb2..0095d144 100644 --- a/tests/test_cmd_connect.c +++ b/tests/test_cmd_connect.c @@ -85,6 +85,7 @@ void cmd_connect_shows_message_when_undefined(void **state) void cmd_connect_when_no_account(void **state) { mock_cons_show(); + mock_ui_ask_password(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", NULL }; @@ -93,7 +94,7 @@ void cmd_connect_when_no_account(void **state) expect_string(accounts_get_account, name, "user@server.org"); will_return(accounts_get_account, NULL); - will_return(ui_ask_password, strdup("password")); + mock_ui_ask_password_returns("password"); expect_cons_show("Connecting as user@server.org"); @@ -110,6 +111,7 @@ void cmd_connect_when_no_account(void **state) void cmd_connect_with_altdomain_when_provided(void **state) { + stub_ui_ask_password(); stub_cons_show(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", "altdomain" }; @@ -119,8 +121,6 @@ void cmd_connect_with_altdomain_when_provided(void **state) expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); - will_return(ui_ask_password, strdup("password")); - jabber_connect_with_details = _mock_jabber_connect_with_details_altdomain; expect_string(_mock_jabber_connect_with_details_altdomain, altdomain, "altdomain"); will_return(_mock_jabber_connect_with_details_altdomain, JABBER_CONNECTING); @@ -134,6 +134,8 @@ void cmd_connect_with_altdomain_when_provided(void **state) void cmd_connect_fail_message(void **state) { stub_cons_show(); + mock_cons_show_error(); + stub_ui_ask_password(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "user@server.org", NULL }; @@ -142,12 +144,10 @@ void cmd_connect_fail_message(void **state) expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); - will_return(ui_ask_password, strdup("password")); - jabber_connect_with_details = _mock_jabber_connect_with_details_result; will_return(_mock_jabber_connect_with_details_result, JABBER_DISCONNECTED); - expect_string(cons_show_error, output, "Connection attempt for user@server.org failed."); + expect_cons_show_error("Connection attempt for user@server.org failed."); gboolean result = cmd_connect(args, *help); assert_true(result); @@ -158,6 +158,7 @@ void cmd_connect_fail_message(void **state) void cmd_connect_lowercases_argument(void **state) { stub_cons_show(); + stub_ui_ask_password(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "USER@server.ORG", NULL }; @@ -166,8 +167,6 @@ void cmd_connect_lowercases_argument(void **state) expect_string(accounts_get_account, name, "user@server.org"); will_return(accounts_get_account, NULL); - will_return(ui_ask_password, strdup("password")); - jabber_connect_with_details = _mock_jabber_connect_with_details_result; will_return(_mock_jabber_connect_with_details_result, JABBER_CONNECTING); @@ -180,6 +179,7 @@ void cmd_connect_lowercases_argument(void **state) void cmd_connect_asks_password_when_not_in_account(void **state) { stub_cons_show(); + stub_ui_ask_password(); CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { "jabber_org", NULL }; ProfAccount *account = malloc(sizeof(ProfAccount)); @@ -192,8 +192,6 @@ void cmd_connect_asks_password_when_not_in_account(void **state) will_return(accounts_create_full_jid, strdup("user@jabber.org")); - will_return(ui_ask_password, strdup("password")); - jabber_connect_with_account = _mock_jabber_connect_with_account_result; will_return(_mock_jabber_connect_with_account_result, JABBER_CONNECTING); diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c index c70fbcf4..83119910 100644 --- a/tests/ui/mock_ui.c +++ b/tests/ui/mock_ui.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "ui/ui.h" @@ -43,321 +44,116 @@ void _stub_cons_show(const char * const msg, ...) { } -void -mock_cons_show(void) -{ - cons_show = _mock_cons_show; - -} - -void -stub_cons_show(void) -{ - cons_show = _stub_cons_show; -} - -void -expect_cons_show(char *output) -{ - expect_string(_mock_cons_show, output, output); -} - -void -expect_cons_show_calls(int n) +static +void _mock_cons_show_error(const char * const msg, ...) { - expect_any_count(_mock_cons_show, output, n); + va_list args; + va_start(args, msg); + vsnprintf(output, sizeof(output), msg, args); + check_expected(output); + va_end(args); } -// ui startup and control -void ui_init(void) {} -void ui_load_colours(void) {} -void ui_refresh(void) {} -void ui_close(void) {} -void ui_resize(const int ch, const char * const input, - const int size) {} - -GSList* ui_get_recipients(void) +static +void _mock_cons_show_account(ProfAccount *account) { - return (GSList *)mock(); + check_expected(account); } -void ui_handle_special_keys(const wint_t * const ch, const char * const inp, - const int size) {} -void ui_switch_win(const int i) {} -void ui_next_win(void) {} -void ui_previous_win(void) {} - -unsigned long ui_get_idle_time(void) +static +void _mock_cons_show_account_list(gchar **accounts) { - return (unsigned long)mock(); + check_expected(accounts); } -void ui_reset_idle_time(void) {} -void ui_new_chat_win(const char * const to) {} -void ui_print_error_from_recipient(const char * const from, const char *err_msg) {} -void ui_print_system_msg_from_recipient(const char * const from, const char *message) {} -void ui_handle_error_message(const char * const from, const char * const err_msg) {} - -gint ui_unread(void) +static +char * _mock_ui_ask_password(void) { - return (gint)mock(); + return (char *)mock(); } -void ui_close_connected_win(int index) {} - -int ui_close_all_wins(void) +static +char * _stub_ui_ask_password(void) { - return (int)mock(); + return NULL; } -int ui_close_read_wins(void) +void +mock_cons_show(void) { - return (int)mock(); + cons_show = _mock_cons_show; + } -// current window actions -void ui_close_current(void) {} -void ui_clear_current(void) {} - -win_type_t ui_current_win_type(void) +void +mock_cons_show_error(void) { - return (win_type_t)mock(); + cons_show_error = _mock_cons_show_error; } -int ui_current_win_index(void) +void +mock_cons_show_account(void) { - return (int)mock(); + cons_show_account = _mock_cons_show_account; } -char* ui_current_recipient(void) +void +mock_cons_show_account_list(void) { - return (char *)mock(); + cons_show_account_list = _mock_cons_show_account_list; } -void ui_current_print_line(const char * const msg, ...) {} -void ui_current_error_line(const char * const msg) {} -void ui_current_page_off(void) {} -win_type_t ui_win_type(int index) -{ - return (win_type_t)mock(); -} - -char * ui_recipient(int index) +void +mock_ui_ask_password(void) { - return (char *)mock(); + ui_ask_password = _mock_ui_ask_password; } -void ui_close_win(int index) {} - -gboolean ui_win_exists(int index) +void +stub_ui_ask_password(void) { - return (gboolean)mock(); + ui_ask_password = _stub_ui_ask_password; } -int ui_win_unread(int index) +void +stub_cons_show(void) { - return (int)mock(); + cons_show = _stub_cons_show; } -// ui events -void ui_contact_typing(const char * const from) {} -void ui_incoming_msg(const char * const from, const char * const message, - GTimeVal *tv_stamp, gboolean priv) {} -void ui_contact_online(const char * const barejid, const char * const resource, - const char * const show, const char * const status, GDateTime *last_activity) {} -void ui_contact_offline(const char * const from, const char * const show, - const char * const status) {} -void ui_disconnected(void) {} -void ui_recipient_gone(const char * const barejid) {} -void ui_outgoing_msg(const char * const from, const char * const to, - const char * const message) {} -void ui_room_join(Jid *jid) {} -void ui_room_roster(const char * const room, GList *roster, const char * const presence) {} -void ui_room_history(const char * const room_jid, const char * const nick, - GTimeVal tv_stamp, const char * const message) {} -void ui_room_message(const char * const room_jid, const char * const nick, - const char * const message) {} -void ui_room_subject(const char * const room_jid, - const char * const subject) {} -void ui_room_broadcast(const char * const room_jid, - const char * const message) {} -void ui_room_member_offline(const char * const room, const char * const nick) {} -void ui_room_member_online(const char * const room, - const char * const nick, const char * const show, const char * const status) {} -void ui_room_member_nick_change(const char * const room, - const char * const old_nick, const char * const nick) {} -void ui_room_nick_change(const char * const room, const char * const nick) {} -void ui_room_member_presence(const char * const room, - const char * const nick, const char * const show, const char * const status) {} -void ui_roster_add(const char * const barejid, const char * const name) {} -void ui_roster_remove(const char * const barejid) {} -void ui_contact_already_in_group(const char * const contact, const char * const group) {} -void ui_contact_not_in_group(const char * const contact, const char * const group) {} -void ui_group_added(const char * const contact, const char * const group) {} -void ui_group_removed(const char * const contact, const char * const group) {} - -// contact status functions -void ui_status_room(const char * const contact) {} -void ui_status(void) {} -void ui_status_private(void) {} - -void ui_create_duck_win(void) {} -void ui_open_duck_win(void) {} -void ui_duck(const char * const query) {} -void ui_duck_result(const char * const result) {} - -gboolean ui_duck_exists(void) +void +expect_cons_show(char *output) { - return (gboolean)mock(); + expect_string(_mock_cons_show, output, output); } -void ui_tidy_wins(void) {} -void ui_prune_wins(void) {} - -char * ui_ask_password(void) +void +expect_cons_show_calls(int n) { - return (char *)mock(); + expect_any_count(_mock_cons_show, output, n); } -// create windows -void create_title_bar(void) {} -void create_status_bar(void) {} -void create_input_window(void) {} - -// title bar actions -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(contact_presence_t status) {} -void title_bar_set_recipient(const char * const from) {} -void title_bar_set_typing(gboolean is_typing) {} -void title_bar_draw(void) {} - -// console window actions -void cons_about(void) {} -void cons_help(void) {} -void cons_basic_help(void) {} -void cons_settings_help(void) {} -void cons_presence_help(void) {} -void cons_navigation_help(void) {} -void cons_prefs(void) {} -void cons_show_ui_prefs(void) {} -void cons_show_desktop_prefs(void) {} -void cons_show_chat_prefs(void) {} -void cons_show_log_prefs(void) {} -void cons_show_presence_prefs(void) {} -void cons_show_connection_prefs(void) {} - -void cons_show_account(ProfAccount *account) +void +expect_cons_show_error(char *output) { - check_expected(account); + expect_string(_mock_cons_show_error, output, output); } -void cons_debug(const char * const msg, ...) {} -void cons_show_time(void) {} -void cons_show_word(const char * const word) {} - -void cons_show_error(const char * const cmd, ...) +void +expect_cons_show_account(ProfAccount *account) { - va_list args; - va_start(args, cmd); - vsnprintf(output, sizeof(output), cmd, args); - check_expected(output); - va_end(args); + expect_memory(_mock_cons_show_account, account, account, sizeof(ProfAccount)); } -void cons_highlight_show(const char * const cmd) {} -void cons_show_contacts(GSList * list) {} -void cons_show_roster(GSList * list) {} -void cons_show_roster_group(const char * const group, GSList * list) {} -void cons_show_wins(void) {} -void cons_show_status(const char * const barejid) {} -void cons_show_info(PContact pcontact) {} -void cons_show_caps(const char * const contact, Resource *resource) {} -void cons_show_themes(GSList *themes) {} -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) +void +expect_cons_show_account_list(gchar **accounts) { - check_expected(accounts); + expect_memory(_mock_cons_show_account_list, accounts, accounts, sizeof(accounts)); } -void cons_show_room_list(GSList *room, const char * const conference_node) {} -void cons_show_bookmarks(const GList *list) {} -void cons_show_disco_items(GSList *items, const char * const jid) {} -void cons_show_disco_info(const char *from, GSList *identities, GSList *features) {} -void cons_show_room_invite(const char * const invitor, const char * const room, - const char * const reason) {} -void cons_check_version(gboolean not_available_msg) {} -void cons_show_typing(const char * const barejid) {} -void cons_show_incoming_message(const char * const short_from, const int win_index) {} -void cons_show_room_invites(GSList *invites) {} -void cons_show_received_subs(void) {} -void cons_show_sent_subs(void) {} -void cons_alert(void) {} -void cons_theme_setting(void) {} -void cons_beep_setting(void) {} -void cons_flash_setting(void) {} -void cons_splash_setting(void) {} -void cons_vercheck_setting(void) {} -void cons_mouse_setting(void) {} -void cons_statuses_setting(void) {} -void cons_titlebar_setting(void) {} -void cons_notify_setting(void) {} -void cons_states_setting(void) {} -void cons_outtype_setting(void) {} -void cons_intype_setting(void) {} -void cons_gone_setting(void) {} -void cons_history_setting(void) {} -void cons_log_setting(void) {} -void cons_chlog_setting(void) {} -void cons_grlog_setting(void) {} -void cons_autoaway_setting(void) {} -void cons_reconnect_setting(void) {} -void cons_autoping_setting(void) {} -void cons_priority_setting(void) {} -void cons_autoconnect_setting(void) {} - -// status bar actions -void status_bar_refresh(void) {} -void status_bar_resize(void) {} -void status_bar_clear(void) {} -void status_bar_clear_message(void) {} -void status_bar_get_password(void) {} -void status_bar_print_message(const char * const msg) {} -void status_bar_inactive(const int win) {} -void status_bar_active(const int win) {} -void status_bar_new(const int win) {} -void status_bar_update_time(void) {} -void status_bar_set_all_inactive(void) {} -void status_bar_current(int i) {} - -// input window actions -wint_t inp_get_char(char *input, int *size) +void +mock_ui_ask_password_returns(char *password) { - return (wint_t)mock(); + will_return(_mock_ui_ask_password, strdup(password)); } -void inp_win_reset(void) {} -void inp_win_resize(const char * input, const int size) {} -void inp_put_back(void) {} -void inp_non_block(void) {} -void inp_block(void) {} -void inp_get_password(char *passwd) {} -void inp_replace_input(char *input, const char * const new_input, int *size) {} - -void notifier_init(void) {} -void notifier_uninit(void) {} - -void notify_typing(const char * const handle) {} -void notify_message(const char * const handle, int win) {} -void notify_room_message(const char * const handle, const char * const room, - int win) {} -void notify_remind(void) {} -void notify_invite(const char * const from, const char * const room, - const char * const reason) {} -void notify_subscription(const char * const from) {} diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h index 76d15614..2833be29 100644 --- a/tests/ui/mock_ui.h +++ b/tests/ui/mock_ui.h @@ -11,4 +11,17 @@ void mock_cons_show(void); void expect_cons_show(char *output); void expect_cons_show_calls(int n); +void mock_cons_show_error(void); +void expect_cons_show_error(char *output); + +void mock_cons_show_account(void); +void expect_cons_show_account(ProfAccount *account); + +void mock_cons_show_account_list(void); +void expect_cons_show_account_list(gchar **accounts); + +void stub_ui_ask_password(void); +void mock_ui_ask_password(void); +void mock_ui_ask_password_returns(char *password); + #endif -- cgit 1.4.1-2-gfad0 From a6859354b453dad686f6ed570c28a4870733dd08 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 22 Dec 2013 23:54:22 +0000 Subject: Bind ui core functions in main.c --- src/main.c | 3 ++ src/ui/core.c | 154 ++++++++++++++++++++++++++++------------------------------ src/ui/ui.h | 2 + 3 files changed, 78 insertions(+), 81 deletions(-) (limited to 'src/ui/ui.h') diff --git a/src/main.c b/src/main.c index d1a99556..2ca76de3 100644 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,7 @@ #include "profanity.h" #include "xmpp/xmpp.h" +#include "ui/ui.h" static gboolean disable_tls = FALSE; static gboolean version = FALSE; @@ -46,6 +47,8 @@ _init_modules(void) message_init_module(); presence_init_module(); roster_init_module(); + + ui_init_module(); } int diff --git a/src/ui/core.c b/src/ui/core.c index 241814bd..c5636d3a 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -95,7 +95,6 @@ _ui_init(void) ui_idle_time = g_timer_new(); wins_refresh_current(); } -void (*ui_init)(void) = _ui_init; static void _ui_refresh(void) @@ -105,7 +104,6 @@ _ui_refresh(void) status_bar_refresh(); inp_put_back(); } -void (*ui_refresh)(void) = _ui_refresh; static unsigned long _ui_get_idle_time(void) @@ -125,15 +123,12 @@ _ui_get_idle_time(void) unsigned long ms_elapsed = seconds_elapsed * 1000.0; return ms_elapsed; } -//unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time; -unsigned long (*ui_get_idle_time)(void) = _ui_get_idle_time; static void _ui_reset_idle_time(void) { g_timer_start(ui_idle_time); } -void (*ui_reset_idle_time)(void) = _ui_reset_idle_time; static void _ui_close(void) @@ -142,7 +137,6 @@ _ui_close(void) wins_destroy(); endwin(); } -void (*ui_close)(void) = _ui_close; static void _ui_resize(const int ch, const char * const input, const int size) @@ -154,7 +148,6 @@ _ui_resize(const int ch, const char * const input, const int size) inp_win_resize(input, size); wins_refresh_current(); } -void (*ui_resize)(const int, const char * const, const int) = _ui_resize; static void _ui_load_colours(void) @@ -165,7 +158,6 @@ _ui_load_colours(void) theme_init_colours(); } } -void (*ui_load_colours)(void) = _ui_load_colours; static gboolean _ui_win_exists(int index) @@ -173,14 +165,12 @@ _ui_win_exists(int index) ProfWin *window = wins_get_by_num(index); return (window != NULL); } -gboolean (*ui_win_exists)(int) = _ui_win_exists; static gboolean _ui_duck_exists(void) { return wins_duck_exists(); } -gboolean (*ui_duck_exists)(void) = _ui_duck_exists; static void _ui_contact_typing(const char * const barejid) @@ -219,7 +209,6 @@ _ui_contact_typing(const char * const barejid) notify_typing(display_usr); } } -void (*ui_contact_typing)(const char * const) = _ui_contact_typing; static GSList * _ui_get_recipients(void) @@ -227,7 +216,6 @@ _ui_get_recipients(void) GSList *recipients = wins_get_chat_recipients(); return recipients; } -GSList * (*ui_get_recipients)(void) = _ui_get_recipients; static void _ui_incoming_msg(const char * const from, const char * const message, @@ -305,8 +293,6 @@ _ui_incoming_msg(const char * const from, const char * const message, free(display_from); } -void (*ui_incoming_msg)(const char * const, const char * const, - GTimeVal*, gboolean) = _ui_incoming_msg; static void _ui_roster_add(const char * const barejid, const char * const name) @@ -317,42 +303,36 @@ _ui_roster_add(const char * const barejid, const char * const name) cons_show("Roster item added: %s", barejid); } } -void (*ui_roster_add)(const char * const, const char * const) = _ui_roster_add; static void _ui_roster_remove(const char * const barejid) { cons_show("Roster item removed: %s", barejid); } -void (*ui_roster_remove)(const char * const) = _ui_roster_remove; static void _ui_contact_already_in_group(const char * const contact, const char * const group) { cons_show("%s already in group %s", contact, group); } -void (*ui_contact_already_in_group)(const char * const, const char * const) = _ui_contact_already_in_group; static void _ui_contact_not_in_group(const char * const contact, const char * const group) { cons_show("%s is not currently in group %s", contact, group); } -void (*ui_contact_not_in_group)(const char * const, const char * const) = _ui_contact_not_in_group; static void _ui_group_added(const char * const contact, const char * const group) { cons_show("%s added to group %s", contact, group); } -void (*ui_group_added)(const char * const, const char * const) = _ui_group_added; static void _ui_group_removed(const char * const contact, const char * const group) { cons_show("%s removed from group %s", contact, group); } -void (*ui_group_removed)(const char * const, const char * const) = _ui_group_removed; static void _ui_handle_error_message(const char * const from, const char * const err_msg) @@ -369,8 +349,6 @@ _ui_handle_error_message(const char * const from, const char * const err_msg) ui_print_error_from_recipient(from, err_msg); } -void (*ui_handle_error_message)(const char * const, - const char * const) = _ui_handle_error_message; static void _ui_contact_online(const char * const barejid, const char * const resource, @@ -397,8 +375,6 @@ _ui_contact_online(const char * const barejid, const char * const resource, wins_refresh_current(); } } -void (*ui_contact_online)(const char * const, const char * const, - const char * const, const char * const, GDateTime*) = _ui_contact_online; static void _ui_contact_offline(const char * const from, const char * const show, @@ -427,8 +403,6 @@ _ui_contact_offline(const char * const from, const char * const show, wins_refresh_current(); } } -void (*ui_contact_offline)(const char * const, const char * const, - const char * const) = _ui_contact_offline; static void _ui_disconnected(void) @@ -438,7 +412,6 @@ _ui_disconnected(void) status_bar_clear_message(); status_bar_refresh(); } -void (*ui_disconnected)(void) = _ui_disconnected; static void _ui_handle_special_keys(const wint_t * const ch, const char * const inp, @@ -451,8 +424,6 @@ _ui_handle_special_keys(const wint_t * const ch, const char * const inp, } } -void (*ui_handle_special_keys)(const wint_t * const, const char * const, - const int) = _ui_handle_special_keys; static void _ui_close_connected_win(int index) @@ -475,7 +446,6 @@ _ui_close_connected_win(int index) } } } -void (*ui_close_connected_win)(int index) = _ui_close_connected_win; static int _ui_close_all_wins(void) @@ -503,7 +473,6 @@ _ui_close_all_wins(void) return count; } -int (*ui_close_all_wins)(void) = _ui_close_all_wins; static int _ui_close_read_wins(void) @@ -531,7 +500,6 @@ _ui_close_read_wins(void) return count; } -int (*ui_close_read_wins)(void) = _ui_close_read_wins; static void _ui_switch_win(const int i) @@ -566,7 +534,6 @@ _ui_switch_win(const int i) wins_refresh_current(); } } -void (*ui_switch_win)(const int) = _ui_switch_win; static void _ui_next_win(void) @@ -600,7 +567,6 @@ _ui_next_win(void) } wins_refresh_current(); } -void (*ui_next_win)(void) = _ui_next_win; static void _ui_previous_win(void) @@ -634,14 +600,12 @@ _ui_previous_win(void) } wins_refresh_current(); } -void (*ui_previous_win)(void) = _ui_previous_win; static void _ui_clear_current(void) { wins_clear_current(); } -void (*ui_clear_current)(void) = _ui_clear_current; static void _ui_close_current(void) @@ -653,7 +617,6 @@ _ui_close_current(void) status_bar_active(1); title_bar_title(); } -void (*ui_close_current)(void) = _ui_close_current; static void _ui_close_win(int index) @@ -665,7 +628,6 @@ _ui_close_win(int index) wins_refresh_current(); } -void (*ui_close_win)(int) = _ui_close_win; static void _ui_tidy_wins(void) @@ -678,7 +640,6 @@ _ui_tidy_wins(void) cons_show("No tidy needed."); } } -void (*ui_tidy_wins)(void) = _ui_tidy_wins; static void _ui_prune_wins(void) @@ -724,7 +685,6 @@ _ui_prune_wins(void) cons_show("No prune needed."); } } -void (*ui_prune_wins)(void) = _ui_prune_wins; static win_type_t _ui_current_win_type(void) @@ -732,14 +692,12 @@ _ui_current_win_type(void) ProfWin *current = wins_get_current(); return current->type; } -win_type_t (*ui_current_win_type)(void) = _ui_current_win_type; static int _ui_current_win_index(void) { return wins_get_current_num(); } -int (*ui_current_win_index)(void) = _ui_current_win_index; static win_type_t _ui_win_type(int index) @@ -747,7 +705,6 @@ _ui_win_type(int index) ProfWin *window = wins_get_by_num(index); return window->type; } -win_type_t (*ui_win_type)(int index) = _ui_win_type; static char * _ui_recipient(int index) @@ -755,7 +712,6 @@ _ui_recipient(int index) ProfWin *window = wins_get_by_num(index); return window->from; } -char * (*ui_recipient)(int) = _ui_recipient; static char * _ui_current_recipient(void) @@ -763,7 +719,6 @@ _ui_current_recipient(void) ProfWin *current = wins_get_current(); return current->from; } -char* (*ui_current_recipient)(void) = _ui_current_recipient; static void _ui_current_print_line(const char * const msg, ...) @@ -775,7 +730,6 @@ _ui_current_print_line(const char * const msg, ...) va_end(arg); win_refresh(current); } -void (*ui_current_print_line)(const char * const, ...) = _ui_current_print_line; static void _ui_current_error_line(const char * const msg) @@ -784,7 +738,6 @@ _ui_current_error_line(const char * const msg) win_print_line(current, '-', COLOUR_ERROR, msg); win_refresh(current); } -void (*ui_current_error_line)(const char * const) = _ui_current_error_line; static void _ui_current_page_off(void) @@ -793,7 +746,6 @@ _ui_current_page_off(void) win_page_off(current); win_refresh(current); } -void (*ui_current_page_off)(void) = _ui_current_page_off; static void _ui_print_error_from_recipient(const char * const from, const char *err_msg) @@ -809,7 +761,6 @@ _ui_print_error_from_recipient(const char * const from, const char *err_msg) } } } -void (*ui_print_error_from_recipient)(const char * const, const char *) = _ui_print_error_from_recipient; static void _ui_print_system_msg_from_recipient(const char * const from, const char *message) @@ -845,8 +796,6 @@ _ui_print_system_msg_from_recipient(const char * const from, const char *message wins_refresh_current(); } } -void (*ui_print_system_msg_from_recipient)(const char * const, - const char *) = _ui_print_system_msg_from_recipient; static void _ui_recipient_gone(const char * const barejid) @@ -870,7 +819,6 @@ _ui_recipient_gone(const char * const barejid) } } } -void (*ui_recipient_gone)(const char * const) = _ui_recipient_gone; static void _ui_new_chat_win(const char * const to) @@ -910,7 +858,6 @@ _ui_new_chat_win(const char * const to) ui_switch_win(num); } -void (*ui_new_chat_win)(const char * const) = _ui_new_chat_win; static void _ui_create_duck_win(void) @@ -920,7 +867,6 @@ _ui_create_duck_win(void) ui_switch_win(num); win_print_line(window, '-', 0, "Type ':help' to find out more."); } -void (*ui_create_duck_win)(void) = _ui_create_duck_win; static void _ui_open_duck_win(void) @@ -931,7 +877,6 @@ _ui_open_duck_win(void) ui_switch_win(num); } } -void (*ui_open_duck_win)(void) = _ui_open_duck_win; static void _ui_duck(const char * const query) @@ -948,7 +893,6 @@ _ui_duck(const char * const query) wprintw(window->win, "\n"); } } -void (*ui_duck)(const char * const) = _ui_duck; static void _ui_duck_result(const char * const result) @@ -982,7 +926,6 @@ _ui_duck_result(const char * const result) wprintw(window->win, "\n"); } } -void (*ui_duck_result)(const char * const) = _ui_duck_result; static void _ui_outgoing_msg(const char * const from, const char * const to, @@ -1035,8 +978,6 @@ _ui_outgoing_msg(const char * const from, const char * const to, } ui_switch_win(num); } -void (*ui_outgoing_msg)(const char * const, const char * const, - const char * const) = _ui_outgoing_msg; static void _ui_room_join(Jid *jid) @@ -1052,7 +993,6 @@ _ui_room_join(Jid *jid) num = wins_get_num(window); ui_switch_win(num); } -void (*ui_room_join)(Jid *) = _ui_room_join; static void _ui_room_roster(const char * const room, GList *roster, const char * const presence) @@ -1108,7 +1048,6 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese wins_refresh_current(); } } -void (*ui_room_roster)(const char * const, GList*, const char * const) = _ui_room_roster; static void _ui_room_member_offline(const char * const room, const char * const nick) @@ -1124,7 +1063,6 @@ _ui_room_member_offline(const char * const room, const char * const nick) wins_refresh_current(); } } -void (*ui_room_member_offline)(const char * const, const char * const) = _ui_room_member_offline; static void _ui_room_member_online(const char * const room, const char * const nick, @@ -1141,8 +1079,6 @@ _ui_room_member_online(const char * const room, const char * const nick, wins_refresh_current(); } } -void (*ui_room_member_online)(const char * const, const char * const, - const char * const, const char * const) = _ui_room_member_online; static void _ui_room_member_presence(const char * const room, const char * const nick, @@ -1158,8 +1094,6 @@ _ui_room_member_presence(const char * const room, const char * const nick, wins_refresh_current(); } } -void (*ui_room_member_presence)(const char * const, const char * const, - const char * const, const char * const) = _ui_room_member_presence; static void _ui_room_member_nick_change(const char * const room, @@ -1176,8 +1110,6 @@ _ui_room_member_nick_change(const char * const room, wins_refresh_current(); } } -void (*ui_room_member_nick_change)(const char * const, - const char * const, const char * const) = _ui_room_member_nick_change; static void _ui_room_nick_change(const char * const room, const char * const nick) @@ -1193,7 +1125,6 @@ _ui_room_nick_change(const char * const room, const char * const nick) wins_refresh_current(); } } -void (*ui_room_nick_change)(const char * const, const char * const) = _ui_room_nick_change; static void _ui_room_history(const char * const room_jid, const char * const nick, @@ -1220,8 +1151,6 @@ _ui_room_history(const char * const room_jid, const char * const nick, wins_refresh_current(); } } -void (*ui_room_history)(const char * const, const char * const, - GTimeVal, const char * const) = _ui_room_history; static void _ui_room_message(const char * const room_jid, const char * const nick, @@ -1294,8 +1223,6 @@ _ui_room_message(const char * const room_jid, const char * const nick, } } } -void (*ui_room_message)(const char * const, const char * const, - const char * const) = _ui_room_message; static void _ui_room_subject(const char * const room_jid, const char * const subject) @@ -1319,7 +1246,6 @@ _ui_room_subject(const char * const room_jid, const char * const subject) status_bar_new(num); } } -void (*ui_room_subject)(const char * const, const char * const) = _ui_room_subject; static void _ui_room_broadcast(const char * const room_jid, const char * const message) @@ -1343,7 +1269,6 @@ _ui_room_broadcast(const char * const room_jid, const char * const message) status_bar_new(num); } } -void (*ui_room_broadcast)(const char * const, const char * const) = _ui_room_broadcast; static void _ui_status(void) @@ -1358,7 +1283,6 @@ _ui_status(void) win_print_line(current, '-', 0, "Error getting contact info."); } } -void (*ui_status)(void) = _ui_status; static void _ui_status_private(void) @@ -1375,7 +1299,6 @@ _ui_status_private(void) jid_destroy(jid); } -void (*ui_status_private)(void) = _ui_status_private; static void _ui_status_room(const char * const contact) @@ -1389,14 +1312,12 @@ _ui_status_room(const char * const contact) win_print_line(current, '-', 0, "No such participant \"%s\" in room.", contact); } } -void (*ui_status_room)(const char * const) = _ui_status_room; static gint _ui_unread(void) { return wins_get_total_unread(); } -gint (*ui_unread)(void) = _ui_unread; static int _ui_win_unread(int index) @@ -1408,7 +1329,6 @@ _ui_win_unread(int index) return 0; } } -int (*ui_win_unread)(int) = _ui_win_unread; static char * _ui_ask_password(void) @@ -1422,7 +1342,6 @@ _ui_ask_password(void) return passwd; } -char * (*ui_ask_password)(void) = _ui_ask_password; static void _ui_draw_win_title(void) @@ -1618,3 +1537,76 @@ _win_show_history(WINDOW *win, int win_index, const char * const contact) g_slist_free_full(history, free); } } + +void +ui_init_module(void) +{ + ui_init = _ui_init; + ui_refresh = _ui_refresh; + ui_get_idle_time = _ui_get_idle_time; + ui_reset_idle_time = _ui_reset_idle_time; + ui_close = _ui_close; + ui_resize = _ui_resize; + ui_load_colours = _ui_load_colours; + ui_win_exists = _ui_win_exists; + ui_duck_exists = _ui_duck_exists; + ui_contact_typing = _ui_contact_typing; + ui_get_recipients = _ui_get_recipients; + ui_incoming_msg = _ui_incoming_msg; + ui_roster_add = _ui_roster_add; + ui_roster_remove = _ui_roster_remove; + ui_contact_already_in_group = _ui_contact_already_in_group; + ui_contact_not_in_group = _ui_contact_not_in_group; + ui_group_added = _ui_group_added; + ui_group_removed = _ui_group_removed; + ui_handle_error_message = _ui_handle_error_message; + ui_contact_online = _ui_contact_online; + ui_contact_offline = _ui_contact_offline; + ui_disconnected = _ui_disconnected; + ui_handle_special_keys = _ui_handle_special_keys; + ui_close_connected_win = _ui_close_connected_win; + ui_close_all_wins = _ui_close_all_wins; + ui_close_read_wins = _ui_close_read_wins; + ui_switch_win = _ui_switch_win; + ui_next_win = _ui_next_win; + ui_previous_win = _ui_previous_win; + ui_clear_current = _ui_clear_current; + ui_close_current = _ui_close_current; + ui_close_win = _ui_close_win; + ui_tidy_wins = _ui_tidy_wins; + ui_prune_wins = _ui_prune_wins; + ui_current_win_type = _ui_current_win_type; + ui_current_win_index = _ui_current_win_index; + ui_win_type = _ui_win_type; + ui_recipient = _ui_recipient; + ui_current_recipient = _ui_current_recipient; + ui_current_print_line = _ui_current_print_line; + ui_current_error_line = _ui_current_error_line; + ui_current_page_off = _ui_current_page_off; + ui_print_error_from_recipient = _ui_print_error_from_recipient; + ui_print_system_msg_from_recipient = _ui_print_system_msg_from_recipient; + ui_recipient_gone = _ui_recipient_gone; + ui_new_chat_win = _ui_new_chat_win; + ui_create_duck_win = _ui_create_duck_win; + ui_open_duck_win = _ui_open_duck_win; + ui_duck = _ui_duck; + ui_duck_result = _ui_duck_result; + ui_outgoing_msg = _ui_outgoing_msg; + ui_room_join = _ui_room_join; + ui_room_roster = _ui_room_roster; + ui_room_member_offline = _ui_room_member_offline; + ui_room_member_online = _ui_room_member_online; + ui_room_member_presence = _ui_room_member_presence; + ui_room_member_nick_change = _ui_room_member_nick_change; + ui_room_nick_change = _ui_room_nick_change; + ui_room_history = _ui_room_history; + ui_room_message = _ui_room_message; + ui_room_subject = _ui_room_subject; + ui_room_broadcast = _ui_room_broadcast; + ui_status = _ui_status; + ui_status_private = _ui_status_private; + ui_status_room = _ui_status_room; + ui_unread = _ui_unread; + ui_win_unread = _ui_win_unread; + ui_ask_password = _ui_ask_password; +} diff --git a/src/ui/ui.h b/src/ui/ui.h index 482d8735..36bb1ff6 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -41,6 +41,8 @@ #define INP_WIN_MAX 1000 +void ui_init_module(void); + // ui startup and control void (*ui_init)(void); void (*ui_load_colours)(void); -- cgit 1.4.1-2-gfad0 From 7fe8f61b9b43357c145ab28ab2f09bd9d870a16e Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 23 Dec 2013 00:08:45 +0000 Subject: Bind console functions in main.c --- src/main.c | 1 + src/ui/console.c | 130 ++++++++++++++++++++++++++++--------------------------- src/ui/ui.h | 1 + 3 files changed, 68 insertions(+), 64 deletions(-) (limited to 'src/ui/ui.h') diff --git a/src/main.c b/src/main.c index 2ca76de3..9b3f54b6 100644 --- a/src/main.c +++ b/src/main.c @@ -49,6 +49,7 @@ _init_modules(void) roster_init_module(); ui_init_module(); + console_init_module(); } int diff --git a/src/ui/console.c b/src/ui/console.c index 57e5eb73..bb6c4a38 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -54,7 +54,6 @@ _cons_show_time(void) win_print_time(console, '-'); wins_refresh_console(); } -void (*cons_show_time)(void) = _cons_show_time; static void _cons_show_word(const char * const word) @@ -63,7 +62,6 @@ _cons_show_word(const char * const word) wprintw(console->win, "%s", word); wins_refresh_console(); } -void (*cons_show_word)(const char * const) = _cons_show_word; static void _cons_debug(const char * const msg, ...) @@ -86,7 +84,6 @@ _cons_debug(const char * const msg, ...) ui_refresh(); } } -void (*cons_debug)(const char * const, ...) = _cons_debug; static void _cons_show(const char * const msg, ...) @@ -102,7 +99,6 @@ _cons_show(const char * const msg, ...) va_end(arg); wins_refresh_console(); } -void (*cons_show)(const char * const, ...) = _cons_show; static void _cons_show_error(const char * const msg, ...) @@ -122,7 +118,6 @@ _cons_show_error(const char * const msg, ...) wins_refresh_console(); cons_alert(); } -void (*cons_show_error)(const char * const, ...) = _cons_show_error; static void _cons_show_typing(const char * const barejid) @@ -141,7 +136,6 @@ _cons_show_typing(const char * const barejid) wins_refresh_console(); cons_alert(); } -void (*cons_show_typing)(const char * const) = _cons_show_typing; static void _cons_show_incoming_message(const char * const short_from, const int win_index) @@ -160,7 +154,6 @@ _cons_show_incoming_message(const char * const short_from, const int win_index) wins_refresh_console(); cons_alert(); } -void (*cons_show_incoming_message)(const char * const, const int) = _cons_show_incoming_message; static void _cons_about(void) @@ -213,7 +206,6 @@ _cons_about(void) wins_refresh_console(); cons_alert(); } -void (*cons_about)(void) = _cons_about; static void _cons_check_version(gboolean not_available_msg) @@ -245,7 +237,6 @@ _cons_check_version(gboolean not_available_msg) } } } -void (*cons_check_version)(gboolean) = _cons_check_version; static void _cons_show_login_success(ProfAccount *account) @@ -266,7 +257,6 @@ _cons_show_login_success(ProfAccount *account) wins_refresh_console(); cons_alert(); } -void (*cons_show_login_success)(ProfAccount*) = _cons_show_login_success; static void _cons_show_wins(void) @@ -288,7 +278,6 @@ _cons_show_wins(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_wins)(void) = _cons_show_wins; static void _cons_show_room_invites(GSList *invites) @@ -307,7 +296,6 @@ _cons_show_room_invites(GSList *invites) wins_refresh_console(); cons_alert(); } -void (*cons_show_room_invites)(GSList*) = _cons_show_room_invites; static void _cons_show_info(PContact pcontact) @@ -441,7 +429,6 @@ _cons_show_info(PContact pcontact) wins_refresh_console(); cons_alert(); } -void (*cons_show_info)(PContact) = _cons_show_info; static void _cons_show_caps(const char * const contact, Resource *resource) @@ -517,7 +504,6 @@ _cons_show_caps(const char * const contact, Resource *resource) wins_refresh_console(); cons_alert(); } -void (*cons_show_caps)(const char * const, Resource*) = _cons_show_caps; static void _cons_show_software_version(const char * const jid, const char * const presence, @@ -545,9 +531,6 @@ _cons_show_software_version(const char * const jid, const char * const presence wins_refresh_console(); cons_alert(); } -void (*cons_show_software_version)(const char * const, const char * const, - const char * const, const char * const, - const char * const) = _cons_show_software_version; static void _cons_show_received_subs(void) @@ -568,7 +551,6 @@ _cons_show_received_subs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_received_subs)(void) = _cons_show_received_subs; static void _cons_show_sent_subs(void) @@ -591,7 +573,6 @@ _cons_show_sent_subs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_sent_subs)(void) = _cons_show_sent_subs; static void _cons_show_room_list(GSList *rooms, const char * const conference_node) @@ -616,7 +597,6 @@ _cons_show_room_list(GSList *rooms, const char * const conference_node) wins_refresh_console(); cons_alert(); } -void (*cons_show_room_list)(GSList*, const char * const) = _cons_show_room_list; static void _cons_show_bookmarks(const GList *list) @@ -647,7 +627,6 @@ _cons_show_bookmarks(const GList *list) wins_refresh_console(); cons_alert(); } -void (*cons_show_bookmarks)(const GList*) = _cons_show_bookmarks; static void _cons_show_disco_info(const char *jid, GSList *identities, GSList *features) @@ -691,7 +670,6 @@ _cons_show_disco_info(const char *jid, GSList *identities, GSList *features) cons_alert(); } } -void (*cons_show_disco_info)(const char*, GSList*, GSList*) = _cons_show_disco_info; static void _cons_show_disco_items(GSList *items, const char * const jid) @@ -717,7 +695,6 @@ _cons_show_disco_items(GSList *items, const char * const jid) wins_refresh_console(); cons_alert(); } -void (*cons_show_disco_items)(GSList*, const char * const) = _cons_show_disco_items; static void _cons_show_status(const char * const barejid) @@ -733,7 +710,6 @@ _cons_show_status(const char * const barejid) wins_refresh_console(); cons_alert(); } -void (*cons_show_status)(const char * const) = _cons_show_status; static void _cons_show_room_invite(const char * const invitor, const char * const room, @@ -771,8 +747,6 @@ _cons_show_room_invite(const char * const invitor, const char * const room, wins_refresh_console(); cons_alert(); } -void (*cons_show_room_invite)(const char * const, const char * const, - const char * const) = _cons_show_room_invite; static void _cons_show_account_list(gchar **accounts) @@ -803,7 +777,6 @@ _cons_show_account_list(gchar **accounts) wins_refresh_console(); cons_alert(); } -void (*cons_show_account_list)(gchar**) = _cons_show_account_list; static void _cons_show_account(ProfAccount *account) @@ -927,7 +900,6 @@ _cons_show_account(ProfAccount *account) wins_refresh_console(); cons_alert(); } -void (*cons_show_account)(ProfAccount*) = _cons_show_account; static void _cons_theme_setting(void) @@ -939,7 +911,6 @@ _cons_theme_setting(void) cons_show("Theme (/theme) : %s", theme); } } -void (*cons_theme_setting)(void) = _cons_theme_setting; static void _cons_beep_setting(void) @@ -949,7 +920,6 @@ _cons_beep_setting(void) else cons_show("Terminal beep (/beep) : OFF"); } -void (*cons_beep_setting)(void) = _cons_beep_setting; static void _cons_flash_setting(void) @@ -959,7 +929,6 @@ _cons_flash_setting(void) else cons_show("Terminal flash (/flash) : OFF"); } -void (*cons_flash_setting)(void) = _cons_flash_setting; static void _cons_splash_setting(void) @@ -969,7 +938,6 @@ _cons_splash_setting(void) else cons_show("Splash screen (/splash) : OFF"); } -void (*cons_splash_setting)(void) = _cons_splash_setting; static void _cons_autoconnect_setting(void) @@ -979,7 +947,6 @@ _cons_autoconnect_setting(void) else cons_show("Autoconnect (/autoconnect) : OFF"); } -void (*cons_autoconnect_setting)(void) = _cons_autoconnect_setting; static void _cons_vercheck_setting(void) @@ -989,7 +956,6 @@ _cons_vercheck_setting(void) else cons_show("Version checking (/vercheck) : OFF"); } -void (*cons_vercheck_setting)(void) = _cons_vercheck_setting; static void _cons_mouse_setting(void) @@ -999,7 +965,6 @@ _cons_mouse_setting(void) else cons_show("Mouse handling (/mouse) : OFF"); } -void (*cons_mouse_setting)(void) = _cons_mouse_setting; static void _cons_statuses_setting(void) @@ -1009,7 +974,6 @@ _cons_statuses_setting(void) else cons_show("Status (/statuses) : OFF"); } -void (*cons_statuses_setting)(void) = _cons_statuses_setting; static void _cons_titlebar_setting(void) @@ -1020,7 +984,6 @@ _cons_titlebar_setting(void) cons_show("Titlebar display (/titlebar) : NONE"); } } -void (*cons_titlebar_setting)(void) = _cons_titlebar_setting; static void _cons_show_ui_prefs(void) @@ -1039,7 +1002,6 @@ _cons_show_ui_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_ui_prefs)(void) = _cons_show_ui_prefs; static void _cons_notify_setting(void) @@ -1073,7 +1035,6 @@ _cons_notify_setting(void) cons_show("Reminder period (/notify remind) : %d seconds", remind_period); } } -void (*cons_notify_setting)(void) = _cons_notify_setting; static void _cons_show_desktop_prefs(void) @@ -1085,7 +1046,6 @@ _cons_show_desktop_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_desktop_prefs)(void) = _cons_show_desktop_prefs; static void _cons_states_setting(void) @@ -1095,7 +1055,6 @@ _cons_states_setting(void) else cons_show("Send chat states (/states) : OFF"); } -void (*cons_states_setting)(void) = _cons_states_setting; static void _cons_outtype_setting(void) @@ -1105,7 +1064,6 @@ _cons_outtype_setting(void) else cons_show("Send composing (/outtype) : OFF"); } -void (*cons_outtype_setting)(void) = _cons_outtype_setting; static void _cons_intype_setting(void) @@ -1115,7 +1073,6 @@ _cons_intype_setting(void) else cons_show("Show typing (/intype) : OFF"); } -void (*cons_intype_setting)(void) = _cons_intype_setting; static void _cons_gone_setting(void) @@ -1129,7 +1086,6 @@ _cons_gone_setting(void) cons_show("Leave conversation (/gone) : %d minutes", gone_time); } } -void (*cons_gone_setting)(void) = _cons_gone_setting; static void _cons_history_setting(void) @@ -1139,7 +1095,6 @@ _cons_history_setting(void) else cons_show("Chat history (/history) : OFF"); } -void (*cons_history_setting)(void) = _cons_history_setting; static void _cons_show_chat_prefs(void) @@ -1155,14 +1110,12 @@ _cons_show_chat_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_chat_prefs)(void) = _cons_show_chat_prefs; static void _cons_log_setting(void) { cons_show("Max log size (/log maxsize) : %d bytes", prefs_get_max_log_size()); } -void (*cons_log_setting)(void) = _cons_log_setting; static void _cons_chlog_setting(void) @@ -1172,7 +1125,6 @@ _cons_chlog_setting(void) else cons_show("Chat logging (/chlog) : OFF"); } -void (*cons_chlog_setting)(void) = _cons_chlog_setting; static void _cons_grlog_setting(void) @@ -1182,7 +1134,6 @@ _cons_grlog_setting(void) else cons_show("Groupchat logging (/grlog) : OFF"); } -void (*cons_grlog_setting)(void) = _cons_grlog_setting; static void _cons_show_log_prefs(void) @@ -1196,7 +1147,6 @@ _cons_show_log_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_log_prefs)(void) = _cons_show_log_prefs; static void _cons_autoaway_setting(void) @@ -1222,7 +1172,6 @@ _cons_autoaway_setting(void) cons_show("Autoaway check (/autoaway check) : OFF"); } } -void (*cons_autoaway_setting)(void) = _cons_autoaway_setting; static void _cons_show_presence_prefs(void) @@ -1234,7 +1183,6 @@ _cons_show_presence_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_presence_prefs)(void) = _cons_show_presence_prefs; static void _cons_reconnect_setting(void) @@ -1248,7 +1196,6 @@ _cons_reconnect_setting(void) cons_show("Reconnect interval (/reconnect) : %d seconds", reconnect_interval); } } -void (*cons_reconnect_setting)(void) = _cons_reconnect_setting; static void _cons_autoping_setting(void) @@ -1262,7 +1209,6 @@ _cons_autoping_setting(void) cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval); } } -void (*cons_autoping_setting)(void) = _cons_autoping_setting; static void _cons_priority_setting(void) @@ -1270,7 +1216,6 @@ _cons_priority_setting(void) gint priority = prefs_get_priority(); cons_show("Priority (/priority) : %d", priority); } -void (*cons_priority_setting)(void) = _cons_priority_setting; static void _cons_show_connection_prefs(void) @@ -1284,7 +1229,6 @@ _cons_show_connection_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_show_connection_prefs)(void) = _cons_show_connection_prefs; static void _cons_show_themes(GSList *themes) @@ -1304,7 +1248,6 @@ _cons_show_themes(GSList *themes) wins_refresh_console(); cons_alert(); } -void (*cons_show_themes)(GSList*) = _cons_show_themes; static void _cons_prefs(void) @@ -1326,7 +1269,6 @@ _cons_prefs(void) wins_refresh_console(); cons_alert(); } -void (*cons_prefs)(void) = _cons_prefs; static void _cons_help(void) @@ -1350,7 +1292,6 @@ _cons_help(void) wins_refresh_console(); cons_alert(); } -void (*cons_help)(void) = _cons_help; static void _cons_navigation_help(void) @@ -1375,7 +1316,6 @@ _cons_navigation_help(void) wins_refresh_console(); cons_alert(); } -void (*cons_navigation_help)(void) = _cons_navigation_help; static void _cons_show_roster_group(const char * const group, GSList *list) @@ -1392,7 +1332,6 @@ _cons_show_roster_group(const char * const group, GSList *list) wins_refresh_console(); cons_alert(); } -void (*cons_show_roster_group)(const char * const, GSList*) = _cons_show_roster_group; static void _cons_show_roster(GSList *list) @@ -1404,7 +1343,6 @@ _cons_show_roster(GSList *list) wins_refresh_console(); cons_alert(); } -void (*cons_show_roster)(GSList*) = _cons_show_roster; static void _cons_show_contacts(GSList *list) @@ -1424,7 +1362,6 @@ _cons_show_contacts(GSList *list) wins_refresh_console(); cons_alert(); } -void (*cons_show_contacts)(GSList*) = _cons_show_contacts; static void _cons_alert(void) @@ -1433,7 +1370,6 @@ _cons_alert(void) status_bar_new(1); } } -void (*cons_alert)(void) = _cons_alert; static void _cons_splash_logo(void) @@ -1566,3 +1502,69 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } } + +void +console_init_module(void) +{ + cons_show_time = _cons_show_time; + cons_show_word = _cons_show_word; + cons_debug = _cons_debug; + cons_show = _cons_show; + cons_show_error = _cons_show_error; + cons_show_typing = _cons_show_typing; + cons_show_incoming_message = _cons_show_incoming_message; + cons_about = _cons_about; + cons_check_version = _cons_check_version; + cons_show_login_success = _cons_show_login_success; + cons_show_wins = _cons_show_wins; + cons_show_room_invites = _cons_show_room_invites; + cons_show_info = _cons_show_info; + cons_show_caps = _cons_show_caps; + cons_show_software_version = _cons_show_software_version; + cons_show_received_subs = _cons_show_received_subs; + cons_show_sent_subs = _cons_show_sent_subs; + cons_show_room_list = _cons_show_room_list; + cons_show_bookmarks = _cons_show_bookmarks; + cons_show_disco_info = _cons_show_disco_info; + cons_show_disco_items = _cons_show_disco_items; + cons_show_status = _cons_show_status; + cons_show_room_invite = _cons_show_room_invite; + cons_show_account_list = _cons_show_account_list; + cons_show_account = _cons_show_account; + cons_theme_setting = _cons_theme_setting; + cons_beep_setting = _cons_beep_setting; + cons_flash_setting = _cons_flash_setting; + cons_splash_setting = _cons_splash_setting; + cons_autoconnect_setting = _cons_autoconnect_setting; + cons_vercheck_setting = _cons_vercheck_setting; + cons_mouse_setting = _cons_mouse_setting; + cons_statuses_setting = _cons_statuses_setting; + cons_titlebar_setting = _cons_titlebar_setting; + cons_show_ui_prefs = _cons_show_ui_prefs; + cons_notify_setting = _cons_notify_setting; + cons_show_desktop_prefs = _cons_show_desktop_prefs; + cons_states_setting = _cons_states_setting; + cons_outtype_setting = _cons_outtype_setting; + cons_intype_setting = _cons_intype_setting; + cons_gone_setting = _cons_gone_setting; + cons_history_setting = _cons_history_setting; + cons_show_chat_prefs = _cons_show_chat_prefs; + cons_log_setting = _cons_log_setting; + cons_chlog_setting = _cons_chlog_setting; + cons_grlog_setting = _cons_grlog_setting; + cons_show_log_prefs = _cons_show_log_prefs; + cons_autoaway_setting = _cons_autoaway_setting; + cons_show_presence_prefs = _cons_show_presence_prefs; + cons_reconnect_setting = _cons_reconnect_setting; + cons_autoping_setting = _cons_autoping_setting; + cons_priority_setting = _cons_priority_setting; + cons_show_connection_prefs = _cons_show_connection_prefs; + cons_show_themes = _cons_show_themes; + cons_prefs = _cons_prefs; + cons_help = _cons_help; + cons_navigation_help = _cons_navigation_help; + cons_show_roster_group = _cons_show_roster_group; + cons_show_roster = _cons_show_roster; + cons_show_contacts = _cons_show_contacts; + cons_alert = _cons_alert; +} diff --git a/src/ui/ui.h b/src/ui/ui.h index 36bb1ff6..9b5e5079 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -42,6 +42,7 @@ #define INP_WIN_MAX 1000 void ui_init_module(void); +void console_init_module(void); // ui startup and control void (*ui_init)(void); -- cgit 1.4.1-2-gfad0 From b83b262d47ea62330e1e1a21e3da12aef08e981d Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 23 Dec 2013 00:23:22 +0000 Subject: Bind remaining ui functions in main.c --- src/main.c | 4 ++++ src/ui/inputwin.c | 23 ++++++++++++++--------- src/ui/notifier.c | 24 ++++++++++++++---------- src/ui/statusbar.c | 29 +++++++++++++++++------------ src/ui/titlebar.c | 23 ++++++++++++++--------- src/ui/ui.h | 4 ++++ 6 files changed, 67 insertions(+), 40 deletions(-) (limited to 'src/ui/ui.h') diff --git a/src/main.c b/src/main.c index 9b3f54b6..233feb6a 100644 --- a/src/main.c +++ b/src/main.c @@ -50,6 +50,10 @@ _init_modules(void) ui_init_module(); console_init_module(); + inputwin_init_module(); + notifier_init_module(); + statusbar_init_module(); + titlebar_init_module(); } int diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 040e87b2..dd02ed70 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -73,7 +73,6 @@ _create_input_window(void) wmove(inp_win, 0, 0); _inp_win_refresh(); } -void (*create_input_window)(void) = _create_input_window; static void _inp_win_resize(const char * const input, const int size) @@ -92,21 +91,18 @@ _inp_win_resize(const char * const input, const int size) _inp_win_refresh(); } -void (*inp_win_resize)(const char * const, const int) = _inp_win_resize; static void _inp_non_block(void) { wtimeout(inp_win, 20); } -void (*inp_non_block)(void) = _inp_non_block; static void _inp_block(void) { wtimeout(inp_win, -1); } -void (*inp_block)(void) = _inp_block; static wint_t _inp_get_char(char *input, int *size) @@ -206,7 +202,6 @@ _inp_get_char(char *input, int *size) return ch; } -wint_t (*inp_get_char)(char*, int*) = _inp_get_char; static void _inp_get_password(char *passwd) @@ -219,14 +214,12 @@ _inp_get_password(char *passwd) echo(); status_bar_clear(); } -void (*inp_get_password)(char*) = _inp_get_password; static void _inp_put_back(void) { _inp_win_refresh(); } -void (*inp_put_back)(void) = _inp_put_back; static void _inp_replace_input(char *input, const char * const new_input, int *size) @@ -240,7 +233,6 @@ _inp_replace_input(char *input, const char * const new_input, int *size) waddstr(inp_win, input); _go_to_end(display_size); } -void (*inp_replace_input)(char*, const char * const, int*) = _inp_replace_input; static void _inp_win_reset(void) @@ -249,7 +241,6 @@ _inp_win_reset(void) pad_start = 0; _inp_win_refresh(); } -void (*inp_win_reset)(void) = _inp_win_reset; static void _clear_input(void) @@ -712,3 +703,17 @@ _printable(const wint_t ch) gunichar unichar = g_utf8_get_char(bytes); return g_unichar_isprint(unichar) && (ch != KEY_MOUSE); } + +void +inputwin_init_module(void) +{ + create_input_window = _create_input_window; + inp_win_resize = _inp_win_resize; + inp_non_block = _inp_non_block; + inp_block = _inp_block; + inp_get_char = _inp_get_char; + inp_get_password = _inp_get_password; + inp_put_back = _inp_put_back; + inp_replace_input = _inp_replace_input; + inp_win_reset = _inp_win_reset; +} diff --git a/src/ui/notifier.c b/src/ui/notifier.c index d0319cb9..ebc61e0d 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -46,7 +46,6 @@ _notifier_init(void) notify_init("Profanity"); #endif } -void (*notifier_init)(void) = _notifier_init; static void _notifier_uninit(void) @@ -57,7 +56,6 @@ _notifier_uninit(void) } #endif } -void (*notifier_uninit)(void) = _notifier_uninit; static void _notify_typing(const char * const handle) @@ -67,7 +65,6 @@ _notify_typing(const char * const handle) _notify(message, 10000, "Incoming message"); } -void (*notify_typing)(const char * const) = _notify_typing; static void _notify_invite(const char * const from, const char * const room, @@ -85,8 +82,6 @@ _notify_invite(const char * const from, const char * const room, g_string_free(message, TRUE); } -void (*notify_invite)(const char * const, const char * const, - const char * const) = _notify_invite; static void _notify_message(const char * const handle, int win) @@ -96,7 +91,6 @@ _notify_message(const char * const handle, int win) _notify(message, 10000, "incoming message"); } -void (*notify_message)(const char * const, int) = _notify_message; static void _notify_room_message(const char * const handle, const char * const room, int win) @@ -110,8 +104,6 @@ _notify_room_message(const char * const handle, const char * const room, int win g_string_free(text, TRUE); } -void (*notify_room_message)(const char * const, const char * const, - int) = _notify_room_message; static void _notify_subscription(const char * const from) @@ -121,7 +113,6 @@ _notify_subscription(const char * const from) _notify(message->str, 10000, "Incomming message"); g_string_free(message, TRUE); } -void (*notify_subscription)(const char * const) = _notify_subscription; static void _notify_remind(void) @@ -167,7 +158,6 @@ _notify_remind(void) g_string_free(text, TRUE); } -void (*notify_remind)(void) = _notify_remind; static void _notify(const char * const message, int timeout, @@ -216,3 +206,17 @@ _notify(const char * const message, int timeout, Shell_NotifyIcon(NIM_MODIFY, &nid); #endif } + +void +notifier_init_module(void) +{ + notifier_init = _notifier_init; + notifier_uninit = _notifier_uninit; + notify_typing = _notify_typing; + notify_invite = _notify_invite; + notify_message = _notify_message; + notify_room_message = _notify_room_message; + notify_subscription = _notify_subscription; + notify_remind = _notify_remind; +} + diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 8a578a56..4d0ab7ef 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -83,7 +83,6 @@ _create_status_bar(void) dirty = TRUE; } -void (*create_status_bar)(void) = _create_status_bar; static void _status_bar_refresh(void) @@ -108,7 +107,6 @@ _status_bar_refresh(void) g_date_time_unref(now_time); } -void (*status_bar_refresh)(void) = _status_bar_refresh; static void _status_bar_resize(void) @@ -135,7 +133,6 @@ _status_bar_resize(void) last_time = g_date_time_new_now_local(); dirty = TRUE; } -void (*status_bar_resize)(void) = _status_bar_resize; static void _status_bar_set_all_inactive(void) @@ -150,7 +147,6 @@ _status_bar_set_all_inactive(void) g_hash_table_remove_all(remaining_active); g_hash_table_remove_all(remaining_new); } -void (*status_bar_set_all_inactive)(void) = _status_bar_set_all_inactive; static void _status_bar_current(int i) @@ -168,7 +164,6 @@ _status_bar_current(int i) mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); wattroff(status_bar, COLOUR_STATUS_BRACKET); } -void (*status_bar_current)(int) = _status_bar_current; static void _status_bar_inactive(const int win) @@ -209,7 +204,6 @@ _status_bar_inactive(const int win) _mark_inactive(true_win); } } -void (*status_bar_inactive)(const int) = _status_bar_inactive; static void _status_bar_active(const int win) @@ -244,7 +238,6 @@ _status_bar_active(const int win) _mark_active(true_win); } } -void (*status_bar_active)(const int) = _status_bar_active; static void _status_bar_new(const int win) @@ -268,7 +261,6 @@ _status_bar_new(const int win) _mark_new(true_win); } } -void (*status_bar_new)(const int) = _status_bar_new; static void _status_bar_get_password(void) @@ -276,7 +268,6 @@ _status_bar_get_password(void) status_bar_print_message("Enter password:"); dirty = TRUE; } -void (*status_bar_get_password)(void) = _status_bar_get_password; static void _status_bar_print_message(const char * const msg) @@ -300,7 +291,6 @@ _status_bar_print_message(const char * const msg) _update_win_statuses(); dirty = TRUE; } -void (*status_bar_print_message)(const char * const) = _status_bar_print_message; static void _status_bar_clear(void) @@ -329,7 +319,6 @@ _status_bar_clear(void) dirty = TRUE; } -void (*status_bar_clear)(void) = _status_bar_clear; static void _status_bar_clear_message(void) @@ -351,7 +340,6 @@ _status_bar_clear_message(void) _update_win_statuses(); dirty = TRUE; } -void (*status_bar_clear_message)(void) = _status_bar_clear_message; static void _status_bar_update_time(void) @@ -433,3 +421,20 @@ _mark_inactive(int num) mvwaddch(status_bar, 0, cols - 34 + active_pos, ' '); dirty = TRUE; } + +void +statusbar_init_module(void) +{ + create_status_bar = _create_status_bar; + status_bar_refresh = _status_bar_refresh; + status_bar_resize = _status_bar_resize; + status_bar_set_all_inactive = _status_bar_set_all_inactive; + status_bar_current = _status_bar_current; + status_bar_inactive = _status_bar_inactive; + status_bar_active = _status_bar_active; + status_bar_new = _status_bar_new; + status_bar_get_password = _status_bar_get_password; + status_bar_print_message = _status_bar_print_message; + status_bar_clear = _status_bar_clear; + status_bar_clear_message = _status_bar_clear_message; +} diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 79baae1d..04492b62 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -48,7 +48,6 @@ _create_title_bar(void) title_bar_set_status(CONTACT_OFFLINE); dirty = TRUE; } -void (*create_title_bar)(void) = _create_title_bar; static void _title_bar_title(void) @@ -60,7 +59,6 @@ _title_bar_title(void) _title_bar_draw_status(); dirty = TRUE; } -void (*title_bar_title)(void) = _title_bar_title; static void _title_bar_resize(void) @@ -74,7 +72,6 @@ _title_bar_resize(void) _title_bar_draw_status(); dirty = TRUE; } -void (*title_bar_resize)(void) = _title_bar_resize; static void _title_bar_refresh(void) @@ -109,7 +106,6 @@ _title_bar_refresh(void) dirty = FALSE; } } -void (*title_bar_refresh)(void) = _title_bar_refresh; static void _title_bar_show(const char * const title) @@ -121,7 +117,6 @@ _title_bar_show(const char * const title) strcpy(current_title, title); _title_bar_draw_title(); } -void (*title_bar_show)(const char * const) = _title_bar_show; static void _title_bar_set_status(contact_presence_t status) @@ -129,7 +124,6 @@ _title_bar_set_status(contact_presence_t status) current_status = status; _title_bar_draw_status(); } -void (*title_bar_set_status)(contact_presence_t) = _title_bar_set_status; static void _title_bar_set_recipient(const char * const from) @@ -149,7 +143,6 @@ _title_bar_set_recipient(const char * const from) dirty = TRUE; } -void (*title_bar_set_recipient)(const char * const) = _title_bar_set_recipient; static void _title_bar_set_typing(gboolean is_typing) @@ -176,7 +169,6 @@ _title_bar_set_typing(gboolean is_typing) dirty = TRUE; } -void (*title_bar_set_typing)(gboolean) = _title_bar_set_typing; static void _title_bar_draw(void) @@ -185,7 +177,6 @@ _title_bar_draw(void) _title_bar_draw_status(); _title_bar_draw_title(); } -void (*title_bar_draw)(void) = _title_bar_draw; static void _title_bar_draw_status(void) @@ -236,3 +227,17 @@ _title_bar_draw_title(void) dirty = TRUE; } + +void +titlebar_init_module(void) +{ + create_title_bar = _create_title_bar; + title_bar_title = _title_bar_title; + title_bar_resize = _title_bar_resize; + title_bar_refresh = _title_bar_refresh; + title_bar_show = _title_bar_show; + title_bar_set_status = _title_bar_set_status; + title_bar_set_recipient = _title_bar_set_recipient; + title_bar_set_typing = _title_bar_set_typing; + title_bar_draw = _title_bar_draw; +} diff --git a/src/ui/ui.h b/src/ui/ui.h index 9b5e5079..e5d4118d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -43,6 +43,10 @@ void ui_init_module(void); void console_init_module(void); +void inputwin_init_module(void); +void notifier_init_module(void); +void statusbar_init_module(void); +void titlebar_init_module(void); // ui startup and control void (*ui_init)(void); -- cgit 1.4.1-2-gfad0