diff options
-rwxr-xr-x | CMakeLists.txt | 4 | ||||
-rw-r--r-- | INSTALL.md | 22 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | testing/nTox.c | 104 | ||||
-rw-r--r-- | testing/nTox_win32.c | 67 | ||||
-rw-r--r-- | testing/nTox_win32.h | 2 | ||||
-rw-r--r-- | testing/toxic/chat.c | 3 | ||||
-rw-r--r-- | testing/toxic/friendlist.c | 1 | ||||
-rw-r--r-- | testing/toxic/main.c | 25 | ||||
-rw-r--r-- | testing/toxic/prompt.c | 2 |
10 files changed, 122 insertions, 109 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bf709e72..ed934c01 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.6.0) | |||
2 | 2 | ||
3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | 3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
4 | 4 | ||
5 | if(UNIX) | ||
6 | find_package(Curses REQUIRED) | ||
7 | endif() | ||
8 | |||
5 | if(NOT WIN32) | 9 | if(NOT WIN32) |
6 | option(USE_NACL "Use NaCl library instead of libsodium") | 10 | option(USE_NACL "Use NaCl library instead of libsodium") |
7 | endif() | 11 | endif() |
@@ -18,6 +18,14 @@ Build dependencies: | |||
18 | ```bash | 18 | ```bash |
19 | apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall | 19 | apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall |
20 | ``` | 20 | ``` |
21 | |||
22 | On Fedora: | ||
23 | |||
24 | ```bash | ||
25 | yum groupinstall "Development Tools" | ||
26 | yum install libtool autoconf automake libconfig-devel ncurses-devel cmake | ||
27 | ``` | ||
28 | |||
21 | Note that `libconfig-dev` should be >= 1.4. | 29 | Note that `libconfig-dev` should be >= 1.4. |
22 | 30 | ||
23 | You should get and install [libsodium](https://github.com/jedisct1/libsodium): | 31 | You should get and install [libsodium](https://github.com/jedisct1/libsodium): |
@@ -31,6 +39,20 @@ sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc | |||
31 | sudo ldconfig | 39 | sudo ldconfig |
32 | ``` | 40 | ``` |
33 | 41 | ||
42 | Or if checkinstall is not easily available for your distribution (e.g. Fedora), | ||
43 | this will install the libs to /usr/local/lib and the headers to /usr/local/include: | ||
44 | |||
45 | ```bash | ||
46 | git clone git://github.com/jedisct1/libsodium.git | ||
47 | cd libsodium | ||
48 | git checkout tags/0.4.2 | ||
49 | ./autogen.sh | ||
50 | ./configure | ||
51 | make check | ||
52 | sudo make install | ||
53 | ``` | ||
54 | |||
55 | |||
34 | Then clone this repo and generate makefile: | 56 | Then clone this repo and generate makefile: |
35 | ```bash | 57 | ```bash |
36 | git clone git://github.com/irungentoo/ProjectTox-Core.git | 58 | git clone git://github.com/irungentoo/ProjectTox-Core.git |
@@ -7,6 +7,7 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use | |||
7 | 7 | ||
8 | **IRC**: #tox on freenode, alternatively, you can use the [webchat](http://webchat.freenode.net/?channels=#tox).<br /> | 8 | **IRC**: #tox on freenode, alternatively, you can use the [webchat](http://webchat.freenode.net/?channels=#tox).<br /> |
9 | **Website**: [http://tox.im](http://tox.im) | 9 | **Website**: [http://tox.im](http://tox.im) |
10 | **Developer Blog**: [http://dev.tox.im](http://dev.tox.im) | ||
10 | 11 | ||
11 | **Website translations**: [see stal888's repository](https://github.com/stal888/ProjectTox-Website)<br/> | 12 | **Website translations**: [see stal888's repository](https://github.com/stal888/ProjectTox-Website)<br/> |
12 | **Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) | 13 | **Qt GUI**: [see nurupo's repository](https://github.com/nurupo/ProjectTox-Qt-GUI) |
diff --git a/testing/nTox.c b/testing/nTox.c index 81cac0b6..13db58d7 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | #include "nTox.h" | 23 | #include "nTox.h" |
24 | #include "misc_tools.h" | 24 | #include "misc_tools.h" |
@@ -44,13 +44,37 @@ int x, y; | |||
44 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; | 44 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; |
45 | uint8_t num_requests = 0; | 45 | uint8_t num_requests = 0; |
46 | 46 | ||
47 | void get_id(char *data) | ||
48 | { | ||
49 | char idstring0[200]; | ||
50 | char idstring1[PUB_KEY_BYTES][5]; | ||
51 | char idstring2[PUB_KEY_BYTES][5]; | ||
52 | int i = 0; | ||
53 | for(i = 0; i < PUB_KEY_BYTES; i++) | ||
54 | { | ||
55 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | ||
56 | strcpy(idstring1[i],"0"); | ||
57 | else | ||
58 | strcpy(idstring1[i], ""); | ||
59 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | ||
60 | } | ||
61 | strcpy(idstring0,"[i] ID: "); | ||
62 | int j = 0; | ||
63 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
64 | strcat(idstring0,idstring1[j]); | ||
65 | strcat(idstring0,idstring2[j]); | ||
66 | } | ||
67 | |||
68 | memcpy(data, idstring0, strlen(idstring0)); | ||
69 | } | ||
70 | |||
47 | void new_lines(char *line) | 71 | void new_lines(char *line) |
48 | { | 72 | { |
49 | int i; | 73 | int i = 0; |
50 | for (i = HISTORY-1; i > 0; i--) | 74 | for (i = HISTORY-1; i > 0; i--) |
51 | strcpy(lines[i], lines[i-1]); | 75 | strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); |
52 | 76 | ||
53 | strcpy(lines[0], line); | 77 | strncpy(lines[0], line, STRING_LENGTH - 1); |
54 | do_refresh(); | 78 | do_refresh(); |
55 | } | 79 | } |
56 | 80 | ||
@@ -109,7 +133,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
109 | if (inpt_command == 'f') { // add friend command: /f ID | 133 | if (inpt_command == 'f') { // add friend command: /f ID |
110 | int i; | 134 | int i; |
111 | char temp_id[128]; | 135 | char temp_id[128]; |
112 | for (i = 0; i < 128; i++) | 136 | for (i = 0; i < 128; i++) |
113 | temp_id[i] = line[i+prompt_offset]; | 137 | temp_id[i] = line[i+prompt_offset]; |
114 | 138 | ||
115 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); | 139 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); |
@@ -142,8 +166,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
142 | } | 166 | } |
143 | else if (inpt_command == 'm') { //message command: /m friendnumber messsage | 167 | else if (inpt_command == 'm') { //message command: /m friendnumber messsage |
144 | size_t len = strlen(line); | 168 | size_t len = strlen(line); |
145 | if(len < 3) | 169 | if(len < 3) |
146 | return; | 170 | return; |
147 | 171 | ||
148 | char numstring[len-3]; | 172 | char numstring[len-3]; |
149 | char message[len-3]; | 173 | char message[len-3]; |
@@ -216,32 +240,15 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
216 | new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); | 240 | new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); |
217 | } | 241 | } |
218 | else if (inpt_command == 'i') { //info | 242 | else if (inpt_command == 'i') { //info |
219 | char idstring0[200]; | 243 | char idstring[200]; |
220 | char idstring1[PUB_KEY_BYTES][5]; | 244 | get_id(idstring); |
221 | char idstring2[PUB_KEY_BYTES][5]; | 245 | new_lines(idstring); |
222 | int i; | ||
223 | for (i = 0; i < PUB_KEY_BYTES; i++) | ||
224 | { | ||
225 | if (self_public_key[i] < (PUB_KEY_BYTES/2)) | ||
226 | strcpy(idstring1[i],"0"); | ||
227 | else | ||
228 | strcpy(idstring1[i], ""); | ||
229 | sprintf(idstring2[i], "%hhX", self_public_key[i]); | ||
230 | } | ||
231 | // | ||
232 | strcpy(idstring0,"[i] ID: "); | ||
233 | int j; | ||
234 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
235 | strcat(idstring0,idstring1[j]); | ||
236 | strcat(idstring0,idstring2[j]); | ||
237 | } | ||
238 | new_lines(idstring0); | ||
239 | } | 246 | } |
240 | 247 | ||
241 | else if (inpt_command == 'q') { //exit | 248 | else if (inpt_command == 'q') { //exit |
242 | endwin(); | 249 | endwin(); |
243 | exit(EXIT_SUCCESS); | 250 | exit(EXIT_SUCCESS); |
244 | } else { | 251 | } else { |
245 | new_lines("[i] invalid command"); | 252 | new_lines("[i] invalid command"); |
246 | } | 253 | } |
247 | } else { | 254 | } else { |
@@ -328,7 +335,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) | |||
328 | new_lines(format_message((char*)string, friendnumber)); | 335 | new_lines(format_message((char*)string, friendnumber)); |
329 | } | 336 | } |
330 | 337 | ||
331 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | 338 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) |
332 | { | 339 | { |
333 | char name[MAX_NAME_LENGTH]; | 340 | char name[MAX_NAME_LENGTH]; |
334 | getname(friendnumber, (uint8_t*)name); | 341 | getname(friendnumber, (uint8_t*)name); |
@@ -337,7 +344,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
337 | new_lines(msg); | 344 | new_lines(msg); |
338 | } | 345 | } |
339 | 346 | ||
340 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) | 347 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
341 | { | 348 | { |
342 | char name[MAX_NAME_LENGTH]; | 349 | char name[MAX_NAME_LENGTH]; |
343 | getname(friendnumber, (uint8_t*)name); | 350 | getname(friendnumber, (uint8_t*)name); |
@@ -346,7 +353,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) | |||
346 | new_lines(msg); | 353 | new_lines(msg); |
347 | } | 354 | } |
348 | 355 | ||
349 | void load_key() | 356 | void load_key() |
350 | { | 357 | { |
351 | FILE *data_file = NULL; | 358 | FILE *data_file = NULL; |
352 | data_file = fopen("data","r"); | 359 | data_file = fopen("data","r"); |
@@ -361,7 +368,7 @@ void load_key() | |||
361 | exit(1); | 368 | exit(1); |
362 | } | 369 | } |
363 | Messenger_load(data, size); | 370 | Messenger_load(data, size); |
364 | } else { | 371 | } else { |
365 | //else save new keys | 372 | //else save new keys |
366 | int size = Messenger_size(); | 373 | int size = Messenger_size(); |
367 | uint8_t data[size]; | 374 | uint8_t data[size]; |
@@ -396,29 +403,14 @@ int main(int argc, char *argv[]) | |||
396 | m_callback_friendmessage(print_message); | 403 | m_callback_friendmessage(print_message); |
397 | m_callback_namechange(print_nickchange); | 404 | m_callback_namechange(print_nickchange); |
398 | m_callback_userstatus(print_statuschange); | 405 | m_callback_userstatus(print_statuschange); |
399 | char idstring0[200]; | 406 | |
400 | char idstring1[PUB_KEY_BYTES][5]; | 407 | char idstring[200]; |
401 | char idstring2[PUB_KEY_BYTES][5]; | 408 | get_id(idstring); |
402 | int i; | ||
403 | for(i = 0; i < PUB_KEY_BYTES; i++) | ||
404 | { | ||
405 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | ||
406 | strcpy(idstring1[i],"0"); | ||
407 | else | ||
408 | strcpy(idstring1[i], ""); | ||
409 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | ||
410 | } | ||
411 | strcpy(idstring0,"[i] your ID: "); | ||
412 | int j; | ||
413 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
414 | strcat(idstring0,idstring1[j]); | ||
415 | strcat(idstring0,idstring2[j]); | ||
416 | } | ||
417 | initscr(); | 409 | initscr(); |
418 | noecho(); | 410 | noecho(); |
419 | raw(); | 411 | raw(); |
420 | getmaxyx(stdscr, y, x); | 412 | getmaxyx(stdscr, y, x); |
421 | new_lines(idstring0); | 413 | new_lines(idstring); |
422 | new_lines(help); | 414 | new_lines(help); |
423 | strcpy(line, ""); | 415 | strcpy(line, ""); |
424 | IP_Port bootstrap_ip_port; | 416 | IP_Port bootstrap_ip_port; |
@@ -426,9 +418,9 @@ int main(int argc, char *argv[]) | |||
426 | int resolved_address = resolve_addr(argv[1]); | 418 | int resolved_address = resolve_addr(argv[1]); |
427 | if (resolved_address != 0) | 419 | if (resolved_address != 0) |
428 | bootstrap_ip_port.ip.i = resolved_address; | 420 | bootstrap_ip_port.ip.i = resolved_address; |
429 | else | 421 | else |
430 | exit(1); | 422 | exit(1); |
431 | 423 | ||
432 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); | 424 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); |
433 | nodelay(stdscr, TRUE); | 425 | nodelay(stdscr, TRUE); |
434 | while(true) { | 426 | while(true) { |
@@ -449,7 +441,7 @@ int main(int argc, char *argv[]) | |||
449 | if (c == '\n') { | 441 | if (c == '\n') { |
450 | line_eval(lines, line); | 442 | line_eval(lines, line); |
451 | strcpy(line, ""); | 443 | strcpy(line, ""); |
452 | } else if (c == 127) { | 444 | } else if (c == 8 || c == 127) { |
453 | line[strlen(line)-1] = '\0'; | 445 | line[strlen(line)-1] = '\0'; |
454 | } else if (isalnum(c) || ispunct(c) || c == ' ') { | 446 | } else if (isalnum(c) || ispunct(c) || c == ' ') { |
455 | strcpy(line, appender(line, (char) c)); | 447 | strcpy(line, appender(line, (char) c)); |
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index 3b6fb043..5501ecf5 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c | |||
@@ -32,6 +32,7 @@ uint32_t maxnumfriends; | |||
32 | 32 | ||
33 | char line[STRING_LENGTH]; | 33 | char line[STRING_LENGTH]; |
34 | char users_id[200]; | 34 | char users_id[200]; |
35 | int friend_request_received; | ||
35 | 36 | ||
36 | void do_header() | 37 | void do_header() |
37 | { | 38 | { |
@@ -44,10 +45,11 @@ void do_header() | |||
44 | 45 | ||
45 | void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) | 46 | void 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 | ||
152 | void list_friends() | 154 | void 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 | ||
173 | void delete_friend() | 184 | void delete_friend() |
@@ -244,7 +255,7 @@ void change_nickname() | |||
244 | fclose(name_file); | 255 | fclose(name_file); |
245 | } | 256 | } |
246 | 257 | ||
247 | void change_status() | 258 | void change_status(int savetofile) |
248 | { | 259 | { |
249 | uint8_t status[MAX_USERSTATUS_LENGTH]; | 260 | uint8_t status[MAX_USERSTATUS_LENGTH]; |
250 | int i = 0; | 261 | int i = 0; |
@@ -263,20 +274,21 @@ void change_status() | |||
263 | sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status); | 274 | sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status); |
264 | printf(numstring); | 275 | printf(numstring); |
265 | 276 | ||
266 | FILE* status_file = NULL; | 277 | if (savetofile == 1) { |
267 | status_file = fopen("statusfile.txt", "w"); | 278 | FILE* status_file = NULL; |
268 | fprintf(status_file, "%s", (char*)status); | 279 | status_file = fopen("statusfile.txt", "w"); |
269 | fclose(status_file); | 280 | fprintf(status_file, "%s", (char*)status); |
281 | fclose(status_file); | ||
282 | } | ||
270 | } | 283 | } |
271 | 284 | ||
272 | void accept_friend_request() | 285 | void accept_friend_request() |
273 | { | 286 | { |
287 | friend_request_received = 0; | ||
274 | uint8_t numf = atoi(line + 3); | 288 | uint8_t numf = atoi(line + 3); |
275 | char numchar[100]; | 289 | 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]); | 290 | int num = m_addfriend_norequest(pending_requests[numf]); |
279 | sprintf(numchar, "\n[i] added friendnumber %d\n\n", num); | 291 | sprintf(numchar, "\n[i] Added friendnumber: %d\n\n", num); |
280 | printf(numchar); | 292 | printf(numchar); |
281 | ++maxnumfriends; | 293 | ++maxnumfriends; |
282 | } | 294 | } |
@@ -288,7 +300,7 @@ void line_eval(char* line) | |||
288 | char inpt_command = line[1]; | 300 | char inpt_command = line[1]; |
289 | 301 | ||
290 | if(inpt_command == 'f') { | 302 | if(inpt_command == 'f') { |
291 | add_friend(line); | 303 | add_friend(); |
292 | } | 304 | } |
293 | 305 | ||
294 | else if (inpt_command == 'r') { | 306 | else if (inpt_command == 'r') { |
@@ -297,32 +309,33 @@ void line_eval(char* line) | |||
297 | } | 309 | } |
298 | 310 | ||
299 | else if (inpt_command == 'l') { | 311 | else if (inpt_command == 'l') { |
300 | list_friends(line); | 312 | list_friends(); |
301 | } | 313 | } |
302 | 314 | ||
303 | else if (inpt_command == 'd') { | 315 | else if (inpt_command == 'd') { |
304 | delete_friend(line); | 316 | delete_friend(); |
305 | } | 317 | } |
306 | /* Send message to friend */ | 318 | /* Send message to friend */ |
307 | else if (inpt_command == 'm') { | 319 | else if (inpt_command == 'm') { |
308 | message_friend(line); | 320 | message_friend(); |
309 | } | 321 | } |
310 | 322 | ||
311 | else if (inpt_command == 'n') { | 323 | else if (inpt_command == 'n') { |
312 | change_nickname(line); | 324 | change_nickname(); |
313 | } | 325 | } |
314 | 326 | ||
315 | else if (inpt_command == 's') { | 327 | else if (inpt_command == 's') { |
316 | change_status(line); | 328 | change_status(1); |
317 | } | 329 | } |
318 | 330 | ||
319 | else if (inpt_command == 'a') { | 331 | else if (inpt_command == 'a') { |
320 | accept_friend_request(line); | 332 | if (friend_request_received == 1) |
333 | accept_friend_request(line); | ||
321 | } | 334 | } |
322 | /* EXIT */ | 335 | /* EXIT */ |
323 | else if (inpt_command == 'q') { | 336 | else if (inpt_command == 'q') { |
324 | uint8_t status[MAX_USERSTATUS_LENGTH] = "Offline"; | 337 | strcpy(line, "---Offline"); |
325 | m_set_userstatus(status, strlen((char*)status)); | 338 | change_status(0); |
326 | exit(EXIT_SUCCESS); | 339 | exit(EXIT_SUCCESS); |
327 | } | 340 | } |
328 | } | 341 | } |
@@ -368,8 +381,7 @@ int main(int argc, char *argv[]) | |||
368 | nameloaded = 1; | 381 | nameloaded = 1; |
369 | printf("%s\n", name); | 382 | printf("%s\n", name); |
370 | fclose(name_file); | 383 | fclose(name_file); |
371 | } | 384 | } |
372 | |||
373 | 385 | ||
374 | FILE* status_file = NULL; | 386 | FILE* status_file = NULL; |
375 | status_file = fopen("statusfile.txt", "r"); | 387 | status_file = fopen("statusfile.txt", "r"); |
@@ -383,7 +395,6 @@ int main(int argc, char *argv[]) | |||
383 | printf("%s\n", status); | 395 | printf("%s\n", status); |
384 | fclose(status_file); | 396 | fclose(status_file); |
385 | } | 397 | } |
386 | |||
387 | 398 | ||
388 | m_callback_friendrequest(print_request); | 399 | m_callback_friendrequest(print_request); |
389 | m_callback_friendmessage(print_message); | 400 | m_callback_friendmessage(print_message); |
diff --git a/testing/nTox_win32.h b/testing/nTox_win32.h index 211ac95f..271403b8 100644 --- a/testing/nTox_win32.h +++ b/testing/nTox_win32.h | |||
@@ -39,7 +39,7 @@ void list_friends(); | |||
39 | void delete_friend(); | 39 | void delete_friend(); |
40 | void message_friend(); | 40 | void message_friend(); |
41 | void change_nickname(); | 41 | void change_nickname(); |
42 | void change_status(); | 42 | void change_status(int savetofile); |
43 | void accept_friend_request(); | 43 | void accept_friend_request(); |
44 | void line_eval(char* line); | 44 | void line_eval(char* line); |
45 | void get_input(); | 45 | void get_input(); |
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 854d3817..1bfd94f5 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -106,6 +106,7 @@ static void chat_onKey(ToxWindow* self, int key) { | |||
106 | } | 106 | } |
107 | 107 | ||
108 | static void chat_onDraw(ToxWindow* self) { | 108 | static void chat_onDraw(ToxWindow* self) { |
109 | curs_set(1); | ||
109 | int x, y; | 110 | int x, y; |
110 | ChatContext* ctx = (ChatContext*) self->x; | 111 | ChatContext* ctx = (ChatContext*) self->x; |
111 | 112 | ||
@@ -117,7 +118,7 @@ static void chat_onDraw(ToxWindow* self) { | |||
117 | 118 | ||
118 | wclear(ctx->linewin); | 119 | wclear(ctx->linewin); |
119 | mvwhline(ctx->linewin, 0, 0, '_', COLS); | 120 | mvwhline(ctx->linewin, 0, 0, '_', COLS); |
120 | mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line); | 121 | mvwprintw(self->window, y-1, 0, "%s\n", ctx->line); |
121 | 122 | ||
122 | wrefresh(self->window); | 123 | wrefresh(self->window); |
123 | } | 124 | } |
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index f9a413f9..b4b619a2 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c | |||
@@ -113,6 +113,7 @@ static void friendlist_onKey(ToxWindow* self, int key) { | |||
113 | } | 113 | } |
114 | 114 | ||
115 | static void friendlist_onDraw(ToxWindow* self) { | 115 | static void friendlist_onDraw(ToxWindow* self) { |
116 | curs_set(0); | ||
116 | size_t i; | 117 | size_t i; |
117 | 118 | ||
118 | wclear(self->window); | 119 | wclear(self->window); |
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index c596b708..391b0b39 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -50,7 +50,7 @@ void on_request(uint8_t* public_key, uint8_t* data, uint16_t length) { | |||
50 | void on_message(int friendnumber, uint8_t* string, uint16_t length) { | 50 | void on_message(int friendnumber, uint8_t* string, uint16_t length) { |
51 | size_t i; | 51 | size_t i; |
52 | 52 | ||
53 | wprintw(prompt->window, "\n(message) %d: %s!\n", friendnumber, string); | 53 | wprintw(prompt->window, "\n(message) %d: %s\n", friendnumber, string); |
54 | 54 | ||
55 | for(i=0; i<w_num; i++) { | 55 | for(i=0; i<w_num; i++) { |
56 | if(windows[i].onMessage != NULL) | 56 | if(windows[i].onMessage != NULL) |
@@ -280,26 +280,6 @@ void prepare_window(WINDOW* w) { | |||
280 | wresize(w, LINES-2, COLS); | 280 | wresize(w, LINES-2, COLS); |
281 | } | 281 | } |
282 | 282 | ||
283 | /* | ||
284 | * Draws cursor relative to input on prompt window. | ||
285 | * Removes cursor on friends window and chat windows. | ||
286 | * | ||
287 | * TODO: Make it work for chat windows | ||
288 | */ | ||
289 | void position_cursor(WINDOW* w, char* title) | ||
290 | { | ||
291 | curs_set(1); | ||
292 | if (strcmp(title, "[prompt]") == 0) { // main/prompt window | ||
293 | int x, y; | ||
294 | getyx(w, y, x); | ||
295 | move(y, x); | ||
296 | } | ||
297 | else if (strcmp(title, "[friends]") == 0) // friends window | ||
298 | curs_set(0); | ||
299 | else // any other window (i.e chat) | ||
300 | curs_set(0); | ||
301 | } | ||
302 | |||
303 | int main(int argc, char* argv[]) { | 283 | int main(int argc, char* argv[]) { |
304 | int ch; | 284 | int ch; |
305 | ToxWindow* a; | 285 | ToxWindow* a; |
@@ -317,9 +297,8 @@ int main(int argc, char* argv[]) { | |||
317 | a = &windows[w_active]; | 297 | a = &windows[w_active]; |
318 | prepare_window(a->window); | 298 | prepare_window(a->window); |
319 | a->blink = false; | 299 | a->blink = false; |
320 | a->onDraw(a); | ||
321 | draw_bar(); | 300 | draw_bar(); |
322 | position_cursor(a->window, a->title); | 301 | a->onDraw(a); |
323 | 302 | ||
324 | // Handle input. | 303 | // Handle input. |
325 | ch = getch(); | 304 | ch = getch(); |
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index b0f83811..1db60883 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c | |||
@@ -140,6 +140,7 @@ static void execute(ToxWindow* self, char* cmd) { | |||
140 | break; | 140 | break; |
141 | case -2: | 141 | case -2: |
142 | wprintw(self->window, "Please add a message to your request.\n"); | 142 | wprintw(self->window, "Please add a message to your request.\n"); |
143 | break; | ||
143 | case -3: | 144 | case -3: |
144 | wprintw(self->window, "That appears to be your own ID.\n"); | 145 | wprintw(self->window, "That appears to be your own ID.\n"); |
145 | break; | 146 | break; |
@@ -287,6 +288,7 @@ static void prompt_onKey(ToxWindow* self, int key) { | |||
287 | } | 288 | } |
288 | 289 | ||
289 | static void prompt_onDraw(ToxWindow* self) { | 290 | static void prompt_onDraw(ToxWindow* self) { |
291 | curs_set(1); | ||
290 | int x, y; | 292 | int x, y; |
291 | 293 | ||
292 | getyx(self->window, y, x); | 294 | getyx(self->window, y, x); |