summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/CMakeLists.txt5
-rw-r--r--testing/nTox.c30
-rw-r--r--testing/nTox_win32.c29
-rw-r--r--testing/toxic/prompt.c6
4 files changed, 50 insertions, 20 deletions
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
index abbc278e..f2a2e95e 100644
--- a/testing/CMakeLists.txt
+++ b/testing/CMakeLists.txt
@@ -8,11 +8,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake)
8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) 8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake)
9include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) 9include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake)
10include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) 10include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake)
11
11if(WIN32) 12if(WIN32)
12 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake) 13 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake)
13endif() 14else()
14
15if(NOT WIN32)
16 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake) 15 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake)
17 add_subdirectory(toxic) 16 add_subdirectory(toxic)
18endif() 17endif()
diff --git a/testing/nTox.c b/testing/nTox.c
index ec597bc3..fe91b1fa 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -42,7 +42,12 @@ char *help = "[i] commands:\n/f ID (to add friend)\n/m friendnumber message "
42 "name)\n/q (to quit)"; 42 "name)\n/q (to quit)";
43int x, y; 43int x, y;
44 44
45uint8_t pending_requests[256][CLIENT_ID_SIZE]; 45typedef struct {
46 uint8_t id[CLIENT_ID_SIZE];
47 uint8_t accepted;
48} Friend_request;
49
50Friend_request pending_requests[256];
46uint8_t num_requests = 0; 51uint8_t num_requests = 0;
47 52
48void get_id(char *data) 53void get_id(char *data)
@@ -231,15 +236,21 @@ void line_eval(char *line)
231 else if (inpt_command == 'a') { 236 else if (inpt_command == 'a') {
232 uint8_t numf = atoi(line + 3); 237 uint8_t numf = atoi(line + 3);
233 char numchar[100]; 238 char numchar[100];
234 int num = m_addfriend_norequest(pending_requests[numf]); 239 if (numf >= num_requests || pending_requests[numf].accepted) {
235 if (num != -1) { 240 sprintf(numchar,"[i] you either didn't receive that request or you already accepted it");
236 sprintf(numchar, "[i] friend request %u accepted", numf);
237 new_lines(numchar);
238 sprintf(numchar, "[i] added friendnumber %d", num);
239 new_lines(numchar); 241 new_lines(numchar);
240 } else { 242 } else {
241 sprintf(numchar, "[i] failed to add friend"); 243 int num = m_addfriend_norequest(pending_requests[numf].id);
242 new_lines(numchar); 244 if (num != -1) {
245 pending_requests[numf].accepted = 1;
246 sprintf(numchar, "[i] friend request %u accepted", numf);
247 new_lines(numchar);
248 sprintf(numchar, "[i] added friendnumber %d", num);
249 new_lines(numchar);
250 } else {
251 sprintf(numchar, "[i] failed to add friend");
252 new_lines(numchar);
253 }
243 } 254 }
244 do_refresh(); 255 do_refresh();
245 } 256 }
@@ -332,7 +343,8 @@ void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
332 char numchar[100]; 343 char numchar[100];
333 sprintf(numchar, "[i] accept request with /a %u", num_requests); 344 sprintf(numchar, "[i] accept request with /a %u", num_requests);
334 new_lines(numchar); 345 new_lines(numchar);
335 memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); 346 memcpy(pending_requests[num_requests].id, public_key, CLIENT_ID_SIZE);
347 pending_requests[num_requests].accepted = 0;
336 ++num_requests; 348 ++num_requests;
337 do_refresh(); 349 do_refresh();
338} 350}
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c
index 5501ecf5..f3c7a188 100644
--- a/testing/nTox_win32.c
+++ b/testing/nTox_win32.c
@@ -26,7 +26,12 @@
26 26
27#include <process.h> 27#include <process.h>
28 28
29uint8_t pending_requests[256][CLIENT_ID_SIZE]; 29typedef struct {
30 uint8_t id[CLIENT_ID_SIZE];
31 uint8_t accepted;
32} Friend_request;
33
34Friend_request pending_requests[256];
30uint8_t num_requests = 0; 35uint8_t num_requests = 0;
31uint32_t maxnumfriends; 36uint32_t maxnumfriends;
32 37
@@ -51,7 +56,8 @@ void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
51 char numchar[100]; 56 char numchar[100];
52 sprintf(numchar, "\n[i] accept request with /a %u\n\n", num_requests); 57 sprintf(numchar, "\n[i] accept request with /a %u\n\n", num_requests);
53 printf(numchar); 58 printf(numchar);
54 memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); 59 memcpy(pending_requests[num_requests].id, public_key, CLIENT_ID_SIZE);
60 pending_requests[num_requests].accepted = 0;
55 ++num_requests; 61 ++num_requests;
56} 62}
57 63
@@ -287,10 +293,21 @@ void accept_friend_request()
287 friend_request_received = 0; 293 friend_request_received = 0;
288 uint8_t numf = atoi(line + 3); 294 uint8_t numf = atoi(line + 3);
289 char numchar[100]; 295 char numchar[100];
290 int num = m_addfriend_norequest(pending_requests[numf]); 296 if (numf >= num_requests || pending_requests[numf].accepted) {
291 sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num); 297 sprintf(numchar, "\n[i] you either didn't receive that request or you already accepted it");
292 printf(numchar); 298 printf(numchar);
293 ++maxnumfriends; 299 } else {
300 int num = m_addfriend_norequest(pending_requests[numf].id);
301 if (num != -1) {
302 pending_requests[numf].accepted = 1;
303 sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num);
304 printf(numchar);
305 ++maxnumfriends;
306 } else {
307 sprintf(numchar, "[i] failed to add friend");
308 printf(numchar);
309 }
310 }
294} 311}
295 312
296void line_eval(char* line) 313void line_eval(char* line)
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index 463b9352..e5dc5086 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -158,7 +158,9 @@ static void execute(ToxWindow* self, char* cmd) {
158 break; 158 break;
159 } 159 }
160 } 160 }
161 161 else if(!strcmp(cmd, "clear")) {
162 wclear(self->window);
163 }
162 else if(!strcmp(cmd, "help")) { 164 else if(!strcmp(cmd, "help")) {
163 print_usage(self); 165 print_usage(self);
164 } 166 }
@@ -316,7 +318,7 @@ static void print_usage(ToxWindow* self) {
316 wprintw(self->window, " myid : Print your ID\n"); 318 wprintw(self->window, " myid : Print your ID\n");
317 wprintw(self->window, " quit/exit : Exit program\n"); 319 wprintw(self->window, " quit/exit : Exit program\n");
318 wprintw(self->window, " help : Print this message again\n"); 320 wprintw(self->window, " help : Print this message again\n");
319 321 wprintw(self->window, " clear : Clear this window\n");
320 322
321 wattron(self->window, A_BOLD); 323 wattron(self->window, A_BOLD);
322 wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n"); 324 wprintw(self->window, "TIP: Use the TAB key to navigate through the tabs.\n\n");