diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-13 18:31:51 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-14 16:16:30 +0000 |
commit | d8fcac5b4f66efcec961cf30cb461ab9231c6a67 (patch) | |
tree | 701cbb063b502c0cedeb87641bff39cc24a6bb8f /toxcore/friend_requests.c | |
parent | 4b54d14d9c35740140962942c48d964ee43b49ba (diff) |
Make Friend_Requests a module-private type.
Diffstat (limited to 'toxcore/friend_requests.c')
-rw-r--r-- | toxcore/friend_requests.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index ba782e2b..4a06654d 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -29,6 +29,24 @@ | |||
29 | 29 | ||
30 | #include "util.h" | 30 | #include "util.h" |
31 | 31 | ||
32 | struct Friend_Requests { | ||
33 | uint32_t nospam; | ||
34 | void (*handle_friendrequest)(void *, const uint8_t *, const uint8_t *, size_t, void *); | ||
35 | uint8_t handle_friendrequest_isset; | ||
36 | void *handle_friendrequest_object; | ||
37 | |||
38 | int (*filter_function)(const uint8_t *, void *); | ||
39 | void *filter_function_userdata; | ||
40 | /* NOTE: The following is just a temporary fix for the multiple friend requests received at the same time problem. | ||
41 | * TODO(irungentoo): Make this better (This will most likely tie in with the way we will handle spam.) | ||
42 | */ | ||
43 | |||
44 | #define MAX_RECEIVED_STORED 32 | ||
45 | |||
46 | uint8_t received_requests[MAX_RECEIVED_STORED][CRYPTO_PUBLIC_KEY_SIZE]; | ||
47 | uint16_t received_requests_index; | ||
48 | }; | ||
49 | |||
32 | /* Set and get the nospam variable used to prevent one type of friend request spam. */ | 50 | /* Set and get the nospam variable used to prevent one type of friend request spam. */ |
33 | void set_nospam(Friend_Requests *fr, uint32_t num) | 51 | void set_nospam(Friend_Requests *fr, uint32_t num) |
34 | { | 52 | { |
@@ -150,3 +168,13 @@ void friendreq_init(Friend_Requests *fr, Friend_Connections *fr_c) | |||
150 | { | 168 | { |
151 | set_friend_request_callback(fr_c, &friendreq_handlepacket, fr); | 169 | set_friend_request_callback(fr_c, &friendreq_handlepacket, fr); |
152 | } | 170 | } |
171 | |||
172 | Friend_Requests *friendreq_new(void) | ||
173 | { | ||
174 | return (Friend_Requests *)calloc(1, sizeof(Friend_Requests)); | ||
175 | } | ||
176 | |||
177 | void friendreq_kill(Friend_Requests *fr) | ||
178 | { | ||
179 | free(fr); | ||
180 | } | ||