diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-02-17 09:01:00 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-02-17 09:01:00 +0100 |
commit | 555e50cc92b03199379d8da027c305b6207e7eed (patch) | |
tree | a2b745af91f6e8456036ab4fff955e52e8269eb3 /src/command/cmd_funcs.c | |
parent | ca3afa7e05ae87158b6c1bfca1758763d4b0d8a2 (diff) | |
parent | 7955f4426281fb14523064f5359a2942ad5996e4 (diff) | |
download | profani-tty-555e50cc92b03199379d8da027c305b6207e7eed.tar.gz |
Merge branch 'feature/sendfile-enc-warn'
Close https://github.com/profanity-im/profanity/pull/1270
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r-- | src/command/cmd_funcs.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 93b002f4..4f617ffe 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4797,6 +4797,47 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) return TRUE; } + switch (window->type) { + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + + // 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."); + free(filename); + return TRUE; + } + break; + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + + if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) + || (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."); + free(filename); + return TRUE; + } + break; + } + case WIN_PRIVATE: + { + //we don't support encryption in private muc windows + break; + } + default: + cons_show_error("Unsupported window for file transmission."); + free(filename); + return TRUE; + } + if (access(filename, R_OK) != 0) { cons_show_error("Uploading '%s' failed: File not found!", filename); free(filename); @@ -7296,6 +7337,11 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) return TRUE; } + if (g_strcmp0(args[0], "sendfile") == 0) { + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files using /sendfile while otherwise using PGP", PREF_PGP_SENDFILE); + return TRUE; + } + cons_bad_cmd_usage(command); return TRUE; #else @@ -7770,6 +7816,19 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args) } gboolean +cmd_otr_sendfile(ProfWin *window, const char *const command, gchar **args) +{ +#ifdef HAVE_LIBOTR + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OTR session via /sendfile", PREF_OTR_SENDFILE); + + return TRUE; +#else + cons_show("This version of Profanity has not been built with OTR support enabled"); + return TRUE; +#endif +} + +gboolean cmd_command_list(ProfWin *window, const char *const command, gchar **args) { jabber_conn_status_t conn_status = connection_get_status(); @@ -8541,6 +8600,19 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args) } gboolean +cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args) +{ +#ifdef HAVE_OMEMO + _cmd_set_boolean_preference(args[1], command, "Sending unencrypted files in an OMEMO session via /sendfile", PREF_OMEMO_SENDFILE); + + return TRUE; +#else + cons_show("This version of Profanity has not been built with OMEMO support enabled"); + return TRUE; +#endif +} + +gboolean cmd_save(ProfWin *window, const char *const command, gchar **args) { log_info("Saving preferences to configuration file"); |