diff options
Diffstat (limited to 'toxcore/friend_requests.c')
-rw-r--r-- | toxcore/friend_requests.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index d8c6858b..a2827280 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -23,11 +23,12 @@ | |||
23 | 23 | ||
24 | #include "friend_requests.h" | 24 | #include "friend_requests.h" |
25 | 25 | ||
26 | /* Try to send a friendrequest to peer with public_key | 26 | /* Try to send a friend request to peer with public_key. |
27 | data is the data in the request and length is the length. | 27 | * data is the data in the request and length is the length. |
28 | return -1 if failure. | 28 | * return -1 if failure. |
29 | return 0 if it sent the friend request directly to the friend. | 29 | * return 0 if it sent the friend request directly to the friend. |
30 | return the number of peers it was routed through if it did not send it directly.*/ | 30 | * return the number of peers it was routed through if it did not send it directly. |
31 | */ | ||
31 | int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length) | 32 | int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length) |
32 | { | 33 | { |
33 | if (length + sizeof(nospam_num) > MAX_DATA_SIZE) | 34 | if (length + sizeof(nospam_num) > MAX_DATA_SIZE) |
@@ -65,9 +66,7 @@ int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8 | |||
65 | } | 66 | } |
66 | 67 | ||
67 | 68 | ||
68 | /* | 69 | /* Set and get the nospam variable used to prevent one type of friend request spam. */ |
69 | * Set and get the nospam variable used to prevent one type of friend request spam | ||
70 | */ | ||
71 | void set_nospam(Friend_Requests *fr, uint32_t num) | 70 | void set_nospam(Friend_Requests *fr, uint32_t num) |
72 | { | 71 | { |
73 | fr->nospam = num; | 72 | fr->nospam = num; |
@@ -79,7 +78,7 @@ uint32_t get_nospam(Friend_Requests *fr) | |||
79 | } | 78 | } |
80 | 79 | ||
81 | 80 | ||
82 | /* set the function that will be executed when a friend request is received. */ | 81 | /* Set the function that will be executed when a friend request is received. */ |
83 | void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), | 82 | void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), |
84 | void *userdata) | 83 | void *userdata) |
85 | { | 84 | { |
@@ -88,7 +87,7 @@ void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uin | |||
88 | fr->handle_friendrequest_userdata = userdata; | 87 | fr->handle_friendrequest_userdata = userdata; |
89 | } | 88 | } |
90 | 89 | ||
91 | /*Add to list of received friend requests*/ | 90 | /* Add to list of received friend requests. */ |
92 | static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id) | 91 | static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id) |
93 | { | 92 | { |
94 | if (fr->received_requests_index >= MAX_RECEIVED_STORED) | 93 | if (fr->received_requests_index >= MAX_RECEIVED_STORED) |
@@ -98,8 +97,10 @@ static void addto_receivedlist(Friend_Requests *fr, uint8_t *client_id) | |||
98 | ++fr->received_requests_index; | 97 | ++fr->received_requests_index; |
99 | } | 98 | } |
100 | 99 | ||
101 | /* Check if a friend request was already received | 100 | /* Check if a friend request was already received. |
102 | return 0 if not, 1 if we did */ | 101 | * return 0 if it did not. |
102 | * return 1 if it did. | ||
103 | */ | ||
103 | static int request_received(Friend_Requests *fr, uint8_t *client_id) | 104 | static int request_received(Friend_Requests *fr, uint8_t *client_id) |
104 | { | 105 | { |
105 | uint32_t i; | 106 | uint32_t i; |