aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
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
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')
-rw-r--r--src/command/cmd_ac.c14
-rw-r--r--src/command/cmd_defs.c5
-rw-r--r--src/command/cmd_funcs.c34
-rw-r--r--src/command/cmd_funcs.h1
4 files changed, 44 insertions, 10 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 386e8939..0e65c3fd 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -176,6 +176,7 @@ static Autocomplete otr_policy_ac;
static Autocomplete omemo_ac;
static Autocomplete omemo_log_ac;
static Autocomplete omemo_policy_ac;
+static Autocomplete omemo_sendfile_ac;
static Autocomplete connect_property_ac;
static Autocomplete tls_property_ac;
static Autocomplete alias_ac;
@@ -626,6 +627,7 @@ cmd_ac_init(void)
autocomplete_add(omemo_ac, "clear_device_list");
autocomplete_add(omemo_ac, "policy");
autocomplete_add(omemo_ac, "char");
+ autocomplete_add(omemo_ac, "sendfile");
omemo_log_ac = autocomplete_new();
autocomplete_add(omemo_log_ac, "on");
@@ -637,6 +639,10 @@ cmd_ac_init(void)
autocomplete_add(omemo_policy_ac, "automatic");
autocomplete_add(omemo_policy_ac, "always");
+ omemo_sendfile_ac = autocomplete_new();
+ autocomplete_add(omemo_sendfile_ac, "on");
+ autocomplete_add(omemo_sendfile_ac, "off");
+
connect_property_ac = autocomplete_new();
autocomplete_add(connect_property_ac, "server");
autocomplete_add(connect_property_ac, "port");
@@ -1187,6 +1193,7 @@ cmd_ac_reset(ProfWin *window)
autocomplete_reset(omemo_ac);
autocomplete_reset(omemo_log_ac);
autocomplete_reset(omemo_policy_ac);
+ autocomplete_reset(omemo_sendfile_ac);
autocomplete_reset(connect_property_ac);
autocomplete_reset(tls_property_ac);
autocomplete_reset(alias_ac);
@@ -1331,6 +1338,7 @@ cmd_ac_uninit(void)
autocomplete_free(omemo_ac);
autocomplete_free(omemo_log_ac);
autocomplete_free(omemo_policy_ac);
+ autocomplete_free(omemo_sendfile_ac);
autocomplete_free(connect_property_ac);
autocomplete_free(tls_property_ac);
autocomplete_free(alias_ac);
@@ -2303,6 +2311,11 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
return found;
}
+ found = autocomplete_param_with_ac(input, "/omemo sendfile", omemo_sendfile_ac, TRUE, previous);
+ if (found) {
+ return found;
+ }
+
jabber_conn_status_t conn_status = connection_get_status();
if (conn_status == JABBER_CONNECTED) {
@@ -2316,7 +2329,6 @@ _omemo_autocomplete(ProfWin *window, const char *const input, gboolean previous)
return found;
}
-
#ifdef HAVE_OMEMO
if (window->type == WIN_CHAT) {
ProfChatWin *chatwin = (ProfChatWin*)window;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 78a2e342..5d3d0067 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2236,7 +2236,8 @@ static struct cmd_t command_defs[] =
{ "fingerprint", cmd_omemo_fingerprint },
{ "char", cmd_omemo_char },
{ "policy", cmd_omemo_policy },
- { "clear_device_list", cmd_omemo_clear_device_list })
+ { "clear_device_list", cmd_omemo_clear_device_list },
+ { "sendfile", cmd_omemo_sendfile} )
CMD_NOMAINFUNC
CMD_TAGS(
CMD_TAG_CHAT,
@@ -2250,6 +2251,7 @@ static struct cmd_t command_defs[] =
"/omemo fingerprint [<contact>]",
"/omemo char <char>",
"/omemo policy manual|automatic|always",
+ "/omemo sendfile on|off",
"/omemo clear_device_list")
CMD_DESC(
"OMEMO commands to manage keys, and perform encryption during chat sessions.")
@@ -2264,6 +2266,7 @@ static struct cmd_t command_defs[] =
{ "policy manual", "Set the global OMEMO policy to manual, OMEMO sessions must be started manually." },
{ "policy automatic", "Set the global OMEMO policy to opportunistic, an OMEMO session will be attempted upon starting a conversation." },
{ "policy always", "Set the global OMEMO policy to always, an error will be displayed if an OMEMO session cannot be initiated upon starting a conversation." },
+ { "sendfile", "Allow /sendfile to send unencrypted files while in an OMEMO session."},
{ "clear_device_list", "Clear your own device list on server side. Each client will reannounce itself when connected back."})
CMD_EXAMPLES(
"/omemo gen",
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");
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index f283c910..389c35de 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -219,6 +219,7 @@ gboolean cmd_omemo_trust(ProfWin *window, const char *const command, gchar **arg
gboolean cmd_omemo_untrust(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_policy(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_omemo_clear_device_list(ProfWin *window, const char *const command, gchar **args);
+gboolean cmd_omemo_sendfile(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_save(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_reload(ProfWin *window, const char *const command, gchar **args);