1 /* SPDX-License-Identifier: GPL-3.0-or-later 2 * Copyright © 2016-2018 The TokTok team. 3 * Copyright © 2014 Tox project. 4 */ 5 6 /* 7 * Handle friend requests. 8 */ 9 #ifndef C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H 10 #define C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H 11 12 #include "friend_connection.h" 13 14 #define MAX_FRIEND_REQUEST_DATA_SIZE (ONION_CLIENT_MAX_DATA_SIZE - (1 + sizeof(uint32_t))) 15 16 typedef struct Friend_Requests Friend_Requests; 17 18 /* Set and get the nospam variable used to prevent one type of friend request spam. */ 19 void set_nospam(Friend_Requests *fr, uint32_t num); 20 uint32_t get_nospam(const Friend_Requests *fr); 21 22 /* Remove real_pk from received_requests list. 23 * 24 * return 0 if it removed it successfully. 25 * return -1 if it didn't find it. 26 */ 27 int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk); 28 29 typedef void fr_friend_request_cb(void *object, const uint8_t *public_key, const uint8_t *message, size_t length, 30 void *user_data); 31 32 /* Set the function that will be executed when a friend request for us is received. 33 */ 34 void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object); 35 36 typedef int filter_function_cb(const uint8_t *public_key, void *user_data); 37 38 /* Set the function used to check if a friend request should be displayed to the user or not. 39 * It must return 0 if the request is ok (anything else if it is bad.) 40 */ 41 void set_filter_function(Friend_Requests *fr, filter_function_cb *function, void *userdata); 42 43 /* Sets up friendreq packet handlers. */ 44 void friendreq_init(Friend_Requests *fr, Friend_Connections *fr_c); 45 46 Friend_Requests *friendreq_new(void); 47 void friendreq_kill(Friend_Requests *fr); 48 49 #endif 50