feat(history): /history backend command and status-bar indicator
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 10m31s
CI Code / Check spelling (pull_request) Failing after 11m2s
CI Code / Check coding style (pull_request) Failing after 11m33s
CI Code / Linux (ubuntu) (pull_request) Failing after 12m2s
CI Code / Linux (debian) (pull_request) Failing after 12m33s
CI Code / Linux (arch) (pull_request) Failing after 13m5s
Some checks failed
CI Code / Code Coverage (pull_request) Failing after 10m31s
CI Code / Check spelling (pull_request) Failing after 11m2s
CI Code / Check coding style (pull_request) Failing after 11m33s
CI Code / Linux (ubuntu) (pull_request) Failing after 12m2s
CI Code / Linux (debian) (pull_request) Failing after 12m33s
CI Code / Linux (arch) (pull_request) Failing after 13m5s
This commit is contained in:
@@ -1146,6 +1146,7 @@ cmd_ac_init(void)
|
|||||||
|
|
||||||
autocomplete_add(history_ac, "on");
|
autocomplete_add(history_ac, "on");
|
||||||
autocomplete_add(history_ac, "off");
|
autocomplete_add(history_ac, "off");
|
||||||
|
autocomplete_add(history_ac, "backend");
|
||||||
autocomplete_add(history_ac, "switch");
|
autocomplete_add(history_ac, "switch");
|
||||||
autocomplete_add(history_ac, "verify");
|
autocomplete_add(history_ac, "verify");
|
||||||
autocomplete_add(history_ac, "export");
|
autocomplete_add(history_ac, "export");
|
||||||
|
|||||||
@@ -1882,6 +1882,7 @@ static const struct cmd_t command_defs[] = {
|
|||||||
CMD_TAG_CHAT)
|
CMD_TAG_CHAT)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/history on|off",
|
"/history on|off",
|
||||||
|
"/history backend",
|
||||||
"/history switch sqlite|flatfile",
|
"/history switch sqlite|flatfile",
|
||||||
"/history verify [<jid>]",
|
"/history verify [<jid>]",
|
||||||
"/history export [<jid>]",
|
"/history export [<jid>]",
|
||||||
@@ -1889,12 +1890,14 @@ static const struct cmd_t command_defs[] = {
|
|||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Switch chat history on or off, /logging chat will automatically be enabled when this setting is on. "
|
"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. "
|
"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 'switch' to change the active database backend at runtime without reconnecting. "
|
||||||
"Use 'verify' to check integrity of stored message history. "
|
"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. "
|
"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).")
|
"Both export and import merge with existing data (duplicates are skipped).")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "on|off", "Enable or disable showing chat history." },
|
{ "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." },
|
{ "switch sqlite|flatfile", "Switch the active database backend at runtime." },
|
||||||
{ "verify [<jid>]", "Verify integrity of message history. Optionally specify a JID to check only one contact." },
|
{ "verify [<jid>]", "Verify integrity of message history. Optionally specify a JID to check only one contact." },
|
||||||
{ "export [<jid>]", "Export SQLite history to flat-file format. Optionally specify a JID to export only one contact." },
|
{ "export [<jid>]", "Export SQLite history to flat-file format. Optionally specify a JID to export only one contact." },
|
||||||
|
|||||||
@@ -6785,6 +6785,15 @@ cmd_history(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
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) {
|
if (g_strcmp0(args[0], "switch") == 0) {
|
||||||
jabber_conn_status_t conn_status = connection_get_status();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
if (conn_status != JABBER_CONNECTED) {
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include "config/theme.h"
|
#include "config/theme.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
|
#include "database.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/statusbar.h"
|
#include "ui/statusbar.h"
|
||||||
#include "ui/inputwin.h"
|
#include "ui/inputwin.h"
|
||||||
@@ -83,6 +84,7 @@ static WINDOW* statusbar_win;
|
|||||||
void _get_range_bounds(int* start, int* end, gboolean is_static);
|
void _get_range_bounds(int* start, int* end, gboolean is_static);
|
||||||
static int _status_bar_draw_time(int pos);
|
static int _status_bar_draw_time(int pos);
|
||||||
static int _status_bar_draw_maintext(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_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_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);
|
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_time(pos);
|
||||||
pos = _status_bar_draw_maintext(pos);
|
pos = _status_bar_draw_maintext(pos);
|
||||||
|
pos = _status_bar_draw_dbbackend(pos);
|
||||||
if (max_tabs != 0)
|
if (max_tabs != 0)
|
||||||
pos = _status_bar_draw_tabs(pos);
|
pos = _status_bar_draw_tabs(pos);
|
||||||
|
|
||||||
@@ -603,6 +606,17 @@ _status_bar_draw_maintext(int pos)
|
|||||||
return 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
|
static void
|
||||||
_destroy_tab(StatusBarTab* tab)
|
_destroy_tab(StatusBarTab* tab)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user