diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 6d87a5d8..2d3209d5 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -683,6 +683,7 @@ cmd_ac_init(void) tls_certpath_ac = autocomplete_new(); autocomplete_add(tls_certpath_ac, "set"); autocomplete_add(tls_certpath_ac, "clear"); + autocomplete_add(tls_certpath_ac, "default"); script_ac = autocomplete_new(); autocomplete_add(script_ac, "run"); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index f8d8c2ff..34400ae3 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -200,6 +200,7 @@ static struct cmd_t command_defs[] = "/tls certpath", "/tls certpath set ", "/tls certpath clear", + "/tls certpath default", "/tls show on|off") CMD_DESC( "Handle TLS certificates. ") @@ -215,6 +216,7 @@ static struct cmd_t command_defs[] = { "certpath", "Show the trusted certificate path." }, { "certpath set ", "Specify filesystem path containing trusted certificates." }, { "certpath clear", "Clear the trusted certificate path." }, + { "certpath default", "Use default system certificate path, if it can be found." }, { "show on|off", "Show or hide the TLS indicator in the titlebar." }) CMD_NOEXAMPLES }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index d052d77f..35ae3119 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -171,14 +171,18 @@ cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args) } return TRUE; } else if (g_strcmp0(args[1], "clear") == 0) { - prefs_set_string(PREF_TLS_CERTPATH, NULL); + prefs_set_string(PREF_TLS_CERTPATH, "none"); cons_show("Certificate path cleared"); return TRUE; + } else if (g_strcmp0(args[1], "default") == 0) { + prefs_set_string(PREF_TLS_CERTPATH, NULL); + cons_show("Certificate path defaulted to finding system certpath."); + return TRUE; } else if (args[1] == NULL) { - char *path = prefs_get_string(PREF_TLS_CERTPATH); + char *path = prefs_get_tls_certpath(); if (path) { cons_show("Trusted certificate path: %s", path); - prefs_free_string(path); + free(path); } else { cons_show("No trusted certificate path set."); } @@ -1156,17 +1160,17 @@ cmd_sub(ProfWin *window, const char *const command, gchar **args) PContact contact = roster_get_contact(jidp->barejid); if ((contact == NULL) || (p_contact_subscription(contact) == NULL)) { if (window->type == WIN_CHAT) { - ui_current_print_line("No subscription information for %s.", jidp->barejid); + win_println(window, THEME_DEFAULT, '-', "No subscription information for %s.", jidp->barejid); } else { cons_show("No subscription information for %s.", jidp->barejid); } } else { if (window->type == WIN_CHAT) { if (p_contact_pending_out(contact)) { - ui_current_print_line("%s subscription status: %s, request pending.", + win_println(window, THEME_DEFAULT, '-', "%s subscription status: %s, request pending.", jidp->barejid, p_contact_subscription(contact)); } else { - ui_current_print_line("%s subscription status: %s.", jidp->barejid, + win_println(window, THEME_DEFAULT, '-', "%s subscription status: %s.", jidp->barejid, p_contact_subscription(contact)); } } else { @@ -1382,7 +1386,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // check for unsaved form if (ui_win_has_unsaved_form(index)) { - ui_current_print_line("You have unsaved changes, use /form submit or /form cancel"); + win_println(window, THEME_DEFAULT, '-', "You have unsaved changes, use /form submit or /form cancel"); return TRUE; } @@ -1417,7 +1421,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // check for unsaved form if (ui_win_has_unsaved_form(index)) { - ui_current_print_line("You have unsaved changes, use /form submit or /form cancel"); + win_println(window, THEME_DEFAULT, '-', "You have unsaved changes, use /form submit or /form cancel"); return TRUE; } @@ -2078,7 +2082,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) g_string_free(full_jid, TRUE); } else { - ui_current_print_line("No such participant \"%s\" in room.", usr); + win_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); } return TRUE; @@ -3111,12 +3115,12 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) win_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); } } else { - ui_current_print_line("You must specify a nickname."); + win_println(window, THEME_DEFAULT, '-', "You must specify a nickname."); } break; case WIN_CHAT: if (usr) { - ui_current_print_line("No parameter required when in chat."); + win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat."); } else { ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); @@ -3130,7 +3134,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) break; case WIN_PRIVATE: if (usr) { - ui_current_print_line("No parameter required when in chat."); + win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat."); } else { ProfPrivateWin *privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); @@ -3184,7 +3188,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant_info(window, mucwin->roomjid, occupant); } else { - ui_current_print_line("No such occupant \"%s\" in room.", usr); + win_println(window, THEME_DEFAULT, '-', "No such occupant \"%s\" in room.", usr); } } else { ProfMucWin *mucwin = (ProfMucWin*)window; @@ -3196,7 +3200,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) break; case WIN_CHAT: if (usr) { - ui_current_print_line("No parameter required when in chat."); + win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat."); } else { ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); @@ -3210,7 +3214,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) break; case WIN_PRIVATE: if (usr) { - ui_current_print_line("No parameter required when in chat."); + win_println(window, THEME_DEFAULT, '-', "No parameter required when in chat."); } else { ProfPrivateWin *privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); @@ -3573,7 +3577,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) DataForm *form = confwin->form; if (form) { if (!form_tag_exists(form, tag)) { - ui_current_print_line("Form does not contain a field with tag %s", tag); + win_println(window, THEME_DEFAULT, '-', "Form does not contain a field with tag %s", tag); return TRUE; } @@ -3589,16 +3593,16 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[0]; if (g_strcmp0(value, "on") == 0) { form_set_value(form, tag, "1"); - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else if (g_strcmp0(value, "off") == 0) { form_set_value(form, tag, "0"); - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); } break; @@ -3607,24 +3611,24 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) case FIELD_JID_SINGLE: value = args[0]; if (value == NULL) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); } else { form_set_value(form, tag, value); - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } break; case FIELD_LIST_SINGLE: value = args[0]; if ((value == NULL) || !form_field_contains_option(form, tag, value)) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); } else { form_set_value(form, tag, value); - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } break; @@ -3635,51 +3639,51 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (value == NULL) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (g_strcmp0(cmd, "add") == 0) { form_add_value(form, tag, value); - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); break; } if (g_strcmp0(args[0], "remove") == 0) { if (!g_str_has_prefix(value, "val")) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (strlen(value) < 4) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } int index = strtol(&value[3], NULL, 10); if ((index < 1) || (index > form_get_value_count(form, tag))) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } removed = form_remove_text_multi_value(form, tag, index); if (removed) { - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("Could not remove %s from %s", value, tag); + win_println(window, THEME_DEFAULT, '-', "Could not remove %s from %s", value, tag); } } break; @@ -3689,15 +3693,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (value == NULL) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (g_strcmp0(args[0], "add") == 0) { @@ -3705,15 +3709,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) if (valid) { added = form_add_unique_value(form, tag, value); if (added) { - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("Value %s already selected for %s", value, tag); + win_println(window, THEME_DEFAULT, '-', "Value %s already selected for %s", value, tag); } } else { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); } break; } @@ -3722,15 +3726,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) if (valid == TRUE) { removed = form_remove_value(form, tag, value); if (removed) { - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("Value %s is not currently set for %s", value, tag); + win_println(window, THEME_DEFAULT, '-', "Value %s is not currently set for %s", value, tag); } } else { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); } } break; @@ -3740,34 +3744,34 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (value == NULL) { - ui_current_print_line("Invalid command, usage:"); + win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); mucconfwin_field_help(confwin, tag); - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); break; } if (g_strcmp0(args[0], "add") == 0) { added = form_add_unique_value(form, tag, value); if (added) { - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("JID %s already exists in %s", value, tag); + win_println(window, THEME_DEFAULT, '-', "JID %s already exists in %s", value, tag); } break; } if (g_strcmp0(args[0], "remove") == 0) { removed = form_remove_value(form, tag, value); if (removed) { - ui_current_print_line("Field updated..."); + win_println(window, THEME_DEFAULT, '-', "Field updated..."); mucconfwin_show_form_field(confwin, form, tag); } else { - ui_current_print_line("Field %s does not contain %s", tag, value); + win_println(window, THEME_DEFAULT, '-', "Field %s does not contain %s", tag, value); } } break; @@ -3827,7 +3831,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) ui_show_lines((ProfWin*) confwin, help_text); } - ui_current_print_line(""); + win_println(window, THEME_DEFAULT, '-', ""); return TRUE; } @@ -4333,9 +4337,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) char *password = muc_password(mucwin->roomjid); gboolean added = bookmark_add(mucwin->roomjid, nick, password, "on"); if (added) { - ui_current_print_formatted_line('!', 0, "Bookmark added for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Bookmark added for %s.", mucwin->roomjid); } else { - ui_current_print_formatted_line('!', 0, "Bookmark already exists for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Bookmark already exists for %s.", mucwin->roomjid); } return TRUE; } @@ -4345,9 +4349,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean removed = bookmark_remove(mucwin->roomjid); if (removed) { - ui_current_print_formatted_line('!', 0, "Bookmark removed for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Bookmark removed for %s.", mucwin->roomjid); } else { - ui_current_print_formatted_line('!', 0, "Bookmark does not exist for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Bookmark does not exist for %s.", mucwin->roomjid); } return TRUE; } @@ -6480,19 +6484,19 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) } if (chatwin->is_otr) { - ui_current_print_formatted_line('!', 0, "You must end the OTR session to start PGP encryption."); + win_println(window, THEME_DEFAULT, '!', "You must end the OTR session to start PGP encryption."); return TRUE; } if (chatwin->pgp_send) { - ui_current_print_formatted_line('!', 0, "You have already started PGP encryption."); + win_println(window, THEME_DEFAULT, '!', "You have already started PGP encryption."); return TRUE; } ProfAccount *account = accounts_get_account(session_get_account_name()); char *err_str = NULL; if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) { - ui_current_print_formatted_line('!', 0, "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str); + win_println(window, THEME_DEFAULT, '!', "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str); free(err_str); account_free(account); return TRUE; @@ -6501,12 +6505,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) account_free(account); if (!p_gpg_available(chatwin->barejid)) { - ui_current_print_formatted_line('!', 0, "No PGP key found for %s.", chatwin->barejid); + win_println(window, THEME_DEFAULT, '!', "No PGP key found for %s.", chatwin->barejid); return TRUE; } chatwin->pgp_send = TRUE; - ui_current_print_formatted_line('!', 0, "PGP encryption enabled."); + win_println(window, THEME_DEFAULT, '!', "PGP encryption enabled."); return TRUE; } @@ -6524,12 +6528,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) ProfChatWin *chatwin = (ProfChatWin*)window; if (chatwin->pgp_send == FALSE) { - ui_current_print_formatted_line('!', 0, "PGP encryption is not currently enabled."); + win_println(window, THEME_DEFAULT, '!', "PGP encryption is not currently enabled."); return TRUE; } chatwin->pgp_send = FALSE; - ui_current_print_formatted_line('!', 0, "PGP encryption disabled."); + win_println(window, THEME_DEFAULT, '!', "PGP encryption disabled."); return TRUE; } @@ -6676,12 +6680,12 @@ cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args) } if (!otr_key_loaded()) { - ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); + win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'"); return TRUE; } char *fingerprint = otr_get_my_fingerprint(); - ui_current_print_formatted_line('!', 0, "Your OTR fingerprint: %s", fingerprint); + win_println(window, THEME_DEFAULT, '!', "Your OTR fingerprint: %s", fingerprint); free(fingerprint); return TRUE; #else @@ -6700,19 +6704,19 @@ cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint."); + win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to view a recipient's fingerprint."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } char *fingerprint = otr_get_their_fingerprint(chatwin->barejid); - ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint); + win_println(window, THEME_DEFAULT, '!', "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint); free(fingerprint); return TRUE; #else @@ -6745,17 +6749,17 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) ui_focus_win((ProfWin*)chatwin); if (chatwin->pgp_send) { - ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You must disable PGP encryption before starting an OTR session."); return TRUE; } if (chatwin->is_otr) { - ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are already in an OTR session."); return TRUE; } if (!otr_key_loaded()) { - ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); + win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'"); return TRUE; } @@ -6772,24 +6776,24 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) // no recipient, use current chat } else { if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in a regular chat window to start an OTR session."); + win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OTR session."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->pgp_send) { - ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You must disable PGP encryption before starting an OTR session."); return TRUE; } if (chatwin->is_otr) { - ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are already in an OTR session."); return TRUE; } if (!otr_key_loaded()) { - ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); + win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'"); return TRUE; } @@ -6814,14 +6818,14 @@ cmd_otr_end(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in a regular chat window to use OTR."); + win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to use OTR."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -6844,14 +6848,14 @@ cmd_otr_trust(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in an OTR session to trust a recipient."); + win_println(window, THEME_DEFAULT, '-', "You must be in an OTR session to trust a recipient."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -6874,14 +6878,14 @@ cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in an OTR session to untrust a recipient."); + win_println(window, THEME_DEFAULT, '-', "You must be in an OTR session to untrust a recipient."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -6904,14 +6908,14 @@ cmd_otr_secret(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in an OTR session to trust a recipient."); + win_println(window, THEME_DEFAULT, '-', "You must be in an OTR session to trust a recipient."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -6946,14 +6950,14 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in an OTR session to trust a recipient."); + win_println(window, THEME_DEFAULT, '-', "You must be in an OTR session to trust a recipient."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -6975,14 +6979,14 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - ui_current_print_line("You must be in an OTR session to trust a recipient."); + win_println(window, THEME_DEFAULT, '-', "You must be in an OTR session to trust a recipient."); return TRUE; } ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->is_otr == FALSE) { - ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); return TRUE; } @@ -7014,7 +7018,7 @@ _cmd_execute(ProfWin *window, const char *const command, const char *const inp) gboolean result = FALSE; gchar **args = parse_args_with_freetext(inp, 1, 2, &result); if (!result) { - ui_current_print_formatted_line('!', 0, "Invalid command, see /form help"); + win_println(window, THEME_DEFAULT, '!', "Invalid command, see /form help"); result = TRUE; } else { gchar **tokens = g_strsplit(inp, " ", 2); @@ -7097,7 +7101,7 @@ _cmd_execute_default(ProfWin *window, const char *inp) jabber_conn_status_t status = connection_get_status(); if (status != JABBER_CONNECTED) { - ui_current_print_line("You are not currently connected."); + win_println(window, THEME_DEFAULT, '-', "You are not currently connected."); return TRUE; } diff --git a/src/config/preferences.c b/src/config/preferences.c index f6f73995..4eed12ff 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -460,6 +460,45 @@ prefs_set_string(preference_t pref, char *value) _save_prefs(); } +char* +prefs_get_tls_certpath(void) +{ + const char *group = _get_group(PREF_TLS_CERTPATH); + const char *key = _get_key(PREF_TLS_CERTPATH); + + char *setting = g_key_file_get_string(prefs, group, key, NULL); + + if (g_strcmp0(setting, "none") == 0) { + prefs_free_string(setting); + return NULL; + } + + if (setting == NULL) { + if (g_file_test("/etc/ssl/certs", G_FILE_TEST_IS_DIR)) { + return strdup("/etc/ssl/certs"); + } + if (g_file_test("/etc/pki/tls/certs", G_FILE_TEST_IS_DIR)) { + return strdup("/etc/pki/tls/certs"); + } + if (g_file_test("/etc/ssl", G_FILE_TEST_IS_DIR)) { + return strdup("/etc/ssl"); + } + if (g_file_test("/etc/pki/tls", G_FILE_TEST_IS_DIR)) { + return strdup("/etc/pki/tls"); + } + if (g_file_test("/system/etc/security/cacerts", G_FILE_TEST_IS_DIR)) { + return strdup("/system/etc/security/cacerts"); + } + + return NULL; + } + + char *result = strdup(setting); + prefs_free_string(setting); + + return result; +} + gint prefs_get_gone(void) { diff --git a/src/config/preferences.h b/src/config/preferences.h index e0ac7442..72385de5 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -266,6 +266,8 @@ char* prefs_get_string(preference_t pref); void prefs_free_string(char *pref); void prefs_set_string(preference_t pref, char *value); +char* prefs_get_tls_certpath(void); + gboolean prefs_do_chat_notify(gboolean current_win); gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const mynick, const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found); diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 09f53beb..b55ebf3a 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -79,7 +79,7 @@ buffer_free(ProfBuff buffer) } void -buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, +buffer_append(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt) { ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); @@ -119,14 +119,14 @@ buffer_mark_received(ProfBuff buffer, const char *const id) } ProfBuffEntry* -buffer_yield_entry(ProfBuff buffer, int entry) +buffer_get_entry(ProfBuff buffer, int entry) { GSList *node = g_slist_nth(buffer->entries, entry); return node->data; } ProfBuffEntry* -buffer_yield_entry_by_id(ProfBuff buffer, const char *const id) +buffer_get_entry_by_id(ProfBuff buffer, const char *const id) { GSList *entries = buffer->entries; while (entries) { diff --git a/src/ui/buffer.h b/src/ui/buffer.h index 19b7bfb7..a191aa45 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -60,11 +60,11 @@ typedef struct prof_buff_t *ProfBuff; ProfBuff buffer_create(); void buffer_free(ProfBuff buffer); -void buffer_push(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, +void buffer_append(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt); int buffer_size(ProfBuff buffer); -ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry); -ProfBuffEntry* buffer_yield_entry_by_id(ProfBuff buffer, const char *const id); +ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry); +ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char *const id); gboolean buffer_mark_received(ProfBuff buffer, const char *const id); #endif diff --git a/src/ui/console.c b/src/ui/console.c index ff80750e..c990f69b 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -63,20 +63,6 @@ static void _cons_splash_logo(void); void _show_roster_contacts(GSList *list, gboolean show_groups); -void -cons_show_time(void) -{ - ProfWin *console = wins_get_console(); - win_print(console, THEME_DEFAULT, '-', ""); -} - -void -cons_show_word(const char *const word) -{ - ProfWin *console = wins_get_console(); - win_append(console, THEME_DEFAULT, "%s", word); -} - void cons_debug(const char *const msg, ...) { diff --git a/src/ui/core.c b/src/ui/core.c index 5b5d8d2a..8078d7b7 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -467,7 +467,7 @@ ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) cons_show(msg->str); ProfWin *current = wins_get_current(); if (current->type == WIN_CHAT) { - ui_current_print_line(msg->str); + win_println(current, THEME_DEFAULT, '-', "%s", msg->str); } } @@ -731,32 +731,6 @@ ui_prune_wins(void) } } -void -ui_current_print_line(const char *const msg, ...) -{ - ProfWin *window = wins_get_current(); - va_list arg; - va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, msg, arg); - win_println(window, THEME_DEFAULT, '-', "%s", fmt_msg->str); - va_end(arg); - g_string_free(fmt_msg, TRUE); -} - -void -ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...) -{ - ProfWin *current = wins_get_current(); - va_list arg; - va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, msg, arg); - win_println(current, attrs, show_char, "%s", fmt_msg->str); - va_end(arg); - g_string_free(fmt_msg, TRUE); -} - void ui_print_system_msg_from_recipient(const char *const barejid, const char *message) { @@ -1315,21 +1289,3 @@ ui_show_software_version(const char *const jid, const char *const presence, win_println(window, THEME_DEFAULT, '-', "OS : %s", os); } } - -void -ui_status_bar_inactive(const int win) -{ - status_bar_inactive(win); -} - -void -ui_status_bar_active(const int win) -{ - status_bar_active(win); -} - -void -ui_status_bar_new(const int win) -{ - status_bar_new(win); -} diff --git a/src/ui/ui.h b/src/ui/ui.h index 55f21eea..44d87966 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -75,8 +75,6 @@ void ui_print_system_msg_from_recipient(const char *const barejid, const char *m void ui_close_connected_win(int index); int ui_close_all_wins(void); int ui_close_read_wins(void); -void ui_current_print_line(const char *const msg, ...); -void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...); void ui_close_win(int index); int ui_win_unread(int index); char* ui_ask_password(void); @@ -120,10 +118,8 @@ void ui_prune_wins(void); void ui_auto_away(char *message, gint time, resource_presence_t res_presence); void ui_handle_login_account_success(ProfAccount *account, gboolean secured); void ui_update_presence(const resource_presence_t resource_presence, const char *const message, const char *const show); -void ui_write(char *line, int offset); void ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)); gboolean ui_win_has_unsaved_form(int num); -void ui_inp_history_append(char *inp); // Chat window ProfChatWin* chatwin_new(const char *const barejid); @@ -246,8 +242,6 @@ void cons_show_otr_prefs(void); void cons_show_pgp_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); @@ -262,8 +256,6 @@ void cons_show_scripts(GSList *scripts); void cons_show_script(const char *const script, GSList *commands); void cons_show_aliases(GList *aliases); void cons_show_login_success(ProfAccount *account, gboolean secured); -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); diff --git a/src/ui/window.c b/src/ui/window.c index 595d6852..1a7dc6bd 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1026,7 +1026,7 @@ win_println_them_message(ProfWin *window, const char *const them, const char *co GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1046,7 +1046,7 @@ win_println_me_message(ProfWin *window, const char *const me, const char *const GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1066,7 +1066,7 @@ win_print_outgoing(ProfWin *window, const char ch, const char *const message, .. GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); _win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1086,7 +1086,7 @@ win_print_history(ProfWin *window, GDateTime *timestamp, const char *const messa GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1106,7 +1106,7 @@ win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *c GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); _win_print(window, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1126,7 +1126,7 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); _win_print(window, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1146,7 +1146,7 @@ win_println_indent(ProfWin *window, int pad, const char *const message, ...) GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); _win_print(window, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1166,7 +1166,7 @@ win_append(ProfWin *window, theme_item_t theme_item, const char *const message, GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1186,7 +1186,7 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1206,7 +1206,7 @@ win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1226,7 +1226,7 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1252,7 +1252,7 @@ win_print_with_receipt(ProfWin *window, const char show_char, const char *const receipt->id = strdup(id); receipt->received = FALSE; - buffer_push(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); + buffer_append(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); _win_print(window, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); // TODO: cross-reference.. this should be replaced by a real event-based system inp_nonblocking(TRUE); @@ -1271,7 +1271,7 @@ win_mark_received(ProfWin *window, const char *const id) void win_update_entry_message(ProfWin *window, const char *const id, const char *const message) { - ProfBuffEntry *entry = buffer_yield_entry_by_id(window->layout->buffer, id); + ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, id); if (entry) { free(entry->message); entry->message = strdup(message); @@ -1282,7 +1282,7 @@ win_update_entry_message(ProfWin *window, const char *const id, const char *cons void win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme_item) { - ProfBuffEntry *entry = buffer_yield_entry_by_id(window->layout->buffer, id); + ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, id); if (entry) { entry->theme_item = theme_item; win_redraw(window); @@ -1310,7 +1310,7 @@ _win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *ti GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); + buffer_append(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1576,7 +1576,7 @@ win_redraw(ProfWin *window) size = buffer_size(window->layout->buffer); for (i = 0; i < size; i++) { - ProfBuffEntry *e = buffer_yield_entry(window->layout->buffer, i); + ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i); _win_print(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt); } } diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 70ca12b0..304d984d 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -160,11 +160,11 @@ connection_connect(const char *const fulljid, const char *const passwd, const ch } #ifdef HAVE_LIBMESODE - char *cert_path = prefs_get_string(PREF_TLS_CERTPATH); + char *cert_path = prefs_get_tls_certpath(); if (cert_path) { xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + free(cert_path); } - prefs_free_string(cert_path); int connect_status = xmpp_connect_client( conn.xmpp_conn, diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index c1a46fc1..314a64b2 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -216,7 +216,7 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state) will_return(connection_get_status, JABBER_CONNECTED); will_return(otr_key_loaded, FALSE); - expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); + expect_win_println("You have not generated or loaded a private key, use '/otr gen'"); gboolean result = cmd_otr_myfp(NULL, CMD_OTR, args); assert_true(result); @@ -233,7 +233,7 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state) will_return(otr_key_loaded, TRUE); will_return(otr_get_my_fingerprint, strdup(fingerprint)); - expect_ui_current_print_formatted_line('!', 0, message->str); + expect_win_println(message->str); gboolean result = cmd_otr_myfp(NULL, CMD_OTR, args); assert_true(result); @@ -250,7 +250,7 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype) will_return(connection_get_status, JABBER_CONNECTED); - expect_ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint."); + expect_win_println("You must be in a regular chat window to view a recipient's fingerprint."); gboolean result = cmd_otr_theirfp(&window, CMD_OTR, args); @@ -286,7 +286,7 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) will_return(connection_get_status, JABBER_CONNECTED); - expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); + expect_win_println("You are not currently in an OTR session."); gboolean result = cmd_otr_theirfp((ProfWin*)&chatwin, CMD_OTR, args); @@ -316,7 +316,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state) expect_string(otr_get_their_fingerprint, recipient, recipient); will_return(otr_get_their_fingerprint, strdup(fingerprint)); - expect_ui_current_print_formatted_line('!', 0, message->str); + expect_win_println(message->str); gboolean result = cmd_otr_theirfp((ProfWin*)&chatwin, CMD_OTR, args); assert_true(result); @@ -333,7 +333,7 @@ test_cmd_otr_start_from_wintype(win_type_t wintype) will_return(connection_get_status, JABBER_CONNECTED); - expect_ui_current_print_line("You must be in a regular chat window to start an OTR session."); + expect_win_println("You must be in a regular chat window to start an OTR session."); gboolean result = cmd_otr_start(&window, CMD_OTR, args); assert_true(result); @@ -370,7 +370,7 @@ void cmd_otr_start_shows_message_when_already_started(void **state) chatwin.pgp_send = FALSE; chatwin.is_otr = TRUE; - expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); + expect_win_println("You are already in an OTR session."); gboolean result = cmd_otr_start((ProfWin*)&chatwin, CMD_OTR, args); assert_true(result); @@ -393,7 +393,7 @@ void cmd_otr_start_shows_message_when_no_key(void **state) chatwin.pgp_send = FALSE; chatwin.is_otr = FALSE; - expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); + expect_win_println("You have not generated or loaded a private key, use '/otr gen'"); gboolean result = cmd_otr_start((ProfWin*)&chatwin, CMD_OTR, args); assert_true(result); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index c93f08fd..e4f56c85 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -43,17 +43,9 @@ expect_any_cons_show_error(void) } void -expect_ui_current_print_line(char *message) +expect_win_println(char *message) { - expect_string(ui_current_print_line, output, message); -} - -void -expect_ui_current_print_formatted_line(char show_char, int attrs, char *message) -{ - expect_value(ui_current_print_formatted_line, show_char, show_char); - expect_value(ui_current_print_formatted_line, attrs, attrs); - expect_string(ui_current_print_formatted_line, output, message); + expect_string(win_println, output, message); } // stubs @@ -517,9 +509,17 @@ void win_hide_subwin(ProfWin *window) {} void win_show_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {} -void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {} + +void win_println(ProfWin *window, theme_item_t theme, const char ch, const char *const message, ...) +{ + va_list args; + va_start(args, message); + vsnprintf(output, sizeof(output), message, args); + check_expected(output); + va_end(args); +} + void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) {} -void win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) {} void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) {} char* win_get_title(ProfWin *window) diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h index d4488c4b..635f719e 100644 --- a/tests/unittests/ui/stub_ui.h +++ b/tests/unittests/ui/stub_ui.h @@ -2,5 +2,4 @@ void expect_cons_show(char *expected); void expect_any_cons_show(void); void expect_cons_show_error(char *expected); void expect_any_cons_show_error(void); -void expect_ui_current_print_line(char *message); -void expect_ui_current_print_formatted_line(char show_char, int attrs, char *message); +void expect_win_println(char *message); diff --git a/themes/bios b/themes/bios index 3d524652..80ac885f 100644 --- a/themes/bios +++ b/themes/bios @@ -86,7 +86,7 @@ time.chat=%d/%m/%y %H:%M:%S time.muc=%d/%m/%y %H:%M:%S time.mucconfig=off time.private=%d/%m/%y %H:%M:%S -time.xml=%H:%M:%S +time.xmlconsole=%H:%M:%S time.statusbar=%H:%M:%S time.lastactivity=%d/%m/%y %H:%M:%S privileges=true diff --git a/themes/boothj5 b/themes/boothj5 index fc7c8b8a..a0da10c5 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -86,7 +86,7 @@ time.chat=%d/%m/%y %H:%M:%S time.muc=%d/%m/%y %H:%M:%S time.mucconfig=off time.private=%d/%m/%y %H:%M:%S -time.xml=%H:%M:%S +time.xmlconsole=%H:%M:%S time.statusbar=%H:%M:%S time.lastactivity=%d/%m/%y %H:%M:%S privileges=true diff --git a/themes/boothj5_laptop b/themes/boothj5_laptop new file mode 100644 index 00000000..86339c1e --- /dev/null +++ b/themes/boothj5_laptop @@ -0,0 +1,144 @@ +[colours] +bkgnd=default +titlebar=blue +titlebar.text=bold_white +titlebar.brackets=bold_white +titlebar.unencrypted=bold_red +titlebar.encrypted=bold_white +titlebar.untrusted=bold_yellow +titlebar.trusted=bold_white +titlebar.online=bold_green +titlebar.offline=bold_red +titlebar.away=bold_cyan +titlebar.xa=bold_cyan +titlebar.dnd=bold_red +titlebar.chat=bold_green +statusbar=blue +statusbar.text=bold_white +statusbar.brackets=bold_white +statusbar.active=bold_cyan +statusbar.new=bold_white +main.text=white +main.text.me=cyan +main.text.them=bold_white +main.splash=bold_red +main.time=yellow +input.text=bold_green +subscribed=green +unsubscribed=red +otr.started.trusted=green +otr.started.untrusted=yellow +otr.ended=red +otr.trusted=green +otr.untrusted=yellow +online=green +away=cyan +chat=white +dnd=magenta +xa=blue +offline=red +incoming=bold_yellow +mention=bold_cyan +trigger=bold_blue +typing=yellow +gone=red +error=red +roominfo=yellow +roommention=bold_white +roommention.term=bold_cyan +roomtrigger=bold_white +roomtrigger.term=bold_blue +me=blue +them=bold_green +roster.header=bold_yellow +roster.chat=white +roster.online=green +roster.away=cyan +roster.xa=blue +roster.dnd=magenta +roster.offline=red +roster.chat.active=white +roster.online.active=green +roster.away.active=cyan +roster.xa.active=blue +roster.dnd.active=magenta +roster.offline.active=red +roster.chat.unread=bold_white +roster.online.unread=bold_green +roster.away.unread=bold_cyan +roster.xa.unread=bold_blue +roster.dnd.unread=bold_magenta +roster.offline.unread=bold_red +roster.room=green +roster.room.unread=bold_green +roster.room.mention=bold_cyan +roster.room.trigger=bold_blue +occupants.header=bold_yellow +receipt.sent=bold_black + +[ui] +beep=false +flash=false +splash=true +wrap=true +time.console=%H:%M:%S +time.chat=%H:%M:%S +time.muc=%H:%M:%S +time.mucconfig=off +time.private=%H:%M:%S +time.xmlconsole=off +time.statusbar=%H:%M:%S +time.lastactivity=%d/%m/%y %H:%M:%S +privileges=true +presence=true +intype=true +enc.warn=true +resource.title=true +resource.message=true +statuses.console=none +statuses.chat=none +statuses.muc=none +roster=true +roster.offline=false +roster.empty=false +roster.by=group +roster.order=presence +roster.unread=after +roster.priority=false +roster.size=30 +roster.wrap=true +roster.header.char=@ +roster.contact.indent=1 +roster.resource=true +roster.resource.char=/ +roster.resource.indent=1 +roster.resource.join=true +roster.presence=true +roster.presence.indent=-1 +roster.status=true +roster.contacts=true +roster.unsubscribed=true +roster.rooms=true +roster.rooms.order=name +roster.rooms.unread=after +roster.rooms.pos=last +roster.rooms.by=none +roster.rooms.private.char=/ +roster.private=room +roster.count=unread +roster.count.zero=false +occupants=true +occupants.size=15 +occupants.jid=false +wins.autotidy=true +otr.char=@ +pgp.char=% +tls.show=true +console.muc=first +console.chat=all +console.private=all +titlebar.position=1 +mainwin.position=2 +statusbar.position=3 +inputwin.position=4 + diff --git a/themes/boothj5_slack b/themes/boothj5_slack index 2c306598..b372df77 100644 --- a/themes/boothj5_slack +++ b/themes/boothj5_slack @@ -86,7 +86,7 @@ time.chat=%d/%m/%y %H:%M:%S time.muc=%d/%m/%y %H:%M:%S time.mucconfig=off time.private=%d/%m/%y %H:%M:%S -time.xml=%H:%M:%S +time.xmlconsole=%H:%M:%S time.statusbar=%H:%M:%S time.lastactivity=%d/%m/%y %H:%M:%S privileges=false