summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorMichael Rose <michael_rose@gmx.de>2013-08-14 11:37:58 +0200
committerMichael Rose <michael_rose@gmx.de>2013-08-14 11:37:58 +0200
commitbfa624139a3d4b7ef582c13bb571c6b95b6141c8 (patch)
tree6a721ea4f5926d29d3332bc9d192a4b868d7bb34 /testing
parentd3828cd7ab38463f5f86179e8adbdcf23ceba7dc (diff)
populate friends in toxic on startup
Diffstat (limited to 'testing')
-rw-r--r--testing/toxic/main.c21
1 files 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()
286 doMessenger(m); 286 doMessenger(m);
287} 287}
288 288
289static void populate_friends()
290{
291 wprintw(prompt->window, "Populating friends...\n");
292 for (int i = 0; i < m->numfriends; i++) {
293 wprintw(prompt->window, "Added friend %d\n", i);
294 friendlist_onFriendAdded(m, i);
295 }
296}
297
289/* 298/*
290 * Store Messenger data to path 299 * Store Messenger data to path
291 * Return 0 Messenger stored successfully 300 * Return 0 Messenger stored successfully
@@ -321,6 +330,8 @@ static int store_data(char *path)
321 free(buf); 330 free(buf);
322 fclose(fd); 331 fclose(fd);
323 332
333 wprintw(prompt->window, "Messenger stored\n");
334
324 return 0; 335 return 0;
325} 336}
326 337
@@ -348,7 +359,9 @@ static void load_data(char *path) {
348 endwin(); 359 endwin();
349 exit(1); 360 exit(1);
350 } 361 }
351 Messenger_load(m, buf, len); 362 if (Messenger_load(m, buf, len) != 0) {
363 fprintf(stderr, "Problem while loading messenger");
364 }
352 free(buf); 365 free(buf);
353 fclose(fd); 366 fclose(fd);
354 } else { 367 } else {
@@ -479,8 +492,10 @@ int main(int argc, char *argv[])
479 init_windows(); 492 init_windows();
480 init_window_status(); 493 init_window_status();
481 494
482 if(f_loadfromfile) 495 if(f_loadfromfile) {
483 load_data(DATA_FILE); 496 load_data(DATA_FILE);
497 populate_friends();
498 }
484 499
485 if (f_flag == -1) { 500 if (f_flag == -1) {
486 attron(COLOR_PAIR(3) | A_BOLD); 501 attron(COLOR_PAIR(3) | A_BOLD);