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 558a80f1c3
7 changed files with 67 additions and 18 deletions

View File

@ -88,12 +88,12 @@ START_TEST(test_m_set_userstatus)
uint16_t bad_length = REALLY_BIG_NUMBER;
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1),
"m_set_userstatus did NOT catch the following length: %d\n",
REALLY_BIG_NUMBER);
"m_set_userstatus did NOT catch the following length: %d\n",
REALLY_BIG_NUMBER);
ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0),
"m_set_userstatus did NOT return 0 on the following length: %d\n"
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
"m_set_userstatus did NOT return 0 on the following length: %d\n"
"MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
}
END_TEST
@ -157,10 +157,10 @@ START_TEST(test_setname)
int bad_length = REALLY_BIG_NUMBER;
ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1),
"setname() did NOT error on %d as a length argument!\n", bad_length);
"setname() did NOT error on %d as a length argument!\n", bad_length);
ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0),
"setname() did NOT return 0 on good arguments!\n");
"setname() did NOT return 0 on good arguments!\n");
}
END_TEST

View File

@ -37,6 +37,8 @@ static int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_i
return -1 if realloc fails */
int realloc_friendlist(Messenger *m, uint32_t num)
{
if (num * sizeof(Friend) == 0) return -1;
Friend *newfriendlist = realloc(m->friendlist, num * sizeof(Friend));
if (newfriendlist == NULL && num != 0)
@ -597,7 +599,6 @@ int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint
/*Interval in seconds between LAN discovery packet sending*/
#define LAN_DISCOVERY_INTERVAL 60
#define PORT 33445
/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/
@ -951,6 +952,7 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length)
}
}
free(temp);
data += size;
length -= size;
@ -968,7 +970,5 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length)
setname(m, data, small_size);
free(temp);
return 0;
}

View File

@ -406,6 +406,8 @@ static int getcryptconnection_id(uint8_t *public_key)
return -1 if realloc fails */
int realloc_cryptoconnection(uint32_t num)
{
if (num * sizeof(Crypto_Connection) == 0) return -1;
Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection));
if (newcrypto_connections == NULL && num != 0)

View File

@ -1,9 +1,24 @@
cmake_minimum_required(VERSION 2.6.0)
cmake_policy(SET CMP0011 NEW)
SET(USER_NAME $ENV{USERNAME} CACHE STRING UserName)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake)
if(WIN32)
file(MAKE_DIRECTORY "C:/Users/${USER_NAME}/AppData/Roaming/.tox")
file(INSTALL DHTservers DESTINATION "C:/Users/${USER_NAME}/AppData/Roaming/.tox")
else()
set(HOME "$ENV{HOME}")
if(APPLE)
file(MAKE_DIRECTORY ${HOME}Library/Application Support/.tox)
file(INSTALL DHTservers DESTINATION ${HOME}Library/Application Support/.tox)
else()
file(MAKE_DIRECTORY ${HOME}/.tox)
file(INSTALL DHTservers DESTINATION ${HOME}/.tox)
endif()
endif()
if(LINUX)
add_subdirectory(bootstrap_serverdaemon)
endif()

View File

@ -5,3 +5,5 @@
81.224.34.47 443 48F0D94C0D54EB1995A2ECEDE7DB6BDD5E05D81704B2F3D1BB9FE43AC97B7269
198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854
95.47.140.214 33445 F4BF7C5A9D0EF4CB684090C38DE937FAE1612021F21FEA4DCBFAC6AAFEF58E68
54.215.145.71 33445 6EDDEE2188EF579303C0766B4796DCBA89C93058B6032FEA51593DCD42FB746C
66.74.30.125 33445 7155386A691E7BD3C4C0589D70ACDA191D488634772885CCED5DD7B3F7E6310D

View File

@ -27,6 +27,7 @@
/* Export for use in Callbacks */
char *DATA_FILE = NULL;
char dir[31];
void on_window_resize(int sig)
{
@ -35,6 +36,17 @@ void on_window_resize(int sig)
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()
{
/* Setup terminal */
@ -52,6 +64,10 @@ static void init_term()
init_pair(3, COLOR_RED, COLOR_BLACK);
init_pair(4, COLOR_BLUE, 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();
@ -68,13 +84,15 @@ static Messenger *init_tox()
m_callback_namechange(m, on_nickchange, NULL);
m_callback_statusmessage(m, on_statuschange, NULL);
m_callback_action(m, on_action, NULL);
#ifdef __linux__
setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif WIN32
setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
#else
setname(m, (uint8_t *) "Hipster", sizeof("Hipster"));
#endif
#ifdef __linux__
setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif defined(WIN32)
setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
#elif defined(MAC_OSX)
setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
#else
setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
#endif
return m;
}
@ -88,7 +106,13 @@ int init_connection(void)
if (DHT_isconnected())
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)
return 1;
@ -255,6 +279,7 @@ static void load_data(Messenger *m, char *path)
int main(int argc, char *argv[])
{
setdir();
char *user_config_dir = get_user_config_dir();
int config_err = 0;
@ -281,12 +306,16 @@ int main(int argc, char *argv[])
config_err = create_user_config_dir(user_config_dir);
if (config_err) {
strcat(DATA_FILE, dir);
DATA_FILE = strdup("data");
} else {
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
strcpy(DATA_FILE, user_config_dir);
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];
setname(m, (uint8_t *) nick, strlen(nick) + 1);
wprintw(self->window, "Nickname set to: %s\n", nick);
if (store_data(m, DATA_FILE)) {
wprintw(self->window, "\nCould not store Messenger data\n");
}