/work/toxcore/friend_requests.h
Line | Count | Source |
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 | 293 | #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 | | non_null() void set_nospam(Friend_Requests *fr, uint32_t num); |
20 | | non_null() uint32_t get_nospam(const Friend_Requests *fr); |
21 | | |
22 | | /** @brief Remove real_pk from received_requests list. |
23 | | * |
24 | | * @retval 0 if it removed it successfully. |
25 | | * @retval -1 if it didn't find it. |
26 | | */ |
27 | | non_null() |
28 | | int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk); |
29 | | |
30 | | typedef void fr_friend_request_cb(void *object, const uint8_t *public_key, const uint8_t *message, size_t length, |
31 | | void *user_data); |
32 | | |
33 | | /** Set the function that will be executed when a friend request for us is received. */ |
34 | | non_null() |
35 | | void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object); |
36 | | |
37 | | typedef int filter_function_cb(void *object, const uint8_t *public_key); |
38 | | |
39 | | /** @brief Set the function used to check if a friend request should be displayed to the user or not. |
40 | | * It must return 0 if the request is ok (anything else if it is bad). |
41 | | */ |
42 | | non_null() |
43 | | void set_filter_function(Friend_Requests *fr, filter_function_cb *function, void *userdata); |
44 | | |
45 | | /** Sets up friendreq packet handlers. */ |
46 | | non_null() |
47 | | void friendreq_init(Friend_Requests *fr, Friend_Connections *fr_c); |
48 | | |
49 | | Friend_Requests *friendreq_new(void); |
50 | | |
51 | | nullable(1) |
52 | | void friendreq_kill(Friend_Requests *fr); |
53 | | |
54 | | #endif /* C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H */ |