1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-12-07 06:46:36 +01:00

autosave every 60 seconds

This commit is contained in:
Jfreegman
2014-07-08 14:46:50 -04:00
parent 442f68cd31
commit 5b9fd70f30
2 changed files with 17 additions and 7 deletions

View File

@@ -67,6 +67,8 @@ ToxAv *av;
char *DATA_FILE = NULL;
ToxWindow *prompt = NULL;
#define AUTOSAVE_FREQ 60
struct arg_opts {
int ignore_data_file;
int use_ipv4;
@@ -640,13 +642,21 @@ int main(int argc, char *argv[])
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
}
sort_friendlist_index();
prompt_init_statusbar(prompt, m);
uint64_t last_save = get_unix_time();
while (true) {
update_unix_time();
do_toxic(m, prompt);
uint64_t cur_time = get_unix_time();
if (timed_out(last_save, cur_time, AUTOSAVE_FREQ)) {
store_data(m, DATA_FILE);
last_save = cur_time;
}
usleep(40000);
}