summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md2
-rw-r--r--auto_tests/messenger_test.c12
-rw-r--r--core/DHT.c6
-rw-r--r--core/Lossless_UDP.c7
-rw-r--r--core/Messenger.c44
-rw-r--r--core/Messenger.h9
-rw-r--r--core/net_crypto.c23
-rw-r--r--other/CMakeLists.txt15
-rw-r--r--other/DHTservers2
-rw-r--r--testing/toxic/chat.c6
-rw-r--r--testing/toxic/configdir.c14
-rw-r--r--testing/toxic/configdir.h4
-rw-r--r--testing/toxic/friendlist.c36
-rw-r--r--testing/toxic/friendlist.h2
-rw-r--r--testing/toxic/main.c23
-rw-r--r--testing/toxic/prompt.c9
-rw-r--r--testing/toxic/prompt.h4
-rw-r--r--testing/toxic/windows.c172
-rw-r--r--testing/toxic/windows.h10
19 files changed, 210 insertions, 190 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 3d01d562..53ce5156 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -37,6 +37,7 @@ git checkout tags/0.4.2
37./configure && make check 37./configure && make check
38sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc 38sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc
39sudo ldconfig 39sudo ldconfig
40cd ..
40``` 41```
41 42
42Or if checkinstall is not easily available for your distribution (e.g. Fedora), 43Or if checkinstall is not easily available for your distribution (e.g. Fedora),
@@ -50,6 +51,7 @@ git checkout tags/0.4.2
50./configure 51./configure
51make check 52make check
52sudo make install 53sudo make install
54cd ..
53``` 55```
54 56
55 57
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index 3ca89152..9de69409 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -88,12 +88,12 @@ START_TEST(test_m_set_userstatus)
88 uint16_t bad_length = REALLY_BIG_NUMBER; 88 uint16_t bad_length = REALLY_BIG_NUMBER;
89 89
90 ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1), 90 ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, bad_length) == -1),
91 "m_set_userstatus did NOT catch the following length: %d\n", 91 "m_set_userstatus did NOT catch the following length: %d\n",
92 REALLY_BIG_NUMBER); 92 REALLY_BIG_NUMBER);
93 93
94 ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0), 94 ck_assert_msg((m_set_statusmessage(m, (uint8_t *)status, good_length) == 0),
95 "m_set_userstatus did NOT return 0 on the following length: %d\n" 95 "m_set_userstatus did NOT return 0 on the following length: %d\n"
96 "MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH); 96 "MAX_STATUSMESSAGE_LENGTH: %d\n", good_length, MAX_STATUSMESSAGE_LENGTH);
97} 97}
98END_TEST 98END_TEST
99 99
@@ -157,10 +157,10 @@ START_TEST(test_setname)
157 int bad_length = REALLY_BIG_NUMBER; 157 int bad_length = REALLY_BIG_NUMBER;
158 158
159 ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1), 159 ck_assert_msg((setname(m, (uint8_t *)good_name, bad_length) == -1),
160 "setname() did NOT error on %d as a length argument!\n", bad_length); 160 "setname() did NOT error on %d as a length argument!\n", bad_length);
161 161
162 ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0), 162 ck_assert_msg((setname(m, (uint8_t *)good_name, good_length) == 0),
163 "setname() did NOT return 0 on good arguments!\n"); 163 "setname() did NOT return 0 on good arguments!\n");
164} 164}
165END_TEST 165END_TEST
166 166
diff --git a/core/DHT.c b/core/DHT.c
index 55f34994..924e3216 100644
--- a/core/DHT.c
+++ b/core/DHT.c
@@ -704,6 +704,12 @@ int DHT_delfriend(uint8_t *client_id)
704 CLIENT_ID_SIZE ); 704 CLIENT_ID_SIZE );
705 } 705 }
706 706
707 if (num_friends == 0) {
708 free(friends_list);
709 friends_list = NULL;
710 return 0;
711 }
712
707 temp = realloc(friends_list, sizeof(Friend) * (num_friends)); 713 temp = realloc(friends_list, sizeof(Friend) * (num_friends));
708 714
709 if (temp == NULL) 715 if (temp == NULL)
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c
index fa5f9144..506a06eb 100644
--- a/core/Lossless_UDP.c
+++ b/core/Lossless_UDP.c
@@ -319,6 +319,13 @@ static void free_connections(void)
319 if (connections_length == i) 319 if (connections_length == i)
320 return; 320 return;
321 321
322 if (i == 0) {
323 free(connections);
324 connections = NULL;
325 connections_length = i;
326 return;
327 }
328
322 Connection *temp; 329 Connection *temp;
323 temp = realloc(connections, sizeof(Connection) * i); 330 temp = realloc(connections, sizeof(Connection) * i);
324 331
diff --git a/core/Messenger.c b/core/Messenger.c
index 051078f9..7fd6a569 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -37,10 +37,15 @@ static int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_i
37 return -1 if realloc fails */ 37 return -1 if realloc fails */
38int realloc_friendlist(Messenger *m, uint32_t num) 38int realloc_friendlist(Messenger *m, uint32_t num)
39{ 39{
40 if (num * sizeof(Friend) == 0) return -1; 40 if (num == 0) {
41 41 free(m->friendlist);
42 m->friendlist = NULL;
43 return 0;
44 }
45
42 Friend *newfriendlist = realloc(m->friendlist, num * sizeof(Friend)); 46 Friend *newfriendlist = realloc(m->friendlist, num * sizeof(Friend));
43 if (newfriendlist == NULL && num != 0) 47
48 if (newfriendlist == NULL)
44 return -1; 49 return -1;
45 50
46 m->friendlist = newfriendlist; 51 m->friendlist = newfriendlist;
@@ -477,6 +482,12 @@ static int send_userstatus(Messenger *m, int friendnumber, USERSTATUS status)
477 return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat)); 482 return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat));
478} 483}
479 484
485static int send_ping(Messenger *m, int friendnumber)
486{
487 m->friendlist[friendnumber].ping_lastsent = unix_time();
488 return write_cryptpacket_id(m, friendnumber, PACKET_ID_PING, 0, 0);
489}
490
480static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length) 491static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length)
481{ 492{
482 if (friendnumber >= m->numfriends || friendnumber < 0) 493 if (friendnumber >= m->numfriends || friendnumber < 0)
@@ -591,7 +602,10 @@ int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint
591 602
592 uint8_t packet[length + 1]; 603 uint8_t packet[length + 1];
593 packet[0] = packet_id; 604 packet[0] = packet_id;
594 memcpy(packet + 1, data, length); 605
606 if (length != 0)
607 memcpy(packet + 1, data, length);
608
595 return write_cryptpacket(m->friendlist[friendnumber].crypt_connection_id, packet, length + 1); 609 return write_cryptpacket(m->friendlist[friendnumber].crypt_connection_id, packet, length + 1);
596} 610}
597 611
@@ -654,6 +668,7 @@ void doFriends(Messenger *m)
654 uint32_t i; 668 uint32_t i;
655 int len; 669 int len;
656 uint8_t temp[MAX_DATA_SIZE]; 670 uint8_t temp[MAX_DATA_SIZE];
671 uint64_t temp_time = unix_time();
657 672
658 for (i = 0; i < m->numfriends; ++i) { 673 for (i = 0; i < m->numfriends; ++i) {
659 if (m->friendlist[i].status == FRIEND_ADDED) { 674 if (m->friendlist[i].status == FRIEND_ADDED) {
@@ -662,7 +677,7 @@ void doFriends(Messenger *m)
662 677
663 if (fr >= 0) { 678 if (fr >= 0) {
664 set_friend_status(m, i, FRIEND_REQUESTED); 679 set_friend_status(m, i, FRIEND_REQUESTED);
665 m->friendlist[i].friendrequest_lastsent = unix_time(); 680 m->friendlist[i].friendrequest_lastsent = temp_time;
666 } 681 }
667 } 682 }
668 683
@@ -671,7 +686,7 @@ void doFriends(Messenger *m)
671 if (m->friendlist[i].status == FRIEND_REQUESTED) { 686 if (m->friendlist[i].status == FRIEND_REQUESTED) {
672 /* If we didn't connect to friend after successfully sending him a friend request the request is deemed 687 /* If we didn't connect to friend after successfully sending him a friend request the request is deemed
673 unsuccessful so we set the status back to FRIEND_ADDED and try again.*/ 688 unsuccessful so we set the status back to FRIEND_ADDED and try again.*/
674 if (m->friendlist[i].friendrequest_lastsent + m->friendlist[i].friendrequest_timeout < unix_time()) { 689 if (m->friendlist[i].friendrequest_lastsent + m->friendlist[i].friendrequest_timeout < temp_time) {
675 set_friend_status(m, i, FRIEND_ADDED); 690 set_friend_status(m, i, FRIEND_ADDED);
676 /* Double the default timeout everytime if friendrequest is assumed to have been 691 /* Double the default timeout everytime if friendrequest is assumed to have been
677 sent unsuccessfully. */ 692 sent unsuccessfully. */
@@ -693,6 +708,7 @@ void doFriends(Messenger *m)
693 m->friendlist[i].name_sent = 0; 708 m->friendlist[i].name_sent = 0;
694 m->friendlist[i].userstatus_sent = 0; 709 m->friendlist[i].userstatus_sent = 0;
695 m->friendlist[i].statusmessage_sent = 0; 710 m->friendlist[i].statusmessage_sent = 0;
711 m->friendlist[i].ping_lastrecv = temp_time;
696 break; 712 break;
697 713
698 case 4: 714 case 4:
@@ -721,6 +737,10 @@ void doFriends(Messenger *m)
721 m->friendlist[i].userstatus_sent = 1; 737 m->friendlist[i].userstatus_sent = 1;
722 } 738 }
723 739
740 if (m->friendlist[i].ping_lastsent + FRIEND_PING_INTERVAL < temp_time) {
741 send_ping(m, i);
742 }
743
724 len = read_cryptpacket(m->friendlist[i].crypt_connection_id, temp); 744 len = read_cryptpacket(m->friendlist[i].crypt_connection_id, temp);
725 uint8_t packet_id = temp[0]; 745 uint8_t packet_id = temp[0];
726 uint8_t *data = temp + 1; 746 uint8_t *data = temp + 1;
@@ -728,6 +748,11 @@ void doFriends(Messenger *m)
728 748
729 if (len > 0) { 749 if (len > 0) {
730 switch (packet_id) { 750 switch (packet_id) {
751 case PACKET_ID_PING: {
752 m->friendlist[i].ping_lastrecv = temp_time;
753 break;
754 }
755
731 case PACKET_ID_NICKNAME: { 756 case PACKET_ID_NICKNAME: {
732 if (data_length >= MAX_NAME_LENGTH || data_length == 0) 757 if (data_length >= MAX_NAME_LENGTH || data_length == 0)
733 break; 758 break;
@@ -816,6 +841,13 @@ void doFriends(Messenger *m)
816 841
817 break; 842 break;
818 } 843 }
844
845 if (m->friendlist[i].ping_lastrecv + FRIEND_CONNECTION_TIMEOUT < temp_time) {
846 /* if we stopped recieving ping packets kill it */
847 crypto_kill(m->friendlist[i].crypt_connection_id);
848 m->friendlist[i].crypt_connection_id = -1;
849 set_friend_status(m, i, FRIEND_CONFIRMED);
850 }
819 } 851 }
820 } 852 }
821} 853}
diff --git a/core/Messenger.h b/core/Messenger.h
index 20ea33fb..9016be93 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -40,6 +40,7 @@ extern "C" {
40 40
41#define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t)) 41#define FRIEND_ADDRESS_SIZE (crypto_box_PUBLICKEYBYTES + sizeof(uint32_t) + sizeof(uint16_t))
42 42
43#define PACKET_ID_PING 0
43#define PACKET_ID_NICKNAME 48 44#define PACKET_ID_NICKNAME 48
44#define PACKET_ID_STATUSMESSAGE 49 45#define PACKET_ID_STATUSMESSAGE 49
45#define PACKET_ID_USERSTATUS 50 46#define PACKET_ID_USERSTATUS 50
@@ -71,6 +72,12 @@ extern "C" {
71/* Default start timeout in seconds between friend requests */ 72/* Default start timeout in seconds between friend requests */
72#define FRIENDREQUEST_TIMEOUT 5; 73#define FRIENDREQUEST_TIMEOUT 5;
73 74
75/* interval between the sending of ping packets.*/
76#define FRIEND_PING_INTERVAL 5
77
78/* If no packets are recieved from friend in this time interval, kill the connection.*/
79#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 2)
80
74/* USERSTATUS 81/* USERSTATUS
75 * Represents userstatuses someone can have. */ 82 * Represents userstatuses someone can have. */
76 83
@@ -100,6 +107,8 @@ typedef struct {
100 uint32_t message_id; /* a semi-unique id used in read receipts */ 107 uint32_t message_id; /* a semi-unique id used in read receipts */
101 uint8_t receives_read_receipts; /* shall we send read receipts to this person? */ 108 uint8_t receives_read_receipts; /* shall we send read receipts to this person? */
102 uint32_t friendrequest_nospam; /*The nospam number used in the friend request*/ 109 uint32_t friendrequest_nospam; /*The nospam number used in the friend request*/
110 uint64_t ping_lastrecv;
111 uint64_t ping_lastsent;
103} Friend; 112} Friend;
104 113
105typedef struct Messenger { 114typedef struct Messenger {
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 6ced942b..8fcb62e1 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -406,11 +406,15 @@ static int getcryptconnection_id(uint8_t *public_key)
406 return -1 if realloc fails */ 406 return -1 if realloc fails */
407int realloc_cryptoconnection(uint32_t num) 407int realloc_cryptoconnection(uint32_t num)
408{ 408{
409 if (num * sizeof(Crypto_Connection) == 0) return -1; 409 if (num == 0) {
410 free(crypto_connections);
411 crypto_connections = NULL;
412 return 0;
413 }
410 414
411 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection)); 415 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection));
412 416
413 if (newcrypto_connections == NULL && num != 0) 417 if (newcrypto_connections == NULL)
414 return -1; 418 return -1;
415 419
416 crypto_connections = newcrypto_connections; 420 crypto_connections = newcrypto_connections;
@@ -665,10 +669,6 @@ static void receive_crypto(void)
665 uint8_t session_key[crypto_box_PUBLICKEYBYTES]; 669 uint8_t session_key[crypto_box_PUBLICKEYBYTES];
666 uint16_t len; 670 uint16_t len;
667 671
668 if (id_packet(crypto_connections[i].number) == 1)
669 /* if the packet is a friend request drop it (because we are already friends) */
670 len = read_packet(crypto_connections[i].number, temp_data);
671
672 if (id_packet(crypto_connections[i].number) == 2) { /* handle handshake packet. */ 672 if (id_packet(crypto_connections[i].number) == 2) { /* handle handshake packet. */
673 len = read_packet(crypto_connections[i].number, temp_data); 673 len = read_packet(crypto_connections[i].number, temp_data);
674 674
@@ -686,9 +686,10 @@ static void receive_crypto(void)
686 crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */ 686 crypto_connections[i].status = CONN_NOT_CONFIRMED; /* set it to its proper value right after. */
687 } 687 }
688 } 688 }
689 } else if (id_packet(crypto_connections[i].number) != -1) // This should not happen kill the connection if it does 689 } else if (id_packet(crypto_connections[i].number) != -1) { // This should not happen kill the connection if it does
690 crypto_kill(crypto_connections[i].number); 690 crypto_kill(crypto_connections[i].number);
691 691 return;
692 }
692 } 693 }
693 694
694 if (crypto_connections[i].status == CONN_NOT_CONFIRMED) { 695 if (crypto_connections[i].status == CONN_NOT_CONFIRMED) {
@@ -710,12 +711,16 @@ static void receive_crypto(void)
710 711
711 /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */ 712 /* connection is accepted so we disable the auto kill by setting it to about 1 month from now. */
712 kill_connection_in(crypto_connections[i].number, 3000000); 713 kill_connection_in(crypto_connections[i].number, 3000000);
713 } else 714 } else {
714 crypto_kill(crypto_connections[i].number); // This should not happen kill the connection if it does 715 crypto_kill(crypto_connections[i].number); // This should not happen kill the connection if it does
716 return;
717 }
715 } else if (id_packet(crypto_connections[i].number) != -1) 718 } else if (id_packet(crypto_connections[i].number) != -1)
716 /* This should not happen 719 /* This should not happen
717 kill the connection if it does */ 720 kill the connection if it does */
718 crypto_kill(crypto_connections[i].number); 721 crypto_kill(crypto_connections[i].number);
722
723 return;
719 } 724 }
720 } 725 }
721} 726}
diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt
index db742e3e..871a9e92 100644
--- a/other/CMakeLists.txt
+++ b/other/CMakeLists.txt
@@ -1,9 +1,24 @@
1cmake_minimum_required(VERSION 2.6.0) 1cmake_minimum_required(VERSION 2.6.0)
2 2
3cmake_policy(SET CMP0011 NEW) 3cmake_policy(SET CMP0011 NEW)
4SET(USER_NAME $ENV{USERNAME} CACHE STRING UserName)
4 5
5include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake) 6include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_bootstrap.cmake)
6 7
8if(WIN32)
9 file(MAKE_DIRECTORY "C:/Users/${USER_NAME}/AppData/Roaming/.config/tox")
10 file(INSTALL DHTservers DESTINATION "C:/Users/${USER_NAME}/AppData/Roaming/.config/tox")
11else()
12 set(HOME "$ENV{HOME}")
13 if(APPLE)
14 file(MAKE_DIRECTORY ${HOME}/Library/Application\ Support/.config/tox)
15 file(INSTALL DHTservers DESTINATION ${HOME}/Library/Application\ Support/.config/tox)
16 else()
17 file(MAKE_DIRECTORY ${HOME}/.config/tox)
18 file(INSTALL DHTservers DESTINATION ${HOME}/.config/tox)
19 endif()
20endif()
21
7if(LINUX) 22if(LINUX)
8 add_subdirectory(bootstrap_serverdaemon) 23 add_subdirectory(bootstrap_serverdaemon)
9endif() 24endif()
diff --git a/other/DHTservers b/other/DHTservers
index 6efba882..bf2d2728 100644
--- a/other/DHTservers
+++ b/other/DHTservers
@@ -5,3 +5,5 @@
581.224.34.47 443 48F0D94C0D54EB1995A2ECEDE7DB6BDD5E05D81704B2F3D1BB9FE43AC97B7269 581.224.34.47 443 48F0D94C0D54EB1995A2ECEDE7DB6BDD5E05D81704B2F3D1BB9FE43AC97B7269
6198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854 6198.46.136.167 33445 728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854
795.47.140.214 33445 F4BF7C5A9D0EF4CB684090C38DE937FAE1612021F21FEA4DCBFAC6AAFEF58E68 795.47.140.214 33445 F4BF7C5A9D0EF4CB684090C38DE937FAE1612021F21FEA4DCBFAC6AAFEF58E68
854.215.145.71 33445 6EDDEE2188EF579303C0766B4796DCBA89C93058B6032FEA51593DCD42FB746C
966.74.30.125 33445 7155386A691E7BD3C4C0589D70ACDA191D488634772885CCED5DD7B3F7E6310D
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index ef932cd2..57404a59 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -123,8 +123,7 @@ static void chat_onStatusChange(ToxWindow *self, int num, uint8_t *status, uint1
123 123
124 status[len - 1] = '\0'; 124 status[len - 1] = '\0';
125 fix_name(status); 125 fix_name(status);
126 snprintf(self->title, sizeof(self->title), "[%s (%d)]", status, num); 126
127
128 wattron(ctx->history, COLOR_PAIR(3)); 127 wattron(ctx->history, COLOR_PAIR(3));
129 wprintw(ctx->history, "* Your partner changed status to '%s'\n", status); 128 wprintw(ctx->history, "* Your partner changed status to '%s'\n", status);
130 wattroff(ctx->history, COLOR_PAIR(3)); 129 wattroff(ctx->history, COLOR_PAIR(3));
@@ -335,7 +334,8 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
335 else if (strcmp(ctx->line, "/close") == 0) { 334 else if (strcmp(ctx->line, "/close") == 0) {
336 int f_num = ctx->friendnum; 335 int f_num = ctx->friendnum;
337 delwin(ctx->linewin); 336 delwin(ctx->linewin);
338 del_window(self, f_num); 337 del_window(self);
338 disable_chatwin(f_num);
339 } 339 }
340 340
341 else 341 else
diff --git a/testing/toxic/configdir.c b/testing/toxic/configdir.c
index 1a62e8ed..a43dd1de 100644
--- a/testing/toxic/configdir.c
+++ b/testing/toxic/configdir.c
@@ -98,14 +98,18 @@ char *get_user_config_dir(void)
98 98
99 snprintf(user_config_dir, len, "%s/Library/Application Support", home); 99 snprintf(user_config_dir, len, "%s/Library/Application Support", home);
100# else /* __APPLE__ */ 100# else /* __APPLE__ */
101 len = strlen(home) + strlen("/.config") + 1;
102 user_config_dir = malloc(len);
103 101
104 if (user_config_dir == NULL) { 102 if (!(user_config_dir = getenv("XDG_CONFIG_HOME"))) {
105 return NULL; 103 len = strlen(home) + strlen("/.config") + 1;
104 user_config_dir = malloc(len);
105
106 if (user_config_dir == NULL) {
107 return NULL;
108 }
109
110 snprintf(user_config_dir, len, "%s/.config", home);
106 } 111 }
107 112
108 snprintf(user_config_dir, len, "%s/.config", home);
109# endif /* __APPLE__ */ 113# endif /* __APPLE__ */
110 114
111 return user_config_dir; 115 return user_config_dir;
diff --git a/testing/toxic/configdir.h b/testing/toxic/configdir.h
index 17d95107..e886e53a 100644
--- a/testing/toxic/configdir.h
+++ b/testing/toxic/configdir.h
@@ -19,9 +19,9 @@
19 */ 19 */
20 20
21#ifdef _win32 21#ifdef _win32
22#define CONFIGDIR "\\toxic\\" 22#define CONFIGDIR "\\tox\\"
23#else 23#else
24#define CONFIGDIR "/toxic/" 24#define CONFIGDIR "/tox/"
25#endif 25#endif
26 26
27#ifndef S_ISDIR 27#ifndef S_ISDIR
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index c85fd3ae..0a58bc54 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -13,7 +13,6 @@
13#include "windows.h" 13#include "windows.h"
14#include "friendlist.h" 14#include "friendlist.h"
15 15
16static char *WINDOW_STATUS;
17 16
18typedef struct { 17typedef struct {
19 uint8_t name[MAX_NAME_LENGTH]; 18 uint8_t name[MAX_NAME_LENGTH];
@@ -48,17 +47,7 @@ void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str,
48 return; 47 return;
49 48
50 if (friends[num].chatwin == -1) { 49 if (friends[num].chatwin == -1) {
51 friends[num].chatwin = num; 50 friends[num].chatwin = add_window(m, new_chat(m, num));
52 int i;
53
54 /* Find first open slot to hold chat window */
55 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
56 if (WINDOW_STATUS[i] == -1) {
57 WINDOW_STATUS[i] = num;
58 add_window(m, new_chat(m, num), i);
59 break;
60 }
61 }
62 } 51 }
63} 52}
64 53
@@ -106,25 +95,9 @@ static void friendlist_onKey(ToxWindow *self, Messenger *m, int key)
106 } else if (key == '\n') { 95 } else if (key == '\n') {
107 /* Jump to chat window if already open */ 96 /* Jump to chat window if already open */
108 if (friends[num_selected].chatwin != -1) { 97 if (friends[num_selected].chatwin != -1) {
109 int i; 98 set_active_window(friends[num_selected].chatwin);
110
111 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
112 if (WINDOW_STATUS[i] == num_selected) {
113 set_active_window(i);
114 break;
115 }
116 }
117 } else { 99 } else {
118 int i; 100 friends[num_selected].chatwin = add_window(m, new_chat(m, num_selected));
119
120 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
121 if (WINDOW_STATUS[i] == -1) {
122 WINDOW_STATUS[i] = num_selected;
123 friends[num_selected].chatwin = num_selected;
124 add_window(m, new_chat(m, num_selected), i);
125 break;
126 }
127 }
128 } 101 }
129 } 102 }
130} 103}
@@ -172,9 +145,8 @@ static void friendlist_onInit(ToxWindow *self, Messenger *m)
172 145
173} 146}
174 147
175ToxWindow new_friendlist(char *ws) 148ToxWindow new_friendlist()
176{ 149{
177 WINDOW_STATUS = ws;
178 ToxWindow ret; 150 ToxWindow ret;
179 memset(&ret, 0, sizeof(ret)); 151 memset(&ret, 0, sizeof(ret));
180 152
diff --git a/testing/toxic/friendlist.h b/testing/toxic/friendlist.h
index f0c27f53..91b917fd 100644
--- a/testing/toxic/friendlist.h
+++ b/testing/toxic/friendlist.h
@@ -4,7 +4,7 @@
4#include "windows.h" 4#include "windows.h"
5#include "chat.h" 5#include "chat.h"
6 6
7ToxWindow new_friendlist(char *ws); 7ToxWindow new_friendlist();
8int friendlist_onFriendAdded(Messenger *m, int num); 8int friendlist_onFriendAdded(Messenger *m, int num);
9void disable_chatwin(int f_num); 9void disable_chatwin(int f_num);
10void fix_name(uint8_t *name); 10void fix_name(uint8_t *name);
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 2da87bc6..9abe8de4 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -27,6 +27,7 @@
27 27
28/* Export for use in Callbacks */ 28/* Export for use in Callbacks */
29char *DATA_FILE = NULL; 29char *DATA_FILE = NULL;
30char *SRVLIST_FILE = NULL;
30 31
31void on_window_resize(int sig) 32void on_window_resize(int sig)
32{ 33{
@@ -74,10 +75,12 @@ static Messenger *init_tox()
74 m_callback_action(m, on_action, NULL); 75 m_callback_action(m, on_action, NULL);
75#ifdef __linux__ 76#ifdef __linux__
76 setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); 77 setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
77#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) 78#elif defined(WIN32)
78 setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); 79 setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
80#elif defined(__APPLE__)
81 setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
79#else 82#else
80 setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); 83 setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
81#endif 84#endif
82 return m; 85 return m;
83} 86}
@@ -89,14 +92,12 @@ static Messenger *init_tox()
89/* Connects to a random DHT server listed in the DHTservers file */ 92/* Connects to a random DHT server listed in the DHTservers file */
90int init_connection(void) 93int init_connection(void)
91{ 94{
95 FILE *fp = NULL;
96
92 if (DHT_isconnected()) 97 if (DHT_isconnected())
93 return 0; 98 return 0;
94 99
95 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) 100 fp = fopen(SRVLIST_FILE, "r");
96 FILE *fp = fopen("DHTservers", "r");
97 #else
98 FILE *fp = fopen("~/.tox/DHTservers", "r");
99 #endif
100 101
101 if (!fp) 102 if (!fp)
102 return 1; 103 return 1;
@@ -290,11 +291,17 @@ int main(int argc, char *argv[])
290 291
291 if (config_err) { 292 if (config_err) {
292 DATA_FILE = strdup("data"); 293 DATA_FILE = strdup("data");
294 SRVLIST_FILE = strdup("../../other/DHTservers");
293 } else { 295 } else {
294 DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); 296 DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
295 strcpy(DATA_FILE, user_config_dir); 297 strcpy(DATA_FILE, user_config_dir);
296 strcat(DATA_FILE, CONFIGDIR); 298 strcat(DATA_FILE, CONFIGDIR);
297 strcat(DATA_FILE, "data"); 299 strcat(DATA_FILE, "data");
300
301 SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
302 strcpy(SRVLIST_FILE, user_config_dir);
303 strcat(SRVLIST_FILE, CONFIGDIR);
304 strcat(SRVLIST_FILE, "DHTservers");
298 } 305 }
299 } 306 }
300 307
@@ -303,7 +310,6 @@ int main(int argc, char *argv[])
303 init_term(); 310 init_term();
304 Messenger *m = init_tox(); 311 Messenger *m = init_tox();
305 ToxWindow *prompt = init_windows(m); 312 ToxWindow *prompt = init_windows(m);
306 init_window_status();
307 313
308 if (f_loadfromfile) 314 if (f_loadfromfile)
309 load_data(m, DATA_FILE); 315 load_data(m, DATA_FILE);
@@ -332,5 +338,6 @@ int main(int argc, char *argv[])
332 338
333 cleanupMessenger(m); 339 cleanupMessenger(m);
334 free(DATA_FILE); 340 free(DATA_FILE);
341 free(SRVLIST_FILE);
335 return 0; 342 return 0;
336} 343}
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index a37fdaaa..473633d4 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -19,7 +19,6 @@ extern int store_data(Messenger *m, char *path);
19uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX 19uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX
20uint8_t num_requests = 0; // XXX 20uint8_t num_requests = 0; // XXX
21 21
22static friendAddedFn *on_friendadded_cb;
23static char prompt_buf[MAX_STR_SIZE] = {0}; 22static char prompt_buf[MAX_STR_SIZE] = {0};
24static int prompt_buf_pos = 0; 23static int prompt_buf_pos = 0;
25 24
@@ -97,7 +96,7 @@ void cmd_accept(ToxWindow *self, Messenger *m, char **args)
97 wprintw(self->window, "Failed to add friend.\n"); 96 wprintw(self->window, "Failed to add friend.\n");
98 else { 97 else {
99 wprintw(self->window, "Friend accepted as: %d.\n", num); 98 wprintw(self->window, "Friend accepted as: %d.\n", num);
100 on_friendadded_cb(m, num); 99 on_friendadded(m, num);
101 } 100 }
102} 101}
103 102
@@ -174,7 +173,7 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
174 173
175 default: 174 default:
176 wprintw(self->window, "Friend added as %d.\n", num); 175 wprintw(self->window, "Friend added as %d.\n", num);
177 on_friendadded_cb(m, num); 176 on_friendadded(m, num);
178 break; 177 break;
179 } 178 }
180} 179}
@@ -273,6 +272,7 @@ void cmd_nick(ToxWindow *self, Messenger *m, char **args)
273 char *nick = args[1]; 272 char *nick = args[1];
274 setname(m, (uint8_t *) nick, strlen(nick) + 1); 273 setname(m, (uint8_t *) nick, strlen(nick) + 1);
275 wprintw(self->window, "Nickname set to: %s\n", nick); 274 wprintw(self->window, "Nickname set to: %s\n", nick);
275
276 if (store_data(m, DATA_FILE)) { 276 if (store_data(m, DATA_FILE)) {
277 wprintw(self->window, "\nCould not store Messenger data\n"); 277 wprintw(self->window, "\nCould not store Messenger data\n");
278 } 278 }
@@ -480,9 +480,8 @@ static void prompt_onInit(ToxWindow *self, Messenger *m)
480 wclrtoeol(self->window); 480 wclrtoeol(self->window);
481} 481}
482 482
483ToxWindow new_prompt(friendAddedFn *f) 483ToxWindow new_prompt()
484{ 484{
485 on_friendadded_cb = f;
486 ToxWindow ret; 485 ToxWindow ret;
487 memset(&ret, 0, sizeof(ret)); 486 memset(&ret, 0, sizeof(ret));
488 ret.onKey = &prompt_onKey; 487 ret.onKey = &prompt_onKey;
diff --git a/testing/toxic/prompt.h b/testing/toxic/prompt.h
index 6c5320ab..8e12a42f 100644
--- a/testing/toxic/prompt.h
+++ b/testing/toxic/prompt.h
@@ -3,9 +3,7 @@
3 3
4#include "windows.h" 4#include "windows.h"
5 5
6typedef void (friendAddedFn)(Messenger *m, int friendnumber); 6ToxWindow new_prompt();
7
8ToxWindow new_prompt(friendAddedFn *f);
9int add_req(uint8_t *public_key); 7int add_req(uint8_t *public_key);
10unsigned char *hex_string_to_bin(char hex_string[]); 8unsigned char *hex_string_to_bin(char hex_string[]);
11 9
diff --git a/testing/toxic/windows.c b/testing/toxic/windows.c
index 11396e2c..c0ff3026 100644
--- a/testing/toxic/windows.c
+++ b/testing/toxic/windows.c
@@ -6,15 +6,10 @@
6extern char *DATA_FILE; 6extern char *DATA_FILE;
7extern int store_data(Messenger *m, char *path); 7extern int store_data(Messenger *m, char *path);
8 8
9/* Holds status of chat windows */ 9static ToxWindow windows[MAX_WINDOWS_NUM];
10char WINDOW_STATUS[MAX_WINDOW_SLOTS]; 10static ToxWindow *active_window;
11
12static int w_num;
13static ToxWindow windows[MAX_WINDOW_SLOTS];
14static Messenger *m;
15int active_window;
16
17static ToxWindow *prompt; 11static ToxWindow *prompt;
12static Messenger *m;
18 13
19/* CALLBACKS START */ 14/* CALLBACKS START */
20void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) 15void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
@@ -31,7 +26,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
31 wprintw(prompt->window, "\nWith the message: %s\n", data); 26 wprintw(prompt->window, "\nWith the message: %s\n", data);
32 wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n); 27 wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n);
33 28
34 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 29 for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
35 if (windows[i].onFriendRequest != NULL) 30 if (windows[i].onFriendRequest != NULL)
36 windows[i].onFriendRequest(&windows[i], public_key, data, length); 31 windows[i].onFriendRequest(&windows[i], public_key, data, length);
37 } 32 }
@@ -41,7 +36,7 @@ void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length
41{ 36{
42 int i; 37 int i;
43 38
44 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 39 for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
45 if (windows[i].onMessage != NULL) 40 if (windows[i].onMessage != NULL)
46 windows[i].onMessage(&windows[i], m, friendnumber, string, length); 41 windows[i].onMessage(&windows[i], m, friendnumber, string, length);
47 } 42 }
@@ -51,7 +46,7 @@ void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length,
51{ 46{
52 int i; 47 int i;
53 48
54 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 49 for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
55 if (windows[i].onAction != NULL) 50 if (windows[i].onAction != NULL)
56 windows[i].onAction(&windows[i], m, friendnumber, string, length); 51 windows[i].onAction(&windows[i], m, friendnumber, string, length);
57 } 52 }
@@ -62,7 +57,7 @@ void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t len
62 wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string); 57 wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string);
63 int i; 58 int i;
64 59
65 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 60 for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
66 if (windows[i].onNickChange != NULL) 61 if (windows[i].onNickChange != NULL)
67 windows[i].onNickChange(&windows[i], friendnumber, string, length); 62 windows[i].onNickChange(&windows[i], friendnumber, string, length);
68 } 63 }
@@ -73,7 +68,7 @@ void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t l
73 wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); 68 wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
74 int i; 69 int i;
75 70
76 for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { 71 for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
77 if (windows[i].onStatusChange != NULL) 72 if (windows[i].onStatusChange != NULL)
78 windows[i].onStatusChange(&windows[i], friendnumber, string, length); 73 windows[i].onStatusChange(&windows[i], friendnumber, string, length);
79 } 74 }
@@ -89,119 +84,89 @@ void on_friendadded(Messenger *m, int friendnumber)
89} 84}
90/* CALLBACKS END */ 85/* CALLBACKS END */
91 86
92int add_window(Messenger *m, ToxWindow w, int n) 87int add_window(Messenger *m, ToxWindow w)
93{ 88{
94 if (w_num >= TOXWINDOWS_MAX_NUM)
95 return -1;
96
97 if (LINES < 2) 89 if (LINES < 2)
98 return -1; 90 return -1;
99 91
100 w.window = newwin(LINES - 2, COLS, 0, 0); 92 int i;
101 93 for(i = 0; i < MAX_WINDOWS_NUM; i++) {
102 if (w.window == NULL) 94 if (windows[i].window)
103 return -1; 95 continue;
104 96
105 windows[n] = w; 97 w.window = newwin(LINES - 2, COLS, 0, 0);
106 w.onInit(&w, m); 98 if (w.window == NULL)
107 w_num++; 99 return -1;
108 active_window = n; 100
109 return n; 101 windows[i] = w;
102 w.onInit(&w, m);
103
104 active_window = windows+i;
105 return i;
106 }
107
108 return -1;
110} 109}
111 110
112/* Deletes window w and cleans up */ 111/* Deletes window w and cleans up */
113void del_window(ToxWindow *w, int f_num) 112void del_window(ToxWindow *w)
114{ 113{
115 active_window = 0; // Go to prompt screen 114 active_window = windows; // Go to prompt screen
116 delwin(w->window); 115 delwin(w->window);
117 int i; 116 if (w->x)
118 117 free(w->x);
119 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) { 118 w->window = NULL;
120 if (WINDOW_STATUS[i] == f_num) { 119 memset(w, 0, sizeof(ToxWindow));
121 WINDOW_STATUS[i] = -1;
122 disable_chatwin(f_num);
123 break;
124 }
125 }
126
127 clear(); 120 clear();
128 refresh(); 121 refresh();
129} 122}
130 123
131/* Shows next window when tab or back-tab is pressed */ 124/* Shows next window when tab or back-tab is pressed */
132void set_active_window(int ch) 125void set_next_window(int ch)
133{ 126{
134 int f_inf = 0; 127 ToxWindow *end = windows+MAX_WINDOWS_NUM-1;
135 int max = MAX_WINDOW_SLOTS - 1; 128 ToxWindow *inf = active_window;
136 129 while(true) {
137 if (ch == '\t') { 130 if (ch == '\t') {
138 int i = (active_window + 1) % max; 131 if (++active_window > end)
139 132 active_window = windows;
140 while (true) { 133 } else
141 if (WINDOW_STATUS[i] != -1) { 134 if (--active_window < windows)
142 active_window = i; 135 active_window = end;
143 return; 136
144 } 137 if (active_window->window)
145 138 return;
146 i = (i + 1) % max; 139
147 140 if (active_window == inf) { // infinite loop check
148 if (f_inf++ > max) { // infinite loop check 141 endwin();
149 endwin(); 142 exit(2);
150 exit(2);
151 }
152 }
153 } else {
154 int i = active_window - 1;
155
156 if (i < 0) i = max;
157
158 while (true) {
159 if (WINDOW_STATUS[i] != -1) {
160 active_window = i;
161 return;
162 }
163
164 if (--i < 0) i = max;
165
166 if (f_inf++ > max) {
167 endwin();
168 exit(2);
169 }
170 } 143 }
171 } 144 }
172} 145}
173 146
174void init_window_status() 147void set_active_window(int index)
175{ 148{
176 /* Default window values decrement from -2 */ 149 if (index < 0 || index >= MAX_WINDOWS_NUM)
177 int i; 150 return;
178 151
179 for (i = 0; i < N_DEFAULT_WINS; ++i) 152 active_window = windows+index;
180 WINDOW_STATUS[i] = -(i + 2);
181
182 int j;
183
184 for (j = N_DEFAULT_WINS; j < MAX_WINDOW_SLOTS; j++)
185 WINDOW_STATUS[j] = -1;
186} 153}
187 154
188ToxWindow *init_windows() 155ToxWindow *init_windows()
189{ 156{
190 w_num = 0; 157 int n_prompt = add_window(m, new_prompt());
191 int n_prompt = 0; 158
192 int n_friendslist = 1; 159 if (n_prompt == -1
193 int n_dhtstatus = 2; 160 || add_window(m, new_friendlist()) == -1
194 161 || add_window(m, new_dhtstatus()) == -1) {
195 if (add_window(m, new_prompt(on_friendadded), n_prompt) == -1
196 || add_window(m, new_friendlist(WINDOW_STATUS), n_friendslist) == -1
197 || add_window(m, new_dhtstatus(), n_dhtstatus) == -1) {
198 fprintf(stderr, "add_window() failed.\n"); 162 fprintf(stderr, "add_window() failed.\n");
199 endwin(); 163 endwin();
200 exit(1); 164 exit(1);
201 } 165 }
202 166
203 active_window = n_prompt;
204 prompt = &windows[n_prompt]; 167 prompt = &windows[n_prompt];
168 active_window = prompt;
169
205 return prompt; 170 return prompt;
206} 171}
207 172
@@ -222,9 +187,9 @@ static void draw_bar()
222 187
223 int i; 188 int i;
224 189
225 for (i = 0; i < (MAX_WINDOW_SLOTS); ++i) { 190 for (i = 0; i < (MAX_WINDOWS_NUM); ++i) {
226 if (WINDOW_STATUS[i] != -1) { 191 if (windows[i].window) {
227 if (i == active_window) 192 if (windows+i == active_window)
228 attron(A_BOLD); 193 attron(A_BOLD);
229 194
230 odd = (odd + 1) % blinkrate; 195 odd = (odd + 1) % blinkrate;
@@ -232,12 +197,13 @@ static void draw_bar()
232 if (windows[i].blink && (odd < (blinkrate / 2))) 197 if (windows[i].blink && (odd < (blinkrate / 2)))
233 attron(COLOR_PAIR(3)); 198 attron(COLOR_PAIR(3));
234 199
200 clrtoeol();
235 printw(" %s", windows[i].title); 201 printw(" %s", windows[i].title);
236 202
237 if (windows[i].blink && (odd < (blinkrate / 2))) 203 if (windows[i].blink && (odd < (blinkrate / 2)))
238 attroff(COLOR_PAIR(3)); 204 attroff(COLOR_PAIR(3));
239 205
240 if (i == active_window) { 206 if (windows+i == active_window) {
241 attroff(A_BOLD); 207 attroff(A_BOLD);
242 } 208 }
243 } 209 }
@@ -255,7 +221,7 @@ void prepare_window(WINDOW *w)
255void draw_active_window(Messenger *m) 221void draw_active_window(Messenger *m)
256{ 222{
257 223
258 ToxWindow *a = &windows[active_window]; 224 ToxWindow *a = active_window;
259 prepare_window(a->window); 225 prepare_window(a->window);
260 a->blink = false; 226 a->blink = false;
261 draw_bar(); 227 draw_bar();
@@ -265,7 +231,7 @@ void draw_active_window(Messenger *m)
265 int ch = getch(); 231 int ch = getch();
266 232
267 if (ch == '\t' || ch == KEY_BTAB) 233 if (ch == '\t' || ch == KEY_BTAB)
268 set_active_window(ch); 234 set_next_window(ch);
269 else if (ch != ERR) 235 else if (ch != ERR)
270 a->onKey(a, m, ch); 236 a->onKey(a, m, ch);
271} 237}
diff --git a/testing/toxic/windows.h b/testing/toxic/windows.h
index 553a6200..be5557e9 100644
--- a/testing/toxic/windows.h
+++ b/testing/toxic/windows.h
@@ -8,7 +8,7 @@
8#include <stdint.h> 8#include <stdint.h>
9#include <stdbool.h> 9#include <stdbool.h>
10#include "../../core/Messenger.h" 10#include "../../core/Messenger.h"
11#define TOXWINDOWS_MAX_NUM 32 11#define MAX_WINDOWS_NUM 32
12#define MAX_FRIENDS_NUM 100 12#define MAX_FRIENDS_NUM 100
13#define MAX_STR_SIZE 256 13#define MAX_STR_SIZE 256
14#define KEY_SIZE_BYTES 32 14#define KEY_SIZE_BYTES 32
@@ -16,9 +16,6 @@
16/* number of permanent default windows */ 16/* number of permanent default windows */
17#define N_DEFAULT_WINS 3 17#define N_DEFAULT_WINS 3
18 18
19/* maximum window slots for WINDOW_STATUS array */
20#define MAX_WINDOW_SLOTS N_DEFAULT_WINS+MAX_FRIENDS_NUM
21
22#ifndef TOXICVER 19#ifndef TOXICVER
23#define TOXICVER "NOVER" //Use the -D flag to set this 20#define TOXICVER "NOVER" //Use the -D flag to set this
24#endif 21#endif
@@ -48,11 +45,10 @@ void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length,
48void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata); 45void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
49void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata); 46void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
50void on_friendadded(Messenger *m, int friendnumber); 47void on_friendadded(Messenger *m, int friendnumber);
51void init_window_status();
52ToxWindow *init_windows(); 48ToxWindow *init_windows();
53void draw_active_window(Messenger *m); 49void draw_active_window(Messenger *m);
54int add_window(Messenger *m, ToxWindow w, int n); 50int add_window(Messenger *m, ToxWindow w);
55void del_window(ToxWindow *w, int f_num); 51void del_window(ToxWindow *w);
56void set_active_window(int ch); 52void set_active_window(int ch);
57#endif 53#endif
58 54