summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-27 20:04:56 -0400
committerirungentoo <irungentoo@gmail.com>2013-07-27 20:04:56 -0400
commitb83359cd0594fae7789697b1d71a5aeb4c09a1fa (patch)
tree62e9163197804959c288863c51866ec6c2fb6478 /testing/nTox.c
parent1864f2b396f501738a104d427a28545beb8a3c33 (diff)
Added friend request accepting to nTox and fixed a bug.
Fixed a bug in Lossless UDP that prevented 2 clients from sometimes connecting when they connected at the same time to each other.
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 7ba31110..2acf7e94 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -38,6 +38,10 @@ char line[STRING_LENGTH];
38int x,y; 38int x,y;
39int nick_before; 39int nick_before;
40 40
41
42uint8_t pending_requests[256][CLIENT_ID_SIZE];
43uint8_t num_requests;
44
41void new_lines(char *line) 45void new_lines(char *line)
42{ 46{
43 int i; 47 int i;
@@ -114,6 +118,17 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
114 sprintf(numstring, "[i] changed status to %s", (char*)status); 118 sprintf(numstring, "[i] changed status to %s", (char*)status);
115 new_lines(numstring); 119 new_lines(numstring);
116 } 120 }
121 else if (line[1] == 'a') {
122 uint8_t numf = atoi(line + 3);
123 char numchar[100];
124 sprintf(numchar, "[i] friend request %u accepted", numf);
125 new_lines(numchar);
126 int num = m_addfriend_norequest(pending_requests[numf]);
127 sprintf(numchar, "[i] added friendnumber %d", num);
128 new_lines(numchar);
129 do_refresh();
130
131 }
117 else if (line[1] == 'q') { //exit 132 else if (line[1] == 'q') { //exit
118 endwin(); 133 endwin();
119 exit(EXIT_SUCCESS); 134 exit(EXIT_SUCCESS);
@@ -184,20 +199,18 @@ void do_refresh()
184 refresh(); 199 refresh();
185} 200}
186 201
202
203
187void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) 204void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
188{ 205{
189 new_lines("[i] received friend request"); 206 new_lines("[i] received friend request with message:");
207 new_lines((char *)data);
208 char numchar[100];
209 sprintf(numchar, "[i] To accept the request do: /a %u", num_requests);
210 new_lines(numchar);
211 memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE);
212 ++num_requests;
190 do_refresh(); 213 do_refresh();
191 if (memcmp(data , "Install Gentoo", sizeof("Install Gentoo")) == 0)
192 //if the request contained the message of peace the person is obviously a friend so we add him.
193 {
194 new_lines("[i] friend request accepted");
195 do_refresh();
196 int num = m_addfriend_norequest(public_key);
197 char numchar[100];
198 sprintf(numchar, "[i] added friendnumber %d", num);
199 new_lines(numchar);
200 }
201} 214}
202 215
203void print_message(int friendnumber, uint8_t * string, uint16_t length) 216void print_message(int friendnumber, uint8_t * string, uint16_t length)