summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/nTox_win32.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c
index 3b6fb043..9c6e0aac 100644
--- a/testing/nTox_win32.c
+++ b/testing/nTox_win32.c
@@ -32,6 +32,7 @@ uint32_t maxnumfriends;
32 32
33char line[STRING_LENGTH]; 33char line[STRING_LENGTH];
34char users_id[200]; 34char users_id[200];
35int friend_request_received;
35 36
36void do_header() 37void do_header()
37{ 38{
@@ -44,10 +45,11 @@ void do_header()
44 45
45void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) 46void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
46{ 47{
48 friend_request_received = 1;
47 printf("\n\n[i] received friend request with message\n"); 49 printf("\n\n[i] received friend request with message\n");
48 printf((char *)data); 50 printf("'%s'",(char *)data);
49 char numchar[100]; 51 char numchar[100];
50 sprintf(numchar, "\n\n[i] accept request with /a %u\n\n", num_requests); 52 sprintf(numchar, "\n[i] accept request with /a %u\n\n", num_requests);
51 printf(numchar); 53 printf(numchar);
52 memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); 54 memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE);
53 ++num_requests; 55 ++num_requests;
@@ -271,12 +273,11 @@ void change_status()
271 273
272void accept_friend_request() 274void accept_friend_request()
273{ 275{
276 friend_request_received = 0;
274 uint8_t numf = atoi(line + 3); 277 uint8_t numf = atoi(line + 3);
275 char numchar[100]; 278 char numchar[100];
276 sprintf(numchar, "\n[i] friend request %u accepted\n\n", numf);
277 printf(numchar);
278 int num = m_addfriend_norequest(pending_requests[numf]); 279 int num = m_addfriend_norequest(pending_requests[numf]);
279 sprintf(numchar, "\n[i] added friendnumber %d\n\n", num); 280 sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num);
280 printf(numchar); 281 printf(numchar);
281 ++maxnumfriends; 282 ++maxnumfriends;
282} 283}
@@ -317,12 +318,14 @@ void line_eval(char* line)
317 } 318 }
318 319
319 else if (inpt_command == 'a') { 320 else if (inpt_command == 'a') {
320 accept_friend_request(line); 321 if (friend_request_received == 1)
322 accept_friend_request(line);
321 } 323 }
322 /* EXIT */ 324 /* EXIT */
323 else if (inpt_command == 'q') { 325 else if (inpt_command == 'q') {
324 uint8_t status[MAX_USERSTATUS_LENGTH] = "Offline"; 326 uint8_t status[MAX_USERSTATUS_LENGTH] = "Offline";
325 m_set_userstatus(status, strlen((char*)status)); 327 m_set_userstatus(status, strlen((char*)status));
328 Sleep(10);
326 exit(EXIT_SUCCESS); 329 exit(EXIT_SUCCESS);
327 } 330 }
328 } 331 }
@@ -368,8 +371,7 @@ int main(int argc, char *argv[])
368 nameloaded = 1; 371 nameloaded = 1;
369 printf("%s\n", name); 372 printf("%s\n", name);
370 fclose(name_file); 373 fclose(name_file);
371 } 374 }
372
373 375
374 FILE* status_file = NULL; 376 FILE* status_file = NULL;
375 status_file = fopen("statusfile.txt", "r"); 377 status_file = fopen("statusfile.txt", "r");
@@ -383,7 +385,6 @@ int main(int argc, char *argv[])
383 printf("%s\n", status); 385 printf("%s\n", status);
384 fclose(status_file); 386 fclose(status_file);
385 } 387 }
386
387 388
388 m_callback_friendrequest(print_request); 389 m_callback_friendrequest(print_request);
389 m_callback_friendmessage(print_message); 390 m_callback_friendmessage(print_message);