mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 08:26:21 +00:00
Add /privacy logging command
Add ability to completely turn logs off, Needed since `/logging` and `/history` didn't stop history logging in the DB, only in files. Command might break something on usage, hence it was primarily introduced for privacy geeks. Privacy command discussion #1836
This commit is contained in:
@@ -122,6 +122,7 @@ static char* _clear_autocomplete(ProfWin* window, const char* const input, gbool
|
||||
static char* _invite_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _status_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _logging_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _privacy_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _color_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _avatar_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
static char* _correction_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||
@@ -269,6 +270,8 @@ static Autocomplete status_ac;
|
||||
static Autocomplete status_state_ac;
|
||||
static Autocomplete logging_ac;
|
||||
static Autocomplete logging_group_ac;
|
||||
static Autocomplete privacy_ac;
|
||||
static Autocomplete privacy_log_ac;
|
||||
static Autocomplete color_ac;
|
||||
static Autocomplete correction_ac;
|
||||
static Autocomplete avatar_ac;
|
||||
@@ -1070,6 +1073,14 @@ cmd_ac_init(void)
|
||||
autocomplete_add(logging_ac, "chat");
|
||||
autocomplete_add(logging_ac, "group");
|
||||
|
||||
privacy_ac = autocomplete_new();
|
||||
autocomplete_add(privacy_ac, "logging");
|
||||
|
||||
privacy_log_ac = autocomplete_new();
|
||||
autocomplete_add(privacy_log_ac, "on");
|
||||
autocomplete_add(privacy_log_ac, "off");
|
||||
autocomplete_add(privacy_log_ac, "redact");
|
||||
|
||||
logging_group_ac = autocomplete_new();
|
||||
autocomplete_add(logging_group_ac, "on");
|
||||
autocomplete_add(logging_group_ac, "off");
|
||||
@@ -1330,6 +1341,7 @@ cmd_ac_init(void)
|
||||
g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/log", _log_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/privacy", _privacy_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/mood", _mood_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/notify", _notify_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/occupants", _occupants_autocomplete);
|
||||
@@ -1682,6 +1694,8 @@ cmd_ac_reset(ProfWin* window)
|
||||
autocomplete_reset(status_state_ac);
|
||||
autocomplete_reset(logging_ac);
|
||||
autocomplete_reset(logging_group_ac);
|
||||
autocomplete_reset(privacy_ac);
|
||||
autocomplete_reset(privacy_log_ac);
|
||||
autocomplete_reset(color_ac);
|
||||
autocomplete_reset(correction_ac);
|
||||
autocomplete_reset(avatar_ac);
|
||||
@@ -1867,6 +1881,8 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(status_state_ac);
|
||||
autocomplete_free(logging_ac);
|
||||
autocomplete_free(logging_group_ac);
|
||||
autocomplete_free(privacy_ac);
|
||||
autocomplete_free(privacy_log_ac);
|
||||
autocomplete_free(color_ac);
|
||||
autocomplete_free(correction_ac);
|
||||
autocomplete_free(avatar_ac);
|
||||
@@ -4213,6 +4229,24 @@ _status_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_privacy_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
{
|
||||
char* found = NULL;
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/privacy", privacy_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
found = autocomplete_param_with_ac(input, "/privacy logging", privacy_log_ac, TRUE, previous);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static char*
|
||||
_logging_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
{
|
||||
|
||||
@@ -2720,6 +2720,21 @@ static const struct cmd_t command_defs[] = {
|
||||
"/strophe verbosity 3",
|
||||
"/strophe sm no-resend")
|
||||
},
|
||||
|
||||
{ CMD_PREAMBLE("/privacy",
|
||||
parse_args, 2, 3, NULL)
|
||||
CMD_MAINFUNC(cmd_privacy)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_CHAT)
|
||||
CMD_SYN(
|
||||
"/privacy logging on|redact|off")
|
||||
CMD_DESC(
|
||||
"Configure privacy settings.")
|
||||
CMD_ARGS(
|
||||
{ "logging on|redact|off", "Switch chat logging. This will also disable logging in the internally used SQL database. Your messages will not be saved anywhere locally. This might have unintended consequences, such as not being able to decrypt OMEMO encrypted messages received later via MAM, and should be used with caution." })
|
||||
CMD_EXAMPLES(
|
||||
"/privacy logging off")
|
||||
},
|
||||
// NEXT-COMMAND (search helper)
|
||||
};
|
||||
|
||||
|
||||
@@ -6949,6 +6949,44 @@ cmd_autoconnect(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_privacy(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (args[0] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "logging") == 0) {
|
||||
gchar* arg = args[1];
|
||||
if (arg == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(arg, "on") == 0) {
|
||||
cons_show("Logging enabled.");
|
||||
prefs_set_string(PREF_DBLOG, arg);
|
||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||
prefs_set_boolean(PREF_HISTORY, TRUE);
|
||||
} else if (g_strcmp0(arg, "off") == 0) {
|
||||
cons_show("Logging disabled.");
|
||||
prefs_set_string(PREF_DBLOG, arg);
|
||||
prefs_set_boolean(PREF_CHLOG, FALSE);
|
||||
prefs_set_boolean(PREF_HISTORY, FALSE);
|
||||
} else if (g_strcmp0(arg, "redact") == 0) {
|
||||
cons_show("Messages are going to be redacted.");
|
||||
prefs_set_string(PREF_DBLOG, arg);
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_logging(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
@@ -6967,10 +7005,7 @@ cmd_logging(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "group") == 0 && args[1] != NULL) {
|
||||
if (g_strcmp0(args[1], "on") == 0 || g_strcmp0(args[1], "off") == 0) {
|
||||
_cmd_set_boolean_preference(args[1], "Groupchat logging", PREF_GRLOG);
|
||||
return TRUE;
|
||||
}
|
||||
return _cmd_set_boolean_preference(args[1], "Groupchat logging", PREF_GRLOG);
|
||||
}
|
||||
|
||||
cons_bad_cmd_usage(command);
|
||||
|
||||
@@ -112,6 +112,7 @@ gboolean cmd_msg(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_nick(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_notify(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_pgp(ProfWin* window, const char* const command, gchar** args);
|
||||
gboolean cmd_privacy(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);
|
||||
|
||||
Reference in New Issue
Block a user