1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 22:43:01 +01:00

Merge branch 'tox-bugs' of https://github.com/stqism/ToxCore into stqism-tox-bugs

This commit is contained in:
irungentoo 2013-08-18 10:19:35 -04:00
commit 3b58ad06b0
2 changed files with 39 additions and 9 deletions

47
main.c
View File

@ -27,6 +27,7 @@
/* Export for use in Callbacks */ /* Export for use in Callbacks */
char *DATA_FILE = NULL; char *DATA_FILE = NULL;
char dir[31];
void on_window_resize(int sig) void on_window_resize(int sig)
{ {
@ -35,6 +36,17 @@ void on_window_resize(int sig)
clear(); clear();
} }
void setdir()
{
#ifdef WIN32
strcpy(dir, "%appdata%/.tox/");
#elif defined(MAC_OSX)
strcpy(dir, "~/Library/Application Support/.tox/");
#elif defined(linux)
strcpy(dir, "~/.tox/");
#endif
}
static void init_term() static void init_term()
{ {
/* Setup terminal */ /* Setup terminal */
@ -52,6 +64,10 @@ static void init_term()
init_pair(3, COLOR_RED, COLOR_BLACK); init_pair(3, COLOR_RED, COLOR_BLACK);
init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK);
init_pair(5, COLOR_YELLOW, COLOR_BLACK); init_pair(5, COLOR_YELLOW, COLOR_BLACK);
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
init_pair(7, COLOR_BLACK, COLOR_BLACK);
init_pair(8, COLOR_BLACK, COLOR_WHITE);
} }
refresh(); refresh();
@ -68,13 +84,15 @@ static Messenger *init_tox()
m_callback_namechange(m, on_nickchange, NULL); m_callback_namechange(m, on_nickchange, NULL);
m_callback_statusmessage(m, on_statuschange, NULL); m_callback_statusmessage(m, on_statuschange, NULL);
m_callback_action(m, on_action, NULL); m_callback_action(m, on_action, NULL);
#ifdef __linux__ #ifdef __linux__
setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif WIN32 #elif defined(WIN32)
setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
#else #elif defined(MAC_OSX)
setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
#endif #else
setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
#endif
return m; return m;
} }
@ -88,7 +106,13 @@ int init_connection(void)
if (DHT_isconnected()) if (DHT_isconnected())
return 0; return 0;
FILE *fp = fopen("../../../other/DHTservers", "r"); #if WIN32
FILE *fp = fopen("%appdata%/.tox/DHTservers", "r");
#elif MAC_OSX
FILE *fp = fopen("~/Library/Application Support/.tox/DHTservers", "r");
#else
FILE *fp = fopen("~/.tox/DHTservers", "r");
#endif
if (!fp) if (!fp)
return 1; return 1;
@ -255,6 +279,7 @@ static void load_data(Messenger *m, char *path)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
setdir();
char *user_config_dir = get_user_config_dir(); char *user_config_dir = get_user_config_dir();
int config_err = 0; int config_err = 0;
@ -281,12 +306,16 @@ int main(int argc, char *argv[])
config_err = create_user_config_dir(user_config_dir); config_err = create_user_config_dir(user_config_dir);
if (config_err) { if (config_err) {
strcat(DATA_FILE, dir);
DATA_FILE = strdup("data"); DATA_FILE = strdup("data");
} else { } else {
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
strcpy(DATA_FILE, user_config_dir); strcpy(DATA_FILE, user_config_dir);
strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, CONFIGDIR);
strcat(DATA_FILE, "data"); strcat(DATA_FILE, dir);
DATA_FILE = strdup("data");
} }
} }

View File

@ -272,6 +272,7 @@ void cmd_nick(ToxWindow *self, Messenger *m, char **args)
char *nick = args[1]; char *nick = args[1];
setname(m, (uint8_t *) nick, strlen(nick) + 1); setname(m, (uint8_t *) nick, strlen(nick) + 1);
wprintw(self->window, "Nickname set to: %s\n", nick); wprintw(self->window, "Nickname set to: %s\n", nick);
if (store_data(m, DATA_FILE)) { if (store_data(m, DATA_FILE)) {
wprintw(self->window, "\nCould not store Messenger data\n"); wprintw(self->window, "\nCould not store Messenger data\n");
} }