diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 6 | ||||
-rw-r--r-- | toxcore/Messenger.h | 3 | ||||
-rw-r--r-- | toxcore/friend_requests.c | 8 | ||||
-rw-r--r-- | toxcore/friend_requests.h | 7 | ||||
-rw-r--r-- | toxcore/network.c | 2 | ||||
-rw-r--r-- | toxcore/tox.c | 3 | ||||
-rw-r--r-- | toxcore/tox.h | 8 |
7 files changed, 22 insertions, 15 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index e48fa5fc..7ce6bb3c 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -721,9 +721,11 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno) | |||
721 | 721 | ||
722 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */ | 722 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); */ |
723 | /* Set the function that will be executed when a friend request is received. */ | 723 | /* Set the function that will be executed when a friend request is received. */ |
724 | void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata) | 724 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, uint8_t *, uint8_t *, uint16_t, void *), |
725 | void *userdata) | ||
725 | { | 726 | { |
726 | callback_friendrequest(&(m->fr), function, userdata); | 727 | void (*handle_friendrequest)(void *, uint8_t *, uint8_t *, uint16_t, void *) = function; |
728 | callback_friendrequest(&(m->fr), handle_friendrequest, m, userdata); | ||
727 | } | 729 | } |
728 | 730 | ||
729 | /* Set the function that will be executed when a message from a friend is received. */ | 731 | /* Set the function that will be executed when a message from a friend is received. */ |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 32b1f1b3..9e91ccee 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -437,7 +437,8 @@ void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno); | |||
437 | /* Set the function that will be executed when a friend request is received. | 437 | /* Set the function that will be executed when a friend request is received. |
438 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) | 438 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) |
439 | */ | 439 | */ |
440 | void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); | 440 | void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, uint8_t *, uint8_t *, uint16_t, void *), |
441 | void *userdata); | ||
441 | 442 | ||
442 | /* Set the function that will be executed when a message from a friend is received. | 443 | /* Set the function that will be executed when a message from a friend is received. |
443 | * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length) | 444 | * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length) |
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index 987b1a4a..7574a881 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -72,11 +72,12 @@ uint32_t get_nospam(Friend_Requests *fr) | |||
72 | 72 | ||
73 | 73 | ||
74 | /* Set the function that will be executed when a friend request is received. */ | 74 | /* Set the function that will be executed when a friend request is received. */ |
75 | void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), | 75 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, uint8_t *, uint8_t *, uint16_t, void *), |
76 | void *userdata) | 76 | void *object, void *userdata) |
77 | { | 77 | { |
78 | fr->handle_friendrequest = function; | 78 | fr->handle_friendrequest = function; |
79 | fr->handle_friendrequest_isset = 1; | 79 | fr->handle_friendrequest_isset = 1; |
80 | fr->handle_friendrequest_object = object; | ||
80 | fr->handle_friendrequest_userdata = userdata; | 81 | fr->handle_friendrequest_userdata = userdata; |
81 | } | 82 | } |
82 | /* Set the function used to check if a friend request should be displayed to the user or not. */ | 83 | /* Set the function used to check if a friend request should be displayed to the user or not. */ |
@@ -145,7 +146,8 @@ static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t | |||
145 | memcpy(message, packet + 4, length - 4); | 146 | memcpy(message, packet + 4, length - 4); |
146 | message[sizeof(message) - 1] = 0; /* Be sure the message is null terminated. */ | 147 | message[sizeof(message) - 1] = 0; /* Be sure the message is null terminated. */ |
147 | 148 | ||
148 | (*fr->handle_friendrequest)(source_pubkey, message, length - 4, fr->handle_friendrequest_userdata); | 149 | (*fr->handle_friendrequest)(fr->handle_friendrequest_object, source_pubkey, message, length - 4, |
150 | fr->handle_friendrequest_userdata); | ||
149 | return 0; | 151 | return 0; |
150 | } | 152 | } |
151 | 153 | ||
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h index 732dc4a2..722c7431 100644 --- a/toxcore/friend_requests.h +++ b/toxcore/friend_requests.h | |||
@@ -30,8 +30,9 @@ | |||
30 | 30 | ||
31 | typedef struct { | 31 | typedef struct { |
32 | uint32_t nospam; | 32 | uint32_t nospam; |
33 | void (*handle_friendrequest)(uint8_t *, uint8_t *, uint16_t, void *); | 33 | void (*handle_friendrequest)(void *, uint8_t *, uint8_t *, uint16_t, void *); |
34 | uint8_t handle_friendrequest_isset; | 34 | uint8_t handle_friendrequest_isset; |
35 | void *handle_friendrequest_object; | ||
35 | void *handle_friendrequest_userdata; | 36 | void *handle_friendrequest_userdata; |
36 | 37 | ||
37 | int (*filter_function)(uint8_t *, void *); | 38 | int (*filter_function)(uint8_t *, void *); |
@@ -57,8 +58,8 @@ uint32_t get_nospam(Friend_Requests *fr); | |||
57 | /* Set the function that will be executed when a friend request for us is received. | 58 | /* Set the function that will be executed when a friend request for us is received. |
58 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) | 59 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length, void * userdata) |
59 | */ | 60 | */ |
60 | void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), | 61 | void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, uint8_t *, uint8_t *, uint16_t, void *), |
61 | void *userdata); | 62 | void *object, void *userdata); |
62 | 63 | ||
63 | /* Set the function used to check if a friend request should be displayed to the user or not. | 64 | /* Set the function used to check if a friend request should be displayed to the user or not. |
64 | * Function format is int function(uint8_t * public_key, void * userdata) | 65 | * Function format is int function(uint8_t * public_key, void * userdata) |
diff --git a/toxcore/network.c b/toxcore/network.c index 35b55bf1..e2e0bff4 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -435,7 +435,7 @@ int networking_wait_cleanup(Networking_Core *net, uint8_t *data) | |||
435 | if (s->send_fail_reset) { | 435 | if (s->send_fail_reset) { |
436 | net->send_fail_eagain = 0; | 436 | net->send_fail_eagain = 0; |
437 | } | 437 | } |
438 | 438 | ||
439 | return 1; | 439 | return 1; |
440 | } | 440 | } |
441 | 441 | ||
diff --git a/toxcore/tox.c b/toxcore/tox.c index aec0d902..9a5be0ad 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -353,7 +353,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size) | |||
353 | /* Set the function that will be executed when a friend request is received. | 353 | /* Set the function that will be executed when a friend request is received. |
354 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) | 354 | * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) |
355 | */ | 355 | */ |
356 | void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata) | 356 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, uint8_t *, uint8_t *, uint16_t, void *), |
357 | void *userdata) | ||
357 | { | 358 | { |
358 | Messenger *m = tox; | 359 | Messenger *m = tox; |
359 | m_callback_friendrequest(m, function, userdata); | 360 | m_callback_friendrequest(m, function, userdata); |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 1c84c1cb..41f868dd 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -98,9 +98,9 @@ typedef struct Tox Tox; | |||
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | /* NOTE: Strings in Tox are all UTF-8, (This means that there is no terminating NULL character.) | 100 | /* NOTE: Strings in Tox are all UTF-8, (This means that there is no terminating NULL character.) |
101 | * | 101 | * |
102 | * The exact buffer you send will be received at the other end without modification. | 102 | * The exact buffer you send will be received at the other end without modification. |
103 | * | 103 | * |
104 | * Do not treat Tox strings as C strings. | 104 | * Do not treat Tox strings as C strings. |
105 | */ | 105 | */ |
106 | 106 | ||
@@ -228,7 +228,6 @@ int tox_get_name_size(Tox *tox, int32_t friendnumber); | |||
228 | int tox_get_self_name_size(Tox *tox); | 228 | int tox_get_self_name_size(Tox *tox); |
229 | 229 | ||
230 | /* Set our user status. | 230 | /* Set our user status. |
231 | * You are responsible for freeing status after. | ||
232 | * | 231 | * |
233 | * userstatus must be one of TOX_USERSTATUS values. | 232 | * userstatus must be one of TOX_USERSTATUS values. |
234 | * | 233 | * |
@@ -300,7 +299,8 @@ uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size); | |||
300 | /* Set the function that will be executed when a friend request is received. | 299 | /* Set the function that will be executed when a friend request is received. |
301 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) | 300 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) |
302 | */ | 301 | */ |
303 | void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); | 302 | void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, uint8_t *, uint8_t *, uint16_t, void *), |
303 | void *userdata); | ||
304 | 304 | ||
305 | /* Set the function that will be executed when a message from a friend is received. | 305 | /* Set the function that will be executed when a message from a friend is received. |
306 | * Function format is: function(Tox *tox, int friendnumber, uint8_t * message, uint32_t length, void *userdata) | 306 | * Function format is: function(Tox *tox, int friendnumber, uint8_t * message, uint32_t length, void *userdata) |