summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-13 19:10:22 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-13 19:30:02 +0000
commit90a63e8188aabde41beb60152b04d2cd4576c2ac (patch)
tree7598acc5d612f29c5463483ed77bcc4cdd3bc42e /toxcore/tox.h
parent3d5fd9c2d0114e7d4bbb389e11216c425adaa216 (diff)
Add conference_by_uid and conference_get_uid functions.
These are useful once we have persistent group chats, so clients can store data associated with this permanent group identifier.
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h73
1 files changed, 62 insertions, 11 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index a5e79d63..6a4df16d 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -41,7 +41,8 @@ extern "C" {
41 41
42 42
43 43
44/** \page core Public core API for Tox clients. 44/**
45 * @page core Public core API for Tox clients.
45 * 46 *
46 * Every function that can fail takes a function-specific error code pointer 47 * Every function that can fail takes a function-specific error code pointer
47 * that can be used to diagnose problems with the Tox state or the function 48 * that can be used to diagnose problems with the Tox state or the function
@@ -79,7 +80,8 @@ extern "C" {
79 * Integer constants and the memory layout of publicly exposed structs are not 80 * Integer constants and the memory layout of publicly exposed structs are not
80 * part of the ABI. 81 * part of the ABI.
81 */ 82 */
82/** \subsection events Events and callbacks 83/**
84 * @subsection events Events and callbacks
83 * 85 *
84 * Events are handled by callbacks. One callback can be registered per event. 86 * Events are handled by callbacks. One callback can be registered per event.
85 * All events have a callback function type named `tox_{event}_cb` and a 87 * All events have a callback function type named `tox_{event}_cb` and a
@@ -101,7 +103,8 @@ extern "C" {
101 * receive that pointer as argument when they are called. They can each have 103 * receive that pointer as argument when they are called. They can each have
102 * their own user data pointer of their own type. 104 * their own user data pointer of their own type.
103 */ 105 */
104/** \subsection threading Threading implications 106/**
107 * @subsection threading Threading implications
105 * 108 *
106 * It is possible to run multiple concurrent threads with a Tox instance for 109 * It is possible to run multiple concurrent threads with a Tox instance for
107 * each thread. It is also possible to run all Tox instances in the same thread. 110 * each thread. It is also possible to run all Tox instances in the same thread.
@@ -123,12 +126,12 @@ extern "C" {
123 * 126 *
124 * E.g. to get the current nickname, one would write 127 * E.g. to get the current nickname, one would write
125 * 128 *
126 * \code 129 * @code
127 * size_t length = tox_self_get_name_size(tox); 130 * size_t length = tox_self_get_name_size(tox);
128 * uint8_t *name = malloc(length); 131 * uint8_t *name = malloc(length);
129 * if (!name) abort(); 132 * if (!name) abort();
130 * tox_self_get_name(tox, name); 133 * tox_self_get_name(tox, name);
131 * \endcode 134 * @endcode
132 * 135 *
133 * If any other thread calls tox_self_set_name while this thread is allocating 136 * If any other thread calls tox_self_set_name while this thread is allocating
134 * memory, the length may have become invalid, and the call to 137 * memory, the length may have become invalid, and the call to
@@ -246,6 +249,13 @@ uint32_t tox_public_key_size(void);
246uint32_t tox_secret_key_size(void); 249uint32_t tox_secret_key_size(void);
247 250
248/** 251/**
252 * The size of a Tox Conference unique id in bytes.
253 */
254#define TOX_CONFERENCE_UID_SIZE 32
255
256uint32_t tox_conference_uid_size(void);
257
258/**
249 * The size of the nospam in bytes when written in a Tox address. 259 * The size of the nospam in bytes when written in a Tox address.
250 */ 260 */
251#define TOX_NOSPAM_SIZE (sizeof(uint32_t)) 261#define TOX_NOSPAM_SIZE (sizeof(uint32_t))
@@ -1269,7 +1279,7 @@ typedef enum TOX_ERR_FRIEND_ADD {
1269 * @param message The message that will be sent along with the friend request. 1279 * @param message The message that will be sent along with the friend request.
1270 * @param length The length of the data byte array. 1280 * @param length The length of the data byte array.
1271 * 1281 *
1272 * @return the friend number on success, UINT32_MAX on failure. 1282 * @return the friend number on success, an unspecified value on failure.
1273 */ 1283 */
1274uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length, 1284uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length,
1275 TOX_ERR_FRIEND_ADD *error); 1285 TOX_ERR_FRIEND_ADD *error);
@@ -1289,7 +1299,7 @@ uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message
1289 * @param public_key A byte array of length TOX_PUBLIC_KEY_SIZE containing the 1299 * @param public_key A byte array of length TOX_PUBLIC_KEY_SIZE containing the
1290 * Public Key (not the Address) of the friend to add. 1300 * Public Key (not the Address) of the friend to add.
1291 * 1301 *
1292 * @return the friend number on success, UINT32_MAX on failure. 1302 * @return the friend number on success, an unspecified value on failure.
1293 * @see tox_friend_add for a more detailed description of friend numbers. 1303 * @see tox_friend_add for a more detailed description of friend numbers.
1294 */ 1304 */
1295uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error); 1305uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error);
@@ -1354,7 +1364,7 @@ typedef enum TOX_ERR_FRIEND_BY_PUBLIC_KEY {
1354/** 1364/**
1355 * Return the friend number associated with that Public Key. 1365 * Return the friend number associated with that Public Key.
1356 * 1366 *
1357 * @return the friend number on success, UINT32_MAX on failure. 1367 * @return the friend number on success, an unspecified value on failure.
1358 * @param public_key A byte array containing the Public Key. 1368 * @param public_key A byte array containing the Public Key.
1359 */ 1369 */
1360uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error); 1370uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error);
@@ -2172,7 +2182,7 @@ typedef enum TOX_ERR_FILE_SEND {
2172 * 2182 *
2173 * @return A file number used as an identifier in subsequent callbacks. This 2183 * @return A file number used as an identifier in subsequent callbacks. This
2174 * number is per friend. File numbers are reused after a transfer terminates. 2184 * number is per friend. File numbers are reused after a transfer terminates.
2175 * On failure, this function returns UINT32_MAX. Any pattern in file numbers 2185 * On failure, this function returns an unspecified value. Any pattern in file numbers
2176 * should not be relied on. 2186 * should not be relied on.
2177 */ 2187 */
2178uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *file_id, 2188uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *file_id,
@@ -2486,7 +2496,7 @@ typedef enum TOX_ERR_CONFERENCE_NEW {
2486 * 2496 *
2487 * This function creates a new text conference. 2497 * This function creates a new text conference.
2488 * 2498 *
2489 * @return conference number on success, or UINT32_MAX on failure. 2499 * @return conference number on success, or an unspecified value on failure.
2490 */ 2500 */
2491uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE_NEW *error); 2501uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE_NEW *error);
2492 2502
@@ -2655,7 +2665,7 @@ typedef enum TOX_ERR_CONFERENCE_JOIN {
2655 * @param cookie Received via the `conference_invite` event. 2665 * @param cookie Received via the `conference_invite` event.
2656 * @param length The size of cookie. 2666 * @param length The size of cookie.
2657 * 2667 *
2658 * @return conference number on success, UINT32_MAX on failure. 2668 * @return conference number on success, an unspecified value on failure.
2659 */ 2669 */
2660uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length, 2670uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length,
2661 TOX_ERR_CONFERENCE_JOIN *error); 2671 TOX_ERR_CONFERENCE_JOIN *error);
@@ -2804,6 +2814,46 @@ typedef enum TOX_ERR_CONFERENCE_GET_TYPE {
2804TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t conference_number, 2814TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t conference_number,
2805 TOX_ERR_CONFERENCE_GET_TYPE *error); 2815 TOX_ERR_CONFERENCE_GET_TYPE *error);
2806 2816
2817/**
2818 * Get the conference unique ID.
2819 *
2820 * If uid is NULL, this function has no effect.
2821 *
2822 * @param uid A memory region large enough to store TOX_CONFERENCE_UID_SIZE bytes.
2823 *
2824 * @return true on success.
2825 */
2826bool tox_conference_get_uid(const Tox *tox, uint32_t conference_number, uint8_t *uid);
2827
2828typedef enum TOX_ERR_CONFERENCE_BY_UID {
2829
2830 /**
2831 * The function returned successfully.
2832 */
2833 TOX_ERR_CONFERENCE_BY_UID_OK,
2834
2835 /**
2836 * One of the arguments to the function was NULL when it was not expected.
2837 */
2838 TOX_ERR_CONFERENCE_BY_UID_NULL,
2839
2840 /**
2841 * No conference with the given uid exists on the conference list.
2842 */
2843 TOX_ERR_CONFERENCE_BY_UID_NOT_FOUND,
2844
2845} TOX_ERR_CONFERENCE_BY_UID;
2846
2847
2848/**
2849 * Return the conference number associated with the specified uid.
2850 *
2851 * @param uid A byte array containing the conference id (TOX_CONFERENCE_UID_SIZE).
2852 *
2853 * @return the conference number on success, an unspecified value on failure.
2854 */
2855uint32_t tox_conference_by_uid(const Tox *tox, const uint8_t *uid, TOX_ERR_CONFERENCE_BY_UID *error);
2856
2807 2857
2808/******************************************************************************* 2858/*******************************************************************************
2809 * 2859 *
@@ -3004,6 +3054,7 @@ typedef TOX_ERR_FILE_SEND_CHUNK Tox_Err_File_Send_Chunk;
3004typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; 3054typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New;
3005typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; 3055typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete;
3006typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; 3056typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query;
3057typedef TOX_ERR_CONFERENCE_BY_UID Tox_Err_Conference_By_Uid;
3007typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; 3058typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite;
3008typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; 3059typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join;
3009typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; 3060typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message;