aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2022-05-05 23:41:45 +0200
committerMichael Vetter <jubalh@iodoru.org>2022-05-05 23:41:45 +0200
commitd011d6707c59b39dec9e83611592ee9c4b0b5a4d (patch)
tree5d4e4afb68fe133414993ead9b020f02414fb9b0 /src/command
parent66eeccf4089de61d2cb029f057d1d58bdbb6ab73 (diff)
downloadprofani-tty-d011d6707c59b39dec9e83611592ee9c4b0b5a4d.tar.gz
ox: Add /ox log command
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c6
-rw-r--r--src/command/cmd_defs.c3
-rw-r--r--src/command/cmd_funcs.c25
-rw-r--r--src/command/cmd_funcs.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 1a29c9cc..508c6f21 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -893,6 +893,11 @@ cmd_ac_init(void)
autocomplete_add(ox_ac, "announce");
autocomplete_add(ox_ac, "discover");
autocomplete_add(ox_ac, "request");
+
+ ox_log_ac = autocomplete_new();
+ autocomplete_add(ox_log_ac, "on");
+ autocomplete_add(ox_log_ac, "off");
+ autocomplete_add(ox_log_ac, "redact");
#endif
tls_ac = autocomplete_new();
@@ -1443,6 +1448,7 @@ cmd_ac_reset(ProfWin* window)
autocomplete_reset(pgp_log_ac);
autocomplete_reset(pgp_sendfile_ac);
autocomplete_reset(ox_ac);
+ autocomplete_reset(ox_log_ac);
#endif
autocomplete_reset(tls_ac);
autocomplete_reset(titlebar_ac);
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index b816ddcc..f2cc1513 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1715,7 +1715,8 @@ static struct cmd_t command_defs[] = {
#ifdef HAVE_LIBGPGME
{ "/ox",
parse_args, 1, 3, NULL,
- CMD_NOSUBFUNCS
+ CMD_SUBFUNCS(
+ { "log", cmd_ox_log })
CMD_MAINFUNC(cmd_ox)
CMD_TAGS(
CMD_TAG_CHAT,
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index f1fa37f1..9d6441b1 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -7725,6 +7725,31 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args)
}
return TRUE;
}
+
+gboolean
+cmd_ox_log(ProfWin* window, const char* const command, gchar** args)
+{
+ char* choice = args[1];
+ if (g_strcmp0(choice, "on") == 0) {
+ prefs_set_string(PREF_OX_LOG, "on");
+ cons_show("OX messages will be logged as plaintext.");
+ if (!prefs_get_boolean(PREF_CHLOG)) {
+ cons_show("Chat logging is currently disabled, use '/logging chat on' to enable.");
+ }
+ } else if (g_strcmp0(choice, "off") == 0) {
+ prefs_set_string(PREF_OX_LOG, "off");
+ cons_show("OX message logging disabled.");
+ } else if (g_strcmp0(choice, "redact") == 0) {
+ prefs_set_string(PREF_OX_LOG, "redact");
+ cons_show("OX messages will be logged as '[redacted]'.");
+ if (!prefs_get_boolean(PREF_CHLOG)) {
+ cons_show("Chat logging is currently disabled, use '/logging chat on' to enable.");
+ }
+ } else {
+ cons_bad_cmd_usage(command);
+ }
+ return TRUE;
+}
#endif // HAVE_LIBGPGME
gboolean
diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h
index 41074720..d0a6a543 100644
--- a/src/command/cmd_funcs.h
+++ b/src/command/cmd_funcs.h
@@ -110,6 +110,7 @@ gboolean cmd_notify(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_pgp(ProfWin* window, const char* const command, gchar** args);
#ifdef HAVE_LIBGPGME
gboolean cmd_ox(ProfWin* window, const char* const command, gchar** args);
+gboolean cmd_ox_log(ProfWin* window, const char* const command, gchar** args);
#endif // HAVE_LIBGPGME
gboolean cmd_outtype(ProfWin* window, const char* const command, gchar** args);
gboolean cmd_prefs(ProfWin* window, const char* const command, gchar** args);