Dynamically load UI functions, fixed tests

This commit is contained in:
James Booth
2013-12-22 22:14:15 +00:00
parent d56f6dc39b
commit 5a5b1340aa
13 changed files with 810 additions and 822 deletions

View File

@@ -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)