summaryrefslogtreecommitdiff
path: root/toxcore/tox.api.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.api.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.api.h')
-rw-r--r--toxcore/tox.api.h57
1 files changed, 46 insertions, 11 deletions
diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h
index f3286bc5..632d79c5 100644
--- a/toxcore/tox.api.h
+++ b/toxcore/tox.api.h
@@ -42,7 +42,8 @@ extern "C" {
42 *****************************************************************************/ 42 *****************************************************************************/
43 43
44 44
45/** \page core Public core API for Tox clients. 45/**
46 * @page core Public core API for Tox clients.
46 * 47 *
47 * Every function that can fail takes a function-specific error code pointer 48 * Every function that can fail takes a function-specific error code pointer
48 * that can be used to diagnose problems with the Tox state or the function 49 * that can be used to diagnose problems with the Tox state or the function
@@ -81,7 +82,8 @@ extern "C" {
81 * part of the ABI. 82 * part of the ABI.
82 */ 83 */
83 84
84/** \subsection events Events and callbacks 85/**
86 * @subsection events Events and callbacks
85 * 87 *
86 * Events are handled by callbacks. One callback can be registered per event. 88 * Events are handled by callbacks. One callback can be registered per event.
87 * All events have a callback function type named `tox_{event}_cb` and a 89 * All events have a callback function type named `tox_{event}_cb` and a
@@ -104,7 +106,8 @@ extern "C" {
104 * their own user data pointer of their own type. 106 * their own user data pointer of their own type.
105 */ 107 */
106 108
107/** \subsection threading Threading implications 109/**
110 * @subsection threading Threading implications
108 * 111 *
109 * It is possible to run multiple concurrent threads with a Tox instance for 112 * It is possible to run multiple concurrent threads with a Tox instance for
110 * each thread. It is also possible to run all Tox instances in the same thread. 113 * each thread. It is also possible to run all Tox instances in the same thread.
@@ -126,12 +129,12 @@ extern "C" {
126 * 129 *
127 * E.g. to get the current nickname, one would write 130 * E.g. to get the current nickname, one would write
128 * 131 *
129 * \code 132 * @code
130 * size_t length = ${tox.self.name.size}(tox); 133 * size_t length = ${tox.self.name.size}(tox);
131 * uint8_t *name = malloc(length); 134 * uint8_t *name = malloc(length);
132 * if (!name) abort(); 135 * if (!name) abort();
133 * ${tox.self.name.get}(tox, name); 136 * ${tox.self.name.get}(tox, name);
134 * \endcode 137 * @endcode
135 * 138 *
136 * If any other thread calls ${tox.self.name.set} while this thread is allocating 139 * If any other thread calls ${tox.self.name.set} while this thread is allocating
137 * memory, the length may have become invalid, and the call to 140 * memory, the length may have become invalid, and the call to
@@ -241,6 +244,11 @@ const PUBLIC_KEY_SIZE = 32;
241const SECRET_KEY_SIZE = 32; 244const SECRET_KEY_SIZE = 32;
242 245
243/** 246/**
247 * The size of a Tox Conference unique id in bytes.
248 */
249const CONFERENCE_UID_SIZE = 32;
250
251/**
244 * The size of the nospam in bytes when written in a Tox address. 252 * The size of the nospam in bytes when written in a Tox address.
245 */ 253 */
246const NOSPAM_SIZE = sizeof(uint32_t); 254const NOSPAM_SIZE = sizeof(uint32_t);
@@ -1078,7 +1086,7 @@ namespace friend {
1078 * @param message The message that will be sent along with the friend request. 1086 * @param message The message that will be sent along with the friend request.
1079 * @param length The length of the data byte array. 1087 * @param length The length of the data byte array.
1080 * 1088 *
1081 * @return the friend number on success, UINT32_MAX on failure. 1089 * @return the friend number on success, an unspecified value on failure.
1082 */ 1090 */
1083 uint32_t add( 1091 uint32_t add(
1084 const uint8_t[ADDRESS_SIZE] address, 1092 const uint8_t[ADDRESS_SIZE] address,
@@ -1134,7 +1142,7 @@ namespace friend {
1134 * @param public_key A byte array of length $PUBLIC_KEY_SIZE containing the 1142 * @param public_key A byte array of length $PUBLIC_KEY_SIZE containing the
1135 * Public Key (not the Address) of the friend to add. 1143 * Public Key (not the Address) of the friend to add.
1136 * 1144 *
1137 * @return the friend number on success, UINT32_MAX on failure. 1145 * @return the friend number on success, an unspecified value on failure.
1138 * @see $add for a more detailed description of friend numbers. 1146 * @see $add for a more detailed description of friend numbers.
1139 */ 1147 */
1140 uint32_t add_norequest(const uint8_t[PUBLIC_KEY_SIZE] public_key) 1148 uint32_t add_norequest(const uint8_t[PUBLIC_KEY_SIZE] public_key)
@@ -1173,7 +1181,7 @@ namespace friend {
1173 /** 1181 /**
1174 * Return the friend number associated with that Public Key. 1182 * Return the friend number associated with that Public Key.
1175 * 1183 *
1176 * @return the friend number on success, UINT32_MAX on failure. 1184 * @return the friend number on success, an unspecified value on failure.
1177 * @param public_key A byte array containing the Public Key. 1185 * @param public_key A byte array containing the Public Key.
1178 */ 1186 */
1179 const uint32_t by_public_key(const uint8_t[PUBLIC_KEY_SIZE] public_key) { 1187 const uint32_t by_public_key(const uint8_t[PUBLIC_KEY_SIZE] public_key) {
@@ -1901,7 +1909,7 @@ namespace file {
1901 * 1909 *
1902 * @return A file number used as an identifier in subsequent callbacks. This 1910 * @return A file number used as an identifier in subsequent callbacks. This
1903 * number is per friend. File numbers are reused after a transfer terminates. 1911 * number is per friend. File numbers are reused after a transfer terminates.
1904 * On failure, this function returns UINT32_MAX. Any pattern in file numbers 1912 * On failure, this function returns an unspecified value. Any pattern in file numbers
1905 * should not be relied on. 1913 * should not be relied on.
1906 */ 1914 */
1907 uint32_t send(uint32_t friend_number, uint32_t kind, uint64_t file_size, 1915 uint32_t send(uint32_t friend_number, uint32_t kind, uint64_t file_size,
@@ -2186,7 +2194,7 @@ namespace conference {
2186 * 2194 *
2187 * This function creates a new text conference. 2195 * This function creates a new text conference.
2188 * 2196 *
2189 * @return conference number on success, or UINT32_MAX on failure. 2197 * @return conference number on success, or an unspecified value on failure.
2190 */ 2198 */
2191 uint32_t new() { 2199 uint32_t new() {
2192 /** 2200 /**
@@ -2301,7 +2309,7 @@ namespace conference {
2301 * @param cookie Received via the `${event invite}` event. 2309 * @param cookie Received via the `${event invite}` event.
2302 * @param length The size of cookie. 2310 * @param length The size of cookie.
2303 * 2311 *
2304 * @return conference number on success, UINT32_MAX on failure. 2312 * @return conference number on success, an unspecified value on failure.
2305 */ 2313 */
2306 uint32_t join(uint32_t friend_number, const uint8_t[length] cookie) { 2314 uint32_t join(uint32_t friend_number, const uint8_t[length] cookie) {
2307 /** 2315 /**
@@ -2453,6 +2461,32 @@ namespace conference {
2453 } 2461 }
2454 } 2462 }
2455 2463
2464 /**
2465 * Get the conference unique ID.
2466 *
2467 * If uid is NULL, this function has no effect.
2468 *
2469 * @param uid A memory region large enough to store $CONFERENCE_UID_SIZE bytes.
2470 *
2471 * @return true on success.
2472 */
2473 const bool get_uid(uint32_t conference_number, uint8_t[CONFERENCE_UID_SIZE] uid);
2474
2475 /**
2476 * Return the conference number associated with the specified uid.
2477 *
2478 * @param uid A byte array containing the conference id ($CONFERENCE_UID_SIZE).
2479 *
2480 * @return the conference number on success, an unspecified value on failure.
2481 */
2482 const uint32_t by_uid(const uint8_t[CONFERENCE_UID_SIZE] uid) {
2483 NULL,
2484 /**
2485 * No conference with the given uid exists on the conference list.
2486 */
2487 NOT_FOUND,
2488 }
2489
2456} 2490}
2457 2491
2458 2492
@@ -2644,6 +2678,7 @@ typedef TOX_ERR_FILE_SEND_CHUNK Tox_Err_File_Send_Chunk;
2644typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; 2678typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New;
2645typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; 2679typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete;
2646typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; 2680typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query;
2681typedef TOX_ERR_CONFERENCE_BY_UID Tox_Err_Conference_By_Uid;
2647typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; 2682typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite;
2648typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; 2683typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join;
2649typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; 2684typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message;