summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/nTox_win32.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c
index 3b6fb043..55440828 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;
@@ -151,23 +153,32 @@ void add_friend()
151 153
152void list_friends() 154void list_friends()
153{ 155{
154 int activefriends = 0;
155 int i; 156 int i;
157
158 printf("\n[i] Friend List");
159
160 printf("----- PENDING -----\n\n");
156 161
157 for (i = 0; i <= maxnumfriends; i++) { 162 for (i = 0; i <= maxnumfriends; i++) {
158 if (m_friendstatus(i) == 4) 163 char name[MAX_NAME_LENGTH];
159 activefriends++; 164 getname(i, (uint8_t*)name);
165 if (m_friendstatus(i) > 0 && m_friendstatus(i) < 4)
166 printf("[%d] %s\n", i, (uint8_t*)name);
160 } 167 }
168
169 printf("\n");
161 170
162 printf("\n[i] Friend List | Total: %d\n\n", activefriends); 171 printf("----- ACTIVE -----\n\n");
163 172
164 for (i = 0; i <= 256; i++) {/* TODO: fix this properly*/ 173 for (i = 0; i <= maxnumfriends; i++) {
165 char name[MAX_NAME_LENGTH]; 174 char name[MAX_NAME_LENGTH];
166 getname(i, (uint8_t*)name); 175 getname(i, (uint8_t*)name);
167 176
168 if (m_friendstatus(i) == 4) 177 if (m_friendstatus(i) == 4)
169 printf("[%d] %s\n\n", i, (uint8_t*)name); 178 printf("[%d] %s\n", i, (uint8_t*)name);
170 } 179 }
180
181 printf("\n");
171} 182}
172 183
173void delete_friend() 184void delete_friend()
@@ -271,12 +282,11 @@ void change_status()
271 282
272void accept_friend_request() 283void accept_friend_request()
273{ 284{
285 friend_request_received = 0;
274 uint8_t numf = atoi(line + 3); 286 uint8_t numf = atoi(line + 3);
275 char numchar[100]; 287 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]); 288 int num = m_addfriend_norequest(pending_requests[numf]);
279 sprintf(numchar, "\n[i] added friendnumber %d\n\n", num); 289 sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num);
280 printf(numchar); 290 printf(numchar);
281 ++maxnumfriends; 291 ++maxnumfriends;
282} 292}
@@ -317,12 +327,13 @@ void line_eval(char* line)
317 } 327 }
318 328
319 else if (inpt_command == 'a') { 329 else if (inpt_command == 'a') {
320 accept_friend_request(line); 330 if (friend_request_received == 1)
331 accept_friend_request(line);
321 } 332 }
322 /* EXIT */ 333 /* EXIT */
323 else if (inpt_command == 'q') { 334 else if (inpt_command == 'q') {
324 uint8_t status[MAX_USERSTATUS_LENGTH] = "Offline"; 335 strcpy(line, "Offline");
325 m_set_userstatus(status, strlen((char*)status)); 336 change_status(line);
326 exit(EXIT_SUCCESS); 337 exit(EXIT_SUCCESS);
327 } 338 }
328 } 339 }
@@ -368,8 +379,7 @@ int main(int argc, char *argv[])
368 nameloaded = 1; 379 nameloaded = 1;
369 printf("%s\n", name); 380 printf("%s\n", name);
370 fclose(name_file); 381 fclose(name_file);
371 } 382 }
372
373 383
374 FILE* status_file = NULL; 384 FILE* status_file = NULL;
375 status_file = fopen("statusfile.txt", "r"); 385 status_file = fopen("statusfile.txt", "r");
@@ -383,7 +393,6 @@ int main(int argc, char *argv[])
383 printf("%s\n", status); 393 printf("%s\n", status);
384 fclose(status_file); 394 fclose(status_file);
385 } 395 }
386
387 396
388 m_callback_friendrequest(print_request); 397 m_callback_friendrequest(print_request);
389 m_callback_friendmessage(print_message); 398 m_callback_friendmessage(print_message);