Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add config option to alter auto-update interval and update toxic version #37

Merged
merged 2 commits into from
Nov 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apidoc/python/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '0.8.2'
version = '0.8.3'
# The full version, including alpha/beta/rc tags.
release = '0.8.2'
release = '0.8.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion cfg/global_vars.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Version
TOXIC_VERSION = 0.8.2
TOXIC_VERSION = 0.8.3
REV = $(shell git rev-list HEAD --count 2>/dev/null || echo -n "error")
ifneq (, $(findstring error, $(REV)))
VERSION = $(TOXIC_VERSION)
Expand Down
4 changes: 2 additions & 2 deletions cfg/targets/doc.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Doc target
doc: $(MANFILES:%=$(DOC_DIR)/%)

$(DOC_DIR)/%: $(DOC_DIR)/%.asc
@echo " MAN $(@F)"
@a2x -f manpage -a revdate=$(shell git log -1 --date=short --format="%ad" $<) \
-a manmanual="Toxic Manual" -a mansource=toxic \
-a manversion=__VERSION__ -a datadir=__DATADIR__ $<

.PHONY: doc
11 changes: 8 additions & 3 deletions doc/toxic.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: toxic.conf
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 2016-09-20
.\" Date: 2018-10-27
.\" Manual: Toxic Manual
.\" Source: toxic __VERSION__
.\" 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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -120,7 +120,12 @@ Enable friend connection change notifications\&. true or false
.PP
\fBnodelist_update_freq\fR
.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
.PP
\fBhistory_size\fR
Expand Down
5 changes: 4 additions & 1 deletion doc/toxic.conf.5.asc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ OPTIONS
Enable friend connection change notifications. true or false

*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*;;
Maximum lines for chat window history. Integer value. (for example: 700)
Expand Down
3 changes: 3 additions & 0 deletions misc/toxic.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ ui = {
// How often in days to update the DHT nodes list. (0 to disable updates)
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
history_size=700;

Expand Down
2 changes: 1 addition & 1 deletion src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ static const char special_commands[SPECIAL_COMMANDS][MAX_CMDNAME_SIZE] = {
#ifdef PYTHON
"/run",
#endif /* PYTHON */
"/title",
"/sendfile",
"/title",
};

/* Returns true if input command is in the special_commands array. */
Expand Down
4 changes: 4 additions & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static struct ui_strings {
const char *show_welcome_msg;
const char *show_connection_msg;
const char *nodeslist_update_freq;
const char *autosave_freq;

const char *line_join;
const char *line_quit;
Expand Down Expand Up @@ -90,6 +91,7 @@ static struct ui_strings {
"show_welcome_msg",
"show_connection_msg",
"nodeslist_update_freq",
"autosave_freq",
"line_join",
"line_quit",
"line_alert",
Expand Down Expand Up @@ -117,6 +119,7 @@ static void ui_defaults(struct user_settings *settings)
settings->show_welcome_msg = SHOW_WELCOME_MSG_ON;
settings->show_connection_msg = SHOW_CONNECTION_MSG_ON;
settings->nodeslist_update_freq = 7;
settings->autosave_freq = 600;

snprintf(settings->line_join, LINE_HINT_MAX + 1, "%s", LINE_JOIN);
snprintf(settings->line_quit, LINE_HINT_MAX + 1, "%s", LINE_QUIT);
Expand Down Expand Up @@ -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.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)) {
snprintf(s->line_join, sizeof(s->line_join), "%s", str);
Expand Down
1 change: 1 addition & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct user_settings {
int show_welcome_msg; /* boolean */
int show_connection_msg; /* boolean */
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_quit[LINE_HINT_MAX + 1];
Expand Down
3 changes: 1 addition & 2 deletions src/toxic.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ ToxWindow *prompt = NULL;
#define DATANAME "toxic_profile.tox"
#define BLOCKNAME "toxic_blocklist"

#define AUTOSAVE_FREQ 600
#define MIN_PASSWORD_LEN 6
#define MAX_PASSWORD_LEN 64

Expand Down Expand Up @@ -1364,7 +1363,7 @@ int main(int argc, char **argv)

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);

if (store_data(m, DATA_FILE) != 0) {
Expand Down