diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/console.c | 314 | ||||
-rw-r--r-- | src/ui/core.c | 353 | ||||
-rw-r--r-- | src/ui/inputwin.c | 50 | ||||
-rw-r--r-- | src/ui/notifier.c | 46 | ||||
-rw-r--r-- | src/ui/statusbar.c | 65 | ||||
-rw-r--r-- | src/ui/titlebar.c | 50 | ||||
-rw-r--r-- | src/ui/ui.h | 348 |
7 files changed, 712 insertions, 514 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 00e891db..83a2b82e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -47,24 +47,24 @@ 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_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_debug(const char * const msg, ...) +static void +_cons_debug(const char * const msg, ...) { ProfWin *console = wins_get_console(); if (strcmp(PACKAGE_STATUS, "development") == 0) { @@ -85,8 +85,8 @@ cons_debug(const char * const msg, ...) } } -void -cons_show(const char * const msg, ...) +static void +_cons_show(const char * const msg, ...) { ProfWin *console = wins_get_console(); va_list arg; @@ -100,8 +100,8 @@ cons_show(const char * const msg, ...) wins_refresh_console(); } -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,8 +119,8 @@ cons_show_error(const char * const msg, ...) cons_alert(); } -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,8 +137,8 @@ cons_show_typing(const char * const barejid) cons_alert(); } -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,8 +155,8 @@ cons_show_incoming_message(const char * const short_from, const int win_index) cons_alert(); } -void -cons_about(void) +static void +_cons_about(void) { ProfWin *console = wins_get_console(); int rows, cols; @@ -207,8 +207,8 @@ cons_about(void) cons_alert(); } -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,8 +238,8 @@ cons_check_version(gboolean not_available_msg) } } -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,8 +258,8 @@ cons_show_login_success(ProfAccount *account) cons_alert(); } -void -cons_show_wins(void) +static void +_cons_show_wins(void) { ProfWin *console = wins_get_console(); cons_show(""); @@ -279,8 +279,8 @@ cons_show_wins(void) cons_alert(); } -void -cons_show_room_invites(GSList *invites) +static void +_cons_show_room_invites(GSList *invites) { cons_show(""); if (invites == NULL) { @@ -297,8 +297,8 @@ cons_show_room_invites(GSList *invites) cons_alert(); } -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,8 +430,8 @@ cons_show_info(PContact pcontact) cons_alert(); } -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,8 +505,8 @@ cons_show_caps(const char * const contact, Resource *resource) cons_alert(); } -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,8 +532,8 @@ cons_show_software_version(const char * const jid, const char * const presence, cons_alert(); } -void -cons_show_received_subs(void) +static void +_cons_show_received_subs(void) { GSList *received = presence_get_subscription_requests(); if (received == NULL) { @@ -548,12 +548,11 @@ cons_show_received_subs(void) g_slist_free_full(received, g_free); } - wins_refresh_console(); cons_alert(); } -void -cons_show_sent_subs(void) +static void +_cons_show_sent_subs(void) { if (roster_has_pending_subscriptions()) { GSList *contacts = roster_get_contacts(); @@ -570,12 +569,11 @@ cons_show_sent_subs(void) cons_show("No pending requests sent."); } - wins_refresh_console(); cons_alert(); } -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,8 +596,8 @@ cons_show_room_list(GSList *rooms, const char * const conference_node) cons_alert(); } -void -cons_show_bookmarks(const GList *list) +static void +_cons_show_bookmarks(const GList *list) { Bookmark *item; @@ -628,8 +626,8 @@ cons_show_bookmarks(const GList *list) cons_alert(); } -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,8 +669,8 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) } } -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,8 +694,8 @@ cons_show_disco_items(GSList *items, const char * const jid) cons_alert(); } -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,8 +709,8 @@ cons_show_status(const char * const barejid) cons_alert(); } -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,8 +746,8 @@ cons_show_room_invite(const char * const invitor, const char * const room, cons_alert(); } -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,8 +776,8 @@ cons_show_account_list(gchar **accounts) cons_alert(); } -void -cons_show_account(ProfAccount *account) +static void +_cons_show_account(ProfAccount *account) { ProfWin *console = wins_get_console(); cons_show(""); @@ -901,8 +899,8 @@ cons_show_account(ProfAccount *account) cons_alert(); } -void -cons_theme_setting(void) +static void +_cons_theme_setting(void) { gchar *theme = prefs_get_string(PREF_THEME); if (theme == NULL) { @@ -912,8 +910,8 @@ cons_theme_setting(void) } } -void -cons_beep_setting(void) +static void +_cons_beep_setting(void) { if (prefs_get_boolean(PREF_BEEP)) cons_show("Terminal beep (/beep) : ON"); @@ -921,8 +919,8 @@ cons_beep_setting(void) cons_show("Terminal beep (/beep) : OFF"); } -void -cons_flash_setting(void) +static void +_cons_flash_setting(void) { if (prefs_get_boolean(PREF_FLASH)) cons_show("Terminal flash (/flash) : ON"); @@ -930,8 +928,8 @@ cons_flash_setting(void) cons_show("Terminal flash (/flash) : OFF"); } -void -cons_splash_setting(void) +static void +_cons_splash_setting(void) { if (prefs_get_boolean(PREF_SPLASH)) cons_show("Splash screen (/splash) : ON"); @@ -939,8 +937,8 @@ cons_splash_setting(void) cons_show("Splash screen (/splash) : OFF"); } -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)); @@ -948,8 +946,8 @@ cons_autoconnect_setting(void) cons_show("Autoconnect (/autoconnect) : OFF"); } -void -cons_vercheck_setting(void) +static void +_cons_vercheck_setting(void) { if (prefs_get_boolean(PREF_VERCHECK)) cons_show("Version checking (/vercheck) : ON"); @@ -957,8 +955,8 @@ cons_vercheck_setting(void) cons_show("Version checking (/vercheck) : OFF"); } -void -cons_mouse_setting(void) +static void +_cons_mouse_setting(void) { if (prefs_get_boolean(PREF_MOUSE)) cons_show("Mouse handling (/mouse) : ON"); @@ -966,8 +964,8 @@ cons_mouse_setting(void) cons_show("Mouse handling (/mouse) : OFF"); } -void -cons_statuses_setting(void) +static void +_cons_statuses_setting(void) { if (prefs_get_boolean(PREF_STATUSES)) cons_show("Status (/statuses) : ON"); @@ -975,8 +973,8 @@ cons_statuses_setting(void) cons_show("Status (/statuses) : OFF"); } -void -cons_titlebar_setting(void) +static void +_cons_titlebar_setting(void) { if (prefs_get_boolean(PREF_TITLEBARVERSION)) { cons_show("Titlebar display (/titlebar) : version"); @@ -985,8 +983,8 @@ cons_titlebar_setting(void) } } -void -cons_show_ui_prefs(void) +static void +_cons_show_ui_prefs(void) { cons_show("UI preferences:"); cons_show(""); @@ -1003,8 +1001,8 @@ cons_show_ui_prefs(void) cons_alert(); } -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,8 +1034,8 @@ cons_notify_setting(void) } } -void -cons_show_desktop_prefs(void) +static void +_cons_show_desktop_prefs(void) { cons_show("Desktop notification preferences:"); cons_show(""); @@ -1047,8 +1045,8 @@ cons_show_desktop_prefs(void) cons_alert(); } -void -cons_states_setting(void) +static void +_cons_states_setting(void) { if (prefs_get_boolean(PREF_STATES)) cons_show("Send chat states (/states) : ON"); @@ -1056,8 +1054,8 @@ cons_states_setting(void) cons_show("Send chat states (/states) : OFF"); } -void -cons_outtype_setting(void) +static void +_cons_outtype_setting(void) { if (prefs_get_boolean(PREF_OUTTYPE)) cons_show("Send composing (/outtype) : ON"); @@ -1065,8 +1063,8 @@ cons_outtype_setting(void) cons_show("Send composing (/outtype) : OFF"); } -void -cons_intype_setting(void) +static void +_cons_intype_setting(void) { if (prefs_get_boolean(PREF_INTYPE)) cons_show("Show typing (/intype) : ON"); @@ -1074,8 +1072,8 @@ cons_intype_setting(void) cons_show("Show typing (/intype) : OFF"); } -void -cons_gone_setting(void) +static void +_cons_gone_setting(void) { gint gone_time = prefs_get_gone(); if (gone_time == 0) { @@ -1087,8 +1085,8 @@ cons_gone_setting(void) } } -void -cons_history_setting(void) +static void +_cons_history_setting(void) { if (prefs_get_boolean(PREF_HISTORY)) cons_show("Chat history (/history) : ON"); @@ -1096,8 +1094,8 @@ cons_history_setting(void) cons_show("Chat history (/history) : OFF"); } -void -cons_show_chat_prefs(void) +static void +_cons_show_chat_prefs(void) { cons_show("Chat preferences:"); cons_show(""); @@ -1111,14 +1109,14 @@ cons_show_chat_prefs(void) cons_alert(); } -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_chlog_setting(void) +static void +_cons_chlog_setting(void) { if (prefs_get_boolean(PREF_CHLOG)) cons_show("Chat logging (/chlog) : ON"); @@ -1126,8 +1124,8 @@ cons_chlog_setting(void) cons_show("Chat logging (/chlog) : OFF"); } -void -cons_grlog_setting(void) +static void +_cons_grlog_setting(void) { if (prefs_get_boolean(PREF_GRLOG)) cons_show("Groupchat logging (/grlog) : ON"); @@ -1135,8 +1133,8 @@ cons_grlog_setting(void) cons_show("Groupchat logging (/grlog) : OFF"); } -void -cons_show_log_prefs(void) +static void +_cons_show_log_prefs(void) { cons_show("Logging preferences:"); cons_show(""); @@ -1148,8 +1146,8 @@ cons_show_log_prefs(void) cons_alert(); } -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,8 +1171,8 @@ cons_autoaway_setting(void) } } -void -cons_show_presence_prefs(void) +static void +_cons_show_presence_prefs(void) { cons_show("Presence preferences:"); cons_show(""); @@ -1184,8 +1182,8 @@ cons_show_presence_prefs(void) cons_alert(); } -void -cons_reconnect_setting(void) +static void +_cons_reconnect_setting(void) { gint reconnect_interval = prefs_get_reconnect(); if (reconnect_interval == 0) { @@ -1197,8 +1195,8 @@ cons_reconnect_setting(void) } } -void -cons_autoping_setting(void) +static void +_cons_autoping_setting(void) { gint autoping_interval = prefs_get_autoping(); if (autoping_interval == 0) { @@ -1210,15 +1208,15 @@ cons_autoping_setting(void) } } -void -cons_priority_setting(void) +static void +_cons_priority_setting(void) { gint priority = prefs_get_priority(); cons_show("Priority (/priority) : %d", priority); } -void -cons_show_connection_prefs(void) +static void +_cons_show_connection_prefs(void) { cons_show("Connection preferences:"); cons_show(""); @@ -1230,8 +1228,8 @@ cons_show_connection_prefs(void) cons_alert(); } -void -cons_show_themes(GSList *themes) +static void +_cons_show_themes(GSList *themes) { cons_show(""); @@ -1249,8 +1247,8 @@ cons_show_themes(GSList *themes) cons_alert(); } -void -cons_prefs(void) +static void +_cons_prefs(void) { cons_show(""); cons_show_ui_prefs(); @@ -1270,8 +1268,8 @@ cons_prefs(void) cons_alert(); } -void -cons_help(void) +static void +_cons_help(void) { cons_show(""); cons_show("Choose a help option:"); @@ -1282,7 +1280,7 @@ cons_help(void) cons_show("/help groupchat - List groupchat commands."); cons_show("/help presence - List commands to change presence."); cons_show("/help roster - List commands for manipulating your roster."); - cons_show("/help service - List service discovery commands"); + cons_show("/help service - List service discovery commands."); cons_show("/help settings - List commands for changing settings."); cons_show("/help other - Other commands."); cons_show("/help navigation - How to navigate around Profanity."); @@ -1293,8 +1291,8 @@ cons_help(void) cons_alert(); } -void -cons_navigation_help(void) +static void +_cons_navigation_help(void) { cons_show(""); cons_show("Navigation:"); @@ -1317,8 +1315,8 @@ cons_navigation_help(void) cons_alert(); } -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,8 +1331,8 @@ cons_show_roster_group(const char * const group, GSList *list) cons_alert(); } -void -cons_show_roster(GSList *list) +static void +_cons_show_roster(GSList *list) { cons_show(""); cons_show("Roster:"); @@ -1344,8 +1342,8 @@ cons_show_roster(GSList *list) cons_alert(); } -void -cons_show_contacts(GSList *list) +static void +_cons_show_contacts(GSList *list) { ProfWin *console = wins_get_console(); GSList *curr = list; @@ -1363,8 +1361,8 @@ cons_show_contacts(GSList *list) cons_alert(); } -void -cons_alert(void) +static void +_cons_alert(void) { if (ui_current_win_type() != WIN_CONSOLE) { status_bar_new(1); @@ -1502,3 +1500,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/core.c b/src/ui/core.c index 1ff41b7d..c06f025e 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(); @@ -96,8 +96,8 @@ ui_init(void) wins_refresh_current(); } -void -ui_refresh(void) +static void +_ui_refresh(void) { _ui_draw_win_title(); title_bar_refresh(); @@ -105,8 +105,8 @@ ui_refresh(void) inp_put_back(); } -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 @@ -124,22 +124,22 @@ ui_get_idle_time(void) return ms_elapsed; } -void -ui_reset_idle_time(void) +static void +_ui_reset_idle_time(void) { g_timer_start(ui_idle_time); } -void -ui_close(void) +static void +_ui_close(void) { notifier_uninit(); wins_destroy(); endwin(); } -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(); @@ -149,8 +149,8 @@ ui_resize(const int ch, const char * const input, const int size) wins_refresh_current(); } -void -ui_load_colours(void) +static void +_ui_load_colours(void) { if (has_colors()) { use_default_colors(); @@ -159,21 +159,21 @@ ui_load_colours(void) } } -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_duck_exists(void) +static gboolean +_ui_duck_exists(void) { return wins_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); @@ -210,15 +210,15 @@ ui_contact_typing(const char * const barejid) } } -GSList * -ui_get_recipients(void) +static GSList * +_ui_get_recipients(void) { GSList *recipients = wins_get_chat_recipients(); return 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; @@ -294,8 +294,8 @@ ui_incoming_msg(const char * const from, const char * const message, free(display_from); } -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); @@ -304,38 +304,38 @@ ui_roster_add(const char * const barejid, const char * const name) } } -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_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_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_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_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_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."); @@ -350,8 +350,8 @@ ui_handle_error_message(const char * const from, const char * const err_msg) ui_print_error_from_recipient(from, err_msg); } -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); @@ -376,8 +376,8 @@ ui_contact_online(const char * const barejid, const char * const resource, } } -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); @@ -404,8 +404,8 @@ ui_contact_offline(const char * const from, const char * const show, } } -void -ui_disconnected(void) +static void +_ui_disconnected(void) { wins_lost_connection(); title_bar_set_status(CONTACT_OFFLINE); @@ -413,8 +413,8 @@ ui_disconnected(void) status_bar_refresh(); } -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); @@ -425,8 +425,8 @@ ui_handle_special_keys(const wint_t * const ch, const char * const inp, } -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) { @@ -447,8 +447,8 @@ ui_close_connected_win(int index) } } -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(); @@ -474,8 +474,8 @@ ui_close_all_wins(void) return count; } -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(); @@ -501,8 +501,8 @@ ui_close_read_wins(void) return count; } -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); @@ -535,8 +535,8 @@ ui_switch_win(const int i) } } -void -ui_next_win(void) +static void +_ui_next_win(void) { ui_current_page_off(); ProfWin *new_current = wins_get_next(); @@ -568,8 +568,8 @@ ui_next_win(void) wins_refresh_current(); } -void -ui_previous_win(void) +static void +_ui_previous_win(void) { ui_current_page_off(); ProfWin *new_current = wins_get_previous(); @@ -601,14 +601,14 @@ ui_previous_win(void) wins_refresh_current(); } -void -ui_clear_current(void) +static void +_ui_clear_current(void) { wins_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); @@ -618,8 +618,8 @@ ui_close_current(void) title_bar_title(); } -void -ui_close_win(int index) +static void +_ui_close_win(int index) { wins_close_by_num(index); status_bar_current(1); @@ -629,8 +629,8 @@ ui_close_win(int index) wins_refresh_current(); } -void -ui_tidy_wins(void) +static void +_ui_tidy_wins(void) { gboolean tidied = wins_tidy(); @@ -641,8 +641,8 @@ ui_tidy_wins(void) } } -void -ui_prune_wins(void) +static void +_ui_prune_wins(void) { jabber_conn_status_t conn_status = jabber_get_connection_status(); gboolean pruned = FALSE; @@ -686,42 +686,42 @@ ui_prune_wins(void) } } -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; } -int -ui_current_win_index(void) +static int +_ui_current_win_index(void) { return wins_get_current_num(); } -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; } -char * -ui_recipient(int index) +static char * +_ui_recipient(int index) { ProfWin *window = wins_get_by_num(index); return window->from; } -char * -ui_current_recipient(void) +static char * +_ui_current_recipient(void) { ProfWin *current = wins_get_current(); return current->from; } -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; @@ -731,24 +731,24 @@ ui_current_print_line(const char * const msg, ...) win_refresh(current); } -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_page_off(void) +static void +_ui_current_page_off(void) { ProfWin *current = wins_get_current(); win_page_off(current); win_refresh(current); } -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; @@ -762,8 +762,8 @@ 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) +static void +_ui_print_system_msg_from_recipient(const char * const from, const char *message) { int num = 0; char from_cpy[strlen(from) + 1]; @@ -797,8 +797,8 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message) } } -void -ui_recipient_gone(const char * const barejid) +static void +_ui_recipient_gone(const char * const barejid) { if (barejid == NULL) return; @@ -820,8 +820,8 @@ ui_recipient_gone(const char * const barejid) } } -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); @@ -859,8 +859,8 @@ ui_new_chat_win(const char * const to) ui_switch_win(num); } -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); @@ -868,8 +868,8 @@ ui_create_duck_win(void) win_print_line(window, '-', 0, "Type ':help' to find out more."); } -void -ui_open_duck_win(void) +static void +_ui_open_duck_win(void) { ProfWin *window = wins_get_by_recipient("DuckDuckGo search"); if (window != NULL) { @@ -878,8 +878,8 @@ ui_open_duck_win(void) } } -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) { @@ -894,8 +894,8 @@ ui_duck(const char * const query) } } -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"); @@ -927,8 +927,8 @@ ui_duck_result(const char * const 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); @@ -954,8 +954,8 @@ ui_outgoing_msg(const char * const from, const char * const to, if (contact != NULL) { if (strcmp(p_contact_presence(contact), "offline") == 0) { - const char const *show = p_contact_presence(contact); - const char const *status = p_contact_status(contact); + const char *show = p_contact_presence(contact); + const char *status = p_contact_status(contact); win_show_status_string(window, to, show, status, NULL, "--", "offline"); } } @@ -979,8 +979,8 @@ ui_outgoing_msg(const char * const from, const char * const to, ui_switch_win(num); } -void -ui_room_join(Jid *jid) +static void +_ui_room_join(Jid *jid) { ProfWin *window = wins_get_by_recipient(jid->barejid); int num = 0; @@ -994,8 +994,8 @@ ui_room_join(Jid *jid) ui_switch_win(num); } -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); @@ -1026,8 +1026,8 @@ ui_room_roster(const char * const room, GList *roster, const char * const presen while (roster != NULL) { PContact member = roster->data; - const char const *nick = p_contact_barejid(member); - const char const *show = p_contact_presence(member); + const char *nick = p_contact_barejid(member); + const char *show = p_contact_presence(member); win_presence_colour_on(window, show); wprintw(window->win, "%s", nick); @@ -1049,8 +1049,8 @@ ui_room_roster(const char * const room, GList *roster, const char * const presen } } -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); @@ -1064,8 +1064,8 @@ 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, +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); @@ -1080,8 +1080,8 @@ ui_room_member_online(const char * const room, const char * const nick, } } -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); @@ -1095,8 +1095,8 @@ ui_room_member_presence(const char * const room, const char * const nick, } } -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); @@ -1111,8 +1111,8 @@ ui_room_member_nick_change(const char * const room, } } -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); @@ -1126,8 +1126,8 @@ ui_room_nick_change(const char * const room, const char * const nick) } } -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); @@ -1152,8 +1152,8 @@ ui_room_history(const char * const room_jid, const char * const nick, } } -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); @@ -1224,8 +1224,8 @@ ui_room_message(const char * const room_jid, const char * const nick, } } -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); @@ -1247,8 +1247,8 @@ 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) +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); @@ -1270,8 +1270,8 @@ ui_room_broadcast(const char * const room_jid, const char * const message) } } -void -ui_status(void) +static void +_ui_status(void) { char *recipient = ui_current_recipient(); PContact pcontact = roster_get_contact(recipient); @@ -1284,8 +1284,8 @@ ui_status(void) } } -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); @@ -1300,8 +1300,8 @@ ui_status_private(void) jid_destroy(jid); } -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(); @@ -1313,14 +1313,14 @@ ui_status_room(const char * const contact) } } -gint -ui_unread(void) +static gint +_ui_unread(void) { return wins_get_total_unread(); } -int -ui_win_unread(int index) +static int +_ui_win_unread(int index) { ProfWin *window = wins_get_by_num(index); if (window != NULL) { @@ -1330,8 +1330,8 @@ ui_win_unread(int index) } } -char * -ui_ask_password(void) +static char * +_ui_ask_password(void) { char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1)); status_bar_get_password(); @@ -1537,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/inputwin.c b/src/ui/inputwin.c index 3306a246..dd02ed70 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); @@ -74,8 +74,8 @@ create_input_window(void) _inp_win_refresh(); } -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); @@ -92,20 +92,20 @@ inp_win_resize(const char * const input, const int size) _inp_win_refresh(); } -void -inp_non_block(void) +static void +_inp_non_block(void) { wtimeout(inp_win, 20); } -void -inp_block(void) +static void +_inp_block(void) { wtimeout(inp_win, -1); } -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; @@ -203,8 +203,8 @@ inp_get_char(char *input, int *size) return ch; } -void -inp_get_password(char *passwd) +static void +_inp_get_password(char *passwd) { _clear_input(); _inp_win_refresh(); @@ -215,14 +215,14 @@ inp_get_password(char *passwd) status_bar_clear(); } -void -inp_put_back(void) +static void +_inp_put_back(void) { _inp_win_refresh(); } -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); @@ -234,8 +234,8 @@ inp_replace_input(char *input, const char * const new_input, int *size) _go_to_end(display_size); } -void -inp_win_reset(void) +static void +_inp_win_reset(void) { _clear_input(); pad_start = 0; @@ -703,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 403c215e..ebc61e0d 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -39,16 +39,16 @@ 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_uninit(void) +static void +_notifier_uninit(void) { #ifdef HAVE_LIBNOTIFY if (notify_is_initted()) { @@ -57,8 +57,8 @@ notifier_uninit(void) #endif } -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); @@ -66,8 +66,8 @@ notify_typing(const char * const handle) _notify(message, 10000, "Incoming message"); } -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: "); @@ -83,8 +83,8 @@ notify_invite(const char * const from, const char * const room, g_string_free(message, TRUE); } -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); @@ -92,8 +92,8 @@ notify_message(const char * const handle, int win) _notify(message, 10000, "incoming 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(""); @@ -105,8 +105,8 @@ notify_room_message(const char * const handle, const char * const room, int win) g_string_free(text, TRUE); } -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); @@ -114,8 +114,8 @@ notify_subscription(const char * const from) g_string_free(message, TRUE); } -void -notify_remind(void) +static void +_notify_remind(void) { gint unread = ui_unread(); gint open = muc_invite_count(); @@ -206,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 16bd31c9..4d0ab7ef 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); @@ -84,8 +84,8 @@ create_status_bar(void) dirty = TRUE; } -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); @@ -108,8 +108,8 @@ status_bar_refresh(void) g_date_time_unref(now_time); } -void -status_bar_resize(void) +static void +_status_bar_resize(void) { int rows, cols; getmaxyx(stdscr, rows, cols); @@ -134,8 +134,8 @@ status_bar_resize(void) dirty = TRUE; } -void -status_bar_set_all_inactive(void) +static void +_status_bar_set_all_inactive(void) { int i = 0; for (i = 0; i < 12; i++) { @@ -148,8 +148,8 @@ status_bar_set_all_inactive(void) g_hash_table_remove_all(remaining_new); } -void -status_bar_current(int i) +static void +_status_bar_current(int i) { if (i == 0) { current = 10; @@ -165,8 +165,8 @@ status_bar_current(int i) wattroff(status_bar, COLOUR_STATUS_BRACKET); } -void -status_bar_inactive(const int win) +static void +_status_bar_inactive(const int win) { int true_win = win; if (true_win == 0) { @@ -205,8 +205,8 @@ status_bar_inactive(const int win) } } -void -status_bar_active(const int win) +static void +_status_bar_active(const int win) { int true_win = win; if (true_win == 0) { @@ -239,8 +239,8 @@ status_bar_active(const int win) } } -void -status_bar_new(const int win) +static void +_status_bar_new(const int win) { int true_win = win; if (true_win == 0) { @@ -262,15 +262,15 @@ status_bar_new(const int win) } } -void -status_bar_get_password(void) +static void +_status_bar_get_password(void) { status_bar_print_message("Enter password:"); dirty = TRUE; } -void -status_bar_print_message(const char * const msg) +static void +_status_bar_print_message(const char * const msg) { werase(status_bar); @@ -292,8 +292,8 @@ status_bar_print_message(const char * const msg) dirty = TRUE; } -void -status_bar_clear(void) +static void +_status_bar_clear(void) { if (message != NULL) { free(message); @@ -320,8 +320,8 @@ status_bar_clear(void) dirty = TRUE; } -void -status_bar_clear_message(void) +static void +_status_bar_clear_message(void) { if (message != NULL) { free(message); @@ -421,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 791a5fbe..04492b62 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); @@ -49,8 +49,8 @@ create_title_bar(void) dirty = TRUE; } -void -title_bar_title(void) +static void +_title_bar_title(void) { werase(title_bar); recipient = NULL; @@ -60,8 +60,8 @@ title_bar_title(void) dirty = TRUE; } -void -title_bar_resize(void) +static void +_title_bar_resize(void) { int cols = getmaxx(stdscr); @@ -73,8 +73,8 @@ title_bar_resize(void) dirty = TRUE; } -void -title_bar_refresh(void) +static void +_title_bar_refresh(void) { if (recipient != NULL) { @@ -107,8 +107,8 @@ title_bar_refresh(void) } } -void -title_bar_show(const char * const title) +static void +_title_bar_show(const char * const title) { if (current_title != NULL) free(current_title); @@ -118,15 +118,15 @@ title_bar_show(const char * const title) _title_bar_draw_title(); } -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_recipient(const char * const from) +static void +_title_bar_set_recipient(const char * const from) { if (typing_elapsed != NULL) { g_timer_destroy(typing_elapsed); @@ -144,8 +144,8 @@ title_bar_set_recipient(const char * const from) dirty = TRUE; } -void -title_bar_set_typing(gboolean is_typing) +static void +_title_bar_set_typing(gboolean is_typing) { if (is_typing) { if (typing_elapsed != NULL) { @@ -170,8 +170,8 @@ title_bar_set_typing(gboolean is_typing) dirty = TRUE; } -void -title_bar_draw(void) +static void +_title_bar_draw(void) { werase(title_bar); _title_bar_draw_status(); @@ -227,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 f6bb98ac..e5d4118d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -41,219 +41,221 @@ #define INP_WIN_MAX 1000 +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); -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); +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); +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_show)(const char * const msg, ...); +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 |