summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
authorDubslow <bunslow@gmail.com>2015-02-28 15:26:19 -0600
committerDubslow <bunslow@gmail.com>2015-03-11 17:09:06 -0500
commit91274495bc1e24bbab039e0e468be14fa34caf23 (patch)
tree158a1e5e255914fa90827e35c0bdff9b4b93a4ff /toxcore/tox.c
parent43fe6e71bd06dd4fcc2bb49662f56b493ed9b6fc (diff)
This is a combination of 11 commits.
The first commit's message is: TOX_STATUS -> TOX_USER_STATUS, is more specific This is the 2nd commit message: I pretty strongly believe tox_iteration needs to be renamed to a verb There are several other noun functions in the API, but none of them *do* things. I think even tox_do is better than tox_iteration. tox_do_interval is one possibility, but I'm open to suggestions. This is the 3rd commit message: private_key -> secret_key This is more consistent with modern/NaCl/elliptic cryptography, and also "pk", meaning public key, is all over other toxcore code and documentation. This will eliminate ambiguity. This is the 4th commit message: Rename some functions for pseudo-namespace consistency The enum change results in long enum types, but I think consistency trumps having a few less characters. This is the 5th commit message: TOX_FILE_KIND -> TOX_FILE_TYPE This is more of an English thing than a consistency thing, but TOX_FILE_KIND sounds funnier/stranger to me than TOX_FILE_TYPE. This is the 6th commit message: More specific file control function names This is the 7th commit message: Rename custom packet functions for pseudo-namespace consistency This also has the issue with long enums... but I still think consistent enum names are better This is the 8th commit message: Rename functions for pseudo-namespace consistency This is the 9th commit message: Consistency with https://github.com/sonOfRa/tox4j/blob/master/doc/core-design.md#naming-conventions and the rest of the api This is the 10th commit message: Fix errors in previous function rename commits This is the 11th commit message: Shorten one error enum name
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 554414b1..9a821bfb 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -411,13 +411,13 @@ void tox_self_get_status_message(const Tox *tox, uint8_t *status)
411 } 411 }
412} 412}
413 413
414void tox_self_set_status(Tox *tox, TOX_STATUS user_status) 414void tox_self_set_status(Tox *tox, TOX_USER_STATUS user_status)
415{ 415{
416 Messenger *m = tox; 416 Messenger *m = tox;
417 m_set_userstatus(m, user_status); 417 m_set_userstatus(m, user_status);
418} 418}
419 419
420TOX_STATUS tox_self_get_status(const Tox *tox) 420TOX_USER_STATUS tox_self_get_status(const Tox *tox)
421{ 421{
422 const Messenger *m = tox; 422 const Messenger *m = tox;
423 return m_get_self_userstatus(m); 423 return m_get_self_userstatus(m);
@@ -561,7 +561,7 @@ size_t tox_friend_list_size(const Tox *tox)
561 return count_friendlist(m); 561 return count_friendlist(m);
562} 562}
563 563
564void tox_friend_list(const Tox *tox, uint32_t *list) 564void tox_friend_get_list(const Tox *tox, uint32_t *list)
565{ 565{
566 if (list) { 566 if (list) {
567 const Messenger *m = tox; 567 const Messenger *m = tox;
@@ -650,7 +650,7 @@ void tox_callback_friend_status_message(Tox *tox, tox_friend_status_message_cb *
650 m_callback_statusmessage(m, function, user_data); 650 m_callback_statusmessage(m, function, user_data);
651} 651}
652 652
653TOX_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) 653TOX_USER_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
654{ 654{
655 const Messenger *m = tox; 655 const Messenger *m = tox;
656 656
@@ -658,7 +658,7 @@ TOX_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TOX_ERR
658 658
659 if (ret == USERSTATUS_INVALID) { 659 if (ret == USERSTATUS_INVALID) {
660 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND); 660 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND);
661 return TOX_STATUS_INVALID; 661 return TOX_USER_STATUS_INVALID;
662 } 662 }
663 663
664 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); 664 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK);
@@ -725,41 +725,41 @@ bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typing, TOX_E
725 return 1; 725 return 1;
726} 726}
727 727
728static void set_message_error(int ret, TOX_ERR_SEND_MESSAGE *error) 728static void set_message_error(int ret, TOX_ERR_FRIEND_SEND_MESSAGE *error)
729{ 729{
730 switch (ret) { 730 switch (ret) {
731 case 0: 731 case 0:
732 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_OK); 732 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_OK);
733 break; 733 break;
734 734
735 case -1: 735 case -1:
736 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_FRIEND_NOT_FOUND); 736 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_FRIEND_NOT_FOUND);
737 break; 737 break;
738 738
739 case -2: 739 case -2:
740 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_TOO_LONG); 740 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG);
741 break; 741 break;
742 742
743 case -3: 743 case -3:
744 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_FRIEND_NOT_CONNECTED); 744 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_FRIEND_NOT_CONNECTED);
745 break; 745 break;
746 746
747 case -4: 747 case -4:
748 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_SENDQ); 748 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_SENDQ);
749 break; 749 break;
750 } 750 }
751} 751}
752 752
753uint32_t tox_send_message(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length, 753uint32_t tox_friend_send_message(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length,
754 TOX_ERR_SEND_MESSAGE *error) 754 TOX_ERR_FRIEND_SEND_MESSAGE *error)
755{ 755{
756 if (!message) { 756 if (!message) {
757 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_NULL); 757 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_NULL);
758 return 0; 758 return 0;
759 } 759 }
760 760
761 if (!length) { 761 if (!length) {
762 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_EMPTY); 762 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_EMPTY);
763 return 0; 763 return 0;
764 } 764 }
765 765
@@ -769,16 +769,16 @@ uint32_t tox_send_message(Tox *tox, uint32_t friend_number, const uint8_t *messa
769 return message_id; 769 return message_id;
770} 770}
771 771
772uint32_t tox_send_action(Tox *tox, uint32_t friend_number, const uint8_t *action, size_t length, 772uint32_t tox_friend_send_action(Tox *tox, uint32_t friend_number, const uint8_t *action, size_t length,
773 TOX_ERR_SEND_MESSAGE *error) 773 TOX_ERR_FRIEND_SEND_MESSAGE *error)
774{ 774{
775 if (!action) { 775 if (!action) {
776 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_NULL); 776 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_NULL);
777 return 0; 777 return 0;
778 } 778 }
779 779
780 if (!length) { 780 if (!length) {
781 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_MESSAGE_EMPTY); 781 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_SEND_MESSAGE_EMPTY);
782 return 0; 782 return 0;
783 } 783 }
784 784
@@ -788,7 +788,7 @@ uint32_t tox_send_action(Tox *tox, uint32_t friend_number, const uint8_t *action
788 return message_id; 788 return message_id;
789} 789}
790 790
791void tox_callback_read_receipt(Tox *tox, tox_read_receipt_cb *function, void *user_data) 791void tox_callback_friend_read_receipt(Tox *tox, tox_friend_read_receipt_cb *function, void *user_data)
792{ 792{
793 Messenger *m = tox; 793 Messenger *m = tox;
794 m_callback_read_receipt(m, function, user_data); 794 m_callback_read_receipt(m, function, user_data);
@@ -871,13 +871,13 @@ bool tox_file_control(Tox *tox, uint32_t friend_number, uint32_t file_number, TO
871 return 0; 871 return 0;
872} 872}
873 873
874void tox_callback_file_control(Tox *tox, tox_file_control_cb *function, void *user_data) 874void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function, void *user_data)
875{ 875{
876 Messenger *m = tox; 876 Messenger *m = tox;
877 callback_file_control(m, function, user_data); 877 callback_file_control(m, function, user_data);
878} 878}
879 879
880uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_KIND kind, uint64_t file_size, 880uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_TYPE kind, uint64_t file_size,
881 const uint8_t *filename, size_t filename_length, TOX_ERR_FILE_SEND *error) 881 const uint8_t *filename, size_t filename_length, TOX_ERR_FILE_SEND *error)
882{ 882{
883 if (!filename) { 883 if (!filename) {
@@ -979,52 +979,52 @@ void tox_callback_file_receive_chunk(Tox *tox, tox_file_receive_chunk_cb *functi
979 callback_file_data(m, function, user_data); 979 callback_file_data(m, function, user_data);
980} 980}
981 981
982static void set_custom_packet_error(int ret, TOX_ERR_SEND_CUSTOM_PACKET *error) 982static void set_custom_packet_error(int ret, TOX_ERR_FRIEND_CUSTOM_PACKET *error)
983{ 983{
984 switch (ret) { 984 switch (ret) {
985 case 0: 985 case 0:
986 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_OK); 986 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_OK);
987 break; 987 break;
988 988
989 case -1: 989 case -1:
990 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_FRIEND_NOT_FOUND); 990 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_FRIEND_NOT_FOUND);
991 break; 991 break;
992 992
993 case -2: 993 case -2:
994 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_TOO_LONG); 994 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_TOO_LONG);
995 break; 995 break;
996 996
997 case -3: 997 case -3:
998 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_INVALID); 998 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_INVALID);
999 break; 999 break;
1000 1000
1001 case -4: 1001 case -4:
1002 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_FRIEND_NOT_CONNECTED); 1002 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_FRIEND_NOT_CONNECTED);
1003 break; 1003 break;
1004 1004
1005 case -5: 1005 case -5:
1006 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_SENDQ); 1006 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_SENDQ);
1007 break; 1007 break;
1008 } 1008 }
1009} 1009}
1010 1010
1011bool tox_send_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length, 1011bool tox_friend_send_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
1012 TOX_ERR_SEND_CUSTOM_PACKET *error) 1012 TOX_ERR_FRIEND_CUSTOM_PACKET *error)
1013{ 1013{
1014 if (!data) { 1014 if (!data) {
1015 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_NULL); 1015 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_NULL);
1016 return 0; 1016 return 0;
1017 } 1017 }
1018 1018
1019 Messenger *m = tox; 1019 Messenger *m = tox;
1020 1020
1021 if (length == 0) { 1021 if (length == 0) {
1022 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_EMPTY); 1022 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_EMPTY);
1023 return 0; 1023 return 0;
1024 } 1024 }
1025 1025
1026 if (data[0] < (PACKET_ID_LOSSY_RANGE_START + PACKET_LOSSY_AV_RESERVED)) { 1026 if (data[0] < (PACKET_ID_LOSSY_RANGE_START + PACKET_LOSSY_AV_RESERVED)) {
1027 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_INVALID); 1027 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_INVALID);
1028 return 0; 1028 return 0;
1029 } 1029 }
1030 1030
@@ -1045,18 +1045,18 @@ void tox_callback_friend_lossy_packet(Tox *tox, tox_friend_lossy_packet_cb *func
1045 custom_lossy_packet_registerhandler(m, function, user_data); 1045 custom_lossy_packet_registerhandler(m, function, user_data);
1046} 1046}
1047 1047
1048bool tox_send_lossless_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length, 1048bool tox_friend_send_lossless_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
1049 TOX_ERR_SEND_CUSTOM_PACKET *error) 1049 TOX_ERR_FRIEND_CUSTOM_PACKET *error)
1050{ 1050{
1051 if (!data) { 1051 if (!data) {
1052 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_NULL); 1052 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_NULL);
1053 return 0; 1053 return 0;
1054 } 1054 }
1055 1055
1056 Messenger *m = tox; 1056 Messenger *m = tox;
1057 1057
1058 if (length == 0) { 1058 if (length == 0) {
1059 SET_ERROR_PARAMETER(error, TOX_ERR_SEND_CUSTOM_PACKET_EMPTY); 1059 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_CUSTOM_PACKET_EMPTY);
1060 return 0; 1060 return 0;
1061 } 1061 }
1062 1062