diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-02-20 18:11:08 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-02-20 23:36:10 +0100 |
commit | 1f8b1eb740391941e79e1004ad041f8178a2b674 (patch) | |
tree | 726eb598bfe2a99f80a239dc5b8f1c41ae5bae71 | |
parent | 280b718cfb592f2eae317bf298a96a71fdf7dff9 (diff) | |
download | profani-tty-1f8b1eb740391941e79e1004ad041f8178a2b674.tar.gz |
Allow utf8 symbols as omemo/pgp/otr indicator char
Fix https://github.com/profanity-im/profanity/issues/1264
-rw-r--r-- | src/command/cmd_funcs.c | 365 | ||||
-rw-r--r-- | src/config/preferences.c | 72 | ||||
-rw-r--r-- | src/config/preferences.h | 14 | ||||
-rw-r--r-- | src/config/theme.c | 12 | ||||
-rw-r--r-- | src/event/server_events.c | 2 | ||||
-rw-r--r-- | src/otr/otr.c | 4 | ||||
-rw-r--r-- | src/plugins/api.c | 24 | ||||
-rw-r--r-- | src/ui/buffer.c | 5 | ||||
-rw-r--r-- | src/ui/buffer.h | 5 | ||||
-rw-r--r-- | src/ui/chatwin.c | 50 | ||||
-rw-r--r-- | src/ui/confwin.c | 88 | ||||
-rw-r--r-- | src/ui/console.c | 174 | ||||
-rw-r--r-- | src/ui/core.c | 68 | ||||
-rw-r--r-- | src/ui/mucwin.c | 175 | ||||
-rw-r--r-- | src/ui/privwin.c | 24 | ||||
-rw-r--r-- | src/ui/ui.h | 4 | ||||
-rw-r--r-- | src/ui/window.c | 147 | ||||
-rw-r--r-- | src/ui/window.h | 10 | ||||
-rw-r--r-- | src/ui/window_list.c | 6 | ||||
-rw-r--r-- | src/ui/xmlwin.c | 12 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 4 |
21 files changed, 643 insertions, 622 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c65bf10a..f32deef0 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1190,17 +1190,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) { - win_println(window, THEME_DEFAULT, '-', "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)) { - win_println(window, THEME_DEFAULT, '-', "%s subscription status: %s, request pending.", + win_println(window, THEME_DEFAULT, "-", "%s subscription status: %s, request pending.", jidp->barejid, p_contact_subscription(contact)); } else { - win_println(window, THEME_DEFAULT, '-', "%s subscription status: %s.", jidp->barejid, + win_println(window, THEME_DEFAULT, "-", "%s subscription status: %s.", jidp->barejid, p_contact_subscription(contact)); } } else { @@ -1401,7 +1401,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // check for unsaved form if (ui_win_has_unsaved_form(index)) { - win_println(window, THEME_DEFAULT, '-', "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; } @@ -1432,7 +1432,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // check for unsaved form if (ui_win_has_unsaved_form(index)) { - win_println(window, THEME_DEFAULT, '-', "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; } @@ -1525,9 +1525,9 @@ _cmd_help_cmd_list(const char *const tag) cons_show(""); ProfWin *console = wins_get_console(); if (tag) { - win_println(console, THEME_HELP_HEADER, '-', "%s commands", tag); + win_println(console, THEME_HELP_HEADER, "-", "%s commands", tag); } else { - win_println(console, THEME_HELP_HEADER, '-', "All commands"); + win_println(console, THEME_HELP_HEADER, "-", "All commands"); } GList *ordered_commands = NULL; @@ -2141,7 +2141,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) g_string_free(full_jid, TRUE); } else { - win_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); + win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr); } return TRUE; @@ -2177,7 +2177,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) #ifdef HAVE_OMEMO #ifdef HAVE_LIBOTR if (omemo_automatic_start(barejid) && otr_is_secure(barejid)) { - win_println(window, THEME_DEFAULT, '!', "Chat could be either OMEMO or OTR encrypted. Use '/omemo start %s' or '/otr start %s' to start a session.", usr, usr); + win_println(window, THEME_DEFAULT, "!", "Chat could be either OMEMO or OTR encrypted. Use '/omemo start %s' or '/otr start %s' to start a session.", usr, usr); return TRUE; } else if (omemo_automatic_start(barejid)) { omemo_start_session(barejid); @@ -3211,10 +3211,10 @@ cmd_status_get(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); + win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr); } } else { - win_println(window, THEME_DEFAULT, '-', "You must specify a nickname."); + win_println(window, THEME_DEFAULT, "-", "You must specify a nickname."); } break; case WIN_CHAT: @@ -3227,7 +3227,7 @@ cmd_status_get(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_contact(window, pcontact); } else { - win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } } break; @@ -3242,7 +3242,7 @@ cmd_status_get(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } jid_destroy(jid); } @@ -3298,7 +3298,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant_info(window, mucwin->roomjid, occupant); } else { - win_println(window, THEME_DEFAULT, '-', "No such occupant \"%s\" in room.", usr); + win_println(window, THEME_DEFAULT, "-", "No such occupant \"%s\" in room.", usr); } } else { ProfMucWin *mucwin = (ProfMucWin*)window; @@ -3318,7 +3318,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_info(window, pcontact); } else { - win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } } break; @@ -3333,7 +3333,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant_info(window, jid->barejid, occupant); } else { - win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, "-", "Error getting contact info."); } jid_destroy(jid); } @@ -3477,7 +3477,7 @@ cmd_software(ProfWin *window, const char *const command, gchar **args) iq_send_software_version(fulljid->str); g_string_free(fulljid, TRUE); } else { - win_println(window, THEME_DEFAULT, '-', "Unknown resource for /software command."); + win_println(window, THEME_DEFAULT, "-", "Unknown resource for /software command."); } } break; @@ -3683,7 +3683,7 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) DataForm *form = confwin->form; if (form) { if (!form_tag_exists(form, tag)) { - win_println(window, THEME_DEFAULT, '-', "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; } @@ -3699,16 +3699,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"); - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else if (g_strcmp0(value, "off") == 0) { form_set_value(form, tag, "0"); - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } break; @@ -3717,24 +3717,24 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) case FIELD_JID_SINGLE: value = args[0]; if (value == NULL) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } else { form_set_value(form, tag, value); - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } break; case FIELD_LIST_SINGLE: value = args[0]; if ((value == NULL) || !form_field_contains_option(form, tag, value)) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } else { form_set_value(form, tag, value); - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } break; @@ -3745,51 +3745,51 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (value == NULL) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (g_strcmp0(cmd, "add") == 0) { form_add_value(form, tag, value); - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); break; } if (g_strcmp0(args[0], "remove") == 0) { if (!g_str_has_prefix(value, "val")) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (strlen(value) < 4) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } int index = strtol(&value[3], NULL, 10); if ((index < 1) || (index > form_get_value_count(form, tag))) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } removed = form_remove_text_multi_value(form, tag, index); if (removed) { - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "Could not remove %s from %s", value, tag); + win_println(window, THEME_DEFAULT, "-", "Could not remove %s from %s", value, tag); } } break; @@ -3799,15 +3799,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (value == NULL) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (g_strcmp0(args[0], "add") == 0) { @@ -3815,15 +3815,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) if (valid) { added = form_add_unique_value(form, tag, value); if (added) { - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "Value %s already selected for %s", value, tag); + win_println(window, THEME_DEFAULT, "-", "Value %s already selected for %s", value, tag); } } else { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } break; } @@ -3832,15 +3832,15 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) if (valid == TRUE) { removed = form_remove_value(form, tag, value); if (removed) { - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "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 { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } } break; @@ -3850,34 +3850,34 @@ cmd_form_field(ProfWin *window, char *tag, gchar **args) value = args[1]; } if ((g_strcmp0(cmd, "add") != 0) && (g_strcmp0(cmd, "remove"))) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (value == NULL) { - win_println(window, THEME_DEFAULT, '-', "Invalid command, usage:"); + win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); confwin_field_help(confwin, tag); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); break; } if (g_strcmp0(args[0], "add") == 0) { added = form_add_unique_value(form, tag, value); if (added) { - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '-', "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated..."); confwin_show_form_field(confwin, form, tag); } else { - win_println(window, THEME_DEFAULT, '-', "Field %s does not contain %s", tag, value); + win_println(window, THEME_DEFAULT, "-", "Field %s does not contain %s", tag, value); } } break; @@ -3937,7 +3937,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) ui_show_lines((ProfWin*) confwin, help_text); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); return TRUE; } @@ -3992,7 +3992,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) char *reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { - win_println(window, THEME_DEFAULT, '!', "Occupant does not exist: %s", nick); + win_println(window, THEME_DEFAULT, "!", "Occupant does not exist: %s", nick); } } else { cons_bad_cmd_usage(command); @@ -4050,10 +4050,10 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) if (args[0] == NULL) { char *subject = muc_subject(mucwin->roomjid); if (subject) { - win_print(window, THEME_ROOMINFO, '!', "Room subject: "); + win_print(window, THEME_ROOMINFO, "!", "Room subject: "); win_appendln(window, THEME_DEFAULT, "%s", subject); } else { - win_println(window, THEME_ROOMINFO, '!', "Room has no subject"); + win_println(window, THEME_ROOMINFO, "!", "Room has no subject"); } return TRUE; } @@ -4085,7 +4085,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set <subject>"); + win_print(window, THEME_ROOMINFO, "!", "Room does not have a subject, use /subject set <subject>"); } } else { cons_bad_cmd_usage(command); @@ -4102,7 +4102,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set <subject>"); + win_print(window, THEME_ROOMINFO, "!", "Room does not have a subject, use /subject set <subject>"); } } else { cons_bad_cmd_usage(command); @@ -4161,7 +4161,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member", true); iq_room_affiliation_list(mucwin->roomjid, "outcast", true); } else if (g_strcmp0(affiliation, "none") == 0) { - win_println(window, THEME_DEFAULT, '!', "Cannot list users with no affiliation."); + win_println(window, THEME_DEFAULT, "!", "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation, true); } @@ -4229,7 +4229,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_println(window, THEME_DEFAULT, '!', "Cannot list users with no role."); + win_println(window, THEME_DEFAULT, "!", "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } @@ -4278,12 +4278,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(mucwin->roomjid); if (!requires_config) { - win_println(window, THEME_ROOMINFO, '!', "Current room does not require configuration."); + win_println(window, THEME_ROOMINFO, "!", "Current room does not require configuration."); return TRUE; } else { iq_confirm_instant_room(mucwin->roomjid); muc_set_requires_config(mucwin->roomjid, FALSE); - win_println(window, THEME_ROOMINFO, '!', "Room unlocked."); + win_println(window, THEME_ROOMINFO, "!", "Room unlocked."); return TRUE; } } else if (g_strcmp0(args[0], "destroy") == 0) { @@ -4602,9 +4602,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) { - win_println(window, THEME_DEFAULT, '!', "Bookmark added for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Bookmark added for %s.", mucwin->roomjid); } else { - win_println(window, THEME_DEFAULT, '!', "Bookmark already exists for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Bookmark already exists for %s.", mucwin->roomjid); } return TRUE; } @@ -4616,9 +4616,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args) assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean removed = bookmark_remove(mucwin->roomjid); if (removed) { - win_println(window, THEME_DEFAULT, '!', "Bookmark removed for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Bookmark removed for %s.", mucwin->roomjid); } else { - win_println(window, THEME_DEFAULT, '!', "Bookmark does not exist for %s.", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Bookmark does not exist for %s.", mucwin->roomjid); } return TRUE; } @@ -4806,7 +4806,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) // only omemo, no pgp/otr available in MUCs if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); - win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; } @@ -4821,7 +4821,7 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) || (chatwin->pgp_send && !prefs_get_boolean(PREF_PGP_SENDFILE)) || (chatwin->is_otr && !prefs_get_boolean(PREF_OTR_SENDFILE))) { cons_show_error("Uploading unencrypted files disabled. See /omemo sendfile, /otr sendfile, /pgp sendfile."); - win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + win_println(window, THEME_ERROR, "-", "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; } @@ -5004,13 +5004,13 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) } if (!tinyurl_valid(url)) { - win_println(window, THEME_ERROR, '-', "/tiny, badly formed URL: %s", url); + win_println(window, THEME_ERROR, "-", "/tiny, badly formed URL: %s", url); return TRUE; } char *tiny = tinyurl_get(url); if (!tiny) { - win_println(window, THEME_ERROR, '-', "Couldn't create tinyurl."); + win_println(window, THEME_ERROR, "-", "Couldn't create tinyurl."); return TRUE; } @@ -5061,9 +5061,9 @@ cmd_clear(ProfWin *window, const char *const command, gchar **args) } } else { if (prefs_get_boolean(PREF_CLEAR_PERSIST_HISTORY)) { - win_println(window, THEME_DEFAULT, '!', " Persistantly clear screen : ON"); + win_println(window, THEME_DEFAULT, "!", " Persistantly clear screen : ON"); } else { - win_println(window, THEME_DEFAULT, '!', " Persistantly clear screen : OFF"); + win_println(window, THEME_DEFAULT, "!", " Persistantly clear screen : OFF"); } return TRUE; } @@ -5505,50 +5505,50 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) if (!args[0]) { ProfWin *current = wins_get_current(); if (current->type == WIN_MUC) { - win_println(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, "-", ""); ProfMucWin *mucwin = (ProfMucWin *)current; - win_println(window, THEME_DEFAULT, '!', "Notification settings for %s:", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Notification settings for %s:", mucwin->roomjid); if (prefs_has_room_notify(mucwin->roomjid)) { if (prefs_get_room_notify(mucwin->roomjid)) { - win_println(window, THEME_DEFAULT, '!', " Message : ON"); + win_println(window, THEME_DEFAULT, "!", " Message : ON"); } else { - win_println(window, THEME_DEFAULT, '!', " Message : OFF"); + win_println(window, THEME_DEFAULT, "!", " Message : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM)) { - win_println(window, THEME_DEFAULT, '!', " Message : ON (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Message : ON (global setting)"); } else { - win_println(window, THEME_DEFAULT, '!', " Message : OFF (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Message : OFF (global setting)"); } } if (prefs_has_room_notify_mention(mucwin->roomjid)) { if (prefs_get_room_notify_mention(mucwin->roomjid)) { - win_println(window, THEME_DEFAULT, '!', " Mention : ON"); + win_println(window, THEME_DEFAULT, "!", " Mention : ON"); } else { - win_println(window, THEME_DEFAULT, '!', " Mention : OFF"); + win_println(window, THEME_DEFAULT, "!", " Mention : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) { - win_println(window, THEME_DEFAULT, '!', " Mention : ON (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Mention : ON (global setting)"); } else { - win_println(window, THEME_DEFAULT, '!', " Mention : OFF (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Mention : OFF (global setting)"); } } if (prefs_has_room_notify_trigger(mucwin->roomjid)) { if (prefs_get_room_notify_trigger(mucwin->roomjid)) { - win_println(window, THEME_DEFAULT, '!', " Triggers : ON"); + win_println(window, THEME_DEFAULT, "!", " Triggers : ON"); } else { - win_println(window, THEME_DEFAULT, '!', " Triggers : OFF"); + win_println(window, THEME_DEFAULT, "!", " Triggers : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) { - win_println(window, THEME_DEFAULT, '!', " Triggers : ON (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Triggers : ON (global setting)"); } else { - win_println(window, THEME_DEFAULT, '!', " Triggers : OFF (global setting)"); + win_println(window, THEME_DEFAULT, "!", " Triggers : OFF (global setting)"); } } - win_println(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, "-", ""); } else { cons_show(""); cons_notify_setting(); @@ -5762,7 +5762,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, TRUE); - win_println(window, THEME_DEFAULT, '!', "Notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Notifications enabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "off") == 0) { @@ -5777,7 +5777,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, FALSE); - win_println(window, THEME_DEFAULT, '!', "Notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Notifications disabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "mention") == 0) { @@ -5793,7 +5793,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, TRUE); - win_println(window, THEME_DEFAULT, '!', "Mention notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Mention notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5802,7 +5802,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, FALSE); - win_println(window, THEME_DEFAULT, '!', "Mention notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Mention notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5821,7 +5821,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, TRUE); - win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Custom trigger notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5830,7 +5830,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, FALSE); - win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Custom trigger notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5849,9 +5849,9 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) ProfMucWin *mucwin = (ProfMucWin*)window; gboolean res = prefs_reset_room_notify(mucwin->roomjid); if (res) { - win_println(window, THEME_DEFAULT, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Notification settings set to global defaults for %s", mucwin->roomjid); } else { - win_println(window, THEME_DEFAULT, '!', "No custom notification settings for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "No custom notification settings for %s", mucwin->roomjid); } } } @@ -7130,12 +7130,13 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) if (strcmp(args[0], "char") == 0) { if (args[1] == NULL) { cons_bad_cmd_usage(command); - } else if (strlen(args[1]) != 1) { - cons_bad_cmd_usage(command); - } else { - prefs_set_pgp_char(args[1][0]); - cons_show("PGP char set to %c.", args[1][0]); + return TRUE; + } else if (g_utf8_strlen(args[1], 4) == 1) { + prefs_set_pgp_char(args[1]); + cons_show("PGP char set to %s.", args[1]); + return TRUE; } + cons_bad_cmd_usage(command); return TRUE; } else if (g_strcmp0(args[0], "log") == 0) { char *choice = args[1]; @@ -7294,19 +7295,19 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) } if (chatwin->is_otr) { - win_println(window, THEME_DEFAULT, '!', "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) { - win_println(window, THEME_DEFAULT, '!', "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)) { - win_println(window, THEME_DEFAULT, '!', "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; @@ -7315,12 +7316,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) account_free(account); if (!p_gpg_available(chatwin->barejid)) { - win_println(window, THEME_DEFAULT, '!', "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; - win_println(window, THEME_DEFAULT, '!', "PGP encryption enabled."); + win_println(window, THEME_DEFAULT, "!", "PGP encryption enabled."); return TRUE; } @@ -7338,12 +7339,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) ProfChatWin *chatwin = (ProfChatWin*)window; if (chatwin->pgp_send == FALSE) { - win_println(window, THEME_DEFAULT, '!', "PGP encryption is not currently enabled."); + win_println(window, THEME_DEFAULT, "!", "PGP encryption is not currently enabled."); return TRUE; } chatwin->pgp_send = FALSE; - win_println(window, THEME_DEFAULT, '!', "PGP encryption disabled."); + win_println(window, THEME_DEFAULT, "!", "PGP encryption disabled."); return TRUE; } @@ -7366,17 +7367,17 @@ cmd_otr_char(ProfWin *window, const char *const command, gchar **args) #ifdef HAVE_LIBOTR if (args[1] == NULL) { cons_bad_cmd_usage(command); - } else if (strlen(args[1]) != 1) { - cons_bad_cmd_usage(command); - } else { - prefs_set_otr_char(args[1][0]); - cons_show("OTR char set to %c.", args[1][0]); + return TRUE; + } else if (g_utf8_strlen(args[1], 4) == 1) { + prefs_set_otr_char(args[1]); + cons_show("OTR char set to %s.", args[1]); + return TRUE; } - return TRUE; + cons_bad_cmd_usage(command); #else cons_show("This version of Profanity has not been built with OTR support enabled"); - return TRUE; #endif + return TRUE; } gboolean @@ -7495,12 +7496,12 @@ cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args) } if (!otr_key_loaded()) { - win_println(window, THEME_DEFAULT, '!', "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(); - win_println(window, THEME_DEFAULT, '!', "Your OTR fingerprint: %s", fingerprint); + win_println(window, THEME_DEFAULT, "!", "Your OTR fingerprint: %s", fingerprint); free(fingerprint); return TRUE; #else @@ -7519,19 +7520,19 @@ cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "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); - win_println(window, THEME_DEFAULT, '!', "%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 @@ -7564,22 +7565,22 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) ui_focus_win((ProfWin*)chatwin); if (chatwin->pgp_send) { - win_println(window, THEME_DEFAULT, '!', "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_omemo) { - win_println(window, THEME_DEFAULT, '!', "You must disable OMEMO before starting an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You must disable OMEMO before starting an OTR session."); return TRUE; } if (chatwin->is_otr) { - win_println(window, THEME_DEFAULT, '!', "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()) { - win_println(window, THEME_DEFAULT, '!', "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; } @@ -7596,24 +7597,24 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args) // no recipient, use current chat } else { if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "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) { - win_println(window, THEME_DEFAULT, '!', "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()) { - win_println(window, THEME_DEFAULT, '!', "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; } @@ -7639,14 +7640,14 @@ cmd_otr_end(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7669,14 +7670,14 @@ cmd_otr_trust(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7699,14 +7700,14 @@ cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7729,14 +7730,14 @@ cmd_otr_secret(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7771,14 +7772,14 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7800,14 +7801,14 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) } if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "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) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OTR session."); return TRUE; } @@ -7962,7 +7963,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) { - win_println(window, THEME_DEFAULT, '!', "Invalid command, see /form help"); + win_println(window, THEME_DEFAULT, "!", "Invalid command, see /form help"); result = TRUE; } else { gchar **tokens = g_strsplit(inp, " ", 2); @@ -8045,7 +8046,7 @@ _cmd_execute_default(ProfWin *window, const char *inp) jabber_conn_status_t status = connection_get_status(); if (status != JABBER_CONNECTED) { - win_println(window, THEME_DEFAULT, '-', "You are not currently connected."); + win_println(window, THEME_DEFAULT, "-", "You are not currently connected."); return TRUE; } @@ -8195,7 +8196,7 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) } if (!omemo_loaded()) { - win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); + win_println(window, THEME_DEFAULT, "!", "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); return TRUE; } @@ -8223,17 +8224,17 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) if (chatwin) { if (chatwin->pgp_send) { - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "You must disable PGP encryption before starting an OMEMO session."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "You must disable PGP encryption before starting an OMEMO session."); return TRUE; } if (chatwin->is_otr) { - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "You must disable OTR encryption before starting an OMEMO session."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "You must disable OTR encryption before starting an OMEMO session."); return TRUE; } if (chatwin->is_omemo) { - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "You are already in an OMEMO session."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "You are already in an OMEMO session."); return TRUE; } @@ -8250,10 +8251,10 @@ cmd_omemo_start(ProfWin *window, const char *const command, gchar **args) omemo_start_muc_sessions(mucwin->roomjid); mucwin->is_omemo = TRUE; } else { - win_println(window, THEME_DEFAULT, '!', "MUC must be non-anonymous (i.e. be configured to present real jid to anyone) and members-only in order to support OMEMO."); + win_println(window, THEME_DEFAULT, "!", "MUC must be non-anonymous (i.e. be configured to present real jid to anyone) and members-only in order to support OMEMO."); } } else { - win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session."); + win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to start an OMEMO session."); } return TRUE; @@ -8269,17 +8270,17 @@ cmd_omemo_char(ProfWin *window, const char *const command, gchar **args) #ifdef HAVE_OMEMO if (args[1] == NULL) { cons_bad_cmd_usage(command); - } else if (strlen(args[1]) != 1) { - cons_bad_cmd_usage(command); - } else { - prefs_set_omemo_char(args[1][0]); - cons_show("OMEMO char set to %c.", args[1][0]); + return TRUE; + } else if (g_utf8_strlen(args[1], 4) == 1) { + prefs_set_omemo_char(args[1]); + cons_show("OMEMO char set to %s.", args[1]); + return TRUE; } - return TRUE; + cons_bad_cmd_usage(command); #else cons_show("This version of Profanity has not been built with OMEMO support enabled"); - return TRUE; #endif + return TRUE; } gboolean @@ -8326,7 +8327,7 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (!chatwin->is_omemo) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OMEMO session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OMEMO session."); return TRUE; } @@ -8337,14 +8338,14 @@ cmd_omemo_end(ProfWin *window, const char *const command, gchar **args) assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (!mucwin->is_omemo) { - win_println(window, THEME_DEFAULT, '!', "You are not currently in an OMEMO session."); + win_println(window, THEME_DEFAULT, "!", "You are not currently in an OMEMO session."); return TRUE; } mucwin->is_omemo = FALSE; accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, FALSE); } else { - win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to start an OMEMO session."); + win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to start an OMEMO session."); return TRUE; } @@ -8365,7 +8366,7 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) } if (!omemo_loaded()) { - win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); + win_println(window, THEME_DEFAULT, "!", "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); return TRUE; } @@ -8380,7 +8381,7 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) ProfChatWin *chatwin = (ProfChatWin*)window; jid = jid_create(chatwin->barejid); } else { - win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to print fingerprint without providing the contact."); + win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to print fingerprint without providing the contact."); return TRUE; } } else { @@ -8400,7 +8401,7 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) GList *fingerprint; if (!fingerprints) { - win_println(window, THEME_DEFAULT, '-', "There is no known fingerprints for %s", jid->barejid); + win_println(window, THEME_DEFAULT, "-", "There is no known fingerprints for %s", jid->barejid); return TRUE; } @@ -8408,15 +8409,15 @@ cmd_omemo_fingerprint(ProfWin *window, const char *const command, gchar **args) char *formatted_fingerprint = omemo_format_fingerprint(fingerprint->data); gboolean trusted = omemo_is_trusted_identity(jid->barejid, fingerprint->data); - win_println(window, THEME_DEFAULT, '-', "%s's OMEMO fingerprint: %s%s", jid->barejid, formatted_fingerprint, trusted ? " (trusted)" : ""); + win_println(window, THEME_DEFAULT, "-", "%s's OMEMO fingerprint: %s%s", jid->barejid, formatted_fingerprint, trusted ? " (trusted)" : ""); free(formatted_fingerprint); } g_list_free(fingerprints); - win_println(window, THEME_DEFAULT, '-', "You can trust it with '/omemo trust <fingerprint>'"); - win_println(window, THEME_DEFAULT, '-', "You can untrust it with '/omemo untrust <fingerprint>'"); + win_println(window, THEME_DEFAULT, "-", "You can trust it with '/omemo trust <fingerprint>'"); + win_println(window, THEME_DEFAULT, "-", "You can untrust it with '/omemo untrust <fingerprint>'"); return TRUE; #else @@ -8440,7 +8441,7 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) } if (!omemo_loaded()) { - win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); + win_println(window, THEME_DEFAULT, "!", "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); return TRUE; } @@ -8452,7 +8453,7 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) fingerprint = args[1]; if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to trust a device without providing the contact."); + win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to trust a device without providing the contact."); return TRUE; } @@ -8483,7 +8484,7 @@ cmd_omemo_trust(ProfWin *window, const char *const command, gchar **args) unformatted_fingerprint[j] = '\0'; gboolean trusted = omemo_is_trusted_identity(barejid, unformatted_fingerprint); - win_println(window, THEME_DEFAULT, '-', "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : ""); + win_println(window, THEME_DEFAULT, "-", "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : ""); free(unformatted_fingerprint); @@ -8509,7 +8510,7 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) } if (!omemo_loaded()) { - win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); + win_println(window, THEME_DEFAULT, "!", "You have not generated or loaded a cryptographic materials, use '/omemo gen'"); return TRUE; } @@ -8521,7 +8522,7 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) fingerprint = args[1]; if (window->type != WIN_CHAT) { - win_println(window, THEME_DEFAULT, '-', "You must be in a regular chat window to trust a device without providing the contact."); + win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to trust a device without providing the contact."); return TRUE; } @@ -8552,7 +8553,7 @@ cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args) unformatted_fingerprint[j] = '\0'; gboolean trusted = omemo_is_trusted_identity(barejid, unformatted_fingerprint); - win_println(window, THEME_DEFAULT, '-', "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : ""); + win_println(window, THEME_DEFAULT, "-", "%s's OMEMO fingerprint: %s%s", barejid, fingerprint, trusted ? " (trusted)" : ""); free(unformatted_fingerprint); @@ -8774,7 +8775,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) } if (!prefs_get_boolean(PREF_CORRECTION_ALLOW)) { - win_println(window, THEME_DEFAULT, '!', "Corrections not enabled. See /help correction."); + win_println(window, THEME_DEFAULT, "!", "Corrections not enabled. See /help correction."); return TRUE; } @@ -8783,7 +8784,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (chatwin->last_msg_id == NULL || chatwin->last_message == NULL) { - win_println(window, THEME_DEFAULT, '!', "No last message to correct."); + win_println(window, THEME_DEFAULT, "!", "No last message to correct."); return TRUE; } @@ -8798,7 +8799,7 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); if (mucwin->last_msg_id == NULL || mucwin->last_message == NULL) { - win_println(window, THEME_DEFAULT, '!', "No last message to correct."); + win_println(window, THEME_DEFAULT, "!", "No last message to correct."); return TRUE; } @@ -8810,6 +8811,6 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args) return TRUE; } - win_println(window, THEME_DEFAULT, '!', "Command /correct only valid in regular chat windows."); + win_println(window, THEME_DEFAULT, "!", "Command /correct only valid in regular chat windows."); return TRUE; } diff --git a/src/config/preferences.c b/src/config/preferences.c index 4b5635a1..a747c911 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -868,82 +868,79 @@ prefs_get_roster_size(void) } } -char +char* prefs_get_otr_char(void) { - char result = '~'; + char *result = "~"; char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OTR, "otr.char", NULL); if (!resultstr) { - result = '~'; + result = strdup("~"); } else { - result = resultstr[0]; + result = resultstr; } - free(resultstr); return result; } void -prefs_set_otr_char(char ch) +prefs_set_otr_char(char *ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_OTR, "otr.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_OTR, "otr.char", ch); + } else { + log_error("Could not set otr char: %s", ch); + } } -char +char* prefs_get_pgp_char(void) { - char result = '~'; + char *result = "~"; char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_PGP, "pgp.char", NULL); if (!resultstr) { - result = '~'; + result = strdup("~"); } else { - result = resultstr[0]; + result = resultstr; } - free(resultstr); return result; } void -prefs_set_pgp_char(char ch) +prefs_set_pgp_char(char *ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_PGP, "pgp.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_PGP, "pgp.char", ch); + } else { + log_error("Could not set pgp char: %s", ch); + } } -char +char* prefs_get_omemo_char(void) { - char result = '~'; + char *result = "~"; char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_OMEMO, "omemo.char", NULL); if (!resultstr) { - result = '~'; + result = strdup("~"); } else { - result = resultstr[0]; + result = resultstr; } - free(resultstr); return result; } void -prefs_set_omemo_char(char ch) +prefs_set_omemo_char(char *ch) { - char str[2]; - str[0] = ch; - str[1] = '\0'; - - g_key_file_set_string(prefs, PREF_GROUP_OMEMO, "omemo.char", str); + if (g_utf8_strlen(ch, 4) == 1) { + g_key_file_set_string(prefs, PREF_GROUP_OMEMO, "omemo.char", ch); + } else { + log_error("Could not set omemo char: %s", ch); + } } char @@ -1201,18 +1198,17 @@ prefs_set_roster_presence_indent(gint value) g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", value); } -char +char* prefs_get_correction_char(void) { - char result = '+'; + char *result = "+"; char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL); if (!resultstr) { - result = '+'; + result = strdup("+"); } else { - result = resultstr[0]; + result = resultstr; } - free(resultstr); return result; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 7eda87db..24e642d9 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -232,12 +232,12 @@ void prefs_free_plugins(gchar **plugins); void prefs_add_plugin(const char *const name); void prefs_remove_plugin(const char *const name); -char prefs_get_otr_char(void); -void prefs_set_otr_char(char ch); -char prefs_get_pgp_char(void); -void prefs_set_pgp_char(char ch); -char prefs_get_omemo_char(void); -void prefs_set_omemo_char(char ch); +char* prefs_get_otr_char(void); +void prefs_set_otr_char(char *ch); +char* prefs_get_pgp_char(void); +void prefs_set_pgp_char(char *ch); +char* prefs_get_omemo_char(void); +void prefs_set_omemo_char(char *ch); char prefs_get_roster_header_char(void); void prefs_set_roster_header_char(char ch); @@ -273,7 +273,7 @@ void prefs_set_roster_presence_indent(gint value); gint prefs_get_occupants_indent(void); void prefs_set_occupants_indent(gint value); -char prefs_get_correction_char(void); +char* prefs_get_correction_char(void); void prefs_set_correction_char(char ch); void prefs_add_login(const char *jid); diff --git a/src/config/theme.c b/src/config/theme.c index 072dc3a8..64c276e9 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -461,24 +461,24 @@ _load_preferences(void) if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) { gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_otr_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_otr_char(ch); g_free(ch); } } if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) { gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_pgp_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_pgp_char(ch); g_free(ch); } } if (g_key_file_has_key(theme, "ui", "omemo.char", NULL)) { gchar *ch = g_key_file_get_string(theme, "ui", "omemo.char", NULL); - if (ch && strlen(ch) > 0) { - prefs_set_omemo_char(ch[0]); + if (ch && g_utf8_strlen(ch, 4) == 1) { + prefs_set_omemo_char(ch); g_free(ch); } } diff --git a/src/event/server_events.c b/src/event/server_events.c index 2272016c..ca1633ff 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -676,7 +676,7 @@ sv_ev_incoming_message(ProfMessage *message) #ifdef HAVE_OMEMO if (message->encrypted) { if (chatwin->is_otr) { - win_println((ProfWin*)chatwin, THEME_DEFAULT, '-', "PGP encrypted message received whilst in OTR session."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "-", "PGP encrypted message received whilst in OTR session."); } else { _sv_ev_incoming_pgp(chatwin, new_win, message, TRUE); } diff --git a/src/otr/otr.c b/src/otr/otr.c index 5ce34758..c32e708e 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -353,14 +353,14 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re free(id); return TRUE; } else { - win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to encrypt and send message."); + win_println((ProfWin*)chatwin, THEME_ERROR, "-", "%s", "Failed to encrypt and send message."); return TRUE; } } // show error if not secure and policy always if (policy == PROF_OTRPOLICY_ALWAYS) { - win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to send message. OTR policy set to: always"); + win_println((ProfWin*)chatwin, THEME_ERROR, "-", "%s", "Failed to send message. OTR policy set to: always"); return TRUE; } diff --git a/src/plugins/api.c b/src/plugins/api.c index 264077cf..745e65c3 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -86,7 +86,7 @@ api_cons_show_themed(const char *const group, const char *const key, const char char *parsed = str_replace(message, "\r\n", "\n"); theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *console = wins_get_console(); - win_println(console, themeitem, '-', "%s", parsed); + win_println(console, themeitem, "-", "%s", parsed); free(parsed); @@ -375,7 +375,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_println(window, THEME_DEFAULT, '!', "%s", line); + win_println(window, THEME_DEFAULT, "!", "%s", line); return 1; } @@ -400,7 +400,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_println(window, themeitem, '!', "%s", line); + win_println(window, themeitem, "!", "%s", line); return 1; } @@ -522,7 +522,7 @@ api_encryption_reset(const char *const barejid) #ifdef HAVE_LIBGPGME if (chatwin->pgp_send) { chatwin->pgp_send = FALSE; - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "PGP encryption disabled."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "PGP encryption disabled."); } #endif @@ -784,7 +784,7 @@ api_chat_show(const char *const barejid, const char *message) } char *parsed = str_replace(message, "\r\n", "\n"); - win_println((ProfWin*)chatwin, THEME_TEXT, '-', "%s", parsed); + win_println((ProfWin*)chatwin, THEME_TEXT, "-", "%s", parsed); free(parsed); return 1; @@ -804,13 +804,13 @@ api_chat_show_themed(const char *const barejid, const char *const group, const c return 0; } - char show_ch = '-'; + char *show_ch = "-"; if (ch) { - if (strlen(ch) != 1) { + if (g_utf8_strlen(ch, 4) != 1) { log_warning("%s", "api_chat_show_themed failed, ch must be a string of length 1"); return 0; } else { - show_ch = ch[0]; + show_ch = (char*)ch; } } @@ -849,7 +849,7 @@ api_room_show(const char *const roomjid, const char *message) } char *parsed = str_replace(message, "\r\n", "\n"); - win_println((ProfWin*)mucwin, THEME_TEXT, '-', "%s", parsed); + win_println((ProfWin*)mucwin, THEME_TEXT, "-", "%s", parsed); free(parsed); return 1; @@ -869,13 +869,13 @@ api_room_show_themed(const char *const roomjid, const char *const group, const c return 0; } - char show_ch = '-'; + char *show_ch = "-"; if (ch) { - if (strlen(ch) != 1) { + if (g_utf8_strlen(ch, 4) != 1) { log_warning("%s", "api_room_show_themed failed, ch must be a string of length 1"); return 0; } else { - show_ch = ch[0]; + show_ch = (char*)ch; } } diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 86f87563..448c11ae 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -81,11 +81,11 @@ buffer_free(ProfBuff buffer) } void -buffer_append(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 display_from, const char *const message, DeliveryReceipt *receipt, const char *const id) { ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); - e->show_char = show_char; + e->show_char = strdup(show_char); e->pad_indent = pad_indent; e->flags = flags; e->theme_item = theme_item; @@ -163,6 +163,7 @@ buffer_get_entry_by_id(ProfBuff buffer, const char *const id) static void _free_entry(ProfBuffEntry *entry) { + free(entry->show_char); free(entry->message); free(entry->display_from); free(entry->id); diff --git a/src/ui/buffer.h b/src/ui/buffer.h index 813ac38e..1ed7d4ae 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -47,7 +47,8 @@ typedef struct delivery_receipt_t { } DeliveryReceipt; typedef struct prof_buff_entry_t { - char show_char; + // pointer because it could be a unicode symbol as well + char *show_char; int pad_indent; GDateTime *time; int flags; @@ -65,7 +66,7 @@ typedef struct prof_buff_t *ProfBuff; ProfBuff buffer_create(); void buffer_free(ProfBuff buffer); -void buffer_append(ProfBuff buffer, const char show_char, int pad_indent, GDateTime *time, +void buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const display_from, const char *const message, DeliveryReceipt *receipt, const char *const id); void buffer_remove_entry_by_id(ProfBuff buffer, const char *const id); int buffer_size(ProfBuff buffer); diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 3aeff951..9ebc8d76 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -109,9 +109,9 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) ProfWin *window = (ProfWin*) chatwin; if (trusted) { - win_println(window, THEME_OTR_STARTED_TRUSTED, '!', "OTR session started (trusted)."); + win_println(window, THEME_OTR_STARTED_TRUSTED, "!", "OTR session started (trusted)."); } else { - win_println(window, THEME_OTR_STARTED_UNTRUSTED, '!', "OTR session started (untrusted)."); + win_println(window, THEME_OTR_STARTED_UNTRUSTED, "!", "OTR session started (untrusted)."); } if (wins_is_current(window)) { @@ -138,7 +138,7 @@ chatwin_otr_unsecured(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_println(window, THEME_OTR_ENDED, '!', "OTR session ended."); + win_println(window, THEME_OTR_ENDED, "!", "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); } @@ -151,41 +151,41 @@ chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *da switch (event) { case PROF_OTR_SMP_INIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); break; case PROF_OTR_SMP_INIT_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s wants to authenticate your identity with the following question:", chatwin->barejid); - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data); - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr answer <answer>'."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", " %s", (char*)data); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "use '/otr answer <answer>'."); break; case PROF_OTR_SMP_SENDER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication failed, the secret you entered does not match the secret entered by %s.", chatwin->barejid); break; case PROF_OTR_SMP_RECEIVER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); break; case PROF_OTR_SMP_ABORT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "SMP session aborted."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "SMP session aborted."); break; case PROF_OTR_SMP_SUCCESS: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication successful."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication successful."); break; case PROF_OTR_SMP_SUCCESS_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s successfully authenticated you.", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s successfully authenticated you.", chatwin->barejid); break; case PROF_OTR_SMP_FAIL_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s failed to authenticate you.", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid); break; case PROF_OTR_SMP_AUTH: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authenticating %s...", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid); break; case PROF_OTR_SMP_AUTH_WAIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Awaiting authentication from %s...", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid); break; default: break; @@ -201,7 +201,7 @@ chatwin_otr_trust(ProfChatWin *chatwin) chatwin->otr_is_trusted = TRUE; ProfWin *window = (ProfWin*)chatwin; - win_println(window, THEME_OTR_TRUSTED, '!', "OTR session trusted."); + win_println(window, THEME_OTR_TRUSTED, "!", "OTR session trusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -216,7 +216,7 @@ chatwin_otr_untrust(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_println(window, THEME_OTR_UNTRUSTED, '!', "OTR session untrusted."); + win_println(window, THEME_OTR_UNTRUSTED, "!", "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -240,7 +240,7 @@ chatwin_recipient_gone(ProfChatWin *chatwin) display_usr = chatwin->barejid; } - win_println((ProfWin*)chatwin, THEME_GONE, '!', "<- %s has left the conversation.", display_usr); + win_println((ProfWin*)chatwin, THEME_GONE, "!", "<- %s has left the conversation.", display_usr); } void @@ -314,15 +314,17 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, { assert(chatwin != NULL); - char enc_char = '-'; + char *enc_char; if (chatwin->outgoing_char) { - enc_char = chatwin->outgoing_char[0]; + enc_char = chatwin->outgoing_char; } else if (enc_mode == PROF_MSG_ENC_OTR) { enc_char = prefs_get_otr_char(); } else if (enc_mode == PROF_MSG_ENC_PGP) { enc_char = prefs_get_pgp_char(); } else if (enc_mode == PROF_MSG_ENC_OMEMO) { enc_char = prefs_get_omemo_char(); + } else { + enc_char = strdup("-"); } if (request_receipt && id) { @@ -331,6 +333,8 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, message); } + free(enc_char); + // save last id and message for LMC if (id) { _chatwin_set_last_message(chatwin, id, message); @@ -342,11 +346,13 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) { assert(chatwin != NULL); - char enc_char = '-'; + char *enc_char; if (message->enc == PROF_MSG_ENC_PGP) { enc_char = prefs_get_pgp_char(); } else if (message->enc == PROF_MSG_ENC_OMEMO) { enc_char = prefs_get_omemo_char(); + } else { + enc_char = strdup("-"); } ProfWin *window = (ProfWin*)chatwin; @@ -354,6 +360,8 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain); int num = wins_get_num(window); status_bar_active(num, WIN_CHAT, chatwin->barejid); + + free(enc_char); } void diff --git a/src/ui/confwin.c b/src/ui/confwin.c index 9ab5a512..af37a640 100644 --- a/src/ui/confwin.c +++ b/src/ui/confwin.c @@ -48,12 +48,12 @@ confwin_show_form(ProfConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { - win_print(window, THEME_DEFAULT, '-', "Form title: "); + win_print(window, THEME_DEFAULT, "-", "Form title: "); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); } else { - win_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); + win_println(window, THEME_DEFAULT, "-", "Configuration for room %s.", confwin->roomjid); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); confwin_form_help(confwin); @@ -65,7 +65,7 @@ confwin_show_form(ProfConfWin *confwin) if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { char *value = field->values->data; - win_println(window, THEME_DEFAULT, '-', "%s", value); + win_println(window, THEME_DEFAULT, "-", "%s", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); @@ -84,7 +84,7 @@ confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) FormField *field = form_get_field_by_tag(form, tag); ProfWin *window = (ProfWin*)confwin; _confwin_form_field(window, tag, field); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } void @@ -97,13 +97,13 @@ confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) confwin_show_form(confwin); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); if (confwin->submit != NULL) { - win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes."); + win_println(window, THEME_DEFAULT, "-", "Use '/form submit' to save changes."); } - win_println(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes."); - win_println(window, THEME_DEFAULT, '-', "See '/form help' for more information."); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", "Use '/form cancel' to cancel changes."); + win_println(window, THEME_DEFAULT, "-", "See '/form help' for more information."); + win_println(window, THEME_DEFAULT, "-", ""); } void @@ -114,16 +114,16 @@ confwin_field_help(ProfConfWin *confwin, char *tag) ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (field) { - win_print(window, THEME_DEFAULT, '-', "%s", field->label); + win_print(window, THEME_DEFAULT, "-", "%s", field->label); if (field->required) { win_appendln(window, THEME_DEFAULT, " (Required):"); } else { win_appendln(window, THEME_DEFAULT, ":"); } if (field->description) { - win_println(window, THEME_DEFAULT, '-', " Description : %s", field->description); + win_println(window, THEME_DEFAULT, "-", " Description : %s", field->description); } - win_println(window, THEME_DEFAULT, '-', " Type : %s", field->type); + win_println(window, THEME_DEFAULT, "-", " Type : %s", field->type); int num_values = 0; GSList *curr_option = NULL; @@ -132,51 +132,51 @@ confwin_field_help(ProfConfWin *confwin, char *tag) switch (field->type_t) { case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: - win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text"); + win_println(window, THEME_DEFAULT, "-", " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); - win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text"); + win_println(window, THEME_DEFAULT, "-", " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is any text"); if (num_values > 0) { - win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> between 'val1' and 'val%d'", num_values); + win_println(window, THEME_DEFAULT, "-", " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> between 'val1' and 'val%d'", num_values); } break; case FIELD_BOOLEAN: - win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is either 'on' or 'off'"); + win_println(window, THEME_DEFAULT, "-", " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: - win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); + win_println(window, THEME_DEFAULT, "-", " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_println(window, THEME_DEFAULT, '-', " %s", option->value); + win_println(window, THEME_DEFAULT, "-", " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_LIST_MULTI: - win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); + win_println(window, THEME_DEFAULT, "-", " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_println(window, THEME_DEFAULT, '-', " %s", option->value); + win_println(window, THEME_DEFAULT, "-", " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_JID_SINGLE: - win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); + win_println(window, THEME_DEFAULT, "-", " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is a valid Jabber ID"); break; case FIELD_JID_MULTI: - win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); + win_println(window, THEME_DEFAULT, "-", " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, "-", " Where : <value> is a valid Jabber ID"); break; case FIELD_FIXED: case FIELD_UNKNOWN: @@ -185,7 +185,7 @@ confwin_field_help(ProfConfWin *confwin, char *tag) break; } } else { - win_println(window, THEME_DEFAULT, '-', "No such field %s", tag); + win_println(window, THEME_DEFAULT, "-", "No such field %s", tag); } } @@ -196,16 +196,16 @@ confwin_form_help(ProfConfWin *confwin) if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; - win_println(window, THEME_DEFAULT, '-', "Supplied instructions:"); - win_println(window, THEME_DEFAULT, '-', "%s", confwin->form->instructions); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", "Supplied instructions:"); + win_println(window, THEME_DEFAULT, "-", "%s", confwin->form->instructions); + win_println(window, THEME_DEFAULT, "-", ""); } } static void _confwin_form_field(ProfWin *window, char *tag, FormField *field) { - win_print(window, THEME_AWAY, '-', "[%s] ", tag); + win_print(window, THEME_AWAY, "-", "[%s] ", tag); win_append(window, THEME_DEFAULT, "%s", field->label); if (field->required) { win_append(window, THEME_DEFAULT, " (required): "); @@ -248,7 +248,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; GString *val_tag = g_string_new(""); g_string_printf(val_tag, "val%d", index++); - win_println(window, THEME_ONLINE, '-', " [%s] %s", val_tag->str, value); + win_println(window, THEME_ONLINE, "-", " [%s] %s", val_tag->str, value); g_string_free(val_tag, TRUE); curr_value = g_slist_next(curr_value); } @@ -278,9 +278,9 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) while (curr_option) { FormOption *option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { - win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); + win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { - win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); + win_println(window, THEME_OFFLINE, "-", " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } @@ -294,9 +294,9 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) while (curr_option) { FormOption *option = curr_option->data; if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { - win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); + win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { - win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); + win_println(window, THEME_OFFLINE, "-", " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } @@ -315,7 +315,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) win_newline(window); while (curr_value) { char *value = curr_value->data; - win_println(window, THEME_ONLINE, '-', " %s", value); + win_println(window, THEME_ONLINE, "-", " %s", value); curr_value = g_slist_next(curr_value); } break; diff --git a/src/ui/console.c b/src/ui/console.c index b60dd75e..f04f3d6f 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -74,7 +74,7 @@ cons_debug(const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str); + win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -88,7 +88,7 @@ cons_show(const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str); + win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -112,8 +112,8 @@ cons_show_help(const char *const cmd, CommandHelp *help) ProfWin *console = wins_get_console(); cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "%s", &cmd[1]); - win_print(console, THEME_HELP_HEADER, '-', ""); + win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]); + win_print(console, THEME_HELP_HEADER, "-", ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { win_append(console, THEME_HELP_HEADER, "-"); @@ -121,12 +121,12 @@ cons_show_help(const char *const cmd, CommandHelp *help) win_appendln(console, THEME_HELP_HEADER, ""); cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "Synopsis"); + win_println(console, THEME_HELP_HEADER, "-", "Synopsis"); ui_show_lines(console, help->synopsis); cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "Description"); - win_println(console, THEME_DEFAULT, '-', "%s", help->desc); + win_println(console, THEME_HELP_HEADER, "-", "Description"); + win_println(console, THEME_DEFAULT, "-", "%s", help->desc); int maxlen = 0; for (i = 0; help->args[i][0] != NULL; i++) { @@ -136,7 +136,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (i > 0) { cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "Arguments"); + win_println(console, THEME_HELP_HEADER, "-", "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { win_println_indent(console, maxlen + 3, "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } @@ -144,7 +144,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (g_strv_length((gchar**)help->examples) > 0) { cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "Examples"); + win_println(console, THEME_HELP_HEADER, "-", "Examples"); ui_show_lines(console, help->examples); } } @@ -169,7 +169,7 @@ cons_show_error(const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_println(console, THEME_ERROR, '-', "%s", fmt_msg->str); + win_println(console, THEME_ERROR, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -284,7 +284,7 @@ cons_show_typing(const char *const barejid) display_usr = barejid; } - win_println(console, THEME_TYPING, '-', "!! %s is typing a message...", display_usr); + win_println(console, THEME_TYPING, "-", "!! %s is typing a message...", display_usr); cons_alert(); } @@ -321,27 +321,27 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, if (g_strcmp0(muc_show, "all") == 0) { if (mention) { - win_println(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); } else if (triggers) { char *triggers_str = _room_triggers_to_string(triggers); - win_println(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); } else { - win_println(console, THEME_INCOMING, '-', "<< room message: %s in %s (win %d)", nick, room, ui_index); + win_println(console, THEME_INCOMING, "-", "<< room message: %s in %s (win %d)", nick, room, ui_index); } cons_alert(); } else if (g_strcmp0(muc_show, "first") == 0) { if (mention) { - win_println(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if (triggers) { char *triggers_str = _room_triggers_to_string(triggers); - win_println(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); cons_alert(); } else if (unread == 0) { - win_println(console, THEME_INCOMING, '-', "<< room message: %s (win %d)", room, ui_index); + win_println(console, THEME_INCOMING, "-", "<< room message: %s (win %d)", room, ui_index); cons_alert(); } } @@ -360,10 +360,10 @@ cons_show_incoming_message(const char *const short_from, const int win_index, in char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT); if (g_strcmp0(chat_show, "all") == 0) { - win_println(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index); + win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); } else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) { - win_println(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index); + win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); } @@ -382,10 +382,10 @@ cons_show_incoming_private_message(const char *const nick, const char *const roo char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); if (g_strcmp0(priv_show, "all") == 0) { - win_println(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if ((g_strcmp0(priv_show, "first") == 0) && unread == 0) { - win_println(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } @@ -405,24 +405,24 @@ cons_about(void) if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - win_println(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else win_println(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION); #endif } else { - win_println(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %s", PACKAGE_VERSION); + win_println(console, THEME_DEFAULT, "-", "Welcome to Profanity, version %s", PACKAGE_VERSION); } } - win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>."); - win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2019 - 2020 Michael Vetter <jubalh@iodoru.org>."); - win_println(console, THEME_DEFAULT, '-', "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>"); - win_println(console, THEME_DEFAULT, '-', ""); - win_println(console, THEME_DEFAULT, '-', "This is free software; you are free to change and redistribute it."); - win_println(console, THEME_DEFAULT, '-', "There is NO WARRANTY, to the extent permitted by law."); - win_println(console, THEME_DEFAULT, '-', ""); - win_println(console, THEME_DEFAULT, '-', "Type '/help' to show complete help."); - win_println(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2012 - 2019 James Booth <boothj5web@gmail.com>."); + win_println(console, THEME_DEFAULT, "-", "Copyright (C) 2019 - 2020 Michael Vetter <jubalh@iodoru.org>."); + win_println(console, THEME_DEFAULT, "-", "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>"); + win_println(console, THEME_DEFAULT, "-", ""); + win_println(console, THEME_DEFAULT, "-", "This is free software; you are free to change and redistribute it."); + win_println(console, THEME_DEFAULT, "-", "There is NO WARRANTY, to the extent permitted by law."); + win_println(console, THEME_DEFAULT, "-", ""); + win_println(console, THEME_DEFAULT, "-", "Type '/help' to show complete help."); + win_println(console, THEME_DEFAULT, "-", ""); if (prefs_get_boolean(PREF_VERCHECK)) { cons_check_version(FALSE); @@ -444,13 +444,13 @@ cons_check_version(gboolean not_available_msg) if (relase_valid) { if (release_is_new(latest_release)) { - win_println(console, THEME_DEFAULT, '-', "A new version of Profanity is available: %s", latest_release); - win_println(console, THEME_DEFAULT, '-', "Check <https://profanity-im.github.io> for details."); - win_println(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, "-", "A new version of Profanity is available: %s", latest_release); + win_println(console, THEME_DEFAULT, "-", "Check <https://profanity-im.github.io> for details."); + win_println(console, THEME_DEFAULT, "-", ""); } else { if (not_available_msg) { - win_println(console, THEME_DEFAULT, '-', "No new version available."); - win_println(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, "-", "No new version available."); + win_println(console, THEME_DEFAULT, "-", ""); } } @@ -466,7 +466,7 @@ cons_show_login_success(ProfAccount *account, gboolean secured) ProfWin *console = wins_get_console(); const char *fulljid = connection_get_fulljid(); - win_print(console, THEME_DEFAULT, '-', "%s logged in successfully, ", fulljid); + win_print(console, THEME_DEFAULT, "-", "%s logged in successfully, ", fulljid); resource_presence_t presence = accounts_get_login_presence(account->name); const char *presence_str = string_from_resource_presence(presence); @@ -500,9 +500,9 @@ cons_show_wins(gboolean unread) GSList *curr = window_strings; while (curr) { if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) { - win_println(console, THEME_CMD_WINS_UNREAD, '-', "%s", curr->data); + win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data); } else { - win_println(console, THEME_DEFAULT, '-', "%s", curr->data); + win_println(console, THEME_DEFAULT, "-", "%s", curr->data); } curr = g_slist_next(curr); } @@ -548,13 +548,13 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) const char *resource_presence = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); - win_print(console, presence_colour, '-', "%s", fulljid); + win_print(console, presence_colour, "-", "%s", fulljid); win_appendln(console, THEME_DEFAULT, ":"); // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, THEME_DEFAULT, '-', "Identity: "); + win_print(console, THEME_DEFAULT, "-", "Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { @@ -576,7 +576,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_print(console, THEME_DEFAULT, '-', "Software: %s", software_version->software); + win_print(console, THEME_DEFAULT, "-", "Software: %s", software_version->software); } if (software_version->software_version) { win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); @@ -585,7 +585,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_newline(console); } if (software_version->os) { - win_print(console, THEME_DEFAULT, '-', "OS: %s", software_version->os); + win_print(console, THEME_DEFAULT, "-", "OS: %s", software_version->os); } if (software_version->os_version) { win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); @@ -596,10 +596,10 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) } if (caps->features) { - win_println(console, THEME_DEFAULT, '-', "Features:"); + win_println(console, THEME_DEFAULT, "-", "Features:"); GSList *feature = caps->features; while (feature) { - win_println(console, THEME_DEFAULT, '-', " %s", feature->data); + win_println(console, THEME_DEFAULT, "-", " %s", feature->data); feature = g_slist_next(feature); } } @@ -661,7 +661,7 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) cons_show("Chat rooms at %s:", conference_node); while (rooms) { DiscoItem *room = rooms->data; - win_print(console, THEME_DEFAULT, '-', " %s", room->jid); + win_print(console, THEME_DEFAULT, "-", " %s", room->jid); if (room->name) { win_append(console, THEME_DEFAULT, ", (%s)", room->name); } @@ -696,7 +696,7 @@ cons_show_bookmarks(const GList *list) if (muc_active(item->barejid) && roomwin) { presence_colour = THEME_ONLINE; } - win_print(console, presence_colour, '-', " %s", item->barejid); + win_print(console, presence_colour, "-", " %s", item->barejid); if (item->nick) { win_append(console, presence_colour, "/%s", item->nick); } @@ -776,7 +776,7 @@ cons_show_disco_items(GSList *items, const char *const jid) cons_show("Service discovery items for %s:", jid); while (items) { DiscoItem *item = items->data; - win_print(console, THEME_DEFAULT, '-', " %s", item->jid); + win_print(console, THEME_DEFAULT, "-", " %s", item->jid); if (item->name) { win_append(console, THEME_DEFAULT, ", (%s)", item->name); } @@ -855,7 +855,7 @@ cons_show_account_list(gchar **accounts) (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { resource_presence_t presence = accounts_get_last_presence(accounts[i]); theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence)); - win_println(console, presence_colour, '-', "%s", accounts[i]); + win_println(console, presence_colour, "-", "%s", accounts[i]); } else { cons_show(accounts[i]); } @@ -974,7 +974,7 @@ cons_show_account(ProfAccount *account) GList *curr = resources; if (curr) { - win_println(console, THEME_DEFAULT, '-', "Resources:"); + win_println(console, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability while (curr) { @@ -992,7 +992,7 @@ cons_show_account(ProfAccount *account) Resource *resource = curr->data; const char *resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); - win_print(console, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_print(console, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { win_append(console, presence_colour, ", \"%s\"", resource->status); @@ -1006,7 +1006,7 @@ cons_show_account(ProfAccount *account) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, THEME_DEFAULT, '-', " Identity: "); + win_print(console, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { @@ -1028,7 +1028,7 @@ cons_show_account(ProfAccount *account) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_print(console, THEME_DEFAULT, '-', " Software: %s", software_version->software); + win_print(console, THEME_DEFAULT, "-", " Software: %s", software_version->software); } if (software_version->software_version) { win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); @@ -1037,7 +1037,7 @@ cons_show_account(ProfAccount *account) win_newline(console); } if (software_version->os) { - win_print(console, THEME_DEFAULT, '-', " OS: %s", software_version->os); + win_print(console, THEME_DEFAULT, "-", " OS: %s", software_version->os); } if (software_version->os_version) { win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); @@ -2034,8 +2034,9 @@ cons_correction_setting(void) cons_show("Last Message Correction (XEP-0308) (/correction) : OFF"); } - char cc = prefs_get_correction_char(); + char *cc = prefs_get_correction_char(); cons_show("LMC indication char (/correction char) : %c", cc); + free(cc); } void @@ -2071,8 +2072,9 @@ cons_show_otr_prefs(void) } prefs_free_string(log_value); - char ch = prefs_get_otr_char(); - cons_show("OTR char (/otr char) : %c", ch); + char *ch = prefs_get_otr_char(); + cons_show("OTR char (/otr char) : %s", ch); + free(ch); if (prefs_get_boolean(PREF_OTR_SENDFILE)) { cons_show("Allow sending unencrypted files in an OTR session via /sendfile (/otr sendfile): ON"); @@ -2099,8 +2101,9 @@ cons_show_pgp_prefs(void) } prefs_free_string(log_value); - char ch = prefs_get_pgp_char(); - cons_show("PGP char (/pgp char) : %c", ch); + char *ch = prefs_get_pgp_char(); + cons_show("PGP char (/pgp char) : %s", ch); + free(ch); if (prefs_get_boolean(PREF_PGP_SENDFILE)) { cons_show("Allow sending unencrypted files via /sendfile while otherwise using PGP (/pgp sendfile): ON"); @@ -2131,8 +2134,9 @@ cons_show_omemo_prefs(void) } prefs_free_string(log_value); - char ch = prefs_get_omemo_char(); - cons_show("OMEMO char (/omemo char) : %c", ch); + char *ch = prefs_get_omemo_char(); + cons_show("OMEMO char (/omemo char) : %s", ch); + free(ch); if (prefs_get_boolean(PREF_OMEMO_SENDFILE)) { cons_show("Allow sending unencrypted files in an OMEMO session via /sendfile (/omemo sendfile): ON"); @@ -2252,7 +2256,7 @@ cons_navigation_help(void) { ProfWin *console = wins_get_console(); cons_show(""); - win_println(console, THEME_HELP_HEADER, '-', "Navigation"); + win_println(console, THEME_HELP_HEADER, "-", "Navigation"); cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window."); cons_show("PAGEUP, PAGEDOWN : Page the main window."); @@ -2358,7 +2362,7 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, THEME_TEXT, '-', "%s", propstr->str); + win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(" "); @@ -2377,7 +2381,7 @@ _cons_theme_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, THEME_TEXT, '-', "%s", propstr->str); + win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(""); @@ -2503,28 +2507,28 @@ cons_theme_colours(void) ProfWin *console = wins_get_console(); cons_show("Available colours:"); - win_print(console, THEME_WHITE, '-', " white "); + win_print(console, THEME_WHITE, "-", " white "); win_appendln(console, THEME_WHITE_BOLD, " bold_white"); - win_print(console, THEME_GREEN, '-', " green "); + win_print(console, THEME_GREEN, "-", " green "); win_appendln(console, THEME_GREEN_BOLD, " bold_green"); - win_print(console, THEME_RED, '-', " red "); + win_print(console, THEME_RED, "-", " red "); win_appendln(console, THEME_RED_BOLD, " bold_red"); - win_print(console, THEME_YELLOW, '-', " yellow "); + win_print(console, THEME_YELLOW, "-", " yellow "); win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow"); - win_print(console, THEME_BLUE, '-', " blue "); + win_print(console, THEME_BLUE, "-", " blue "); win_appendln(console, THEME_BLUE_BOLD, " bold_blue"); - win_print(console, THEME_CYAN, '-', " cyan "); + win_print(console, THEME_CYAN, "-", " cyan "); win_appendln(console, THEME_CYAN_BOLD, " bold_cyan"); - win_print(console, THEME_MAGENTA, '-', " magenta "); + win_print(console, THEME_MAGENTA, "-", " magenta "); win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); - win_print(console, THEME_BLACK, '-', " black "); + win_print(console, THEME_BLACK, "-", " black "); win_appendln(console, THEME_BLACK_BOLD, " bold_black"); if (COLORS >= 256) { @@ -2541,25 +2545,25 @@ static void _cons_splash_logo(void) { ProfWin *console = wins_get_console(); - win_println(console, THEME_DEFAULT, '-', "Welcome to"); + win_println(console, THEME_DEFAULT, "-", "Welcome to"); - win_println(console, THEME_SPLASH, '-', " ___ _ "); - win_println(console, THEME_SPLASH, '-', " / __) (_)_ "); - win_println(console, THEME_SPLASH, '-', " ____ ___ ___ | |__ ____ ____ _| |_ _ _ "); - win_println(console, THEME_SPLASH, '-', "| _ \\ / __) _ \\| __) _ | _ \\| | _) | | |"); - win_println(console, THEME_SPLASH, '-', "| | ) | | | (_) | | | ( | | | | | | |_| |_| |"); - win_println(console, THEME_SPLASH, '-', "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); - win_println(console, THEME_SPLASH, '-', "|_| (____/ "); - win_println(console, THEME_SPLASH, '-', ""); + win_println(console, THEME_SPLASH, "-", " ___ _ "); + win_println(console, THEME_SPLASH, "-", " / __) (_)_ "); + win_println(console, THEME_SPLASH, "-", " ____ ___ ___ | |__ ____ ____ _| |_ _ _ "); + win_println(console, THEME_SPLASH, "-", "| _ \\ / __) _ \\| __) _ | _ \\| | _) | | |"); + win_println(console, THEME_SPLASH, "-", "| | ) | | | (_) | | | ( | | | | | | |_| |_| |"); + win_println(console, THEME_SPLASH, "-", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); + win_println(console, THEME_SPLASH, "-", "|_| (____/ "); + win_println(console, THEME_SPLASH, "-", ""); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - win_println(console, THEME_DEFAULT, '-', "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_println(console, THEME_DEFAULT, "-", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else win_println(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION); #endif } else { - win_println(console, THEME_DEFAULT, '-', "Version %s", PACKAGE_VERSION); + win_println(console, THEME_DEFAULT, "-", "Version %s", PACKAGE_VERSION); } } @@ -2586,7 +2590,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } else { presence_colour = theme_main_presence_attrs("offline"); } - win_print(console, presence_colour, '-', "%s", title->str); + win_print(console, presence_colour, "-", "%s", title->str); g_string_free(title, TRUE); diff --git a/src/ui/core.c b/src/ui/core.c index 813fc9ad..fca1111f 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -414,19 +414,19 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg ProfChatWin *chatwin = wins_get_chat(recipient); if (chatwin) { - win_println((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)chatwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } ProfMucWin *mucwin = wins_get_muc(recipient); if (mucwin) { - win_println((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)mucwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } ProfPrivateWin *privatewin = wins_get_private(recipient); if (privatewin) { - win_println((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)privatewin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } } @@ -436,7 +436,7 @@ ui_handle_otr_error(const char *const barejid, const char *const message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin) { - win_println((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message); + win_println((ProfWin*)chatwin, THEME_ERROR, "!", "%s", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -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) { - win_println(current, THEME_DEFAULT, '-', "%s", msg->str); + win_println(current, THEME_DEFAULT, "-", "%s", msg->str); } } @@ -778,7 +778,7 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag } } - win_println(window, THEME_DEFAULT, '-', "*%s %s", barejid, message); + win_println(window, THEME_DEFAULT, "-", "*%s %s", barejid, message); } void @@ -791,7 +791,7 @@ ui_room_join(const char *const roomjid, gboolean focus) ProfWin *window = (ProfWin*)mucwin; char *nick = muc_nick(roomjid); - win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick); + win_print(window, THEME_ROOMINFO, "!", "-> You have joined the room as %s", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { char *role = muc_role_str(roomjid); char *affiliation = muc_affiliation_str(roomjid); @@ -811,7 +811,7 @@ ui_room_join(const char *const roomjid, gboolean focus) status_bar_active(num, WIN_MUC, mucwin->roomjid); ProfWin *console = wins_get_console(); char *nick = muc_nick(roomjid); - win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); + win_println(console, THEME_TYPING, "!", "-> Autojoined %s as %s (%d).", roomjid, nick, num); } GList *privwins = wins_get_private_chats(roomjid); @@ -887,16 +887,16 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha ProfWin *console = wins_get_console(); if (reason) { - win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason); + win_println(console, THEME_TYPING, "!", "<- Room destroyed: %s, reason: %s", roomjid, reason); } else { - win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid); + win_println(console, THEME_TYPING, "!", "<- Room destroyed: %s", roomjid); } if (new_jid) { if (password) { - win_println(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password); + win_println(console, THEME_TYPING, "!", "Replacement room: %s, password: %s", new_jid, password); } else { - win_println(console, THEME_TYPING, '!', "Replacement room: %s", new_jid); + win_println(console, THEME_TYPING, "!", "Replacement room: %s", new_jid); } } } @@ -933,7 +933,7 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_println(console, THEME_TYPING, '!', "<- %s", message->str); + win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -969,7 +969,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_println(console, THEME_TYPING, '!', "<- %s", message->str); + win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -1012,16 +1012,16 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) { ProfWin *current = wins_get_current(); - win_println(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, "-", ""); if (prev_fail) { - win_println(current, THEME_DEFAULT, '!', "Incorrect passphrase"); + win_println(current, THEME_DEFAULT, "!", "Incorrect passphrase"); } if (hint) { - win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint); + win_println(current, THEME_DEFAULT, "!", "Enter PGP key passphrase for %s", hint); } else { - win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase"); + win_println(current, THEME_DEFAULT, "!", "Enter PGP key passphrase"); } ui_update(); @@ -1144,7 +1144,7 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c g_string_append(message_str, message); } - win_println(window, THEME_ERROR, '-', "%s", message_str->str); + win_println(window, THEME_ERROR, "-", "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1168,7 +1168,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) if (muc_window) { ui_focus_win((ProfWin*)muc_window); - win_println(muc_window, THEME_ROOMINFO, '!', "Room configuration successful"); + win_println(muc_window, THEME_ROOMINFO, "!", "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); @@ -1195,25 +1195,25 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (form_window) { if (message) { - win_println(form_window, THEME_ERROR, '!', "Configuration error: %s", message); + win_println(form_window, THEME_ERROR, "!", "Configuration error: %s", message); } else { - win_println(form_window, THEME_ERROR, '!', "Configuration error"); + win_println(form_window, THEME_ERROR, "!", "Configuration error"); } } else if (muc_window) { if (message) { - win_println(muc_window, THEME_ERROR, '!', "Configuration error: %s", message); + win_println(muc_window, THEME_ERROR, "!", "Configuration error: %s", message); } else { - win_println(muc_window, THEME_ERROR, '!', "Configuration error"); + win_println(muc_window, THEME_ERROR, "!", "Configuration error"); } } else { if (message) { - win_println(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message); + win_println(console, THEME_ERROR, "!", "Configuration error for %s: %s", roomjid, message); } else { - win_println(console, THEME_ERROR, '!', "Configuration error for %s", roomjid); + win_println(console, THEME_ERROR, "!", "Configuration error for %s", roomjid); } } } else { - win_println(console, THEME_ERROR, '!', "Configuration error"); + win_println(console, THEME_ERROR, "!", "Configuration error"); } } @@ -1223,7 +1223,7 @@ ui_show_lines(ProfWin *window, gchar** lines) if (lines) { int i; for (i = 0; lines[i] != NULL; i++) { - win_println(window, THEME_DEFAULT, '-', "%s", lines[i]); + win_println(window, THEME_DEFAULT, "-", "%s", lines[i]); } } } @@ -1260,7 +1260,7 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me g_string_append(message_str, message); } - win_println(window, THEME_ERROR, '-', "%s", message_str->str); + win_println(window, THEME_ERROR, "-", "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1300,18 +1300,18 @@ ui_show_software_version(const char *const jid, const char *const presence, } if (name || version || os) { - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_print(window, presence_colour, '-', "%s", jid); + win_print(window, presence_colour, "-", "%s", jid); win_appendln(window, THEME_DEFAULT, ":"); } if (name) { - win_println(window, THEME_DEFAULT, '-', "Name : %s", name); + win_println(window, THEME_DEFAULT, "-", "Name : %s", name); } if (version) { - win_println(window, THEME_DEFAULT, '-', "Version : %s", version); + win_println(window, THEME_DEFAULT, "-", "Version : %s", version); } if (os) { - win_println(window, THEME_DEFAULT, '-', "OS : %s", os); + win_println(window, THEME_DEFAULT, "-", "OS : %s", os); } } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 2005ce28..ce542b5f 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -76,7 +76,7 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "Your role has been changed to: %s", role); + win_print(window, THEME_ROOMINFO, "!", "Your role has been changed to: %s", role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -93,7 +93,7 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "Your affiliation has been changed to: %s", affiliation); + win_print(window, THEME_ROOMINFO, "!", "Your affiliation has been changed to: %s", affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -110,7 +110,7 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); + win_print(window, THEME_ROOMINFO, "!", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -128,7 +128,7 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "%s's role has been changed to: %s", nick, role); + win_print(window, THEME_ROOMINFO, "!", "%s's role has been changed to: %s", nick, role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -145,7 +145,7 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "%s's affiliation has been changed to: %s", nick, affiliation); + win_print(window, THEME_ROOMINFO, "!", "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -162,7 +162,7 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ROOMINFO, '!', "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); + win_print(window, THEME_ROOMINFO, "!", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); } @@ -178,8 +178,8 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_DEFAULT, '!', "Room info request failed: %s", error); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "!", "Room info request failed: %s", error); + win_println(window, THEME_DEFAULT, "-", ""); } void @@ -191,7 +191,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { if (identities) { - win_println(window, THEME_DEFAULT, '!', "Identities:"); + win_println(window, THEME_DEFAULT, "!", "Identities:"); } while (identities) { DiscoIdentity *identity = identities->data; // anme trpe, cat @@ -207,19 +207,19 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_println(window, THEME_DEFAULT, '!', "%s", identity_str->str); + win_println(window, THEME_DEFAULT, "!", "%s", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_println(window, THEME_DEFAULT, '!', "Features:"); + win_println(window, THEME_DEFAULT, "!", "Features:"); } while (features) { - win_println(window, THEME_DEFAULT, '!', " %s", features->data); + win_println(window, THEME_DEFAULT, "!", " %s", features->data); features = g_slist_next(features); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } } @@ -231,16 +231,16 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) ProfWin *window = (ProfWin*)mucwin; if ((roster == NULL) || (g_list_length(roster) == 0)) { if (presence == NULL) { - win_println(window, THEME_ROOMINFO, '!', "Room is empty."); + win_println(window, THEME_ROOMINFO, "!", "Room is empty."); } else { - win_println(window, THEME_ROOMINFO, '!', "No occupants %s.", presence); + win_println(window, THEME_ROOMINFO, "!", "No occupants %s.", presence); } } else { int length = g_list_length(roster); if (presence == NULL) { - win_print(window, THEME_ROOMINFO, '!', "%d occupants: ", length); + win_print(window, THEME_ROOMINFO, "!", "%d occupants: ", length); } else { - win_print(window, THEME_ROOMINFO, '!', "%d %s: ", length, presence); + win_print(window, THEME_ROOMINFO, "!", "%d %s: ", length, presence); } while (roster) { @@ -266,7 +266,7 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_OFFLINE, '!', "<- %s has left the room.", nick); + win_println(window, THEME_OFFLINE, "!", "<- %s has left the room.", nick); } void @@ -287,7 +287,7 @@ mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *c g_string_append(message, reason); } - win_println(window, THEME_OFFLINE, '!', "<- %s", message->str); + win_println(window, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -309,7 +309,7 @@ mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *c g_string_append(message, reason); } - win_println(window, THEME_OFFLINE, '!', "<- %s", message->str); + win_println(window, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -320,7 +320,7 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_print(window, THEME_ONLINE, '!', "-> %s has joined the room", nick); + win_print(window, THEME_ONLINE, "!", "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { win_append(window, THEME_ONLINE, ", role: %s", role); @@ -348,7 +348,7 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_THEM, '!', "** %s is now known as %s", old_nick, nick); + win_println(window, THEME_THEM, "!", "** %s is now known as %s", old_nick, nick); } void @@ -357,7 +357,7 @@ mucwin_nick_change(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ME, '!', "** You are now known as %s", nick); + win_println(window, THEME_ME, "!", "** You are now known as %s", nick); } void @@ -415,11 +415,11 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co char *before_str = g_strndup(message + last_pos, pos - last_pos); if (strncmp(before_str, "/me ", 4) == 0) { - win_print_them(window, THEME_ROOMMENTION, *ch, flags, ""); + win_print_them(window, THEME_ROOMMENTION, ch, flags, ""); win_append_highlight(window, THEME_ROOMMENTION, "*%s ", from); win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str + 4); } else { - win_print_them(window, THEME_ROOMMENTION, *ch, flags, from); + win_print_them(window, THEME_ROOMMENTION, ch, flags, from); win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str); } g_free(before_str); @@ -529,18 +529,21 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c ProfWin *window = (ProfWin*)mucwin; char *mynick = muc_nick(mucwin->roomjid); - char ch = '-'; + char *ch; if (mucwin->message_char) { - ch = mucwin->message_char[0]; + ch = strdup(mucwin->message_char); } else if (enc_mode == PROF_MSG_ENC_OTR) { ch = prefs_get_otr_char(); } else if (enc_mode == PROF_MSG_ENC_PGP) { ch = prefs_get_pgp_char(); } else if (enc_mode == PROF_MSG_ENC_OMEMO) { ch = prefs_get_omemo_char(); + } else { + ch = strdup("-"); } win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message); + free(ch); // save last id and message for LMC if (id) { @@ -566,27 +569,31 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList ProfWin *window = (ProfWin*)mucwin; char *mynick = muc_nick(mucwin->roomjid); - char ch = '-'; + char *ch; if (mucwin->message_char) { - ch = mucwin->message_char[0]; + ch = strdup(mucwin->message_char); } else if (message->enc == PROF_MSG_ENC_OTR) { ch = prefs_get_otr_char(); } else if (message->enc == PROF_MSG_ENC_PGP) { ch = prefs_get_pgp_char(); } else if (message->enc == PROF_MSG_ENC_OMEMO) { ch = prefs_get_omemo_char(); + } else { + ch = strdup("-"); } win_insert_last_read_position_marker((ProfWin*)mucwin, mucwin->roomjid); if (g_slist_length(mentions) > 0) { - _mucwin_print_mention(window, message->plain, message->jid->resourcepart, mynick, mentions, &ch, flags); + _mucwin_print_mention(window, message->plain, message->jid->resourcepart, mynick, mentions, ch, flags); } else if (triggers) { win_print_them(window, THEME_ROOMTRIGGER, ch, flags, message->jid->resourcepart); _mucwin_print_triggers(window, message->plain, triggers); } else { win_println_incoming_muc_msg(window, ch, flags, message->jid->resourcepart, message->id, message->replace_id, message->plain); } + + free(ch); } void @@ -597,12 +604,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ProfWin *window = (ProfWin*)mucwin; int num = wins_get_num(window); - win_println(window, THEME_DEFAULT, '-', ""); - win_println(window, THEME_ROOMINFO, '!', "Room locked, requires configuration."); - win_println(window, THEME_ROOMINFO, '!', "Use '/room accept' to accept the defaults"); - win_println(window, THEME_ROOMINFO, '!', "Use '/room destroy' to cancel and destroy the room"); - win_println(window, THEME_ROOMINFO, '!', "Use '/room config' to edit the room configuration"); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); + win_println(window, THEME_ROOMINFO, "!", "Room locked, requires configuration."); + win_println(window, THEME_ROOMINFO, "!", "Use '/room accept' to accept the defaults"); + win_println(window, THEME_ROOMINFO, "!", "Use '/room destroy' to cancel and destroy the room"); + win_println(window, THEME_ROOMINFO, "!", "Use '/room config' to edit the room configuration"); + win_println(window, THEME_DEFAULT, "-", ""); // currently in groupchat window if (wins_is_current(window)) { @@ -622,17 +629,17 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub ProfWin *window = (ProfWin*)mucwin; if (subject) { if (nick) { - win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick); + win_print(window, THEME_ROOMINFO, "!", "*%s has set the room subject: ", nick); win_appendln(window, THEME_DEFAULT, "%s", subject); } else { - win_print(window, THEME_ROOMINFO, '!', "Room subject: "); + win_print(window, THEME_ROOMINFO, "!", "Room subject: "); win_appendln(window, THEME_DEFAULT, "%s", subject); } } else { if (nick) { - win_println(window, THEME_ROOMINFO, '!', "*%s has cleared the room subject.", nick); + win_println(window, THEME_ROOMINFO, "!", "*%s has cleared the room subject.", nick); } else { - win_println(window, THEME_ROOMINFO, '!', "Room subject cleared"); + win_println(window, THEME_ROOMINFO, "!", "Room subject cleared"); } } } @@ -643,7 +650,7 @@ mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ERROR, '!', "Error kicking %s: %s", nick, error); + win_println(window, THEME_ERROR, "!", "Error kicking %s: %s", nick, error); } void @@ -654,7 +661,7 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) ProfWin *window = (ProfWin*)mucwin; int num = wins_get_num(window); - win_print(window, THEME_ROOMINFO, '!', "Room message: "); + win_print(window, THEME_ROOMINFO, "!", "Room message: "); win_appendln(window, THEME_DEFAULT, "%s", message); // currently in groupchat window @@ -674,7 +681,7 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", affiliation, error); + win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", affiliation, error); } void @@ -684,17 +691,17 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation ProfWin *window = (ProfWin*)mucwin; if (jids) { - win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); GSList *curr_jid = jids; while (curr_jid) { const char *jid = curr_jid->data; - win_println(window, THEME_DEFAULT, '!', " %s", jid); + win_println(window, THEME_DEFAULT, "!", " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", ""); } else { - win_println(window, THEME_DEFAULT, '!', "No users found with affiliation: %s", affiliation); - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", "No users found with affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, "!", ""); } } @@ -709,34 +716,34 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, '!', "No owners found."); + win_println(window, THEME_DEFAULT, "!", "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, '!', "No admins found."); + win_println(window, THEME_DEFAULT, "!", "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, '!', "No members found."); + win_println(window, THEME_DEFAULT, "!", "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, '!', "No outcasts found."); + win_println(window, THEME_DEFAULT, "!", "No outcasts found."); break; default: break; } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, '!', "Owners:"); + win_println(window, THEME_DEFAULT, "!", "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, '!', "Admins:"); + win_println(window, THEME_DEFAULT, "!", "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, '!', "Members:"); + win_println(window, THEME_DEFAULT, "!", "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, '!', "Outcasts:"); + win_println(window, THEME_DEFAULT, "!", "Outcasts:"); break; default: break; @@ -747,16 +754,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) Occupant *occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { - win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); + win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); } else { - win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick); + win_println(window, THEME_DEFAULT, "!", " %s", occupant->nick); } } curr_occupant = g_slist_next(curr_occupant); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } } @@ -766,7 +773,7 @@ mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", role, error); + win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", role, error); } void @@ -776,26 +783,26 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick ProfWin *window = (ProfWin*)mucwin; if (nicks) { - win_println(window, THEME_DEFAULT, '!', "Role: %s", role); + win_println(window, THEME_DEFAULT, "!", "Role: %s", role); GSList *curr_nick = nicks; while (curr_nick) { const char *nick = curr_nick->data; Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { if (occupant->jid) { - win_println(window, THEME_DEFAULT, '!', " %s (%s)", nick, occupant->jid); + win_println(window, THEME_DEFAULT, "!", " %s (%s)", nick, occupant->jid); } else { - win_println(window, THEME_DEFAULT, '!', " %s", nick); + win_println(window, THEME_DEFAULT, "!", " %s", nick); } } else { - win_println(window, THEME_DEFAULT, '!', " %s", nick); + win_println(window, THEME_DEFAULT, "!", " %s", nick); } curr_nick = g_slist_next(curr_nick); } - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", ""); } else { - win_println(window, THEME_DEFAULT, '!', "No occupants found with role: %s", role); - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", "No occupants found with role: %s", role); + win_println(window, THEME_DEFAULT, "!", ""); } } @@ -810,28 +817,28 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, '!', "No moderators found."); + win_println(window, THEME_DEFAULT, "!", "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, '!', "No participants found."); + win_println(window, THEME_DEFAULT, "!", "No participants found."); break; case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, '!', "No visitors found."); + win_println(window, THEME_DEFAULT, "!", "No visitors found."); break; default: break; } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } else { switch (role) { case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, '!', "Moderators:"); + win_println(window, THEME_DEFAULT, "!", "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, '!', "Participants:"); + win_println(window, THEME_DEFAULT, "!", "Participants:"); break; case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, '!', "Visitors:"); + win_println(window, THEME_DEFAULT, "!", "Visitors:"); break; default: break; @@ -842,16 +849,16 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) Occupant *occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { - win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); + win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); } else { - win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick); + win_println(window, THEME_DEFAULT, "!", " %s", occupant->nick); } } curr_occupant = g_slist_next(curr_occupant); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } } @@ -862,7 +869,7 @@ mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ERROR, '!', "Error setting %s affiliation for %s: %s", affiliation, jid, error); + win_println(window, THEME_ERROR, "!", "Error setting %s affiliation for %s: %s", affiliation, jid, error); } void @@ -872,7 +879,7 @@ mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *co assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_println(window, THEME_ERROR, '!', "Error setting %s role for %s: %s", role, nick, error); + win_println(window, THEME_ERROR, "!", "Error setting %s role for %s: %s", role, nick, error); } void @@ -884,10 +891,10 @@ mucwin_info(ProfMucWin *mucwin) char *affiliation = muc_affiliation_str(mucwin->roomjid); ProfWin *window = (ProfWin*) mucwin; - win_println(window, THEME_DEFAULT, '!', "Room: %s", mucwin->roomjid); - win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); - win_println(window, THEME_DEFAULT, '!', "Role: %s", role); - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "!", "Room: %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, "!", "Role: %s", role); + win_println(window, THEME_DEFAULT, "-", ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index b05c67cf..cbe32500 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -95,7 +95,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_print_outgoing((ProfWin*)privwin, '-', NULL, NULL , message); + win_print_outgoing((ProfWin*)privwin, "-", NULL, NULL , message); } void @@ -103,7 +103,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_println((ProfWin*)privwin, THEME_ERROR, '-', "Unable to send message, occupant no longer present in room."); + win_println((ProfWin*)privwin, THEME_ERROR, "-", "Unable to send message, occupant no longer present in room."); } void @@ -111,7 +111,7 @@ privwin_message_left_room(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_println((ProfWin*)privwin, THEME_ERROR, '-', "Unable to send message, you are no longer present in room."); + win_println((ProfWin*)privwin, THEME_ERROR, "-", "Unable to send message, you are no longer present in room."); } void @@ -121,7 +121,7 @@ privwin_occupant_offline(ProfPrivateWin *privwin) privwin->occupant_offline = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_println((ProfWin*)privwin, THEME_OFFLINE, '-', "<- %s has left the room.", jidp->resourcepart); + win_println((ProfWin*)privwin, THEME_OFFLINE, "-", "<- %s has left the room.", jidp->resourcepart); jid_destroy(jidp); } @@ -144,7 +144,7 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const g_string_append(message, reason); } - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -167,7 +167,7 @@ privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const g_string_append(message, reason); } - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -178,7 +178,7 @@ privwin_occupant_online(ProfPrivateWin *privwin) privwin->occupant_offline = FALSE; Jid *jidp = jid_create(privwin->fulljid); - win_println((ProfWin*)privwin, THEME_ONLINE, '-', "-- %s has joined the room.", jidp->resourcepart); + win_println((ProfWin*)privwin, THEME_ONLINE, "-", "-- %s has joined the room.", jidp->resourcepart); jid_destroy(jidp); } @@ -189,7 +189,7 @@ privwin_room_destroyed(ProfPrivateWin *privwin) privwin->room_left = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- %s has been destroyed.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- %s has been destroyed.", jidp->barejid); jid_destroy(jidp); } @@ -200,7 +200,7 @@ privwin_room_joined(ProfPrivateWin *privwin) privwin->room_left = FALSE; Jid *jidp = jid_create(privwin->fulljid); - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have joined %s.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have joined %s.", jidp->barejid); jid_destroy(jidp); } @@ -211,7 +211,7 @@ privwin_room_left(ProfPrivateWin *privwin) privwin->room_left = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have left %s.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have left %s.", jidp->barejid); jid_destroy(jidp); } @@ -234,7 +234,7 @@ privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char g_string_append(message, reason); } - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } @@ -257,7 +257,7 @@ privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char g_string_append(message, reason); } - win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "<- %s", message->str); g_string_free(message, TRUE); } diff --git a/src/ui/ui.h b/src/ui/ui.h index 8790e464..702da631 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -360,8 +360,8 @@ void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); -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_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); +void win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); void win_println_indent(ProfWin *window, int pad, const char *const message, ...); void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); diff --git a/src/ui/window.c b/src/ui/window.c index 815e6e93..9eaa0118 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -64,8 +64,8 @@ #define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) -static 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_id, const char *const message, ...); -static void _win_print_internal(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, +static 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_id, const char *const message, ...); +static void _win_print_internal(ProfWin *window, 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); static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent); @@ -761,7 +761,7 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, presence_colour, '-', "%s", occupant->nick); + win_print(window, presence_colour, "-", "%s", occupant->nick); win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { @@ -783,9 +783,9 @@ win_show_contact(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); if (name) { - win_print(window, presence_colour, '-', "%s", name); + win_print(window, presence_colour, "-", "%s", name); } else { - win_print(window, presence_colour, '-', "%s", barejid); + win_print(window, presence_colour, "-", "%s", barejid); } win_append(window, presence_colour, " is %s", presence); @@ -824,7 +824,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, presence_colour, '!', "%s", occupant->nick); + win_print(window, presence_colour, "!", "%s", occupant->nick); win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { @@ -834,11 +834,11 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); if (occupant->jid) { - win_println(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid); + win_println(window, THEME_DEFAULT, "!", " Jid: %s", occupant->jid); } - win_println(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation); - win_println(window, THEME_DEFAULT, '!', " Role: %s", occupant_role); + win_println(window, THEME_DEFAULT, "!", " Affiliation: %s", occupant_affiliation); + win_println(window, THEME_DEFAULT, "!", " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); @@ -848,7 +848,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, THEME_DEFAULT, '!', " Identity: "); + win_print(window, THEME_DEFAULT, "!", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { @@ -870,7 +870,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_print(window, THEME_DEFAULT, '!', " Software: %s", software_version->software); + win_print(window, THEME_DEFAULT, "!", " Software: %s", software_version->software); } if (software_version->software_version) { win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); @@ -879,7 +879,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); } if (software_version->os) { - win_print(window, THEME_DEFAULT, '!', " OS: %s", software_version->os); + win_print(window, THEME_DEFAULT, "!", " OS: %s", software_version->os); } if (software_version->os_version) { win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); @@ -892,7 +892,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa caps_destroy(caps); } - win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, "-", ""); } void @@ -906,15 +906,15 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_println(window, THEME_DEFAULT, '-', ""); - win_print(window, presence_colour, '-', "%s", barejid); + win_println(window, THEME_DEFAULT, "-", ""); + win_print(window, presence_colour, "-", "%s", barejid); if (name) { win_append(window, presence_colour, " (%s)", name); } win_appendln(window, THEME_DEFAULT, ":"); if (sub) { - win_println(window, THEME_DEFAULT, '-', "Subscription: %s", sub); + win_println(window, THEME_DEFAULT, "-", "Subscription: %s", sub); } if (last_activity) { @@ -928,10 +928,10 @@ win_show_info(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_println(window, THEME_DEFAULT, '-', "Last activity: %dh%dm%ds", hours, minutes, seconds); + win_println(window, THEME_DEFAULT, "-", "Last activity: %dh%dm%ds", hours, minutes, seconds); } else { - win_println(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds); + win_println(window, THEME_DEFAULT, "-", "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); @@ -940,7 +940,7 @@ win_show_info(ProfWin *window, PContact contact) GList *resources = p_contact_get_available_resources(contact); GList *ordered_resources = NULL; if (resources) { - win_println(window, THEME_DEFAULT, '-', "Resources:"); + win_println(window, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability GList *curr = resources; @@ -958,7 +958,7 @@ win_show_info(ProfWin *window, PContact contact) Resource *resource = curr->data; const char *resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); - win_print(window, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_print(window, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { win_append(window, presence_colour, ", \"%s\"", resource->status); } @@ -972,7 +972,7 @@ win_show_info(ProfWin *window, PContact contact) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, THEME_DEFAULT, '-', " Identity: "); + win_print(window, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { @@ -994,7 +994,7 @@ win_show_info(ProfWin *window, PContact contact) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_print(window, THEME_DEFAULT, '-', " Software: %s", software_version->software); + win_print(window, THEME_DEFAULT, "-", " Software: %s", software_version->software); } if (software_version->software_version) { win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); @@ -1003,7 +1003,7 @@ win_show_info(ProfWin *window, PContact contact) win_newline(window); } if (software_version->os) { - win_print(window, THEME_DEFAULT, '-', " OS: %s", software_version->os); + win_print(window, THEME_DEFAULT, "-", " OS: %s", software_version->os); } if (software_version->os_version) { win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); @@ -1037,7 +1037,7 @@ win_show_status_string(ProfWin *window, const char *const from, presence_colour = THEME_OFFLINE; } - win_print(window, presence_colour, '-', "%s %s", pre, from); + win_print(window, presence_colour, "-", "%s %s", pre, from); if (show) win_append(window, presence_colour, " is %s", show); @@ -1082,6 +1082,7 @@ _win_correct(ProfWin *window, const char *const message, const char *const id, c entry->date = buffer_date_new_now(); */ + free(entry->show_char); entry->show_char = prefs_get_correction_char(); if (entry->message) { @@ -1100,7 +1101,7 @@ _win_correct(ProfWin *window, const char *const message, const char *const id, c void win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMessage *message) { - char enc_char = '-'; + char *enc_char = "-"; int flags = NO_ME; if (!message->trusted) { @@ -1113,7 +1114,7 @@ win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMes { ProfChatWin *chatwin = (ProfChatWin*)window; if (chatwin->incoming_char) { - enc_char = chatwin->incoming_char[0]; + enc_char = strdup(chatwin->incoming_char); } else if (message->enc == PROF_MSG_ENC_OTR) { enc_char = prefs_get_otr_char(); } else if (message->enc == PROF_MSG_ENC_PGP) { @@ -1127,10 +1128,12 @@ win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMes } else { _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->id, "%s", message->plain); } + + free(enc_char); break; } case WIN_PRIVATE: - _win_printf(window, '-', 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->id, "%s", message->plain); + _win_printf(window, "-", 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->id, "%s", message->plain); break; default: assert(FALSE); @@ -1139,13 +1142,13 @@ win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMes } void -win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them) +win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them) { - _win_printf(window, ch, 0, NULL, flags | NO_ME | NO_EOL, theme_item, them, NULL, ""); + _win_printf(window, show_char, 0, NULL, flags | NO_ME | NO_EOL, theme_item, them, NULL, ""); } void -win_println_incoming_muc_msg(ProfWin *window, char ch, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message) +win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message) { //TODO: we always use current timestamp here. instead of the message->timestamp one if available. i think somewhere else we check whether it exists first. GDateTime *timestamp = g_date_time_new_now_local(); @@ -1153,34 +1156,34 @@ win_println_incoming_muc_msg(ProfWin *window, char ch, int flags, const char *co if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && replace_id) { _win_correct(window, message, id, replace_id); } else { - _win_printf(window, ch, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, id, "%s", message); + _win_printf(window, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, id, "%s", message); } -// buffer_append(window->layout->buffer, ch, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL, NULL); - // _win_print_internal(window, ch, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL); +// buffer_append(window->layout->buffer, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL, NULL); + // _win_print_internal(window, show_char, 0, timestamp, flags | NO_ME, THEME_TEXT_THEM, them, message, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); } void -win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message) { GDateTime *timestamp = g_date_time_new_now_local(); if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && replace_id) { _win_correct(window, message, id, replace_id); } else { - _win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, id, "%s", message); + _win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, me, id, "%s", message); } -// buffer_append(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, me, message, NULL, NULL); -// _win_print_internal(window, ch, 0, timestamp, 0, THEME_TEXT_ME, me, message, NULL); +// buffer_append(window->layout->buffer, show_char, 0, timestamp, 0, THEME_TEXT_ME, me, message, NULL, NULL); +// _win_print_internal(window, show_char, 0, timestamp, 0, THEME_TEXT_ME, me, message, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); } void -win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message) { //TODO: we always use current timestamp here. instead of the message->timestamp one if available. i think somewhere else we check whether it exists first. GDateTime *timestamp = g_date_time_new_now_local(); @@ -1188,7 +1191,7 @@ win_print_outgoing(ProfWin *window, const char ch, const char *const id, const c if (replace_id) { _win_correct(window, message, id, replace_id); } else { - _win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", message); + _win_printf(window, show_char, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", message); } inp_nonblocking(TRUE); @@ -1200,15 +1203,15 @@ win_print_history(ProfWin *window, GDateTime *timestamp, const char *const messa { g_date_time_ref(timestamp); - buffer_append(window->layout->buffer, '-', 0, timestamp, 0, THEME_TEXT_HISTORY, "", message, NULL, NULL); - _win_print_internal(window, '-', 0, timestamp, 0, THEME_TEXT_HISTORY, "", message, NULL); + buffer_append(window->layout->buffer, "-", 0, timestamp, 0, THEME_TEXT_HISTORY, "", message, NULL, NULL); + _win_print_internal(window, "-", 0, timestamp, 0, THEME_TEXT_HISTORY, "", message, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); } void -win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) +win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1217,8 +1220,8 @@ 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_append(window->layout->buffer, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, show_char, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL, NULL); + _win_print_internal(window, show_char, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1228,7 +1231,7 @@ win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *c } void -win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) +win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1237,8 +1240,8 @@ 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_append(window->layout->buffer, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, show_char, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL, NULL); + _win_print_internal(window, show_char, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1257,8 +1260,8 @@ 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_append(window->layout->buffer, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); + buffer_append(window->layout->buffer, "-", pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL, NULL); + _win_print_internal(window, "-", pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1277,8 +1280,8 @@ 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_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, '-', 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, NULL); + _win_print_internal(window, "-", 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1297,8 +1300,8 @@ 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_append(window->layout->buffer, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, '-', 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, NULL); + _win_print_internal(window, "-", 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1317,8 +1320,8 @@ 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_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, '-', 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, NULL); + _win_print_internal(window, "-", 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1337,8 +1340,8 @@ 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_append(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL, NULL); - _win_print_internal(window, '-', 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, NULL); + _win_print_internal(window, "-", 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); @@ -1350,11 +1353,11 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con void win_print_http_upload(ProfWin *window, const char *const message, char *url) { - win_print_outgoing_with_receipt(window, '!', NULL, message, url, NULL); + win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL); } void -win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id) +win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id) { GDateTime *time = g_date_time_new_now_local(); @@ -1407,7 +1410,7 @@ win_newline(ProfWin *window) } static void -_win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, +_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_id, const char *const message, ...) { if (timestamp == NULL) { @@ -1433,7 +1436,7 @@ _win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *ti } static void -_win_print_internal(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, +_win_print_internal(ProfWin *window, 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) { // flags : 1st bit = 0/1 - me/not me. define: NO_ME @@ -1488,7 +1491,7 @@ _win_print_internal(ProfWin *window, const char show_char, int pad_indent, GDate wbkgdset(window->layout->win, theme_attrs(THEME_TIME)); wattron(window->layout->win, theme_attrs(THEME_TIME)); } - wprintw(window->layout->win, "%s %c ", date_fmt, show_char); + wprintw(window->layout->win, "%s %s ", date_fmt, show_char); if ((flags & NO_COLOUR_DATE) == 0) { wattroff(window->layout->win, theme_attrs(THEME_TIME)); } @@ -1824,7 +1827,7 @@ win_command_list_error(ProfWin *window, const char *const error) { assert(window != NULL); - win_println(window, THEME_ERROR, '!', "Error retrieving command list: %s", error); + win_println(window, THEME_ERROR, "!", "Error retrieving command list: %s", error); } void @@ -1836,7 +1839,7 @@ win_command_exec_error(ProfWin *window, const char *const command, const char *c GString *msg = g_string_new(NULL); g_string_vprintf(msg, error, arg); - win_println(window, THEME_ERROR, '!', "Error executing command %s: %s", command, msg->str); + win_println(window, THEME_ERROR, "!", "Error executing command %s: %s", command, msg->str); g_string_free(msg, TRUE); va_end(arg); @@ -1848,17 +1851,17 @@ win_handle_command_list(ProfWin *window, GSList *cmds) assert(window != NULL); if (cmds) { - win_println(window, THEME_DEFAULT, '!', "Ad hoc commands:"); + win_println(window, THEME_DEFAULT, "!", "Ad hoc commands:"); GSList *curr_cmd = cmds; while (curr_cmd) { const char *cmd = curr_cmd->data; - win_println(window, THEME_DEFAULT, '!', " %s", cmd); + win_println(window, THEME_DEFAULT, "!", " %s", cmd); curr_cmd = g_slist_next(curr_cmd); } - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", ""); } else { - win_println(window, THEME_DEFAULT, '!', "No commands found"); - win_println(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, "!", "No commands found"); + win_println(window, THEME_DEFAULT, "!", ""); } } @@ -1866,14 +1869,14 @@ void win_handle_command_exec_status(ProfWin *window, const char *const command, const char *const value) { assert(window != NULL); - win_println(window, THEME_DEFAULT, '!', "%s %s", command, value); + win_println(window, THEME_DEFAULT, "!", "%s %s", command, value); } void win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value) { assert(window != NULL); - win_println(window, THEME_DEFAULT, '!', value); + win_println(window, THEME_DEFAULT, "!", value); } void @@ -1898,7 +1901,7 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) // the separator will actually be print in win_redraw(). // this only puts it in the buffer and win_redraw() will interpret it. // so that we have the correct length even when resizing. - buffer_append(window->layout->buffer, ' ', 0, time, 0, THEME_TEXT, NULL, "-", NULL, id); + buffer_append(window->layout->buffer, " ", 0, time, 0, THEME_TEXT, NULL, "-", NULL, id); win_redraw(window); g_date_time_unref(time); diff --git a/src/ui/window.h b/src/ui/window.h index 7927e009..7764c91a 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -62,12 +62,12 @@ void win_show_status_string(ProfWin *window, const char *const from, GDateTime *last_activity, const char *const pre, const char *const default_show); -void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them); +void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them); void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); -void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message); -void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id); -void win_println_incoming_muc_msg(ProfWin *window, char ch, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message); -void win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message); +void win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message); +void win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id); +void win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message); +void win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message); void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message); void win_print_http_upload(ProfWin *window, const char *const message, char *url); diff --git a/src/ui/window_list.c b/src/ui/window_list.c index c316ec6e..dd065c25 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -279,7 +279,7 @@ wins_private_nick_change(const char *const roomjid, const char *const oldnick, c Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); privwin->fulljid = strdup(newjid->fulljid); - win_println((ProfWin*)privwin, THEME_THEM, '!', "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); + win_println((ProfWin*)privwin, THEME_THEM, "!", "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); autocomplete_remove(wins_ac, oldjid->fulljid); autocomplete_remove(wins_close_ac, oldjid->fulljid); @@ -830,7 +830,7 @@ wins_lost_connection(void) while (curr) { ProfWin *window = curr->data; if (window->type != WIN_CONSOLE) { - win_println(window, THEME_ERROR, '-', "Lost connection."); + win_println(window, THEME_ERROR, "-", "Lost connection."); // if current win, set current_win_dirty if (wins_is_current(window)) { @@ -851,7 +851,7 @@ wins_reestablished_connection(void) while (curr) { ProfWin *window = curr->data; if (window->type != WIN_CONSOLE) { - win_println(window, THEME_TEXT, '-', "Connection re-established."); + win_println(window, THEME_TEXT, "-", "Connection re-established."); // if current win, set current_win_dirty if (wins_is_current(window)) { diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index 5f303de0..b6a085ef 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -46,13 +46,13 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) ProfWin *window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { - win_println(window, THEME_DEFAULT, '-', "SENT:"); - win_println(window, THEME_ONLINE, '-', "%s", &msg[6]); - win_println(window, THEME_ONLINE, '-', ""); + win_println(window, THEME_DEFAULT, "-", "SENT:"); + win_println(window, THEME_ONLINE, "-", "%s", &msg[6]); + win_println(window, THEME_ONLINE, "-", ""); } else if (g_str_has_prefix(msg, "RECV:")) { - win_println(window, THEME_DEFAULT, '-', "RECV:"); - win_println(window, THEME_AWAY, '-', "%s", &msg[6]); - win_println(window, THEME_AWAY, '-', ""); + win_println(window, THEME_DEFAULT, "-", "RECV:"); + win_println(window, THEME_AWAY, "-", "%s", &msg[6]); + win_println(window, THEME_AWAY, "-", ""); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index c60ebc08..f9f8a201 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -532,7 +532,7 @@ void win_show_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {} -void win_println(ProfWin *window, theme_item_t theme, const char ch, 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); @@ -541,7 +541,7 @@ void win_println(ProfWin *window, theme_item_t theme, const char ch, const char va_end(args); } -void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) {} +void win_print(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) |