summaryrefslogtreecommitdiff
path: root/testing/toxic/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r--testing/toxic/main.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index b2310c80..162cce68 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -3,14 +3,23 @@
3 */ 3 */
4 4
5#include <curses.h> 5#include <curses.h>
6#include <errno.h>
6#include <stdio.h> 7#include <stdio.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <stdbool.h> 9#include <stdbool.h>
9#include <stdint.h> 10#include <stdint.h>
10 11
12#ifdef _win32
13#include <direct.h>
14#else
15#include <sys/stat.h>
16#include <sys/types.h>
17#endif
18
11#include "../../core/Messenger.h" 19#include "../../core/Messenger.h"
12#include "../../core/network.h" 20#include "../../core/network.h"
13 21
22#include "configdir.h"
14#include "windows.h" 23#include "windows.h"
15 24
16extern ToxWindow new_prompt(); 25extern ToxWindow new_prompt();
@@ -22,7 +31,10 @@ extern int add_req(uint8_t *public_key); // XXX
22 31
23/* Holds status of chat windows */ 32/* Holds status of chat windows */
24char WINDOW_STATUS[MAX_WINDOW_SLOTS]; 33char WINDOW_STATUS[MAX_WINDOW_SLOTS];
25#define TOXICVER "0.1.0" //Will be moved to a -D flag later 34
35#ifndef TOXICVER
36#define TOXICVER "NOVER" //Use the -D flag to set this
37#endif
26 38
27static ToxWindow windows[MAX_WINDOW_SLOTS]; 39static ToxWindow windows[MAX_WINDOW_SLOTS];
28static ToxWindow* prompt; 40static ToxWindow* prompt;
@@ -37,7 +49,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
37 wprintw(prompt->window, "\nFriend request from:\n"); 49 wprintw(prompt->window, "\nFriend request from:\n");
38 50
39 int i; 51 int i;
40 for (i = 0; i < 32; ++i) { 52 for (i = 0; i < KEY_SIZE_BYTES; ++i) {
41 wprintw(prompt->window, "%02x", public_key[i] & 0xff); 53 wprintw(prompt->window, "%02x", public_key[i] & 0xff);
42 } 54 }
43 55
@@ -331,9 +343,19 @@ int main(int argc, char *argv[])
331{ 343{
332 int ch; 344 int ch;
333 int f_flag = 0; 345 int f_flag = 0;
334 char *filename = "data"; 346 char *user_config_dir = get_user_config_dir();
347 char *filename;
348 int config_err = create_user_config_dir(user_config_dir);
349 if(config_err) {
350 filename = "data";
351 } else {
352 filename = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
353 strcpy(filename, user_config_dir);
354 strcat(filename, CONFIGDIR);
355 strcat(filename, "data");
356 }
357
335 ToxWindow* a; 358 ToxWindow* a;
336
337 int i = 0; 359 int i = 0;
338 for (i = 0; i < argc; ++i) { 360 for (i = 0; i < argc; ++i) {
339 if (argv[i] == NULL) 361 if (argv[i] == NULL)
@@ -351,6 +373,7 @@ int main(int argc, char *argv[])
351 init_term(); 373 init_term();
352 init_tox(); 374 init_tox();
353 load_data(filename); 375 load_data(filename);
376 free(filename);
354 init_windows(); 377 init_windows();
355 init_window_status(); 378 init_window_status();
356 379
@@ -360,6 +383,13 @@ int main(int argc, char *argv[])
360 "defaulting to 'data' for a keyfile...\n"); 383 "defaulting to 'data' for a keyfile...\n");
361 attroff(COLOR_PAIR(3) | A_BOLD); 384 attroff(COLOR_PAIR(3) | A_BOLD);
362 } 385 }
386
387 if(config_err) {
388 attron(COLOR_PAIR(3) | A_BOLD);
389 wprintw(prompt->window, "Unable to determine configuration directory!\n"
390 "defaulting to 'data' for a keyfile...\n");
391 attroff(COLOR_PAIR(3) | A_BOLD);
392 }
363 393
364 while(true) { 394 while(true) {
365 /* Update tox */ 395 /* Update tox */