diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-13 19:10:22 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-13 19:30:02 +0000 |
commit | 90a63e8188aabde41beb60152b04d2cd4576c2ac (patch) | |
tree | 7598acc5d612f29c5463483ed77bcc4cdd3bc42e /toxcore/tox.h | |
parent | 3d5fd9c2d0114e7d4bbb389e11216c425adaa216 (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.h | 73 |
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); | |||
246 | uint32_t tox_secret_key_size(void); | 249 | uint32_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 | |||
256 | uint32_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 | */ |
1274 | uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length, | 1284 | uint32_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 | */ |
1295 | uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error); | 1305 | uint32_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 | */ |
1360 | uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error); | 1370 | uint32_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 | */ |
2178 | uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *file_id, | 2188 | uint32_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 | */ |
2491 | uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE_NEW *error); | 2501 | uint32_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 | */ |
2660 | uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length, | 2670 | uint32_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 { | |||
2804 | TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t conference_number, | 2814 | TOX_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 | */ | ||
2826 | bool tox_conference_get_uid(const Tox *tox, uint32_t conference_number, uint8_t *uid); | ||
2827 | |||
2828 | typedef 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 | */ | ||
2855 | uint32_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; | |||
3004 | typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; | 3054 | typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; |
3005 | typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; | 3055 | typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; |
3006 | typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; | 3056 | typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; |
3057 | typedef TOX_ERR_CONFERENCE_BY_UID Tox_Err_Conference_By_Uid; | ||
3007 | typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; | 3058 | typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; |
3008 | typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; | 3059 | typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; |
3009 | typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; | 3060 | typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; |