diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test_avatars.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/testing/test_avatars.c b/testing/test_avatars.c index 7d96bd52..fc7e9d6f 100644 --- a/testing/test_avatars.c +++ b/testing/test_avatars.c | |||
@@ -86,8 +86,8 @@ typedef struct { | |||
86 | 86 | ||
87 | static const def_avatar_name_t def_avatar_names[] = { | 87 | static const def_avatar_name_t def_avatar_names[] = { |
88 | /* In order of preference */ | 88 | /* In order of preference */ |
89 | { TOX_AVATARFORMAT_PNG, "png", "avatar.png" }, | 89 | { TOX_AVATAR_FORMAT_PNG, "png", "avatar.png" }, |
90 | { TOX_AVATARFORMAT_NONE, NULL, NULL }, /* Must be the last one */ | 90 | { TOX_AVATAR_FORMAT_NONE, NULL, NULL }, /* Must be the last one */ |
91 | }; | 91 | }; |
92 | 92 | ||
93 | 93 | ||
@@ -99,7 +99,7 @@ static char *get_avatar_suffix_from_format(uint8_t format) | |||
99 | { | 99 | { |
100 | int i; | 100 | int i; |
101 | 101 | ||
102 | for (i = 0; def_avatar_names[i].format != TOX_AVATARFORMAT_NONE; i++) | 102 | for (i = 0; def_avatar_names[i].format != TOX_AVATAR_FORMAT_NONE; i++) |
103 | if (def_avatar_names[i].format == format) | 103 | if (def_avatar_names[i].format == format) |
104 | return def_avatar_names[i].suffix; | 104 | return def_avatar_names[i].suffix; |
105 | 105 | ||
@@ -118,7 +118,7 @@ static int load_avatar_data(char *fname, uint8_t *buf) | |||
118 | if (fp == NULL) | 118 | if (fp == NULL) |
119 | return -1; /* Error */ | 119 | return -1; /* Error */ |
120 | 120 | ||
121 | size_t n = fread(buf, 1, TOX_MAX_AVATAR_DATA_LENGTH, fp); | 121 | size_t n = fread(buf, 1, TOX_AVATAR_MAX_DATA_LENGTH, fp); |
122 | int ret; | 122 | int ret; |
123 | 123 | ||
124 | if (ferror(fp) != 0 || n == 0) | 124 | if (ferror(fp) != 0 || n == 0) |
@@ -267,7 +267,7 @@ static int delete_user_avatar(Tox *tox, char *base_dir, int friendnum) | |||
267 | /* This iteration is dumb and inefficient */ | 267 | /* This iteration is dumb and inefficient */ |
268 | int i; | 268 | int i; |
269 | 269 | ||
270 | for (i = 0; def_avatar_names[i].format != TOX_AVATARFORMAT_NONE; i++) { | 270 | for (i = 0; def_avatar_names[i].format != TOX_AVATAR_FORMAT_NONE; i++) { |
271 | int ret = make_avatar_file_name(path, sizeof(path), base_dir, | 271 | int ret = make_avatar_file_name(path, sizeof(path), base_dir, |
272 | def_avatar_names[i].format, addr); | 272 | def_avatar_names[i].format, addr); |
273 | 273 | ||
@@ -318,7 +318,7 @@ static void friend_avatar_info_cb(Tox *tox, int32_t n, uint8_t format, uint8_t * | |||
318 | byte_to_hex_str(hash, TOX_AVATAR_HASH_LENGTH, hash_str); | 318 | byte_to_hex_str(hash, TOX_AVATAR_HASH_LENGTH, hash_str); |
319 | DEBUG("format=%u, hash=%s", format, hash_str); | 319 | DEBUG("format=%u, hash=%s", format, hash_str); |
320 | 320 | ||
321 | if (format == TOX_AVATARFORMAT_NONE) { | 321 | if (format == TOX_AVATAR_FORMAT_NONE) { |
322 | printf(" -> User do not have an avatar.\n"); | 322 | printf(" -> User do not have an avatar.\n"); |
323 | /* User have no avatar anymore, delete it from our cache */ | 323 | /* User have no avatar anymore, delete it from our cache */ |
324 | delete_user_avatar(tox, base_dir, n); | 324 | delete_user_avatar(tox, base_dir, n); |
@@ -332,7 +332,7 @@ static void friend_avatar_info_cb(Tox *tox, int32_t n, uint8_t format, uint8_t * | |||
332 | * these events. | 332 | * these events. |
333 | */ | 333 | */ |
334 | uint32_t cur_av_len; | 334 | uint32_t cur_av_len; |
335 | uint8_t cur_av_data[TOX_MAX_AVATAR_DATA_LENGTH]; | 335 | uint8_t cur_av_data[TOX_AVATAR_MAX_DATA_LENGTH]; |
336 | uint8_t cur_av_hash[TOX_AVATAR_HASH_LENGTH]; | 336 | uint8_t cur_av_hash[TOX_AVATAR_HASH_LENGTH]; |
337 | int ret; | 337 | int ret; |
338 | 338 | ||
@@ -370,7 +370,7 @@ static void friend_avatar_data_cb(Tox *tox, int32_t n, uint8_t format, | |||
370 | 370 | ||
371 | delete_user_avatar(tox, base_dir, n); | 371 | delete_user_avatar(tox, base_dir, n); |
372 | 372 | ||
373 | if (format != TOX_AVATARFORMAT_NONE) { | 373 | if (format != TOX_AVATAR_FORMAT_NONE) { |
374 | int ret = save_user_avatar(tox, base_dir, n, format, data, datalen); | 374 | int ret = save_user_avatar(tox, base_dir, n, format, data, datalen); |
375 | 375 | ||
376 | if (ret == 0) | 376 | if (ret == 0) |
@@ -406,7 +406,7 @@ static void friend_msg_cb(Tox *tox, int n, const uint8_t *msg, uint16_t len, voi | |||
406 | set_avatar(tox, base_dir); | 406 | set_avatar(tox, base_dir); |
407 | reply_ptr = "Setting image avatar"; | 407 | reply_ptr = "Setting image avatar"; |
408 | } else if (strstr(msg_str, "!remove-avatar") != NULL) { | 408 | } else if (strstr(msg_str, "!remove-avatar") != NULL) { |
409 | int r = tox_set_avatar(tox, TOX_AVATARFORMAT_NONE, NULL, 0); | 409 | int r = tox_set_avatar(tox, TOX_AVATAR_FORMAT_NONE, NULL, 0); |
410 | DEBUG("tox_set_avatar returned %d", r); | 410 | DEBUG("tox_set_avatar returned %d", r); |
411 | reply_ptr = "Removing avatar"; | 411 | reply_ptr = "Removing avatar"; |
412 | } | 412 | } |
@@ -453,10 +453,10 @@ static int try_avatar_file(Tox *tox, const char *base_dir, const def_avatar_name | |||
453 | FILE *fp = fopen(path, "rb"); | 453 | FILE *fp = fopen(path, "rb"); |
454 | 454 | ||
455 | if (fp != NULL) { | 455 | if (fp != NULL) { |
456 | uint8_t buf[2 * TOX_MAX_AVATAR_DATA_LENGTH]; | 456 | uint8_t buf[2 * TOX_AVATAR_MAX_DATA_LENGTH]; |
457 | int len = fread(buf, 1, sizeof(buf), fp); | 457 | int len = fread(buf, 1, sizeof(buf), fp); |
458 | 458 | ||
459 | if (len >= 0 && len <= TOX_MAX_AVATAR_DATA_LENGTH) { | 459 | if (len >= 0 && len <= TOX_AVATAR_MAX_DATA_LENGTH) { |
460 | int r = tox_set_avatar(tox, an->format, buf, len); | 460 | int r = tox_set_avatar(tox, an->format, buf, len); |
461 | DEBUG("%d bytes, tox_set_avatar returned=%d", len, r); | 461 | DEBUG("%d bytes, tox_set_avatar returned=%d", len, r); |
462 | 462 | ||
@@ -468,7 +468,7 @@ static int try_avatar_file(Tox *tox, const char *base_dir, const def_avatar_name | |||
468 | DEBUG("read error %d", len); | 468 | DEBUG("read error %d", len); |
469 | } else { | 469 | } else { |
470 | printf("Avatar file %s if too big (more than %d bytes)", | 470 | printf("Avatar file %s if too big (more than %d bytes)", |
471 | path, TOX_MAX_AVATAR_DATA_LENGTH); | 471 | path, TOX_AVATAR_MAX_DATA_LENGTH); |
472 | } | 472 | } |
473 | 473 | ||
474 | fclose(fp); | 474 | fclose(fp); |
@@ -486,8 +486,8 @@ static void set_avatar(Tox *tox, const char *base_dir) | |||
486 | int i; | 486 | int i; |
487 | 487 | ||
488 | for (i = 0; i < 4; i++) { | 488 | for (i = 0; i < 4; i++) { |
489 | if (def_avatar_names[i].format == TOX_AVATARFORMAT_NONE) { | 489 | if (def_avatar_names[i].format == TOX_AVATAR_FORMAT_NONE) { |
490 | tox_set_avatar(tox, TOX_AVATARFORMAT_NONE, NULL, 0); | 490 | tox_set_avatar(tox, TOX_AVATAR_FORMAT_NONE, NULL, 0); |
491 | printf("No avatar file found, setting to NONE.\n"); | 491 | printf("No avatar file found, setting to NONE.\n"); |
492 | return; | 492 | return; |
493 | } else { | 493 | } else { |
@@ -504,7 +504,7 @@ static void set_avatar(Tox *tox, const char *base_dir) | |||
504 | static void print_avatar_info(Tox *tox) | 504 | static void print_avatar_info(Tox *tox) |
505 | { | 505 | { |
506 | uint8_t format; | 506 | uint8_t format; |
507 | uint8_t data[TOX_MAX_AVATAR_DATA_LENGTH]; | 507 | uint8_t data[TOX_AVATAR_MAX_DATA_LENGTH]; |
508 | uint8_t hash[TOX_AVATAR_HASH_LENGTH]; | 508 | uint8_t hash[TOX_AVATAR_HASH_LENGTH]; |
509 | uint32_t data_length; | 509 | uint32_t data_length; |
510 | char hash_str[2 * TOX_AVATAR_HASH_LENGTH + 1]; | 510 | char hash_str[2 * TOX_AVATAR_HASH_LENGTH + 1]; |