From 16aa5693291334e0ecee4f93cefa8a56884180eb Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Mon, 4 May 2026 17:17:41 +0300 Subject: [PATCH] feat(history): /history backend command and status-bar indicator --- src/command/cmd_ac.c | 1 + src/command/cmd_defs.c | 3 +++ src/command/cmd_funcs.c | 9 +++++++++ src/ui/statusbar.c | 14 ++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index dbb86b39..e1be7656 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1146,6 +1146,7 @@ cmd_ac_init(void) autocomplete_add(history_ac, "on"); autocomplete_add(history_ac, "off"); + autocomplete_add(history_ac, "backend"); autocomplete_add(history_ac, "switch"); autocomplete_add(history_ac, "verify"); autocomplete_add(history_ac, "export"); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 7b7a3678..3dd130da 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1882,6 +1882,7 @@ static const struct cmd_t command_defs[] = { CMD_TAG_CHAT) CMD_SYN( "/history on|off", + "/history backend", "/history switch sqlite|flatfile", "/history verify []", "/history export []", @@ -1889,12 +1890,14 @@ static const struct cmd_t command_defs[] = { CMD_DESC( "Switch chat history on or off, /logging chat will automatically be enabled when this setting is on. " "When history is enabled, previous messages are shown in chat windows. " + "Use 'backend' to show the active database backend. " "Use 'switch' to change the active database backend at runtime without reconnecting. " "Use 'verify' to check integrity of stored message history. " "Use 'export' to copy messages from SQLite to flat-file format, or 'import' to copy from flat-file to SQLite. " "Both export and import merge with existing data (duplicates are skipped).") CMD_ARGS( { "on|off", "Enable or disable showing chat history." }, + { "backend", "Show the name of the active database backend." }, { "switch sqlite|flatfile", "Switch the active database backend at runtime." }, { "verify []", "Verify integrity of message history. Optionally specify a JID to check only one contact." }, { "export []", "Export SQLite history to flat-file format. Optionally specify a JID to export only one contact." }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 442a4e99..722de40f 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6785,6 +6785,15 @@ cmd_history(ProfWin* window, const char* const command, gchar** args) return TRUE; } + if (g_strcmp0(args[0], "backend") == 0) { + if (active_db_backend && active_db_backend->name) { + cons_show("Active database backend: %s", active_db_backend->name); + } else { + cons_show("No database backend is currently active."); + } + return TRUE; + } + if (g_strcmp0(args[0], "switch") == 0) { jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 49b37e8b..6dc157ea 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -52,6 +52,7 @@ #include "config/theme.h" #include "config/preferences.h" +#include "database.h" #include "ui/ui.h" #include "ui/statusbar.h" #include "ui/inputwin.h" @@ -83,6 +84,7 @@ static WINDOW* statusbar_win; void _get_range_bounds(int* start, int* end, gboolean is_static); static int _status_bar_draw_time(int pos); static int _status_bar_draw_maintext(int pos); +static int _status_bar_draw_dbbackend(int pos); static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch); static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static); static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets); @@ -313,6 +315,7 @@ status_bar_draw(void) pos = _status_bar_draw_time(pos); pos = _status_bar_draw_maintext(pos); + pos = _status_bar_draw_dbbackend(pos); if (max_tabs != 0) pos = _status_bar_draw_tabs(pos); @@ -603,6 +606,17 @@ _status_bar_draw_maintext(int pos) return pos; } +static int +_status_bar_draw_dbbackend(int pos) +{ + if (!active_db_backend || !active_db_backend->name) + return pos; + + auto_gchar gchar* label = g_strdup_printf(" [%s]", active_db_backend->name); + mvwprintw(statusbar_win, 0, pos, "%s", label); + return pos + utf8_display_len(label); +} + static void _destroy_tab(StatusBarTab* tab) {