feat(history): consolidate logging controls and add dbbackend statusbar indicator
All checks were successful
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 33s
CI Code / Code Coverage (push) Successful in 2m42s
CI Code / Linux (debian) (push) Successful in 4m40s
CI Code / Linux (ubuntu) (push) Successful in 4m53s
CI Code / Linux (arch) (push) Successful in 5m38s
All checks were successful
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 33s
CI Code / Code Coverage (push) Successful in 2m42s
CI Code / Linux (debian) (push) Successful in 4m40s
CI Code / Linux (ubuntu) (push) Successful in 4m53s
CI Code / Linux (arch) (push) Successful in 5m38s
Deprecate /logging command in favor of /history for chat logging control.
/history off now stops persistence (sets PREF_DBLOG=off + PREF_CHLOG=false)
in addition to hiding history on open. /history on restores persistence
(re-enabling PREF_DBLOG=on if it was off) and PREF_CHLOG.
statusbar
- PREF_STATUSBAR_SHOW_DBBACKEND (default ON) gates the [sqlite] /
[flatfile] indicator; toggle via "/statusbar show|hide dbbackend"
/history off|on
- "/history off" now stops persistence as well as hiding history on
open: sets PREF_DBLOG=off + PREF_CHLOG=false in addition to
PREF_HISTORY=false
- "/history on" restores persistence (re-enabling PREF_DBLOG=on if
it was off) and PREF_CHLOG, in addition to PREF_HISTORY=true
/logging
- Deprecated /logging command. It now prints a single notice
pointing to /history; CMD_PREAMBLE trimmed (min_args=0, no
setting_func, syntax/args/examples dropped); subcommand 'group'
removed from autocomplete
- All "use '/logging chat on' to enable" hints replaced with
"/history on" across /omemo-log, /pgp-log, /otr-log, and /ox-log
/privacy logging
- Single-pass validation across {on, off, redact, flatfile}
- Backend-switching values (on, flatfile) now take effect
immediately when connected (via log_database_switch_backend),
matching "/history switch" behaviour; off/redact only flip
pref bits and keep the live backend open
/correction off
- win_print_outgoing and win_print_outgoing_with_receipt now gate
_win_correct on PREF_CORRECTION_ALLOW, matching incoming-msg
paths. Previously a peer's correction reflected via XEP-0280
carbons (or the user's own /correct invocation) was applied
in-buffer regardless of the pref
console
- Drop orphaned /logging chat reference from cons_privacy_setting()
- Delete cons_logging_setting() and remove its call from
cons_show_log_prefs()
autocomplete
- Add dbbackend to statusbar_show_ac
- Remove logging_ac entries for chat/group subcommands
- Remove _logging_autocomplete() param handler for chat subcommand
database_flatfile
- Two local g_strndup allocations switched from char* with manual
g_free to auto_gchar gchar* for automatic cleanup
tests
- Update test_cmd_otr.c to expect new /history-on warning messages
@author: jabber.developer2 <jabber.developer2@jabber.space>
This commit is contained in:
@@ -6002,6 +6002,12 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "dbbackend") == 0) {
|
||||
prefs_set_boolean(PREF_STATUSBAR_SHOW_DBBACKEND, TRUE);
|
||||
cons_show("Enabled showing database backend indicator.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -6035,6 +6041,12 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args)
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
if (g_strcmp0(args[1], "dbbackend") == 0) {
|
||||
prefs_set_boolean(PREF_STATUSBAR_SHOW_DBBACKEND, FALSE);
|
||||
cons_show("Disabled showing database backend indicator.");
|
||||
ui_resize();
|
||||
return TRUE;
|
||||
}
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -6668,36 +6680,48 @@ cmd_privacy(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "logging") == 0) {
|
||||
gchar* arg = args[1];
|
||||
const gchar* arg = args[1];
|
||||
if (arg == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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 if (g_strcmp0(arg, "flatfile") == 0) {
|
||||
auto_gchar gchar* ff_path = files_get_data_path(DIR_FLATLOG);
|
||||
cons_show("Using flat-file backend for message logging. Takes effect on next connection.");
|
||||
cons_show("Flatfile directory: %s", ff_path);
|
||||
prefs_set_string(PREF_DBLOG, arg);
|
||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||
prefs_set_boolean(PREF_HISTORY, TRUE);
|
||||
} else {
|
||||
const gboolean is_on = (g_strcmp0(arg, "on") == 0);
|
||||
const gboolean is_off = (g_strcmp0(arg, "off") == 0);
|
||||
const gboolean is_redact = (g_strcmp0(arg, "redact") == 0);
|
||||
const gboolean is_flatfile = (g_strcmp0(arg, "flatfile") == 0);
|
||||
|
||||
if (!is_on && !is_off && !is_redact && !is_flatfile) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
prefs_set_string(PREF_DBLOG, arg);
|
||||
prefs_set_boolean(PREF_CHLOG, !is_off);
|
||||
prefs_set_boolean(PREF_HISTORY, !is_off);
|
||||
|
||||
// For backend-switching values (on = sqlite, flatfile), apply the
|
||||
// change immediately when connected so the user does not have to
|
||||
// reconnect to see the new backend take effect. off/redact change
|
||||
// write semantics but keep the currently-open backend alive.
|
||||
if ((is_on || is_flatfile)
|
||||
&& active_db_backend
|
||||
&& connection_get_status() == JABBER_CONNECTED
|
||||
&& g_strcmp0(active_db_backend->name, is_on ? "sqlite" : "flatfile") != 0) {
|
||||
log_database_switch_backend(is_on ? "on" : "flatfile");
|
||||
}
|
||||
|
||||
if (is_on) {
|
||||
cons_show("Database logging enabled (sqlite).");
|
||||
} else if (is_off) {
|
||||
cons_show("Database logging disabled.");
|
||||
} else if (is_redact) {
|
||||
cons_show("Database logging set to redact (message bodies replaced with [REDACTED]).");
|
||||
} else if (is_flatfile) {
|
||||
auto_gchar gchar* ff_path = files_get_data_path(DIR_FLATLOG);
|
||||
cons_show("Database logging set to flat-file backend.");
|
||||
cons_show("Flatfile directory: %s", ff_path);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6707,26 +6731,7 @@ cmd_privacy(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean
|
||||
cmd_logging(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (args[0] == NULL) {
|
||||
cons_logging_setting();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp(args[0], "chat") == 0 && args[1] != NULL) {
|
||||
_cmd_set_boolean_preference(args[1], "Chat logging", PREF_CHLOG);
|
||||
|
||||
// if set to off, disable history
|
||||
if (strcmp(args[1], "off") == 0) {
|
||||
prefs_set_boolean(PREF_HISTORY, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else if (g_strcmp0(args[0], "group") == 0 && args[1] != NULL) {
|
||||
_cmd_set_boolean_preference(args[1], "Groupchat logging", PREF_GRLOG);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("The '/logging' command is deprecated, use '/history' instead.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6873,9 +6878,20 @@ cmd_history(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
_cmd_set_boolean_preference(args[0], "Chat history", PREF_HISTORY);
|
||||
|
||||
// if set to on, set chlog (/logging chat on)
|
||||
// /history off should stop persisting messages too, not just hide
|
||||
// existing history on chat-window open. /history on resumes
|
||||
// persistence (default backend) and parallel text chatlogs.
|
||||
if (strcmp(args[0], "on") == 0) {
|
||||
prefs_set_boolean(PREF_CHLOG, TRUE);
|
||||
auto_gchar gchar* dblog = prefs_get_string(PREF_DBLOG);
|
||||
if (g_strcmp0(dblog, "off") == 0) {
|
||||
prefs_set_string(PREF_DBLOG, "on");
|
||||
cons_show("Database logging re-enabled (sqlite).");
|
||||
}
|
||||
} else if (strcmp(args[0], "off") == 0) {
|
||||
prefs_set_boolean(PREF_CHLOG, FALSE);
|
||||
prefs_set_string(PREF_DBLOG, "off");
|
||||
cons_show("Database logging disabled.");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -7292,7 +7308,7 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_PGP_LOG, "on");
|
||||
cons_show("PGP 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else if (g_strcmp0(choice, "off") == 0) {
|
||||
prefs_set_string(PREF_PGP_LOG, "off");
|
||||
@@ -7301,7 +7317,7 @@ cmd_pgp(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_PGP_LOG, "redact");
|
||||
cons_show("PGP 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
@@ -7788,7 +7804,7 @@ cmd_ox_log(ProfWin* window, const char* const command, gchar** args)
|
||||
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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else if (g_strcmp0(choice, "off") == 0) {
|
||||
prefs_set_string(PREF_OX_LOG, "off");
|
||||
@@ -7797,7 +7813,7 @@ cmd_ox_log(ProfWin* window, const char* const command, gchar** args)
|
||||
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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
@@ -7837,7 +7853,7 @@ cmd_otr_log(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_OTR_LOG, "on");
|
||||
cons_show("OTR 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else if (g_strcmp0(choice, "off") == 0) {
|
||||
prefs_set_string(PREF_OTR_LOG, "off");
|
||||
@@ -7846,7 +7862,7 @@ cmd_otr_log(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_OTR_LOG, "redact");
|
||||
cons_show("OTR 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
@@ -8783,7 +8799,7 @@ cmd_omemo_log(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_OMEMO_LOG, "on");
|
||||
cons_show("OMEMO 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else if (g_strcmp0(choice, "off") == 0) {
|
||||
prefs_set_string(PREF_OMEMO_LOG, "off");
|
||||
@@ -8792,7 +8808,7 @@ cmd_omemo_log(ProfWin* window, const char* const command, gchar** args)
|
||||
prefs_set_string(PREF_OMEMO_LOG, "redact");
|
||||
cons_show("OMEMO 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.");
|
||||
cons_show("Chat logging is currently disabled, use '/history on' to enable.");
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
|
||||
Reference in New Issue
Block a user