ffi-tox 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ProjectTox-Core/AUTHORS +0 -0
- data/ProjectTox-Core/ChangeLog +0 -0
- data/ProjectTox-Core/INSTALL +370 -0
- data/ProjectTox-Core/INSTALL.md +455 -56
- data/ProjectTox-Core/Makefile.am +35 -0
- data/ProjectTox-Core/NEWS +0 -0
- data/ProjectTox-Core/README +43 -0
- data/ProjectTox-Core/README.md +34 -44
- data/ProjectTox-Core/auto_tests/Makefile.inc +110 -0
- data/ProjectTox-Core/auto_tests/TCP_test.c +519 -0
- data/ProjectTox-Core/auto_tests/assoc_test.c +160 -0
- data/ProjectTox-Core/auto_tests/crypto_test.c +302 -0
- data/ProjectTox-Core/auto_tests/dht_test.c +362 -0
- data/ProjectTox-Core/auto_tests/encryptsave_test.c +104 -0
- data/ProjectTox-Core/auto_tests/friends_test.c +238 -0
- data/ProjectTox-Core/auto_tests/helpers.h +15 -0
- data/ProjectTox-Core/auto_tests/messenger_test.c +365 -0
- data/ProjectTox-Core/auto_tests/network_test.c +171 -0
- data/ProjectTox-Core/auto_tests/onion_test.c +363 -0
- data/ProjectTox-Core/auto_tests/skeleton_test.c +49 -0
- data/ProjectTox-Core/auto_tests/tox_test.c +454 -0
- data/ProjectTox-Core/auto_tests/toxav_basic_test.c +597 -0
- data/ProjectTox-Core/auto_tests/toxav_many_test.c +402 -0
- data/ProjectTox-Core/autogen.sh +6 -0
- data/ProjectTox-Core/build/Makefile.am +14 -0
- data/ProjectTox-Core/configure.ac +694 -0
- data/ProjectTox-Core/dist-build/android-arm.sh +3 -0
- data/ProjectTox-Core/dist-build/android-armv7.sh +3 -0
- data/ProjectTox-Core/dist-build/android-build.sh +59 -0
- data/ProjectTox-Core/dist-build/android-mips.sh +3 -0
- data/ProjectTox-Core/dist-build/android-x86.sh +3 -0
- data/ProjectTox-Core/docs/Group-Chats.md +71 -0
- data/ProjectTox-Core/docs/Hardening.txt +60 -0
- data/ProjectTox-Core/docs/Hardening_docs.txt +30 -0
- data/ProjectTox-Core/docs/Prevent_Tracking.txt +160 -0
- data/ProjectTox-Core/docs/TCP_Network.txt +154 -0
- data/ProjectTox-Core/docs/TODO +62 -0
- data/ProjectTox-Core/docs/Tox_middle_level_network_protocol.txt +120 -0
- data/ProjectTox-Core/docs/av_api.md +194 -0
- data/ProjectTox-Core/libtoxav.pc.in +11 -0
- data/ProjectTox-Core/libtoxcore.pc.in +11 -0
- data/ProjectTox-Core/m4/ax_have_epoll.m4 +104 -0
- data/ProjectTox-Core/m4/ax_pthread.m4 +317 -0
- data/ProjectTox-Core/m4/pkg.m4 +199 -0
- data/ProjectTox-Core/other/DHT_bootstrap.c +121 -58
- data/ProjectTox-Core/other/DHTnodes +3 -0
- data/ProjectTox-Core/other/Makefile.inc +20 -0
- data/ProjectTox-Core/other/bootstrap_node_packets.c +65 -0
- data/ProjectTox-Core/other/tox.png +0 -0
- data/ProjectTox-Core/testing/DHT_test.c +170 -98
- data/ProjectTox-Core/testing/Makefile.inc +112 -0
- data/ProjectTox-Core/testing/Messenger_test.c +133 -69
- data/ProjectTox-Core/testing/dns3_test.c +115 -0
- data/ProjectTox-Core/testing/misc_tools.c +59 -13
- data/ProjectTox-Core/testing/nTox.c +1127 -264
- data/ProjectTox-Core/testing/nTox.h +10 -19
- data/ProjectTox-Core/testing/tox_shell.c +159 -0
- data/ProjectTox-Core/testing/tox_sync.c +299 -0
- data/ProjectTox-Core/tools/README +11 -0
- data/ProjectTox-Core/tools/astylerc +11 -0
- data/ProjectTox-Core/tools/pre-commit +17 -0
- data/ProjectTox-Core/toxav/Makefile.inc +36 -0
- data/ProjectTox-Core/toxav/codec.c +357 -0
- data/ProjectTox-Core/toxav/codec.h +116 -0
- data/ProjectTox-Core/toxav/msi.c +1949 -0
- data/ProjectTox-Core/toxav/msi.h +267 -0
- data/ProjectTox-Core/toxav/rtp.c +600 -0
- data/ProjectTox-Core/toxav/rtp.h +196 -0
- data/ProjectTox-Core/toxav/toxav.c +1148 -0
- data/ProjectTox-Core/toxav/toxav.h +389 -0
- data/ProjectTox-Core/toxcore/DHT.c +2521 -0
- data/ProjectTox-Core/toxcore/DHT.h +412 -0
- data/ProjectTox-Core/toxcore/LAN_discovery.c +322 -0
- data/ProjectTox-Core/{core → toxcore}/LAN_discovery.h +17 -12
- data/ProjectTox-Core/toxcore/Makefile.inc +67 -0
- data/ProjectTox-Core/toxcore/Messenger.c +3006 -0
- data/ProjectTox-Core/toxcore/Messenger.h +818 -0
- data/ProjectTox-Core/toxcore/TCP_client.c +858 -0
- data/ProjectTox-Core/toxcore/TCP_client.h +156 -0
- data/ProjectTox-Core/toxcore/TCP_server.c +1332 -0
- data/ProjectTox-Core/toxcore/TCP_server.h +181 -0
- data/ProjectTox-Core/toxcore/assoc.c +1033 -0
- data/ProjectTox-Core/toxcore/assoc.h +104 -0
- data/ProjectTox-Core/toxcore/crypto_core.c +278 -0
- data/ProjectTox-Core/toxcore/crypto_core.h +151 -0
- data/ProjectTox-Core/toxcore/friend_requests.c +175 -0
- data/ProjectTox-Core/toxcore/friend_requests.h +83 -0
- data/ProjectTox-Core/toxcore/group_chats.c +837 -0
- data/ProjectTox-Core/toxcore/group_chats.h +199 -0
- data/ProjectTox-Core/toxcore/list.c +256 -0
- data/ProjectTox-Core/toxcore/list.h +85 -0
- data/ProjectTox-Core/toxcore/logger.c +153 -0
- data/ProjectTox-Core/toxcore/logger.h +84 -0
- data/ProjectTox-Core/toxcore/misc_tools.h +70 -0
- data/ProjectTox-Core/toxcore/net_crypto.c +2753 -0
- data/ProjectTox-Core/toxcore/net_crypto.h +410 -0
- data/ProjectTox-Core/toxcore/network.c +979 -0
- data/ProjectTox-Core/toxcore/network.h +367 -0
- data/ProjectTox-Core/toxcore/onion.c +540 -0
- data/ProjectTox-Core/toxcore/onion.h +150 -0
- data/ProjectTox-Core/toxcore/onion_announce.c +433 -0
- data/ProjectTox-Core/toxcore/onion_announce.h +139 -0
- data/ProjectTox-Core/toxcore/onion_client.c +1347 -0
- data/ProjectTox-Core/toxcore/onion_client.h +253 -0
- data/ProjectTox-Core/toxcore/ping.c +346 -0
- data/ProjectTox-Core/toxcore/ping.h +47 -0
- data/ProjectTox-Core/toxcore/ping_array.c +162 -0
- data/ProjectTox-Core/toxcore/ping_array.h +75 -0
- data/ProjectTox-Core/toxcore/tox.c +940 -0
- data/ProjectTox-Core/toxcore/tox.h +734 -0
- data/ProjectTox-Core/toxcore/util.c +193 -0
- data/ProjectTox-Core/toxcore/util.h +63 -0
- data/ProjectTox-Core/toxdns/Makefile.inc +29 -0
- data/ProjectTox-Core/toxdns/toxdns.c +238 -0
- data/ProjectTox-Core/toxdns/toxdns.h +88 -0
- data/ProjectTox-Core/toxencryptsave/Makefile.inc +45 -0
- data/ProjectTox-Core/toxencryptsave/toxencryptsave.c +179 -0
- data/ProjectTox-Core/toxencryptsave/toxencryptsave.h +74 -0
- data/interfaces/libtox.i +2 -6
- data/lib/ffi-tox/libtox.rb +406 -28
- metadata +124 -46
- data/ProjectTox-Core/CMakeLists.txt +0 -50
- data/ProjectTox-Core/cmake/FindLIBCONFIG.cmake +0 -15
- data/ProjectTox-Core/cmake/FindNaCl.cmake +0 -17
- data/ProjectTox-Core/cmake/FindSODIUM.cmake +0 -15
- data/ProjectTox-Core/core/CMakeLists.txt +0 -19
- data/ProjectTox-Core/core/DHT.c +0 -1104
- data/ProjectTox-Core/core/DHT.h +0 -111
- data/ProjectTox-Core/core/LAN_discovery.c +0 -79
- data/ProjectTox-Core/core/Lossless_UDP.c +0 -755
- data/ProjectTox-Core/core/Lossless_UDP.h +0 -106
- data/ProjectTox-Core/core/Messenger.c +0 -596
- data/ProjectTox-Core/core/Messenger.h +0 -165
- data/ProjectTox-Core/core/friend_requests.c +0 -131
- data/ProjectTox-Core/core/friend_requests.h +0 -51
- data/ProjectTox-Core/core/net_crypto.c +0 -575
- data/ProjectTox-Core/core/net_crypto.h +0 -134
- data/ProjectTox-Core/core/network.c +0 -205
- data/ProjectTox-Core/core/network.h +0 -134
- data/ProjectTox-Core/docs/commands.md +0 -25
- data/ProjectTox-Core/docs/start_guide.de.md +0 -40
- data/ProjectTox-Core/docs/start_guide.md +0 -38
- data/ProjectTox-Core/other/CMakeLists.txt +0 -9
- data/ProjectTox-Core/testing/CMakeLists.txt +0 -18
- data/ProjectTox-Core/testing/DHT_cryptosendfiletest.c +0 -228
- data/ProjectTox-Core/testing/DHT_sendfiletest.c +0 -176
- data/ProjectTox-Core/testing/Lossless_UDP_testclient.c +0 -214
- data/ProjectTox-Core/testing/Lossless_UDP_testserver.c +0 -201
- data/ProjectTox-Core/testing/misc_tools.h +0 -29
- data/ProjectTox-Core/testing/nTox_win32.c +0 -387
- data/ProjectTox-Core/testing/nTox_win32.h +0 -40
- data/ProjectTox-Core/testing/rect.py +0 -45
@@ -0,0 +1,734 @@
|
|
1
|
+
/* tox.h
|
2
|
+
*
|
3
|
+
* The Tox public API.
|
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 TOX_H
|
25
|
+
#define TOX_H
|
26
|
+
|
27
|
+
#include <stdint.h>
|
28
|
+
|
29
|
+
|
30
|
+
#ifdef __cplusplus
|
31
|
+
extern "C" {
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#define TOX_MAX_NAME_LENGTH 128
|
35
|
+
|
36
|
+
/* Maximum length of single messages after which they should be split. */
|
37
|
+
#define TOX_MAX_MESSAGE_LENGTH 1368
|
38
|
+
#define TOX_MAX_STATUSMESSAGE_LENGTH 1007
|
39
|
+
#define TOX_CLIENT_ID_SIZE 32
|
40
|
+
|
41
|
+
#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
|
42
|
+
|
43
|
+
#define TOX_ENABLE_IPV6_DEFAULT 1
|
44
|
+
|
45
|
+
#define TOX_ENC_SAVE_MAGIC_NUMBER "toxEsave"
|
46
|
+
#define TOX_ENC_SAVE_MAGIC_LENGTH 8
|
47
|
+
|
48
|
+
/* Errors for m_addfriend
|
49
|
+
* FAERR - Friend Add Error
|
50
|
+
*/
|
51
|
+
enum {
|
52
|
+
TOX_FAERR_TOOLONG = -1,
|
53
|
+
TOX_FAERR_NOMESSAGE = -2,
|
54
|
+
TOX_FAERR_OWNKEY = -3,
|
55
|
+
TOX_FAERR_ALREADYSENT = -4,
|
56
|
+
TOX_FAERR_UNKNOWN = -5,
|
57
|
+
TOX_FAERR_BADCHECKSUM = -6,
|
58
|
+
TOX_FAERR_SETNEWNOSPAM = -7,
|
59
|
+
TOX_FAERR_NOMEM = -8
|
60
|
+
};
|
61
|
+
|
62
|
+
/* USERSTATUS -
|
63
|
+
* Represents userstatuses someone can have.
|
64
|
+
*/
|
65
|
+
typedef enum {
|
66
|
+
TOX_USERSTATUS_NONE,
|
67
|
+
TOX_USERSTATUS_AWAY,
|
68
|
+
TOX_USERSTATUS_BUSY,
|
69
|
+
TOX_USERSTATUS_INVALID
|
70
|
+
}
|
71
|
+
TOX_USERSTATUS;
|
72
|
+
|
73
|
+
#ifndef __TOX_DEFINED__
|
74
|
+
#define __TOX_DEFINED__
|
75
|
+
typedef struct Tox Tox;
|
76
|
+
#endif
|
77
|
+
|
78
|
+
/* NOTE: Strings in Tox are all UTF-8, (This means that there is no terminating NULL character.)
|
79
|
+
*
|
80
|
+
* The exact buffer you send will be received at the other end without modification.
|
81
|
+
*
|
82
|
+
* Do not treat Tox strings as C strings.
|
83
|
+
*/
|
84
|
+
|
85
|
+
/* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others.
|
86
|
+
* format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]
|
87
|
+
*/
|
88
|
+
void tox_get_address(const Tox *tox, uint8_t *address);
|
89
|
+
|
90
|
+
/* Add a friend.
|
91
|
+
* Set the data that will be sent along with friend request.
|
92
|
+
* address is the address of the friend (returned by getaddress of the friend you wish to add) it must be TOX_FRIEND_ADDRESS_SIZE bytes. TODO: add checksum.
|
93
|
+
* data is the data and length is the length.
|
94
|
+
*
|
95
|
+
* return the friend number if success.
|
96
|
+
* return TOX_FAERR_TOOLONG if message length is too long.
|
97
|
+
* return TOX_FAERR_NOMESSAGE if no message (message length must be >= 1 byte).
|
98
|
+
* return TOX_FAERR_OWNKEY if user's own key.
|
99
|
+
* return TOX_FAERR_ALREADYSENT if friend request already sent or already a friend.
|
100
|
+
* return TOX_FAERR_UNKNOWN for unknown error.
|
101
|
+
* return TOX_FAERR_BADCHECKSUM if bad checksum in address.
|
102
|
+
* return TOX_FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different.
|
103
|
+
* (the nospam for that friend was set to the new one).
|
104
|
+
* return TOX_FAERR_NOMEM if increasing the friend list size fails.
|
105
|
+
*/
|
106
|
+
int32_t tox_add_friend(Tox *tox, const uint8_t *address, const uint8_t *data, uint16_t length);
|
107
|
+
|
108
|
+
|
109
|
+
/* Add a friend without sending a friendrequest.
|
110
|
+
* return the friend number if success.
|
111
|
+
* return -1 if failure.
|
112
|
+
*/
|
113
|
+
int32_t tox_add_friend_norequest(Tox *tox, const uint8_t *client_id);
|
114
|
+
|
115
|
+
/* return the friend number associated to that client id.
|
116
|
+
return -1 if no such friend */
|
117
|
+
int32_t tox_get_friend_number(const Tox *tox, const uint8_t *client_id);
|
118
|
+
|
119
|
+
/* Copies the public key associated to that friend id into client_id buffer.
|
120
|
+
* Make sure that client_id is of size CLIENT_ID_SIZE.
|
121
|
+
* return 0 if success.
|
122
|
+
* return -1 if failure.
|
123
|
+
*/
|
124
|
+
int tox_get_client_id(const Tox *tox, int32_t friendnumber, uint8_t *client_id);
|
125
|
+
|
126
|
+
/* Remove a friend.
|
127
|
+
*
|
128
|
+
* return 0 if success.
|
129
|
+
* return -1 if failure.
|
130
|
+
*/
|
131
|
+
int tox_del_friend(Tox *tox, int32_t friendnumber);
|
132
|
+
|
133
|
+
/* Checks friend's connecting status.
|
134
|
+
*
|
135
|
+
* return 1 if friend is connected to us (Online).
|
136
|
+
* return 0 if friend is not connected to us (Offline).
|
137
|
+
* return -1 on failure.
|
138
|
+
*/
|
139
|
+
int tox_get_friend_connection_status(const Tox *tox, int32_t friendnumber);
|
140
|
+
|
141
|
+
/* Checks if there exists a friend with given friendnumber.
|
142
|
+
*
|
143
|
+
* return 1 if friend exists.
|
144
|
+
* return 0 if friend doesn't exist.
|
145
|
+
*/
|
146
|
+
int tox_friend_exists(const Tox *tox, int32_t friendnumber);
|
147
|
+
|
148
|
+
/* Send a text chat message to an online friend.
|
149
|
+
*
|
150
|
+
* return the message id if packet was successfully put into the send queue.
|
151
|
+
* return 0 if it was not.
|
152
|
+
*
|
153
|
+
* maximum length of messages is TOX_MAX_MESSAGE_LENGTH, your client must split larger messages
|
154
|
+
* or else sending them will not work. No the core will not split messages for you because that
|
155
|
+
* requires me to parse UTF-8.
|
156
|
+
*
|
157
|
+
* You will want to retain the return value, it will be passed to your read_receipt callback
|
158
|
+
* if one is received.
|
159
|
+
*/
|
160
|
+
uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length);
|
161
|
+
|
162
|
+
/* Send an action to an online friend.
|
163
|
+
*
|
164
|
+
* return the message id if packet was successfully put into the send queue.
|
165
|
+
* return 0 if it was not.
|
166
|
+
*
|
167
|
+
* maximum length of actions is TOX_MAX_MESSAGE_LENGTH, your client must split larger actions
|
168
|
+
* or else sending them will not work. No the core will not split actions for you because that
|
169
|
+
* requires me to parse UTF-8.
|
170
|
+
*
|
171
|
+
* You will want to retain the return value, it will be passed to your read_receipt callback
|
172
|
+
* if one is received.
|
173
|
+
*/
|
174
|
+
uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length);
|
175
|
+
|
176
|
+
/* Set our nickname.
|
177
|
+
* name must be a string of maximum MAX_NAME_LENGTH length.
|
178
|
+
* length must be at least 1 byte.
|
179
|
+
* length is the length of name.
|
180
|
+
*
|
181
|
+
* return 0 if success.
|
182
|
+
* return -1 if failure.
|
183
|
+
*/
|
184
|
+
int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length);
|
185
|
+
|
186
|
+
/*
|
187
|
+
* Get your nickname.
|
188
|
+
* m - The messenger context to use.
|
189
|
+
* name - needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
190
|
+
*
|
191
|
+
* return length of name.
|
192
|
+
* return 0 on error.
|
193
|
+
*/
|
194
|
+
uint16_t tox_get_self_name(const Tox *tox, uint8_t *name);
|
195
|
+
|
196
|
+
/* Get name of friendnumber and put it in name.
|
197
|
+
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
198
|
+
*
|
199
|
+
* return length of name if success.
|
200
|
+
* return -1 if failure.
|
201
|
+
*/
|
202
|
+
int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name);
|
203
|
+
|
204
|
+
/* returns the length of name on success.
|
205
|
+
* returns -1 on failure.
|
206
|
+
*/
|
207
|
+
int tox_get_name_size(const Tox *tox, int32_t friendnumber);
|
208
|
+
int tox_get_self_name_size(const Tox *tox);
|
209
|
+
|
210
|
+
/* Set our user status.
|
211
|
+
*
|
212
|
+
* userstatus must be one of TOX_USERSTATUS values.
|
213
|
+
* max length of the status is TOX_MAX_STATUSMESSAGE_LENGTH.
|
214
|
+
*
|
215
|
+
* returns 0 on success.
|
216
|
+
* returns -1 on failure.
|
217
|
+
*/
|
218
|
+
int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length);
|
219
|
+
int tox_set_user_status(Tox *tox, uint8_t userstatus);
|
220
|
+
|
221
|
+
/* returns the length of status message on success.
|
222
|
+
* returns -1 on failure.
|
223
|
+
*/
|
224
|
+
int tox_get_status_message_size(const Tox *tox, int32_t friendnumber);
|
225
|
+
int tox_get_self_status_message_size(const Tox *tox);
|
226
|
+
|
227
|
+
/* Copy friendnumber's status message into buf, truncating if size is over maxlen.
|
228
|
+
* Get the size you need to allocate from m_get_statusmessage_size.
|
229
|
+
* The self variant will copy our own status message.
|
230
|
+
*
|
231
|
+
* returns the length of the copied data on success
|
232
|
+
* retruns -1 on failure.
|
233
|
+
*/
|
234
|
+
int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
|
235
|
+
int tox_get_self_status_message(const Tox *tox, uint8_t *buf, uint32_t maxlen);
|
236
|
+
|
237
|
+
/* return one of TOX_USERSTATUS values.
|
238
|
+
* Values unknown to your application should be represented as TOX_USERSTATUS_NONE.
|
239
|
+
* As above, the self variant will return our own TOX_USERSTATUS.
|
240
|
+
* If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID.
|
241
|
+
*/
|
242
|
+
uint8_t tox_get_user_status(const Tox *tox, int32_t friendnumber);
|
243
|
+
uint8_t tox_get_self_user_status(const Tox *tox);
|
244
|
+
|
245
|
+
|
246
|
+
/* returns timestamp of last time friendnumber was seen online, or 0 if never seen.
|
247
|
+
* returns -1 on error.
|
248
|
+
*/
|
249
|
+
uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber);
|
250
|
+
|
251
|
+
/* Set our typing status for a friend.
|
252
|
+
* You are responsible for turning it on or off.
|
253
|
+
*
|
254
|
+
* returns 0 on success.
|
255
|
+
* returns -1 on failure.
|
256
|
+
*/
|
257
|
+
int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing);
|
258
|
+
|
259
|
+
/* Get the typing status of a friend.
|
260
|
+
*
|
261
|
+
* returns 0 if friend is not typing.
|
262
|
+
* returns 1 if friend is typing.
|
263
|
+
*/
|
264
|
+
uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber);
|
265
|
+
|
266
|
+
/* Return the number of friends in the instance m.
|
267
|
+
* You should use this to determine how much memory to allocate
|
268
|
+
* for copy_friendlist. */
|
269
|
+
uint32_t tox_count_friendlist(const Tox *tox);
|
270
|
+
|
271
|
+
/* Return the number of online friends in the instance m. */
|
272
|
+
uint32_t tox_get_num_online_friends(const Tox *tox);
|
273
|
+
|
274
|
+
/* Copy a list of valid friend IDs into the array out_list.
|
275
|
+
* If out_list is NULL, returns 0.
|
276
|
+
* Otherwise, returns the number of elements copied.
|
277
|
+
* If the array was too small, the contents
|
278
|
+
* of out_list will be truncated to list_size. */
|
279
|
+
uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size);
|
280
|
+
|
281
|
+
/* Set the function that will be executed when a friend request is received.
|
282
|
+
* Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata)
|
283
|
+
*/
|
284
|
+
void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint8_t *, const uint8_t *, uint16_t,
|
285
|
+
void *), void *userdata);
|
286
|
+
|
287
|
+
/* Set the function that will be executed when a message from a friend is received.
|
288
|
+
* Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint16_t length, void *userdata)
|
289
|
+
*/
|
290
|
+
void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
|
291
|
+
void *userdata);
|
292
|
+
|
293
|
+
/* Set the function that will be executed when an action from a friend is received.
|
294
|
+
* Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * action, uint16_t length, void *userdata)
|
295
|
+
*/
|
296
|
+
void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
|
297
|
+
void *userdata);
|
298
|
+
|
299
|
+
/* Set the callback for name changes.
|
300
|
+
* function(Tox *tox, int32_t friendnumber, uint8_t *newname, uint16_t length, void *userdata)
|
301
|
+
* You are not responsible for freeing newname
|
302
|
+
*/
|
303
|
+
void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
|
304
|
+
void *userdata);
|
305
|
+
|
306
|
+
/* Set the callback for status message changes.
|
307
|
+
* function(Tox *tox, int32_t friendnumber, uint8_t *newstatus, uint16_t length, void *userdata)
|
308
|
+
* You are not responsible for freeing newstatus.
|
309
|
+
*/
|
310
|
+
void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
|
311
|
+
void *userdata);
|
312
|
+
|
313
|
+
/* Set the callback for status type changes.
|
314
|
+
* function(Tox *tox, int32_t friendnumber, uint8_t TOX_USERSTATUS, void *userdata)
|
315
|
+
*/
|
316
|
+
void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata);
|
317
|
+
|
318
|
+
/* Set the callback for typing changes.
|
319
|
+
* function (Tox *tox, int32_t friendnumber, uint8_t is_typing, void *userdata)
|
320
|
+
*/
|
321
|
+
void tox_callback_typing_change(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata);
|
322
|
+
|
323
|
+
/* Set the callback for read receipts.
|
324
|
+
* function(Tox *tox, int32_t friendnumber, uint32_t receipt, void *userdata)
|
325
|
+
*
|
326
|
+
* If you are keeping a record of returns from m_sendmessage;
|
327
|
+
* receipt might be one of those values, meaning the message
|
328
|
+
* has been received on the other side.
|
329
|
+
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
330
|
+
* In that case, you should discard it.
|
331
|
+
*/
|
332
|
+
void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int32_t, uint32_t, void *), void *userdata);
|
333
|
+
|
334
|
+
/* Set the callback for connection status changes.
|
335
|
+
* function(Tox *tox, int32_t friendnumber, uint8_t status, void *userdata)
|
336
|
+
*
|
337
|
+
* Status:
|
338
|
+
* 0 -- friend went offline after being previously online
|
339
|
+
* 1 -- friend went online
|
340
|
+
*
|
341
|
+
* NOTE: This callback is not called when adding friends, thus the "after
|
342
|
+
* being previously online" part. it's assumed that when adding friends,
|
343
|
+
* their connection status is offline.
|
344
|
+
*/
|
345
|
+
void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata);
|
346
|
+
|
347
|
+
|
348
|
+
/**********ADVANCED FUNCTIONS (If you don't know what they do you can safely ignore them.) ************/
|
349
|
+
|
350
|
+
/* Functions to get/set the nospam part of the id.
|
351
|
+
*/
|
352
|
+
uint32_t tox_get_nospam(const Tox *tox);
|
353
|
+
void tox_set_nospam(Tox *tox, uint32_t nospam);
|
354
|
+
|
355
|
+
/* Copy the public and secret key from the Tox object.
|
356
|
+
public_key and secret_key must be 32 bytes big.
|
357
|
+
if the pointer is NULL, no data will be copied to it.*/
|
358
|
+
void tox_get_keys(Tox *tox, uint8_t *public_key, uint8_t *secret_key);
|
359
|
+
|
360
|
+
/* Maximum size of custom packets. */
|
361
|
+
#define TOX_MAX_CUSTOM_PACKET_SIZE 1373
|
362
|
+
|
363
|
+
/* Set handlers for custom lossy packets.
|
364
|
+
* Set the function to be called when friend sends us a lossy packet starting with byte.
|
365
|
+
* byte must be in the 200-254 range.
|
366
|
+
*
|
367
|
+
* NOTE: lossy packets behave like UDP packets meaning they might never reach the other side
|
368
|
+
* or might arrive more than once (if someone is messing with the connection) or might arrive
|
369
|
+
* in the wrong order.
|
370
|
+
*
|
371
|
+
* Unless latency is an issue, it is recommended that you use lossless packets instead.
|
372
|
+
*
|
373
|
+
* return -1 on failure.
|
374
|
+
* return 0 on success.
|
375
|
+
*/
|
376
|
+
int tox_lossy_packet_registerhandler(Tox *tox, int32_t friendnumber, uint8_t byte,
|
377
|
+
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
|
378
|
+
|
379
|
+
/* Function to send custom lossy packets.
|
380
|
+
* First byte of data must be in the range: 200-254.
|
381
|
+
*
|
382
|
+
* return -1 on failure.
|
383
|
+
* return 0 on success.
|
384
|
+
*/
|
385
|
+
int tox_send_lossy_packet(const Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t length);
|
386
|
+
|
387
|
+
/* Set handlers for custom lossless packets.
|
388
|
+
* Set the function to be called when friend sends us a lossless packet starting with byte.
|
389
|
+
* byte must be in the 160-191 range.
|
390
|
+
*
|
391
|
+
* Lossless packets behave kind of like TCP (reliability, arrive in order.) but with packets instead of a stream.
|
392
|
+
*
|
393
|
+
* return -1 on failure.
|
394
|
+
* return 0 on success.
|
395
|
+
*/
|
396
|
+
int tox_lossless_packet_registerhandler(Tox *tox, int32_t friendnumber, uint8_t byte,
|
397
|
+
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
|
398
|
+
|
399
|
+
/* Function to send custom lossless packets.
|
400
|
+
* First byte of data must be in the range: 160-191.
|
401
|
+
*
|
402
|
+
* return -1 on failure.
|
403
|
+
* return 0 on success.
|
404
|
+
*/
|
405
|
+
int tox_send_lossless_packet(const Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t length);
|
406
|
+
|
407
|
+
/**********GROUP CHAT FUNCTIONS: WARNING Group chats will be rewritten so this might change ************/
|
408
|
+
|
409
|
+
/* Set the callback for group invites.
|
410
|
+
*
|
411
|
+
* Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata)
|
412
|
+
*/
|
413
|
+
void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, void *), void *userdata);
|
414
|
+
|
415
|
+
/* Set the callback for group messages.
|
416
|
+
*
|
417
|
+
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
|
418
|
+
*/
|
419
|
+
void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *),
|
420
|
+
void *userdata);
|
421
|
+
|
422
|
+
/* Set the callback for group actions.
|
423
|
+
*
|
424
|
+
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * action, uint16_t length, void *userdata)
|
425
|
+
*/
|
426
|
+
void tox_callback_group_action(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *),
|
427
|
+
void *userdata);
|
428
|
+
|
429
|
+
/* Set callback function for peer name list changes.
|
430
|
+
*
|
431
|
+
* It gets called every time the name list changes(new peer/name, deleted peer)
|
432
|
+
* Function(Tox *tox, int groupnumber, int peernumber, TOX_CHAT_CHANGE change, void *userdata)
|
433
|
+
*/
|
434
|
+
typedef enum {
|
435
|
+
TOX_CHAT_CHANGE_PEER_ADD,
|
436
|
+
TOX_CHAT_CHANGE_PEER_DEL,
|
437
|
+
TOX_CHAT_CHANGE_PEER_NAME,
|
438
|
+
} TOX_CHAT_CHANGE;
|
439
|
+
|
440
|
+
void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *),
|
441
|
+
void *userdata);
|
442
|
+
|
443
|
+
/* Creates a new groupchat and puts it in the chats array.
|
444
|
+
*
|
445
|
+
* return group number on success.
|
446
|
+
* return -1 on failure.
|
447
|
+
*/
|
448
|
+
int tox_add_groupchat(Tox *tox);
|
449
|
+
|
450
|
+
/* Delete a groupchat from the chats array.
|
451
|
+
*
|
452
|
+
* return 0 on success.
|
453
|
+
* return -1 if failure.
|
454
|
+
*/
|
455
|
+
int tox_del_groupchat(Tox *tox, int groupnumber);
|
456
|
+
|
457
|
+
/* Copy the name of peernumber who is in groupnumber to name.
|
458
|
+
* name must be at least TOX_MAX_NAME_LENGTH long.
|
459
|
+
*
|
460
|
+
* return length of name if success
|
461
|
+
* return -1 if failure
|
462
|
+
*/
|
463
|
+
int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name);
|
464
|
+
|
465
|
+
/* invite friendnumber to groupnumber
|
466
|
+
* return 0 on success
|
467
|
+
* return -1 on failure
|
468
|
+
*/
|
469
|
+
int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber);
|
470
|
+
|
471
|
+
/* Join a group (you need to have been invited first.)
|
472
|
+
*
|
473
|
+
* returns group number on success
|
474
|
+
* returns -1 on failure.
|
475
|
+
*/
|
476
|
+
int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *friend_group_public_key);
|
477
|
+
|
478
|
+
/* send a group message
|
479
|
+
* return 0 on success
|
480
|
+
* return -1 on failure
|
481
|
+
*/
|
482
|
+
int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint32_t length);
|
483
|
+
|
484
|
+
/* send a group action
|
485
|
+
* return 0 on success
|
486
|
+
* return -1 on failure
|
487
|
+
*/
|
488
|
+
int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint32_t length);
|
489
|
+
|
490
|
+
/* Return the number of peers in the group chat on success.
|
491
|
+
* return -1 on failure
|
492
|
+
*/
|
493
|
+
int tox_group_number_peers(const Tox *tox, int groupnumber);
|
494
|
+
|
495
|
+
/* List all the peers in the group chat.
|
496
|
+
*
|
497
|
+
* Copies the names of the peers to the name[length][TOX_MAX_NAME_LENGTH] array.
|
498
|
+
*
|
499
|
+
* Copies the lengths of the names to lengths[length]
|
500
|
+
*
|
501
|
+
* returns the number of peers on success.
|
502
|
+
*
|
503
|
+
* return -1 on failure.
|
504
|
+
*/
|
505
|
+
int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[],
|
506
|
+
uint16_t length);
|
507
|
+
|
508
|
+
/* Return the number of chats in the instance m.
|
509
|
+
* You should use this to determine how much memory to allocate
|
510
|
+
* for copy_chatlist. */
|
511
|
+
uint32_t tox_count_chatlist(const Tox *tox);
|
512
|
+
|
513
|
+
/* Copy a list of valid chat IDs into the array out_list.
|
514
|
+
* If out_list is NULL, returns 0.
|
515
|
+
* Otherwise, returns the number of elements copied.
|
516
|
+
* If the array was too small, the contents
|
517
|
+
* of out_list will be truncated to list_size. */
|
518
|
+
uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size);
|
519
|
+
|
520
|
+
|
521
|
+
/****************FILE SENDING FUNCTIONS*****************/
|
522
|
+
/* NOTE: This how to will be updated.
|
523
|
+
*
|
524
|
+
* HOW TO SEND FILES CORRECTLY:
|
525
|
+
* 1. Use tox_new_file_sender(...) to create a new file sender.
|
526
|
+
* 2. Wait for the callback set with tox_callback_file_control(...) to be called with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT
|
527
|
+
* 3. Send the data with tox_file_send_data(...) with chunk size tox_file_data_size(...)
|
528
|
+
* 4. When sending is done, send a tox_file_send_control(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED
|
529
|
+
* 5. when the callback set with tox_callback_file_control(...) is called with receive_send == 1 and control_type == TOX_FILECONTROL_FINISHED
|
530
|
+
* the other person has received the file correctly.
|
531
|
+
*
|
532
|
+
* HOW TO RECEIVE FILES CORRECTLY:
|
533
|
+
* 1. wait for the callback set with tox_callback_file_send_request(...)
|
534
|
+
* 2. accept or refuse the connection with tox_file_send_control(...) with send_receive = 1 and message_id = TOX_FILECONTROL_ACCEPT or TOX_FILECONTROL_KILL
|
535
|
+
* 3. save all the data received with the callback set with tox_callback_file_data(...) to a file.
|
536
|
+
* 4. when the callback set with tox_callback_file_control(...) is called with receive_send == 0 and control_type == TOX_FILECONTROL_FINISHED
|
537
|
+
* the file is done transferring.
|
538
|
+
* 5. send a tox_file_send_control(...) with send_receive = 1 and message_id = TOX_FILECONTROL_FINISHED to confirm that we did receive the file.
|
539
|
+
*
|
540
|
+
* tox_file_data_remaining(...) can be used to know how many bytes are left to send/receive.
|
541
|
+
*
|
542
|
+
* If the connection breaks during file sending (The other person goes offline without pausing the sending and then comes back)
|
543
|
+
* the receiver must send a control packet with send_receive == 1 message_id = TOX_FILECONTROL_RESUME_BROKEN and the data being
|
544
|
+
* a uint64_t (in host byte order) containing the number of bytes received.
|
545
|
+
*
|
546
|
+
* If the sender receives this packet, he must send a control packet with send_receive == 0 and control_type == TOX_FILECONTROL_ACCEPT
|
547
|
+
* then he must start sending file data from the position (data , uint64_t in host byte order) received in the TOX_FILECONTROL_RESUME_BROKEN packet.
|
548
|
+
*
|
549
|
+
* To pause a file transfer send a control packet with control_type == TOX_FILECONTROL_PAUSE.
|
550
|
+
* To unpause a file transfer send a control packet with control_type == TOX_FILECONTROL_ACCEPT.
|
551
|
+
*
|
552
|
+
* If you receive a control packet with receive_send == 1 and control_type == TOX_FILECONTROL_PAUSE, you must stop sending filenumber until the other
|
553
|
+
* person sends a control packet with send_receive == 0 and control_type == TOX_FILECONTROL_ACCEPT with the filenumber being a paused filenumber.
|
554
|
+
*
|
555
|
+
* If you receive a control packet with receive_send == 0 and control_type == TOX_FILECONTROL_PAUSE, it means the sender of filenumber has paused the
|
556
|
+
* transfer and will resume it later with a control packet with send_receive == 1 and control_type == TOX_FILECONTROL_ACCEPT for that file number.
|
557
|
+
*
|
558
|
+
* More to come...
|
559
|
+
*/
|
560
|
+
|
561
|
+
enum {
|
562
|
+
TOX_FILECONTROL_ACCEPT,
|
563
|
+
TOX_FILECONTROL_PAUSE,
|
564
|
+
TOX_FILECONTROL_KILL,
|
565
|
+
TOX_FILECONTROL_FINISHED,
|
566
|
+
TOX_FILECONTROL_RESUME_BROKEN
|
567
|
+
};
|
568
|
+
/* Set the callback for file send requests.
|
569
|
+
*
|
570
|
+
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
571
|
+
*/
|
572
|
+
void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, const uint8_t *,
|
573
|
+
uint16_t, void *), void *userdata);
|
574
|
+
|
575
|
+
/* Set the callback for file control requests.
|
576
|
+
*
|
577
|
+
* receive_send is 1 if the message is for a slot on which we are currently sending a file and 0 if the message
|
578
|
+
* is for a slot on which we are receiving the file
|
579
|
+
*
|
580
|
+
* Function(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
|
581
|
+
*
|
582
|
+
*/
|
583
|
+
void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *,
|
584
|
+
uint16_t, void *), void *userdata);
|
585
|
+
|
586
|
+
/* Set the callback for file data.
|
587
|
+
*
|
588
|
+
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
589
|
+
*
|
590
|
+
*/
|
591
|
+
void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, const uint8_t *, uint16_t length,
|
592
|
+
void *), void *userdata);
|
593
|
+
|
594
|
+
|
595
|
+
/* Send a file send request.
|
596
|
+
* Maximum filename length is 255 bytes.
|
597
|
+
* return file number on success
|
598
|
+
* return -1 on failure
|
599
|
+
*/
|
600
|
+
int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, const uint8_t *filename,
|
601
|
+
uint16_t filename_length);
|
602
|
+
|
603
|
+
/* Send a file control request.
|
604
|
+
*
|
605
|
+
* send_receive is 0 if we want the control packet to target a file we are currently sending,
|
606
|
+
* 1 if it targets a file we are currently receiving.
|
607
|
+
*
|
608
|
+
* return 0 on success
|
609
|
+
* return -1 on failure
|
610
|
+
*/
|
611
|
+
int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
612
|
+
const uint8_t *data, uint16_t length);
|
613
|
+
|
614
|
+
/* Send file data.
|
615
|
+
*
|
616
|
+
* return 0 on success
|
617
|
+
* return -1 on failure
|
618
|
+
*/
|
619
|
+
int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length);
|
620
|
+
|
621
|
+
/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data()
|
622
|
+
*
|
623
|
+
* return size on success
|
624
|
+
* return -1 on failure (currently will never return -1)
|
625
|
+
*/
|
626
|
+
int tox_file_data_size(const Tox *tox, int32_t friendnumber);
|
627
|
+
|
628
|
+
/* Give the number of bytes left to be sent/received.
|
629
|
+
*
|
630
|
+
* send_receive is 0 if we want the sending files, 1 if we want the receiving.
|
631
|
+
*
|
632
|
+
* return number of bytes remaining to be sent/received on success
|
633
|
+
* return 0 on failure
|
634
|
+
*/
|
635
|
+
uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
|
636
|
+
|
637
|
+
/***************END OF FILE SENDING FUNCTIONS******************/
|
638
|
+
|
639
|
+
/*
|
640
|
+
* Use this function to bootstrap the client.
|
641
|
+
*/
|
642
|
+
|
643
|
+
/* Resolves address into an IP address. If successful, sends a "get nodes"
|
644
|
+
* request to the given node with ip, port (in host byte order).
|
645
|
+
* and public_key to setup connections
|
646
|
+
*
|
647
|
+
* address can be a hostname or an IP address (IPv4 or IPv6).
|
648
|
+
*
|
649
|
+
* returns 1 if the address could be converted into an IP address
|
650
|
+
* returns 0 otherwise
|
651
|
+
*/
|
652
|
+
int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);
|
653
|
+
|
654
|
+
/* Like tox_bootstrap_from_address but for TCP relays only.
|
655
|
+
*
|
656
|
+
* return 0 on failure.
|
657
|
+
* return 1 on success.
|
658
|
+
*/
|
659
|
+
int tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);
|
660
|
+
|
661
|
+
/* return 0 if we are not connected to the DHT.
|
662
|
+
* return 1 if we are.
|
663
|
+
*/
|
664
|
+
int tox_isconnected(const Tox *tox);
|
665
|
+
|
666
|
+
typedef struct {
|
667
|
+
/*
|
668
|
+
* The type of UDP socket created depends on ipv6enabled:
|
669
|
+
* If set to 0 (zero), creates an IPv4 socket which subsequently only allows
|
670
|
+
* IPv4 communication
|
671
|
+
* If set to anything else (default), creates an IPv6 socket which allows both IPv4 AND
|
672
|
+
* IPv6 communication
|
673
|
+
*/
|
674
|
+
uint8_t ipv6enabled;
|
675
|
+
|
676
|
+
/* Set to 1 to disable udp support. (default: 0)
|
677
|
+
This will force Tox to use TCP only which may slow things down.
|
678
|
+
Disabling udp support is necessary when using anonymous proxies or Tor.*/
|
679
|
+
uint8_t udp_disabled;
|
680
|
+
|
681
|
+
/* Enable proxy support. (only basic TCP socks5 proxy currently supported.) (default: 0 (disabled))*/
|
682
|
+
uint8_t proxy_enabled;
|
683
|
+
char proxy_address[256]; /* Proxy ip or domain in NULL terminated string format. */
|
684
|
+
uint16_t proxy_port; /* Proxy port: in host byte order. */
|
685
|
+
} Tox_Options;
|
686
|
+
|
687
|
+
/*
|
688
|
+
* Run this function at startup.
|
689
|
+
*
|
690
|
+
* Options are some options that can be passed to the Tox instance (see above struct).
|
691
|
+
*
|
692
|
+
* If options is NULL, tox_new() will use default settings.
|
693
|
+
*
|
694
|
+
* Initializes a tox structure
|
695
|
+
* return allocated instance of tox on success.
|
696
|
+
* return NULL on failure.
|
697
|
+
*/
|
698
|
+
Tox *tox_new(Tox_Options *options);
|
699
|
+
|
700
|
+
/* Run this before closing shop.
|
701
|
+
* Free all datastructures. */
|
702
|
+
void tox_kill(Tox *tox);
|
703
|
+
|
704
|
+
/* Return the time in milliseconds before tox_do() should be called again
|
705
|
+
* for optimal performance.
|
706
|
+
*
|
707
|
+
* returns time (in ms) before the next tox_do() needs to be run on success.
|
708
|
+
*/
|
709
|
+
uint32_t tox_do_interval(Tox *tox);
|
710
|
+
|
711
|
+
/* The main loop that needs to be run in intervals of tox_do_interval() ms. */
|
712
|
+
void tox_do(Tox *tox);
|
713
|
+
|
714
|
+
/* SAVING AND LOADING FUNCTIONS: */
|
715
|
+
|
716
|
+
/* return size of messenger data (for saving). */
|
717
|
+
uint32_t tox_size(const Tox *tox);
|
718
|
+
|
719
|
+
/* Save the messenger in data (must be allocated memory of size Messenger_size()). */
|
720
|
+
void tox_save(const Tox *tox, uint8_t *data);
|
721
|
+
|
722
|
+
/* Load the messenger from data of size length.
|
723
|
+
*
|
724
|
+
* returns 0 on success
|
725
|
+
* returns -1 on failure
|
726
|
+
* returns +1 on finding encrypted save data
|
727
|
+
*/
|
728
|
+
int tox_load(Tox *tox, const uint8_t *data, uint32_t length);
|
729
|
+
|
730
|
+
#ifdef __cplusplus
|
731
|
+
}
|
732
|
+
#endif
|
733
|
+
|
734
|
+
#endif
|