summaryrefslogtreecommitdiff
path: root/toxcore/friend_requests.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/friend_requests.c')
-rw-r--r--toxcore/friend_requests.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c
index 67977c23..589bd315 100644
--- a/toxcore/friend_requests.c
+++ b/toxcore/friend_requests.c
@@ -96,6 +96,12 @@ void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uin
96 fr->handle_friendrequest_isset = 1; 96 fr->handle_friendrequest_isset = 1;
97 fr->handle_friendrequest_userdata = userdata; 97 fr->handle_friendrequest_userdata = userdata;
98} 98}
99/* Set the function used to check if a friend request should be displayed to the user or not. */
100void set_filter_function(Friend_Requests *fr, int (*function)(uint8_t *, void *), void *userdata)
101{
102 fr->filter_function = function;
103 fr->filter_function_userdata = userdata;
104}
99 105
100/* Add to list of received friend requests. */ 106/* Add to list of received friend requests. */
101static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id) 107static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id)
@@ -141,6 +147,10 @@ static int friendreq_handlepacket(void *object, IP_Port source, uint8_t *source_
141 if (memcmp(packet, &fr->nospam, sizeof(fr->nospam)) != 0) 147 if (memcmp(packet, &fr->nospam, sizeof(fr->nospam)) != 0)
142 return 1; 148 return 1;
143 149
150 if (fr->filter_function)
151 if ((*fr->filter_function)(source_pubkey, fr->filter_function_userdata) != 0)
152 return 1;
153
144 addto_receivedlist(fr, source_pubkey); 154 addto_receivedlist(fr, source_pubkey);
145 (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata); 155 (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata);
146 return 0; 156 return 0;