diff options
Diffstat (limited to 'testing/nTox.c')
-rw-r--r-- | testing/nTox.c | 133 |
1 files changed, 70 insertions, 63 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 329191d7..ff419c9a 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -105,7 +105,7 @@ int x, y; | |||
105 | int conversation_default = 0; | 105 | int conversation_default = 0; |
106 | 106 | ||
107 | typedef struct { | 107 | typedef struct { |
108 | uint8_t id[TOX_CLIENT_ID_SIZE]; | 108 | uint8_t id[TOX_PUBLIC_KEY_SIZE]; |
109 | uint8_t accepted; | 109 | uint8_t accepted; |
110 | } Friend_request; | 110 | } Friend_request; |
111 | 111 | ||
@@ -179,19 +179,19 @@ int add_filesender(Tox *m, uint16_t friendnum, char *filename) | |||
179 | 179 | ||
180 | 180 | ||
181 | #define FRADDR_TOSTR_CHUNK_LEN 8 | 181 | #define FRADDR_TOSTR_CHUNK_LEN 8 |
182 | #define FRADDR_TOSTR_BUFSIZE (TOX_FRIEND_ADDRESS_SIZE * 2 + TOX_FRIEND_ADDRESS_SIZE / FRADDR_TOSTR_CHUNK_LEN + 1) | 182 | #define FRADDR_TOSTR_BUFSIZE (TOX_ADDRESS_SIZE * 2 + TOX_ADDRESS_SIZE / FRADDR_TOSTR_CHUNK_LEN + 1) |
183 | 183 | ||
184 | static void fraddr_to_str(uint8_t *id_bin, char *id_str) | 184 | static void fraddr_to_str(uint8_t *id_bin, char *id_str) |
185 | { | 185 | { |
186 | uint32_t i, delta = 0, pos_extra, sum_extra = 0; | 186 | uint32_t i, delta = 0, pos_extra, sum_extra = 0; |
187 | 187 | ||
188 | for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) { | 188 | for (i = 0; i < TOX_ADDRESS_SIZE; i++) { |
189 | sprintf(&id_str[2 * i + delta], "%02hhX", id_bin[i]); | 189 | sprintf(&id_str[2 * i + delta], "%02hhX", id_bin[i]); |
190 | 190 | ||
191 | if ((i + 1) == TOX_CLIENT_ID_SIZE) | 191 | if ((i + 1) == TOX_PUBLIC_KEY_SIZE) |
192 | pos_extra = 2 * (i + 1) + delta; | 192 | pos_extra = 2 * (i + 1) + delta; |
193 | 193 | ||
194 | if (i >= TOX_CLIENT_ID_SIZE) | 194 | if (i >= TOX_PUBLIC_KEY_SIZE) |
195 | sum_extra |= id_bin[i]; | 195 | sum_extra |= id_bin[i]; |
196 | 196 | ||
197 | if (!((i + 1) % FRADDR_TOSTR_CHUNK_LEN)) { | 197 | if (!((i + 1) % FRADDR_TOSTR_CHUNK_LEN)) { |
@@ -210,14 +210,15 @@ void get_id(Tox *m, char *data) | |||
210 | { | 210 | { |
211 | sprintf(data, "[i] ID: "); | 211 | sprintf(data, "[i] ID: "); |
212 | int offset = strlen(data); | 212 | int offset = strlen(data); |
213 | uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; | 213 | uint8_t address[TOX_ADDRESS_SIZE]; |
214 | tox_get_address(m, address); | 214 | tox_self_get_address(m, address); |
215 | fraddr_to_str(address, data + offset); | 215 | fraddr_to_str(address, data + offset); |
216 | } | 216 | } |
217 | 217 | ||
218 | int getfriendname_terminated(Tox *m, int friendnum, char *namebuf) | 218 | int getfriendname_terminated(Tox *m, int friendnum, char *namebuf) |
219 | { | 219 | { |
220 | int res = tox_get_name(m, friendnum, (uint8_t *)namebuf); | 220 | tox_friend_get_name(m, friendnum, (uint8_t *)namebuf, NULL); |
221 | int res = tox_friend_get_name_size(m, friendnum, NULL); | ||
221 | 222 | ||
222 | if (res >= 0) | 223 | if (res >= 0) |
223 | namebuf[res] = 0; | 224 | namebuf[res] = 0; |
@@ -249,13 +250,13 @@ void new_lines(char *line) | |||
249 | 250 | ||
250 | 251 | ||
251 | const char ptrn_friend[] = "[i] Friend %i: %s\n+ id: %s"; | 252 | const char ptrn_friend[] = "[i] Friend %i: %s\n+ id: %s"; |
252 | const int id_str_len = TOX_FRIEND_ADDRESS_SIZE * 2 + 3; | 253 | const int id_str_len = TOX_ADDRESS_SIZE * 2 + 3; |
253 | void print_friendlist(Tox *m) | 254 | void print_friendlist(Tox *m) |
254 | { | 255 | { |
255 | new_lines("[i] Friend List:"); | 256 | new_lines("[i] Friend List:"); |
256 | 257 | ||
257 | char name[TOX_MAX_NAME_LENGTH + 1]; | 258 | char name[TOX_MAX_NAME_LENGTH + 1]; |
258 | uint8_t fraddr_bin[TOX_FRIEND_ADDRESS_SIZE]; | 259 | uint8_t fraddr_bin[TOX_ADDRESS_SIZE]; |
259 | char fraddr_str[FRADDR_TOSTR_BUFSIZE]; | 260 | char fraddr_str[FRADDR_TOSTR_BUFSIZE]; |
260 | 261 | ||
261 | /* account for the longest name and the longest "base" string and number (int) and id_str */ | 262 | /* account for the longest name and the longest "base" string and number (int) and id_str */ |
@@ -264,7 +265,7 @@ void print_friendlist(Tox *m) | |||
264 | uint32_t i = 0; | 265 | uint32_t i = 0; |
265 | 266 | ||
266 | while (getfriendname_terminated(m, i, name) != -1) { | 267 | while (getfriendname_terminated(m, i, name) != -1) { |
267 | if (!tox_get_client_id(m, i, fraddr_bin)) | 268 | if (tox_friend_get_public_key(m, i, fraddr_bin, NULL)) |
268 | fraddr_to_str(fraddr_bin, fraddr_str); | 269 | fraddr_to_str(fraddr_bin, fraddr_str); |
269 | else | 270 | else |
270 | sprintf(fraddr_str, "???"); | 271 | sprintf(fraddr_str, "???"); |
@@ -347,50 +348,59 @@ void line_eval(Tox *m, char *line) | |||
347 | } | 348 | } |
348 | 349 | ||
349 | unsigned char *bin_string = hex_string_to_bin(temp_id); | 350 | unsigned char *bin_string = hex_string_to_bin(temp_id); |
350 | int num = tox_add_friend(m, bin_string, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); | 351 | TOX_ERR_FRIEND_ADD error; |
352 | uint32_t num = tox_friend_add(m, bin_string, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo"), &error); | ||
351 | free(bin_string); | 353 | free(bin_string); |
352 | char numstring[100]; | 354 | char numstring[100]; |
353 | 355 | ||
354 | switch (num) { | 356 | switch (error) { |
355 | case TOX_FAERR_TOOLONG: | 357 | case TOX_ERR_FRIEND_ADD_TOO_LONG: |
356 | sprintf(numstring, "[i] Message is too long."); | 358 | sprintf(numstring, "[i] Message is too long."); |
357 | break; | 359 | break; |
358 | 360 | ||
359 | case TOX_FAERR_NOMESSAGE: | 361 | case TOX_ERR_FRIEND_ADD_NO_MESSAGE: |
360 | sprintf(numstring, "[i] Please add a message to your request."); | 362 | sprintf(numstring, "[i] Please add a message to your request."); |
361 | break; | 363 | break; |
362 | 364 | ||
363 | case TOX_FAERR_OWNKEY: | 365 | case TOX_ERR_FRIEND_ADD_OWN_KEY: |
364 | sprintf(numstring, "[i] That appears to be your own ID."); | 366 | sprintf(numstring, "[i] That appears to be your own ID."); |
365 | break; | 367 | break; |
366 | 368 | ||
367 | case TOX_FAERR_ALREADYSENT: | 369 | case TOX_ERR_FRIEND_ADD_ALREADY_SENT: |
368 | sprintf(numstring, "[i] Friend request already sent."); | 370 | sprintf(numstring, "[i] Friend request already sent."); |
369 | break; | 371 | break; |
370 | 372 | ||
371 | case TOX_FAERR_UNKNOWN: | 373 | case TOX_ERR_FRIEND_ADD_BAD_CHECKSUM: |
372 | sprintf(numstring, "[i] Undefined error when adding friend."); | 374 | sprintf(numstring, "[i] Address has a bad checksum."); |
373 | break; | 375 | break; |
374 | 376 | ||
375 | default: | 377 | case TOX_ERR_FRIEND_ADD_SET_NEW_NOSPAM: |
376 | if (num >= 0) { | 378 | sprintf(numstring, "[i] New nospam set."); |
377 | sprintf(numstring, "[i] Added friend as %d.", num); | 379 | break; |
378 | save_data(m); | 380 | |
379 | } else | 381 | case TOX_ERR_FRIEND_ADD_MALLOC: |
380 | sprintf(numstring, "[i] Unknown error %i.", num); | 382 | sprintf(numstring, "[i] malloc error."); |
383 | break; | ||
381 | 384 | ||
385 | case TOX_ERR_FRIEND_ADD_NULL: | ||
386 | sprintf(numstring, "[i] message was NULL."); | ||
387 | break; | ||
388 | |||
389 | case TOX_ERR_FRIEND_ADD_OK: | ||
390 | sprintf(numstring, "[i] Added friend as %d.", num); | ||
391 | save_data(m); | ||
382 | break; | 392 | break; |
383 | } | 393 | } |
384 | 394 | ||
385 | new_lines(numstring); | 395 | new_lines(numstring); |
386 | } else if (inpt_command == 'd') { | 396 | } else if (inpt_command == 'd') { |
387 | tox_do(m); | 397 | tox_iteration(m); |
388 | } else if (inpt_command == 'm') { //message command: /m friendnumber messsage | 398 | } else if (inpt_command == 'm') { //message command: /m friendnumber messsage |
389 | char *posi[1]; | 399 | char *posi[1]; |
390 | int num = strtoul(line + prompt_offset, posi, 0); | 400 | int num = strtoul(line + prompt_offset, posi, 0); |
391 | 401 | ||
392 | if (**posi != 0) { | 402 | if (**posi != 0) { |
393 | if (tox_send_message(m, num, (uint8_t *) *posi + 1, strlen(*posi + 1)) < 1) { | 403 | if (tox_send_message(m, num, (uint8_t *) *posi + 1, strlen(*posi + 1), NULL) < 1) { |
394 | char sss[256]; | 404 | char sss[256]; |
395 | sprintf(sss, "[i] could not send message to friend num %u", num); | 405 | sprintf(sss, "[i] could not send message to friend num %u", num); |
396 | new_lines(sss); | 406 | new_lines(sss); |
@@ -410,14 +420,14 @@ void line_eval(Tox *m, char *line) | |||
410 | } | 420 | } |
411 | 421 | ||
412 | name[i - 3] = 0; | 422 | name[i - 3] = 0; |
413 | tox_set_name(m, name, i - 2); | 423 | tox_self_set_name(m, name, i - 2, NULL); |
414 | char numstring[100]; | 424 | char numstring[100]; |
415 | sprintf(numstring, "[i] changed nick to %s", (char *)name); | 425 | sprintf(numstring, "[i] changed nick to %s", (char *)name); |
416 | new_lines(numstring); | 426 | new_lines(numstring); |
417 | } else if (inpt_command == 'l') { | 427 | } else if (inpt_command == 'l') { |
418 | print_friendlist(m); | 428 | print_friendlist(m); |
419 | } else if (inpt_command == 's') { | 429 | } else if (inpt_command == 's') { |
420 | uint8_t status[TOX_MAX_STATUSMESSAGE_LENGTH]; | 430 | uint8_t status[TOX_MAX_STATUS_MESSAGE_LENGTH]; |
421 | size_t i, len = strlen(line); | 431 | size_t i, len = strlen(line); |
422 | 432 | ||
423 | for (i = 3; i < len; i++) { | 433 | for (i = 3; i < len; i++) { |
@@ -427,7 +437,7 @@ void line_eval(Tox *m, char *line) | |||
427 | } | 437 | } |
428 | 438 | ||
429 | status[i - 3] = 0; | 439 | status[i - 3] = 0; |
430 | tox_set_status_message(m, status, strlen((char *)status)); | 440 | tox_self_set_status_message(m, status, strlen((char *)status), NULL); |
431 | char numstring[100]; | 441 | char numstring[100]; |
432 | sprintf(numstring, "[i] changed status to %s", (char *)status); | 442 | sprintf(numstring, "[i] changed status to %s", (char *)status); |
433 | new_lines(numstring); | 443 | new_lines(numstring); |
@@ -439,9 +449,9 @@ void line_eval(Tox *m, char *line) | |||
439 | sprintf(numchar, "[i] you either didn't receive that request or you already accepted it"); | 449 | sprintf(numchar, "[i] you either didn't receive that request or you already accepted it"); |
440 | new_lines(numchar); | 450 | new_lines(numchar); |
441 | } else { | 451 | } else { |
442 | int num = tox_add_friend_norequest(m, pending_requests[numf].id); | 452 | uint32_t num = tox_friend_add_norequest(m, pending_requests[numf].id, NULL); |
443 | 453 | ||
444 | if (num != -1) { | 454 | if (num != UINT32_MAX) { |
445 | pending_requests[numf].accepted = 1; | 455 | pending_requests[numf].accepted = 1; |
446 | sprintf(numchar, "[i] friend request %u accepted as friend no. %d", numf, num); | 456 | sprintf(numchar, "[i] friend request %u accepted as friend no. %d", numf, num); |
447 | new_lines(numchar); | 457 | new_lines(numchar); |
@@ -475,9 +485,9 @@ void line_eval(Tox *m, char *line) | |||
475 | } while ((c != 'y') && (c != 'n') && (c != EOF)); | 485 | } while ((c != 'y') && (c != 'n') && (c != EOF)); |
476 | 486 | ||
477 | if (c == 'y') { | 487 | if (c == 'y') { |
478 | int res = tox_del_friend(m, numf); | 488 | int res = tox_friend_delete(m, numf, NULL); |
479 | 489 | ||
480 | if (res == 0) | 490 | if (res) |
481 | sprintf(msg, "[i] [%i: %s] is no longer your friend", numf, fname); | 491 | sprintf(msg, "[i] [%i: %s] is no longer your friend", numf, fname); |
482 | else | 492 | else |
483 | sprintf(msg, "[i] failed to remove friend"); | 493 | sprintf(msg, "[i] failed to remove friend"); |
@@ -602,7 +612,7 @@ void line_eval(Tox *m, char *line) | |||
602 | if (conversation_default != 0) { | 612 | if (conversation_default != 0) { |
603 | if (conversation_default > 0) { | 613 | if (conversation_default > 0) { |
604 | int friendnumber = conversation_default - 1; | 614 | int friendnumber = conversation_default - 1; |
605 | uint32_t res = tox_send_message(m, friendnumber, (uint8_t *)line, strlen(line)); | 615 | uint32_t res = tox_send_message(m, friendnumber, (uint8_t *)line, strlen(line), NULL); |
606 | 616 | ||
607 | if (res == 0) { | 617 | if (res == 0) { |
608 | char sss[128]; | 618 | char sss[128]; |
@@ -863,20 +873,20 @@ void do_refresh() | |||
863 | refresh(); | 873 | refresh(); |
864 | } | 874 | } |
865 | 875 | ||
866 | void print_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata) | 876 | void print_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) |
867 | { | 877 | { |
868 | new_lines("[i] received friend request with message:"); | 878 | new_lines("[i] received friend request with message:"); |
869 | new_lines((char *)data); | 879 | new_lines((char *)data); |
870 | char numchar[100]; | 880 | char numchar[100]; |
871 | sprintf(numchar, "[i] accept request with /a %u", num_requests); | 881 | sprintf(numchar, "[i] accept request with /a %u", num_requests); |
872 | new_lines(numchar); | 882 | new_lines(numchar); |
873 | memcpy(pending_requests[num_requests].id, public_key, TOX_CLIENT_ID_SIZE); | 883 | memcpy(pending_requests[num_requests].id, public_key, TOX_PUBLIC_KEY_SIZE); |
874 | pending_requests[num_requests].accepted = 0; | 884 | pending_requests[num_requests].accepted = 0; |
875 | ++num_requests; | 885 | ++num_requests; |
876 | do_refresh(); | 886 | do_refresh(); |
877 | } | 887 | } |
878 | 888 | ||
879 | void print_message(Tox *m, int friendnumber, const uint8_t *string, uint16_t length, void *userdata) | 889 | void print_message(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata) |
880 | { | 890 | { |
881 | /* ensure null termination */ | 891 | /* ensure null termination */ |
882 | uint8_t null_string[length + 1]; | 892 | uint8_t null_string[length + 1]; |
@@ -885,7 +895,7 @@ void print_message(Tox *m, int friendnumber, const uint8_t *string, uint16_t len | |||
885 | print_formatted_message(m, (char *)null_string, friendnumber, 0); | 895 | print_formatted_message(m, (char *)null_string, friendnumber, 0); |
886 | } | 896 | } |
887 | 897 | ||
888 | void print_nickchange(Tox *m, int friendnumber, const uint8_t *string, uint16_t length, void *userdata) | 898 | void print_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata) |
889 | { | 899 | { |
890 | char name[TOX_MAX_NAME_LENGTH + 1]; | 900 | char name[TOX_MAX_NAME_LENGTH + 1]; |
891 | 901 | ||
@@ -901,7 +911,7 @@ void print_nickchange(Tox *m, int friendnumber, const uint8_t *string, uint16_t | |||
901 | } | 911 | } |
902 | } | 912 | } |
903 | 913 | ||
904 | void print_statuschange(Tox *m, int friendnumber, const uint8_t *string, uint16_t length, void *userdata) | 914 | void print_statuschange(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata) |
905 | { | 915 | { |
906 | char name[TOX_MAX_NAME_LENGTH + 1]; | 916 | char name[TOX_MAX_NAME_LENGTH + 1]; |
907 | 917 | ||
@@ -919,7 +929,7 @@ void print_statuschange(Tox *m, int friendnumber, const uint8_t *string, uint16_ | |||
919 | 929 | ||
920 | static char *data_file_name = NULL; | 930 | static char *data_file_name = NULL; |
921 | 931 | ||
922 | static int load_data(Tox *m) | 932 | static Tox *load_data() |
923 | { | 933 | { |
924 | FILE *data_file = fopen(data_file_name, "r"); | 934 | FILE *data_file = fopen(data_file_name, "r"); |
925 | 935 | ||
@@ -936,7 +946,7 @@ static int load_data(Tox *m) | |||
936 | return 0; | 946 | return 0; |
937 | } | 947 | } |
938 | 948 | ||
939 | tox_load(m, data, size); | 949 | Tox *m = tox_new(0, data, size, NULL); |
940 | 950 | ||
941 | if (fclose(data_file) < 0) { | 951 | if (fclose(data_file) < 0) { |
942 | perror("[!] fclose failed"); | 952 | perror("[!] fclose failed"); |
@@ -944,10 +954,10 @@ static int load_data(Tox *m) | |||
944 | /* return 0; */ | 954 | /* return 0; */ |
945 | } | 955 | } |
946 | 956 | ||
947 | return 1; | 957 | return m; |
948 | } | 958 | } |
949 | 959 | ||
950 | return 0; | 960 | return tox_new(0, 0, 0, NULL); |
951 | } | 961 | } |
952 | 962 | ||
953 | static int save_data(Tox *m) | 963 | static int save_data(Tox *m) |
@@ -960,7 +970,7 @@ static int save_data(Tox *m) | |||
960 | } | 970 | } |
961 | 971 | ||
962 | int res = 1; | 972 | int res = 1; |
963 | size_t size = tox_size(m); | 973 | size_t size = tox_save_size(m); |
964 | uint8_t data[size]; | 974 | uint8_t data[size]; |
965 | tox_save(m, data); | 975 | tox_save(m, data); |
966 | 976 | ||
@@ -977,13 +987,10 @@ static int save_data(Tox *m) | |||
977 | return res; | 987 | return res; |
978 | } | 988 | } |
979 | 989 | ||
980 | static int load_data_or_init(Tox *m, char *path) | 990 | static int save_data_file(Tox *m, char *path) |
981 | { | 991 | { |
982 | data_file_name = path; | 992 | data_file_name = path; |
983 | 993 | ||
984 | if (load_data(m)) | ||
985 | return 1; | ||
986 | |||
987 | if (save_data(m)) | 994 | if (save_data(m)) |
988 | return 1; | 995 | return 1; |
989 | 996 | ||
@@ -1176,7 +1183,7 @@ void write_file(Tox *m, int friendnumber, uint8_t filenumber, const uint8_t *dat | |||
1176 | char timeout_getch(Tox *m) | 1183 | char timeout_getch(Tox *m) |
1177 | { | 1184 | { |
1178 | char c; | 1185 | char c; |
1179 | int slpval = tox_do_interval(m); | 1186 | int slpval = tox_iteration_interval(m); |
1180 | 1187 | ||
1181 | fd_set fds; | 1188 | fd_set fds; |
1182 | FD_ZERO(&fds); | 1189 | FD_ZERO(&fds); |
@@ -1214,7 +1221,7 @@ int main(int argc, char *argv[]) | |||
1214 | } | 1221 | } |
1215 | 1222 | ||
1216 | /* let user override default by cmdline */ | 1223 | /* let user override default by cmdline */ |
1217 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ | 1224 | uint8_t ipv6enabled = 1; /* x */ |
1218 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | 1225 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); |
1219 | 1226 | ||
1220 | if (argvoffset < 0) | 1227 | if (argvoffset < 0) |
@@ -1231,19 +1238,20 @@ int main(int argc, char *argv[]) | |||
1231 | if (!strcmp(argv[argc - 2], "-f")) | 1238 | if (!strcmp(argv[argc - 2], "-f")) |
1232 | filename = argv[argc - 1]; | 1239 | filename = argv[argc - 1]; |
1233 | 1240 | ||
1234 | m = tox_new(0); | 1241 | data_file_name = filename; |
1242 | m = load_data(); | ||
1235 | 1243 | ||
1236 | if ( !m ) { | 1244 | if ( !m ) { |
1237 | fputs("Failed to allocate Messenger datastructure", stderr); | 1245 | fputs("Failed to allocate Messenger datastructure", stderr); |
1238 | exit(0); | 1246 | exit(0); |
1239 | } | 1247 | } |
1240 | 1248 | ||
1241 | load_data_or_init(m, filename); | 1249 | save_data_file(m, filename); |
1242 | 1250 | ||
1243 | tox_callback_friend_request(m, print_request, NULL); | 1251 | tox_callback_friend_request(m, print_request, NULL); |
1244 | tox_callback_friend_message(m, print_message, NULL); | 1252 | tox_callback_friend_message(m, print_message, NULL); |
1245 | tox_callback_name_change(m, print_nickchange, NULL); | 1253 | tox_callback_friend_name(m, print_nickchange, NULL); |
1246 | tox_callback_status_message(m, print_statuschange, NULL); | 1254 | tox_callback_friend_status_message(m, print_statuschange, NULL); |
1247 | tox_callback_group_invite(m, print_invite, NULL); | 1255 | tox_callback_group_invite(m, print_invite, NULL); |
1248 | tox_callback_group_message(m, print_groupmessage, NULL); | 1256 | tox_callback_group_message(m, print_groupmessage, NULL); |
1249 | tox_callback_file_data(m, write_file, NULL); | 1257 | tox_callback_file_data(m, write_file, NULL); |
@@ -1263,7 +1271,7 @@ int main(int argc, char *argv[]) | |||
1263 | 1271 | ||
1264 | uint16_t port = atoi(argv[argvoffset + 2]); | 1272 | uint16_t port = atoi(argv[argvoffset + 2]); |
1265 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 1273 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
1266 | int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string); | 1274 | int res = tox_bootstrap(m, argv[argvoffset + 1], port, binary_string, NULL); |
1267 | 1275 | ||
1268 | if (!res) { | 1276 | if (!res) { |
1269 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); | 1277 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); |
@@ -1275,7 +1283,8 @@ int main(int argc, char *argv[]) | |||
1275 | 1283 | ||
1276 | new_lines("[i] change username with /n"); | 1284 | new_lines("[i] change username with /n"); |
1277 | uint8_t name[TOX_MAX_NAME_LENGTH + 1]; | 1285 | uint8_t name[TOX_MAX_NAME_LENGTH + 1]; |
1278 | uint16_t namelen = tox_get_self_name(m, name); | 1286 | tox_self_get_name(m, name); |
1287 | uint16_t namelen = tox_self_get_name_size(m); | ||
1279 | name[namelen] = 0; | 1288 | name[namelen] = 0; |
1280 | 1289 | ||
1281 | if (namelen > 0) { | 1290 | if (namelen > 0) { |
@@ -1288,7 +1297,7 @@ int main(int argc, char *argv[]) | |||
1288 | 1297 | ||
1289 | while (1) { | 1298 | while (1) { |
1290 | if (on == 0) { | 1299 | if (on == 0) { |
1291 | if (tox_isconnected(m)) { | 1300 | if (tox_get_connection_status(m)) { |
1292 | new_lines("[i] connected to DHT"); | 1301 | new_lines("[i] connected to DHT"); |
1293 | on = 1; | 1302 | on = 1; |
1294 | } else { | 1303 | } else { |
@@ -1296,15 +1305,13 @@ int main(int argc, char *argv[]) | |||
1296 | 1305 | ||
1297 | if (timestamp0 + 10 < timestamp1) { | 1306 | if (timestamp0 + 10 < timestamp1) { |
1298 | timestamp0 = timestamp1; | 1307 | timestamp0 = timestamp1; |
1299 | tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string); | 1308 | tox_bootstrap(m, argv[argvoffset + 1], port, binary_string, NULL); |
1300 | } | 1309 | } |
1301 | } | 1310 | } |
1302 | } | 1311 | } |
1303 | 1312 | ||
1304 | |||
1305 | |||
1306 | send_filesenders(m); | 1313 | send_filesenders(m); |
1307 | tox_do(m); | 1314 | tox_iteration(m); |
1308 | do_refresh(); | 1315 | do_refresh(); |
1309 | 1316 | ||
1310 | int c = timeout_getch(m); | 1317 | int c = timeout_getch(m); |
@@ -1320,7 +1327,7 @@ int main(int argc, char *argv[]) | |||
1320 | } else if (c == 8 || c == 127) { | 1327 | } else if (c == 8 || c == 127) { |
1321 | input_line[strlen(input_line) - 1] = '\0'; | 1328 | input_line[strlen(input_line) - 1] = '\0'; |
1322 | } else if (isalnum(c) || ispunct(c) || c == ' ') { | 1329 | } else if (isalnum(c) || ispunct(c) || c == ' ') { |
1323 | strcpy(input_line, appender(input_line, (char) c)); | 1330 | appender(input_line, (char) c); |
1324 | } | 1331 | } |
1325 | } | 1332 | } |
1326 | 1333 | ||