summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-02-17 15:49:22 -0500
committerirungentoo <irungentoo@gmail.com>2015-02-17 15:49:22 -0500
commitc6a59e64b7a7fb86ed8a99c21a0b7b023559b0ea (patch)
treeb987c1382e0631bc91a9cd50438b58622d8d901b
parent7cefc9c4582c367092cd6187ea924da9a1fcf2f0 (diff)
Updated types in Messenger callbacks to fit with the ones in the new api.
Friend number changed from int32_t to uint32_t. Some lengths changed to size_t.
-rw-r--r--toxav/msi.c5
-rw-r--r--toxav/rtp.c2
-rw-r--r--toxcore/Messenger.c54
-rw-r--r--toxcore/Messenger.h114
-rw-r--r--toxcore/friend_requests.c2
-rw-r--r--toxcore/friend_requests.h6
-rw-r--r--toxcore/group.c2
7 files changed, 95 insertions, 90 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index fda41d0c..dcb7b62a 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -774,7 +774,7 @@ static int terminate_call ( MSISession *session, MSICall *call )
774 return 0; 774 return 0;
775} 775}
776 776
777static void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8_t status, void *session_p) 777static void handle_remote_connection_change(Messenger *messenger, uint32_t friend_num, uint8_t status, void *session_p)
778{ 778{
779 (void)messenger; 779 (void)messenger;
780 MSISession *session = session_p; 780 MSISession *session = session_p;
@@ -1101,7 +1101,8 @@ static int handle_recv_error ( MSISession *session, MSICall *call, MSIMessage *m
1101 * 1101 *
1102 * 1102 *
1103 */ 1103 */
1104static void msi_handle_packet ( Messenger *messenger, int source, const uint8_t *data, uint16_t length, void *object ) 1104static void msi_handle_packet ( Messenger *messenger, uint32_t source, const uint8_t *data, uint16_t length,
1105 void *object )
1105{ 1106{
1106 LOGGER_DEBUG("Got msi message"); 1107 LOGGER_DEBUG("Got msi message");
1107 /* Unused */ 1108 /* Unused */
diff --git a/toxav/rtp.c b/toxav/rtp.c
index 2af89ebf..63c2cdcb 100644
--- a/toxav/rtp.c
+++ b/toxav/rtp.c
@@ -341,7 +341,7 @@ RTPMessage *msg_parse ( const uint8_t *data, int length )
341/** 341/**
342 * Callback for networking core. 342 * Callback for networking core.
343 */ 343 */
344int rtp_handle_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length, void *object ) 344int rtp_handle_packet ( Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t length, void *object )
345{ 345{
346 RTPSession *session = object; 346 RTPSession *session = object;
347 RTPMessage *msg; 347 RTPMessage *msg;
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index f566a344..4a173de7 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -886,83 +886,83 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno)
886 m->friendlist[friendnumber].receives_read_receipts = yesno; 886 m->friendlist[friendnumber].receives_read_receipts = yesno;
887} 887}
888 888
889/* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */
890/* Set the function that will be executed when a friend request is received. */ 889/* Set the function that will be executed when a friend request is received. */
891void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, 890void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, size_t,
892 void *), void *userdata) 891 void *), void *userdata)
893{ 892{
894 void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, uint16_t, void *) = (void *)function; 893 void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, size_t, void *) = (void *)function;
895 callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata); 894 callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata);
896} 895}
897 896
898/* Set the function that will be executed when a message from a friend is received. */ 897/* Set the function that will be executed when a message from a friend is received. */
899void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 898void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
900 void *userdata) 899 void *userdata)
901{ 900{
902 m->friend_message = function; 901 m->friend_message = function;
903 m->friend_message_userdata = userdata; 902 m->friend_message_userdata = userdata;
904} 903}
905 904
906void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 905void m_callback_action(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
907 void *userdata) 906 void *userdata)
908{ 907{
909 m->friend_action = function; 908 m->friend_action = function;
910 m->friend_action_userdata = userdata; 909 m->friend_action_userdata = userdata;
911} 910}
912 911
913void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 912void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
914 void *userdata) 913 void *userdata)
915{ 914{
916 m->friend_namechange = function; 915 m->friend_namechange = function;
917 m->friend_namechange_userdata = userdata; 916 m->friend_namechange_userdata = userdata;
918} 917}
919 918
920void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 919void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
921 void *userdata) 920 void *userdata)
922{ 921{
923 m->friend_statusmessagechange = function; 922 m->friend_statusmessagechange = function;
924 m->friend_statuschange_userdata = userdata; 923 m->friend_statuschange_userdata = userdata;
925} 924}
926 925
927void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata) 926void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata)
928{ 927{
929 m->friend_userstatuschange = function; 928 m->friend_userstatuschange = function;
930 m->friend_userstatuschange_userdata = userdata; 929 m->friend_userstatuschange_userdata = userdata;
931} 930}
932 931
933void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata) 932void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata)
934{ 933{
935 m->friend_typingchange = function; 934 m->friend_typingchange = function;
936 m->friend_typingchange_userdata = userdata; 935 m->friend_typingchange_userdata = userdata;
937} 936}
938 937
939void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata) 938void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *), void *userdata)
940{ 939{
941 m->read_receipt = function; 940 m->read_receipt = function;
942 m->read_receipt_userdata = userdata; 941 m->read_receipt_userdata = userdata;
943} 942}
944 943
945void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata) 944void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *),
945 void *userdata)
946{ 946{
947 m->friend_connectionstatuschange = function; 947 m->friend_connectionstatuschange = function;
948 m->friend_connectionstatuschange_userdata = userdata; 948 m->friend_connectionstatuschange_userdata = userdata;
949} 949}
950 950
951void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), 951void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *),
952 void *userdata) 952 void *userdata)
953{ 953{
954 m->friend_connectionstatuschange_internal = function; 954 m->friend_connectionstatuschange_internal = function;
955 m->friend_connectionstatuschange_internal_userdata = userdata; 955 m->friend_connectionstatuschange_internal_userdata = userdata;
956} 956}
957 957
958void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, void *), 958void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t *, void *),
959 void *userdata) 959 void *userdata)
960{ 960{
961 m->avatar_info_recv = function; 961 m->avatar_info_recv = function;
962 m->avatar_info_recv_userdata = userdata; 962 m->avatar_info_recv_userdata = userdata;
963} 963}
964 964
965void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint8_t *, 965void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t *, uint8_t *,
966 uint32_t, void *), void *userdata) 966 uint32_t, void *), void *userdata)
967{ 967{
968 m->avatar_data_recv = function; 968 m->avatar_data_recv = function;
@@ -1027,9 +1027,9 @@ static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_
1027 1027
1028/* Set the callback for group invites. 1028/* Set the callback for group invites.
1029 * 1029 *
1030 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length) 1030 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length)
1031 */ 1031 */
1032void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t)) 1032void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t))
1033{ 1033{
1034 m->group_invite = function; 1034 m->group_invite = function;
1035} 1035}
@@ -1050,9 +1050,10 @@ int send_group_invite_packet(const Messenger *m, int32_t friendnumber, const uin
1050 1050
1051/* Set the callback for file send requests. 1051/* Set the callback for file send requests.
1052 * 1052 *
1053 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) 1053 * Function(Tox *tox, uint32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
1054 */ 1054 */
1055void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, 1055void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint64_t,
1056 const uint8_t *,
1056 uint16_t, void *), void *userdata) 1057 uint16_t, void *), void *userdata)
1057{ 1058{
1058 m->file_sendrequest = function; 1059 m->file_sendrequest = function;
@@ -1061,10 +1062,10 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int3
1061 1062
1062/* Set the callback for file control requests. 1063/* Set the callback for file control requests.
1063 * 1064 *
1064 * Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) 1065 * Function(Tox *tox, uint32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
1065 * 1066 *
1066 */ 1067 */
1067void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, 1068void callback_file_control(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t, uint8_t,
1068 const uint8_t *, uint16_t, void *), void *userdata) 1069 const uint8_t *, uint16_t, void *), void *userdata)
1069{ 1070{
1070 m->file_filecontrol = function; 1071 m->file_filecontrol = function;
@@ -1073,10 +1074,11 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t,
1073 1074
1074/* Set the callback for file data. 1075/* Set the callback for file data.
1075 * 1076 *
1076 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) 1077 * Function(Tox *tox, uint32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
1077 * 1078 *
1078 */ 1079 */
1079void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length, 1080void callback_file_data(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, const uint8_t *,
1081 uint16_t length,
1080 void *), void *userdata) 1082 void *), void *userdata)
1081{ 1083{
1082 m->file_filedata = function; 1084 m->file_filedata = function;
@@ -1397,7 +1399,7 @@ static int handle_filecontrol(const Messenger *m, int32_t friendnumber, uint8_t
1397 * 1399 *
1398 * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata) 1400 * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata)
1399 */ 1401 */
1400void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 1402void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t, void *),
1401 void *userdata) 1403 void *userdata)
1402{ 1404{
1403 m->msi_packet = function; 1405 m->msi_packet = function;
@@ -1430,7 +1432,7 @@ static int handle_custom_lossy_packet(void *object, int friend_num, const uint8_
1430} 1432}
1431 1433
1432int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, 1434int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
1433 int (*packet_handler_callback)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object), 1435 int (*packet_handler_callback)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object),
1434 void *object) 1436 void *object)
1435{ 1437{
1436 if (friend_not_valid(m, friendnumber)) 1438 if (friend_not_valid(m, friendnumber))
@@ -1481,7 +1483,7 @@ static int handle_custom_lossless_packet(void *object, int friend_num, const uin
1481} 1483}
1482 1484
1483int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, 1485int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
1484 int (*packet_handler_callback)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object), 1486 int (*packet_handler_callback)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object),
1485 void *object) 1487 void *object)
1486{ 1488{
1487 if (friend_not_valid(m, friendnumber)) 1489 if (friend_not_valid(m, friendnumber))
@@ -2839,7 +2841,7 @@ uint32_t get_num_online_friends(const Messenger *m)
2839 * Otherwise, returns the number of elements copied. 2841 * Otherwise, returns the number of elements copied.
2840 * If the array was too small, the contents 2842 * If the array was too small, the contents
2841 * of out_list will be truncated to list_size. */ 2843 * of out_list will be truncated to list_size. */
2842uint32_t copy_friendlist(Messenger const *m, int32_t *out_list, uint32_t list_size) 2844uint32_t copy_friendlist(Messenger const *m, uint32_t *out_list, uint32_t list_size)
2843{ 2845{
2844 if (!out_list) 2846 if (!out_list)
2845 return 0; 2847 return 0;
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index b1f1c152..db0777cb 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -222,12 +222,12 @@ typedef struct {
222 AVATAR_RECEIVEDATA *avatar_recv_data; // We are receiving avatar data from this friend. 222 AVATAR_RECEIVEDATA *avatar_recv_data; // We are receiving avatar data from this friend.
223 223
224 struct { 224 struct {
225 int (*function)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object); 225 int (*function)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object);
226 void *object; 226 void *object;
227 } lossy_packethandlers[PACKET_ID_LOSSY_RANGE_SIZE]; 227 } lossy_packethandlers[PACKET_ID_LOSSY_RANGE_SIZE];
228 228
229 struct { 229 struct {
230 int (*function)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object); 230 int (*function)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object);
231 void *object; 231 void *object;
232 } lossless_packethandlers[PACKET_ID_LOSSLESS_RANGE_SIZE]; 232 } lossless_packethandlers[PACKET_ID_LOSSLESS_RANGE_SIZE];
233} Friend; 233} Friend;
@@ -270,43 +270,43 @@ struct Messenger {
270 uint8_t has_added_relays; // If the first connection has occurred in do_messenger 270 uint8_t has_added_relays; // If the first connection has occurred in do_messenger
271 Node_format loaded_relays[NUM_SAVED_TCP_RELAYS]; // Relays loaded from config 271 Node_format loaded_relays[NUM_SAVED_TCP_RELAYS]; // Relays loaded from config
272 272
273 void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 273 void (*friend_message)(struct Messenger *m, uint32_t, const uint8_t *, size_t, void *);
274 void *friend_message_userdata; 274 void *friend_message_userdata;
275 void (*friend_action)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 275 void (*friend_action)(struct Messenger *m, uint32_t, const uint8_t *, size_t, void *);
276 void *friend_action_userdata; 276 void *friend_action_userdata;
277 void (*friend_namechange)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 277 void (*friend_namechange)(struct Messenger *m, uint32_t, const uint8_t *, size_t, void *);
278 void *friend_namechange_userdata; 278 void *friend_namechange_userdata;
279 void (*friend_statusmessagechange)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 279 void (*friend_statusmessagechange)(struct Messenger *m, uint32_t, const uint8_t *, size_t, void *);
280 void *friend_statusmessagechange_userdata; 280 void *friend_statusmessagechange_userdata;
281 void (*friend_userstatuschange)(struct Messenger *m, int32_t, uint8_t, void *); 281 void (*friend_userstatuschange)(struct Messenger *m, uint32_t, uint8_t, void *);
282 void *friend_userstatuschange_userdata; 282 void *friend_userstatuschange_userdata;
283 void (*friend_typingchange)(struct Messenger *m, int32_t, uint8_t, void *); 283 void (*friend_typingchange)(struct Messenger *m, uint32_t, uint8_t, void *);
284 void *friend_typingchange_userdata; 284 void *friend_typingchange_userdata;
285 void (*read_receipt)(struct Messenger *m, int32_t, uint32_t, void *); 285 void (*read_receipt)(struct Messenger *m, uint32_t, uint32_t, void *);
286 void *read_receipt_userdata; 286 void *read_receipt_userdata;
287 void (*friend_statuschange)(struct Messenger *m, int32_t, uint8_t, void *); 287 void (*friend_statuschange)(struct Messenger *m, uint32_t, uint8_t, void *);
288 void *friend_statuschange_userdata; 288 void *friend_statuschange_userdata;
289 void (*friend_connectionstatuschange)(struct Messenger *m, int32_t, uint8_t, void *); 289 void (*friend_connectionstatuschange)(struct Messenger *m, uint32_t, uint8_t, void *);
290 void *friend_connectionstatuschange_userdata; 290 void *friend_connectionstatuschange_userdata;
291 void (*friend_connectionstatuschange_internal)(struct Messenger *m, int32_t, uint8_t, void *); 291 void (*friend_connectionstatuschange_internal)(struct Messenger *m, uint32_t, uint8_t, void *);
292 void *friend_connectionstatuschange_internal_userdata; 292 void *friend_connectionstatuschange_internal_userdata;
293 void *avatar_info_recv_userdata; 293 void *avatar_info_recv_userdata;
294 void (*avatar_info_recv)(struct Messenger *m, int32_t, uint8_t, uint8_t *, void *); 294 void (*avatar_info_recv)(struct Messenger *m, uint32_t, uint8_t, uint8_t *, void *);
295 void *avatar_data_recv_userdata; 295 void *avatar_data_recv_userdata;
296 void (*avatar_data_recv)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint8_t *, uint32_t, void *); 296 void (*avatar_data_recv)(struct Messenger *m, uint32_t, uint8_t, uint8_t *, uint8_t *, uint32_t, void *);
297 297
298 void *group_chat_object; /* Set by new_groupchats()*/ 298 void *group_chat_object; /* Set by new_groupchats()*/
299 void (*group_invite)(struct Messenger *m, int32_t, const uint8_t *, uint16_t); 299 void (*group_invite)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t);
300 void (*group_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t); 300 void (*group_message)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t);
301 301
302 void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t, void *); 302 void (*file_sendrequest)(struct Messenger *m, uint32_t, uint8_t, uint64_t, const uint8_t *, uint16_t, void *);
303 void *file_sendrequest_userdata; 303 void *file_sendrequest_userdata;
304 void (*file_filecontrol)(struct Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *, uint16_t, void *); 304 void (*file_filecontrol)(struct Messenger *m, uint32_t, uint8_t, uint8_t, uint8_t, const uint8_t *, uint16_t, void *);
305 void *file_filecontrol_userdata; 305 void *file_filecontrol_userdata;
306 void (*file_filedata)(struct Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length, void *); 306 void (*file_filedata)(struct Messenger *m, uint32_t, uint8_t, const uint8_t *, uint16_t length, void *);
307 void *file_filedata_userdata; 307 void *file_filedata_userdata;
308 308
309 void (*msi_packet)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 309 void (*msi_packet)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t, void *);
310 void *msi_packet_userdata; 310 void *msi_packet_userdata;
311 311
312 Messenger_Options options; 312 Messenger_Options options;
@@ -624,50 +624,50 @@ uint8_t m_get_istyping(const Messenger *m, int32_t friendnumber);
624void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno); 624void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno);
625 625
626/* Set the function that will be executed when a friend request is received. 626/* Set the function that will be executed when a friend request is received.
627 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) 627 * Function format is function(uint8_t * public_key, uint8_t * data, size_t length)
628 */ 628 */
629void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, uint16_t, 629void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const uint8_t *, const uint8_t *, size_t,
630 void *), void *userdata); 630 void *), void *userdata);
631 631
632/* Set the function that will be executed when a message from a friend is received. 632/* Set the function that will be executed when a message from a friend is received.
633 * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length) 633 * Function format is: function(uint32_t friendnumber, uint8_t * message, uint32_t length)
634 */ 634 */
635void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 635void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
636 void *userdata); 636 void *userdata);
637 637
638/* Set the function that will be executed when an action from a friend is received. 638/* Set the function that will be executed when an action from a friend is received.
639 * Function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length) 639 * Function format is: function(uint32_t friendnumber, uint8_t * action, uint32_t length)
640 */ 640 */
641void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 641void m_callback_action(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
642 void *userdata); 642 void *userdata);
643 643
644/* Set the callback for name changes. 644/* Set the callback for name changes.
645 * Function(int32_t friendnumber, uint8_t *newname, uint16_t length) 645 * Function(uint32_t friendnumber, uint8_t *newname, size_t length)
646 * You are not responsible for freeing newname. 646 * You are not responsible for freeing newname.
647 */ 647 */
648void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 648void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
649 void *userdata); 649 void *userdata);
650 650
651/* Set the callback for status message changes. 651/* Set the callback for status message changes.
652 * Function(int32_t friendnumber, uint8_t *newstatus, uint16_t length) 652 * Function(uint32_t friendnumber, uint8_t *newstatus, size_t length)
653 * 653 *
654 * You are not responsible for freeing newstatus 654 * You are not responsible for freeing newstatus
655 */ 655 */
656void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 656void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, size_t, void *),
657 void *userdata); 657 void *userdata);
658 658
659/* Set the callback for status type changes. 659/* Set the callback for status type changes.
660 * Function(int32_t friendnumber, USERSTATUS kind) 660 * Function(uint32_t friendnumber, USERSTATUS kind)
661 */ 661 */
662void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata); 662void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata);
663 663
664/* Set the callback for typing changes. 664/* Set the callback for typing changes.
665 * Function(int32_t friendnumber, uint8_t is_typing) 665 * Function(uint32_t friendnumber, uint8_t is_typing)
666 */ 666 */
667void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata); 667void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata);
668 668
669/* Set the callback for read receipts. 669/* Set the callback for read receipts.
670 * Function(int32_t friendnumber, uint32_t receipt) 670 * Function(uint32_t friendnumber, uint32_t receipt)
671 * 671 *
672 * If you are keeping a record of returns from m_sendmessage, 672 * If you are keeping a record of returns from m_sendmessage,
673 * receipt might be one of those values, meaning the message 673 * receipt might be one of those values, meaning the message
@@ -675,10 +675,10 @@ void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t
675 * Since core doesn't track ids for you, receipt may not correspond to any message. 675 * Since core doesn't track ids for you, receipt may not correspond to any message.
676 * In that case, you should discard it. 676 * In that case, you should discard it.
677 */ 677 */
678void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata); 678void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32_t, uint32_t, void *), void *userdata);
679 679
680/* Set the callback for connection status changes. 680/* Set the callback for connection status changes.
681 * function(int32_t friendnumber, uint8_t status) 681 * function(uint32_t friendnumber, uint8_t status)
682 * 682 *
683 * Status: 683 * Status:
684 * 0 -- friend went offline after being previously online. 684 * 0 -- friend went offline after being previously online.
@@ -688,10 +688,10 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_
688 * being previously online" part. 688 * being previously online" part.
689 * It's assumed that when adding friends, their connection status is offline. 689 * It's assumed that when adding friends, their connection status is offline.
690 */ 690 */
691void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), 691void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *),
692 void *userdata); 692 void *userdata);
693/* Same as previous but for internal A/V core usage only */ 693/* Same as previous but for internal A/V core usage only */
694void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), 694void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *),
695 void *userdata); 695 void *userdata);
696 696
697 697
@@ -701,14 +701,14 @@ void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Mess
701 * information requests. 701 * information requests.
702 * 702 *
703 * Function format is: 703 * Function format is:
704 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata) 704 * function(Tox *tox, uint32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata)
705 * 705 *
706 * where 'format' is the avatar image format (see AVATAR_FORMAT) and 'hash' is the hash of 706 * where 'format' is the avatar image format (see AVATAR_FORMAT) and 'hash' is the hash of
707 * the avatar data for caching purposes and it is exactly AVATAR_HASH_LENGTH long. If the 707 * the avatar data for caching purposes and it is exactly AVATAR_HASH_LENGTH long. If the
708 * image format is NONE, the hash is zeroed. 708 * image format is NONE, the hash is zeroed.
709 * 709 *
710 */ 710 */
711void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, void *), 711void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t *, void *),
712 void *userdata); 712 void *userdata);
713 713
714 714
@@ -717,7 +717,7 @@ void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, int32_t
717 * friend. This only happens in reply of a avatar data request (see tox_request_avatar_data); 717 * friend. This only happens in reply of a avatar data request (see tox_request_avatar_data);
718 * 718 *
719 * Function format is: 719 * Function format is:
720 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata) 720 * function(Tox *tox, uint32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata)
721 * 721 *
722 * where 'format' is the avatar image format (see AVATAR_FORMAT); 'hash' is the 722 * where 'format' is the avatar image format (see AVATAR_FORMAT); 'hash' is the
723 * locally-calculated cryptographic hash of the avatar data and it is exactly 723 * locally-calculated cryptographic hash of the avatar data and it is exactly
@@ -732,7 +732,7 @@ void m_callback_avatar_info(Messenger *m, void (*function)(Messenger *m, int32_t
732 * potentially malicious. The library only ensures that the data which arrived is the same the 732 * potentially malicious. The library only ensures that the data which arrived is the same the
733 * other user sent, and does not interpret or validate any image data. 733 * other user sent, and does not interpret or validate any image data.
734 */ 734 */
735void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint8_t *, 735void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t *, uint8_t *,
736 uint32_t, void *), void *userdata); 736 uint32_t, void *), void *userdata);
737 737
738 738
@@ -741,9 +741,9 @@ void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, int32_t
741 741
742/* Set the callback for group invites. 742/* Set the callback for group invites.
743 * 743 *
744 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length) 744 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length)
745 */ 745 */
746void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t)); 746void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t));
747 747
748/* Send a group invite packet. 748/* Send a group invite packet.
749 * 749 *
@@ -757,25 +757,27 @@ int send_group_invite_packet(const Messenger *m, int32_t friendnumber, const uin
757 757
758/* Set the callback for file send requests. 758/* Set the callback for file send requests.
759 * 759 *
760 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) 760 * Function(Tox *tox, uint32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
761 */ 761 */
762void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, 762void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint64_t,
763 const uint8_t *,
763 uint16_t, void *), void *userdata); 764 uint16_t, void *), void *userdata);
764 765
765/* Set the callback for file control requests. 766/* Set the callback for file control requests.
766 * 767 *
767 * Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) 768 * Function(Tox *tox, uint32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
768 * 769 *
769 */ 770 */
770void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, 771void callback_file_control(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, uint8_t, uint8_t,
771 const uint8_t *, uint16_t, void *), void *userdata); 772 const uint8_t *, uint16_t, void *), void *userdata);
772 773
773/* Set the callback for file data. 774/* Set the callback for file data.
774 * 775 *
775 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) 776 * Function(Tox *tox, uint32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
776 * 777 *
777 */ 778 */
778void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length, 779void callback_file_data(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, const uint8_t *,
780 uint16_t length,
779 void *), void *userdata); 781 void *), void *userdata);
780 782
781/* Send a file send request. 783/* Send a file send request.
@@ -823,9 +825,9 @@ uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t fi
823 825
824/* Set the callback for msi packets. 826/* Set the callback for msi packets.
825 * 827 *
826 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata) 828 * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
827 */ 829 */
828void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *), 830void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t, void *),
829 void *userdata); 831 void *userdata);
830 832
831/* Send an msi packet. 833/* Send an msi packet.
@@ -843,7 +845,7 @@ int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data,
843 * return 0 on success. 845 * return 0 on success.
844 */ 846 */
845int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, 847int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
846 int (*packet_handler_callback)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object), 848 int (*packet_handler_callback)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object),
847 void *object); 849 void *object);
848 850
849/* High level function to send custom lossy packets. 851/* High level function to send custom lossy packets.
@@ -862,7 +864,7 @@ int send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uin
862 * return 0 on success. 864 * return 0 on success.
863 */ 865 */
864int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, 866int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
865 int (*packet_handler_callback)(Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t len, void *object), 867 int (*packet_handler_callback)(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint32_t len, void *object),
866 void *object); 868 void *object);
867 869
868/* High level function to send custom lossless packets. 870/* High level function to send custom lossless packets.
@@ -918,6 +920,6 @@ uint32_t get_num_online_friends(const Messenger *m);
918 * Otherwise, returns the number of elements copied. 920 * Otherwise, returns the number of elements copied.
919 * If the array was too small, the contents 921 * If the array was too small, the contents
920 * of out_list will be truncated to list_size. */ 922 * of out_list will be truncated to list_size. */
921uint32_t copy_friendlist(const Messenger *m, int32_t *out_list, uint32_t list_size); 923uint32_t copy_friendlist(const Messenger *m, uint32_t *out_list, uint32_t list_size);
922 924
923#endif 925#endif
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c
index e4a10008..dae1694a 100644
--- a/toxcore/friend_requests.c
+++ b/toxcore/friend_requests.c
@@ -42,7 +42,7 @@ uint32_t get_nospam(const Friend_Requests *fr)
42 42
43 43
44/* Set the function that will be executed when a friend request is received. */ 44/* Set the function that will be executed when a friend request is received. */
45void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, 45void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, size_t,
46 void *), void *object, void *userdata) 46 void *), void *object, void *userdata)
47{ 47{
48 fr->handle_friendrequest = function; 48 fr->handle_friendrequest = function;
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h
index 86069f3b..ae21f7dc 100644
--- a/toxcore/friend_requests.h
+++ b/toxcore/friend_requests.h
@@ -30,7 +30,7 @@
30 30
31typedef struct { 31typedef struct {
32 uint32_t nospam; 32 uint32_t nospam;
33 void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, uint16_t, void *); 33 void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, size_t, void *);
34 uint8_t handle_friendrequest_isset; 34 uint8_t handle_friendrequest_isset;
35 void *handle_friendrequest_object; 35 void *handle_friendrequest_object;
36 void *handle_friendrequest_userdata; 36 void *handle_friendrequest_userdata;
@@ -59,9 +59,9 @@ uint32_t get_nospam(const Friend_Requests *fr);
59int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk); 59int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk);
60 60
61/* Set the function that will be executed when a friend request for us is received. 61/* Set the function that will be executed when a friend request for us is received.
62 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) 62 * Function format is function(uint8_t * public_key, uint8_t * data, size_t length, void * userdata)
63 */ 63 */
64void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, uint16_t, 64void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, const uint8_t *, const uint8_t *, size_t,
65 void *), void *object, void *userdata); 65 void *), void *object, void *userdata);
66 66
67/* Set the function used to check if a friend request should be displayed to the user or not. 67/* Set the function used to check if a friend request should be displayed to the user or not.
diff --git a/toxcore/group.c b/toxcore/group.c
index 786a9cdd..c688ccff 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -1236,7 +1236,7 @@ int group_title_get(const Group_Chats *g_c, int groupnumber, uint8_t *title, uin
1236 return max_length; 1236 return max_length;
1237} 1237}
1238 1238
1239static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length) 1239static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length)
1240{ 1240{
1241 Group_Chats *g_c = m->group_chat_object; 1241 Group_Chats *g_c = m->group_chat_object;
1242 1242