summaryrefslogtreecommitdiff
path: root/toxcore/friend_requests.h
diff options
context:
space:
mode:
authorjin-eld <jin at mediatomb dot cc>2013-08-04 15:10:37 +0300
committerjin-eld <jin at mediatomb dot cc>2013-08-24 03:25:07 +0300
commite658892793c42b2d058eed0937025ef2ddaaa372 (patch)
tree2a022cab057f2c16ca95860ed980092880052f6e /toxcore/friend_requests.h
parente2aa8161adc85795fe4d63d4642f47e90937ddc2 (diff)
Rename core directory because of autoconf name clash
While doing the checks configure might generate "core" files and will then try to remove them. Having a "core" directory generates an error while runing the configure script. There's no workaround but to rename the core directory.
Diffstat (limited to 'toxcore/friend_requests.h')
-rw-r--r--toxcore/friend_requests.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h
new file mode 100644
index 00000000..2ebd557b
--- /dev/null
+++ b/toxcore/friend_requests.h
@@ -0,0 +1,70 @@
1/* friend_requests.h
2 *
3 * Handle friend requests.
4 *
5 * Copyright (C) 2013 Tox project All Rights Reserved.
6 *
7 * This file is part of Tox.
8 *
9 * Tox is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * Tox is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#ifndef FRIEND_REQUESTS_H
25#define FRIEND_REQUESTS_H
26
27#include "DHT.h"
28#include "net_crypto.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34typedef struct {
35 uint32_t nospam;
36 void (*handle_friendrequest)(uint8_t *, uint8_t *, uint16_t, void *);
37 uint8_t handle_friendrequest_isset;
38 void *handle_friendrequest_userdata;
39
40 /*NOTE: the following is just a temporary fix for the multiple friend requests received at the same time problem
41 TODO: Make this better (This will most likely tie in with the way we will handle spam.)*/
42
43#define MAX_RECEIVED_STORED 32
44
45 uint8_t received_requests[MAX_RECEIVED_STORED][crypto_box_PUBLICKEYBYTES];
46 uint16_t received_requests_index;
47} Friend_Requests;
48
49/* Try to send a friendrequest to peer with public_key
50 data is the data in the request and length is the length. */
51int send_friendrequest(DHT *dht, uint8_t *public_key, uint32_t nospam_num, uint8_t *data, uint32_t length);
52/*
53 * Set and get the nospam variable used to prevent one type of friend request spam
54 */
55void set_nospam(Friend_Requests *fr, uint32_t num);
56uint32_t get_nospam(Friend_Requests *fr);
57
58/* set the function that will be executed when a friend request for us is received.
59 function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */
60void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *),
61 void *userdata);
62
63/* sets up friendreq packet handlers */
64void friendreq_init(Friend_Requests *fr, Net_Crypto *c);
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif