about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-02-17 08:31:46 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-02-17 08:31:46 +0100
commit36713a2ed73368cf1892ce1fa43bb74106657391 (patch)
treeabb484bef8c8017df07a21eb81de2966323e956a /src/command/cmd_funcs.c
parent674a8aaf7ec08f9ec8be79e41cc7d4c8f3e81970 (diff)
downloadprofani-tty-36713a2ed73368cf1892ce1fa43bb74106657391.tar.gz
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
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c34
1 files changed, 26 insertions, 8 deletions
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:
@@ -8576,6 +8581,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");