mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 15:03:03 +01:00
Add config option to set data file auto-save frequency
This commit is contained in:
parent
e4abd8b36b
commit
73aaa44d12
@ -1,10 +1,10 @@
|
|||||||
# Doc target
|
# Doc target
|
||||||
doc: $(MANFILES:%=$(DOC_DIR)/%)
|
doc: $(MANFILES:%=$(DOC_DIR)/%)
|
||||||
|
|
||||||
$(DOC_DIR)/%: $(DOC_DIR)/%.asc
|
$(DOC_DIR)/%: $(DOC_DIR)/%.asc
|
||||||
@echo " MAN $(@F)"
|
@echo " MAN $(@F)"
|
||||||
@a2x -f manpage -a revdate=$(shell git log -1 --date=short --format="%ad" $<) \
|
@a2x -f manpage -a revdate=$(shell git log -1 --date=short --format="%ad" $<) \
|
||||||
-a manmanual="Toxic Manual" -a mansource=toxic \
|
-a manmanual="Toxic Manual" -a mansource=toxic \
|
||||||
-a manversion=__VERSION__ -a datadir=__DATADIR__ $<
|
-a manversion=__VERSION__ -a datadir=__DATADIR__ $<
|
||||||
|
|
||||||
.PHONY: doc
|
.PHONY: doc
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
.\" Title: toxic.conf
|
.\" Title: toxic.conf
|
||||||
.\" Author: [see the "AUTHORS" section]
|
.\" Author: [see the "AUTHORS" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 2016-09-20
|
.\" Date: 2018-10-27
|
||||||
.\" Manual: Toxic Manual
|
.\" Manual: Toxic Manual
|
||||||
.\" Source: toxic __VERSION__
|
.\" Source: toxic __VERSION__
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "TOXIC\&.CONF" "5" "2016\-09\-20" "toxic __VERSION__" "Toxic Manual"
|
.TH "TOXIC\&.CONF" "5" "2018\-10\-27" "toxic __VERSION__" "Toxic Manual"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
@ -120,7 +120,12 @@ Enable friend connection change notifications\&. true or false
|
|||||||
.PP
|
.PP
|
||||||
\fBnodelist_update_freq\fR
|
\fBnodelist_update_freq\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
How often in days to update the DHT nodes list\&. (0 to disable updates)
|
How often in days to update the DHT nodes list\&. (integer; 0 to disable)
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
\fBautosave_freq\fR
|
||||||
|
.RS 4
|
||||||
|
How often in seconds to auto\-save the Tox data file\&. (integer; 0 to disable)
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
\fBhistory_size\fR
|
\fBhistory_size\fR
|
||||||
|
@ -76,7 +76,10 @@ OPTIONS
|
|||||||
Enable friend connection change notifications. true or false
|
Enable friend connection change notifications. true or false
|
||||||
|
|
||||||
*nodelist_update_freq*;;
|
*nodelist_update_freq*;;
|
||||||
How often in days to update the DHT nodes list. (0 to disable updates)
|
How often in days to update the DHT nodes list. (integer; 0 to disable)
|
||||||
|
|
||||||
|
*autosave_freq*;;
|
||||||
|
How often in seconds to auto-save the Tox data file. (integer; 0 to disable)
|
||||||
|
|
||||||
*history_size*;;
|
*history_size*;;
|
||||||
Maximum lines for chat window history. Integer value. (for example: 700)
|
Maximum lines for chat window history. Integer value. (for example: 700)
|
||||||
|
@ -47,6 +47,9 @@ ui = {
|
|||||||
// How often in days to update the DHT nodes list. (0 to disable updates)
|
// How often in days to update the DHT nodes list. (0 to disable updates)
|
||||||
nodeslist_update_freq=7;
|
nodeslist_update_freq=7;
|
||||||
|
|
||||||
|
// How often in seconds to auto-save the Tox data file. (0 to disable periodic auto-saves)
|
||||||
|
autosave_freq=600;
|
||||||
|
|
||||||
// maximum lines for chat window history
|
// maximum lines for chat window history
|
||||||
history_size=700;
|
history_size=700;
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ static const char special_commands[SPECIAL_COMMANDS][MAX_CMDNAME_SIZE] = {
|
|||||||
#ifdef PYTHON
|
#ifdef PYTHON
|
||||||
"/run",
|
"/run",
|
||||||
#endif /* PYTHON */
|
#endif /* PYTHON */
|
||||||
"/title",
|
|
||||||
"/sendfile",
|
"/sendfile",
|
||||||
|
"/title",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Returns true if input command is in the special_commands array. */
|
/* Returns true if input command is in the special_commands array. */
|
||||||
|
@ -63,6 +63,7 @@ static struct ui_strings {
|
|||||||
const char *show_welcome_msg;
|
const char *show_welcome_msg;
|
||||||
const char *show_connection_msg;
|
const char *show_connection_msg;
|
||||||
const char *nodeslist_update_freq;
|
const char *nodeslist_update_freq;
|
||||||
|
const char *autosave_freq;
|
||||||
|
|
||||||
const char *line_join;
|
const char *line_join;
|
||||||
const char *line_quit;
|
const char *line_quit;
|
||||||
@ -90,6 +91,7 @@ static struct ui_strings {
|
|||||||
"show_welcome_msg",
|
"show_welcome_msg",
|
||||||
"show_connection_msg",
|
"show_connection_msg",
|
||||||
"nodeslist_update_freq",
|
"nodeslist_update_freq",
|
||||||
|
"autosave_freq",
|
||||||
"line_join",
|
"line_join",
|
||||||
"line_quit",
|
"line_quit",
|
||||||
"line_alert",
|
"line_alert",
|
||||||
@ -117,6 +119,7 @@ static void ui_defaults(struct user_settings *settings)
|
|||||||
settings->show_welcome_msg = SHOW_WELCOME_MSG_ON;
|
settings->show_welcome_msg = SHOW_WELCOME_MSG_ON;
|
||||||
settings->show_connection_msg = SHOW_CONNECTION_MSG_ON;
|
settings->show_connection_msg = SHOW_CONNECTION_MSG_ON;
|
||||||
settings->nodeslist_update_freq = 7;
|
settings->nodeslist_update_freq = 7;
|
||||||
|
settings->autosave_freq = 600;
|
||||||
|
|
||||||
snprintf(settings->line_join, LINE_HINT_MAX + 1, "%s", LINE_JOIN);
|
snprintf(settings->line_join, LINE_HINT_MAX + 1, "%s", LINE_JOIN);
|
||||||
snprintf(settings->line_quit, LINE_HINT_MAX + 1, "%s", LINE_QUIT);
|
snprintf(settings->line_quit, LINE_HINT_MAX + 1, "%s", LINE_QUIT);
|
||||||
@ -370,6 +373,7 @@ int settings_load(struct user_settings *s, const char *patharg)
|
|||||||
|
|
||||||
config_setting_lookup_int(setting, ui_strings.history_size, &s->history_size);
|
config_setting_lookup_int(setting, ui_strings.history_size, &s->history_size);
|
||||||
config_setting_lookup_int(setting, ui_strings.nodeslist_update_freq, &s->nodeslist_update_freq);
|
config_setting_lookup_int(setting, ui_strings.nodeslist_update_freq, &s->nodeslist_update_freq);
|
||||||
|
config_setting_lookup_int(setting, ui_strings.autosave_freq, &s->autosave_freq);
|
||||||
|
|
||||||
if (config_setting_lookup_string(setting, ui_strings.line_join, &str)) {
|
if (config_setting_lookup_string(setting, ui_strings.line_join, &str)) {
|
||||||
snprintf(s->line_join, sizeof(s->line_join), "%s", str);
|
snprintf(s->line_join, sizeof(s->line_join), "%s", str);
|
||||||
|
@ -54,6 +54,7 @@ struct user_settings {
|
|||||||
int show_welcome_msg; /* boolean */
|
int show_welcome_msg; /* boolean */
|
||||||
int show_connection_msg; /* boolean */
|
int show_connection_msg; /* boolean */
|
||||||
int nodeslist_update_freq; /* int (<= 0 to disable updates) */
|
int nodeslist_update_freq; /* int (<= 0 to disable updates) */
|
||||||
|
int autosave_freq; /* int (<= 0 to disable autosave) */
|
||||||
|
|
||||||
char line_join[LINE_HINT_MAX + 1];
|
char line_join[LINE_HINT_MAX + 1];
|
||||||
char line_quit[LINE_HINT_MAX + 1];
|
char line_quit[LINE_HINT_MAX + 1];
|
||||||
|
@ -94,7 +94,6 @@ ToxWindow *prompt = NULL;
|
|||||||
#define DATANAME "toxic_profile.tox"
|
#define DATANAME "toxic_profile.tox"
|
||||||
#define BLOCKNAME "toxic_blocklist"
|
#define BLOCKNAME "toxic_blocklist"
|
||||||
|
|
||||||
#define AUTOSAVE_FREQ 600
|
|
||||||
#define MIN_PASSWORD_LEN 6
|
#define MIN_PASSWORD_LEN 6
|
||||||
#define MAX_PASSWORD_LEN 64
|
#define MAX_PASSWORD_LEN 64
|
||||||
|
|
||||||
@ -1364,7 +1363,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
time_t cur_time = get_unix_time();
|
time_t cur_time = get_unix_time();
|
||||||
|
|
||||||
if (timed_out(last_save, AUTOSAVE_FREQ)) {
|
if (user_settings->autosave_freq > 0 && timed_out(last_save, user_settings->autosave_freq)) {
|
||||||
pthread_mutex_lock(&Winthread.lock);
|
pthread_mutex_lock(&Winthread.lock);
|
||||||
|
|
||||||
if (store_data(m, DATA_FILE) != 0) {
|
if (store_data(m, DATA_FILE) != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user