From 36713a2ed73368cf1892ce1fa43bb74106657391 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 17 Feb 2020 08:31:46 +0100 Subject: Make /sendfile in OMEMO session configurable `/omemo sendfile on` allows unencrypted file transfer in an OMEMO session. Regards https://github.com/profanity-im/profanity/pull/1270 --- src/command/cmd_funcs.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/command/cmd_funcs.c') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 8ac15535..e5c540c3 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4802,8 +4802,10 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) { ProfMucWin *mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - if (mucwin->is_omemo) { //no pgp or otr available in MUCs - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + + // only omemo, no pgp/otr available in MUCs + if (mucwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) { + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); free(filename); return TRUE; @@ -4814,12 +4816,15 @@ cmd_sendfile(ProfWin *window, const char *const command, gchar **args) { ProfChatWin *chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - if (chatwin->pgp_send || chatwin->is_omemo || chatwin->is_otr) { - cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); - win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); - free(filename); - return TRUE; - } + + if ((chatwin->is_omemo && !prefs_get_boolean(PREF_OMEMO_SENDFILE)) + || (chatwin->pgp_send) + || (chatwin->is_otr)) { + cons_show_error("Uploading '%s' failed: Encrypted file uploads not yet implemented!", filename); + win_println(window, THEME_ERROR, '-', "Sending encrypted files via http_upload is not possible yet."); + free(filename); + return TRUE; + } break; } case WIN_PRIVATE: @@ -8575,6 +8580,19 @@ cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args) #endif } +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) { -- cgit 1.4.1-2-gfad0