diff options
author | irungentoo <irungentoo@gmail.com> | 2015-02-24 20:29:01 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-02-24 20:29:01 -0500 |
commit | d83efd35dd342da7f5b0f4b6e11ffd943d7f3c63 (patch) | |
tree | 4fa5e862c65c9bb9a007dab78424c161ddd61341 /testing/tox_sync.c | |
parent | 8fa8e9dcd798540bf539d502d0dbba71184f7489 (diff) |
Ported some of the code in testing/ to the new api.
Diffstat (limited to 'testing/tox_sync.c')
-rw-r--r-- | testing/tox_sync.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/testing/tox_sync.c b/testing/tox_sync.c index 8b64b6ca..77f75c36 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c | |||
@@ -192,9 +192,9 @@ void write_file(Tox *m, int friendnumber, uint8_t filenumber, const uint8_t *dat | |||
192 | printf("Error writing data\n"); | 192 | printf("Error writing data\n"); |
193 | } | 193 | } |
194 | 194 | ||
195 | void print_online(Tox *tox, int friendnumber, uint8_t status, void *userdata) | 195 | void print_online(Tox *tox, uint32_t friendnumber, uint8_t status, void *userdata) |
196 | { | 196 | { |
197 | if (status == 1) | 197 | if (status) |
198 | printf("\nOther went online.\n"); | 198 | printf("\nOther went online.\n"); |
199 | else | 199 | else |
200 | printf("\nOther went offline.\n"); | 200 | printf("\nOther went offline.\n"); |
@@ -202,7 +202,7 @@ void print_online(Tox *tox, int friendnumber, uint8_t status, void *userdata) | |||
202 | 202 | ||
203 | int main(int argc, char *argv[]) | 203 | int main(int argc, char *argv[]) |
204 | { | 204 | { |
205 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ | 205 | uint8_t ipv6enabled = 1; /* x */ |
206 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | 206 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); |
207 | 207 | ||
208 | if (argvoffset < 0) | 208 | if (argvoffset < 0) |
@@ -214,15 +214,15 @@ int main(int argc, char *argv[]) | |||
214 | exit(0); | 214 | exit(0); |
215 | } | 215 | } |
216 | 216 | ||
217 | Tox *tox = tox_new(0); | 217 | Tox *tox = tox_new(0, 0, 0, 0); |
218 | tox_callback_file_data(tox, write_file, NULL); | 218 | tox_callback_file_data(tox, write_file, NULL); |
219 | tox_callback_file_control(tox, file_print_control, NULL); | 219 | tox_callback_file_control(tox, file_print_control, NULL); |
220 | tox_callback_file_send_request(tox, file_request_accept, NULL); | 220 | tox_callback_file_send_request(tox, file_request_accept, NULL); |
221 | tox_callback_connection_status(tox, print_online, NULL); | 221 | tox_callback_friend_connection_status(tox, print_online, NULL); |
222 | 222 | ||
223 | uint16_t port = atoi(argv[argvoffset + 2]); | 223 | uint16_t port = atoi(argv[argvoffset + 2]); |
224 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 224 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
225 | int res = tox_bootstrap_from_address(tox, argv[argvoffset + 1], port, binary_string); | 225 | int res = tox_bootstrap(tox, argv[argvoffset + 1], port, binary_string, 0); |
226 | free(binary_string); | 226 | free(binary_string); |
227 | 227 | ||
228 | if (!res) { | 228 | if (!res) { |
@@ -230,11 +230,11 @@ int main(int argc, char *argv[]) | |||
230 | exit(1); | 230 | exit(1); |
231 | } | 231 | } |
232 | 232 | ||
233 | uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; | 233 | uint8_t address[TOX_ADDRESS_SIZE]; |
234 | tox_get_address(tox, address); | 234 | tox_self_get_address(tox, address); |
235 | uint32_t i; | 235 | uint32_t i; |
236 | 236 | ||
237 | for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) { | 237 | for (i = 0; i < TOX_ADDRESS_SIZE; i++) { |
238 | printf("%02X", address[i]); | 238 | printf("%02X", address[i]); |
239 | } | 239 | } |
240 | 240 | ||
@@ -246,10 +246,10 @@ int main(int argc, char *argv[]) | |||
246 | } | 246 | } |
247 | 247 | ||
248 | uint8_t *bin_id = hex_string_to_bin(temp_id); | 248 | uint8_t *bin_id = hex_string_to_bin(temp_id); |
249 | int num = tox_add_friend(tox, bin_id, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); | 249 | uint32_t num = tox_friend_add(tox, bin_id, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo"), 0); |
250 | free(bin_id); | 250 | free(bin_id); |
251 | 251 | ||
252 | if (num < 0) { | 252 | if (num == UINT32_MAX) { |
253 | printf("\nSomething went wrong when adding friend.\n"); | 253 | printf("\nSomething went wrong when adding friend.\n"); |
254 | return 1; | 254 | return 1; |
255 | } | 255 | } |
@@ -260,12 +260,12 @@ int main(int argc, char *argv[]) | |||
260 | uint8_t notconnected = 1; | 260 | uint8_t notconnected = 1; |
261 | 261 | ||
262 | while (1) { | 262 | while (1) { |
263 | if (tox_isconnected(tox) && notconnected) { | 263 | if (tox_get_connection_status(tox) && notconnected) { |
264 | printf("\nDHT connected.\n"); | 264 | printf("\nDHT connected.\n"); |
265 | notconnected = 0; | 265 | notconnected = 0; |
266 | } | 266 | } |
267 | 267 | ||
268 | if (not_sending() && tox_get_friend_connection_status(tox, num)) { | 268 | if (not_sending() && tox_friend_get_connection_status(tox, num, 0)) { |
269 | d = opendir(path); | 269 | d = opendir(path); |
270 | 270 | ||
271 | if (d) { | 271 | if (d) { |
@@ -291,7 +291,7 @@ int main(int argc, char *argv[]) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | send_filesenders(tox); | 293 | send_filesenders(tox); |
294 | tox_do(tox); | 294 | tox_iteration(tox); |
295 | c_sleep(1); | 295 | c_sleep(1); |
296 | } | 296 | } |
297 | 297 | ||