From bfa624139a3d4b7ef582c13bb571c6b95b6141c8 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Wed, 14 Aug 2013 11:37:58 +0200 Subject: [PATCH] populate friends in toxic on startup --- testing/toxic/main.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/testing/toxic/main.c b/testing/toxic/main.c index fd3c732f..40b70ba5 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -286,6 +286,15 @@ static void do_tox() doMessenger(m); } +static void populate_friends() +{ + wprintw(prompt->window, "Populating friends...\n"); + for (int i = 0; i < m->numfriends; i++) { + wprintw(prompt->window, "Added friend %d\n", i); + friendlist_onFriendAdded(m, i); + } +} + /* * Store Messenger data to path * Return 0 Messenger stored successfully @@ -321,6 +330,8 @@ static int store_data(char *path) free(buf); fclose(fd); + wprintw(prompt->window, "Messenger stored\n"); + return 0; } @@ -348,7 +359,9 @@ static void load_data(char *path) { endwin(); exit(1); } - Messenger_load(m, buf, len); + if (Messenger_load(m, buf, len) != 0) { + fprintf(stderr, "Problem while loading messenger"); + } free(buf); fclose(fd); } else { @@ -479,8 +492,10 @@ int main(int argc, char *argv[]) init_windows(); init_window_status(); - if(f_loadfromfile) - load_data(DATA_FILE); + if(f_loadfromfile) { + load_data(DATA_FILE); + populate_friends(); + } if (f_flag == -1) { attron(COLOR_PAIR(3) | A_BOLD);