diff options
-rw-r--r-- | toxcore/group.c | 37 | ||||
-rw-r--r-- | toxcore/group.h | 13 | ||||
-rw-r--r-- | toxcore/tox.api.h | 57 | ||||
-rw-r--r-- | toxcore/tox.c | 25 | ||||
-rw-r--r-- | toxcore/tox.h | 73 |
5 files changed, 178 insertions, 27 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index 3e0c1fd3..2ee81de8 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -183,6 +183,17 @@ static int32_t get_group_num(const Group_Chats *g_c, const uint8_t *identifier) | |||
183 | return -1; | 183 | return -1; |
184 | } | 184 | } |
185 | 185 | ||
186 | int32_t conference_by_uid(const Group_Chats *g_c, const uint8_t *uid) | ||
187 | { | ||
188 | for (uint16_t i = 0; i < g_c->num_chats; ++i) { | ||
189 | if (crypto_memcmp(g_c->chats[i].identifier + 1, uid, GROUP_IDENTIFIER_LENGTH - 1) == 0) { | ||
190 | return i; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | return -1; | ||
195 | } | ||
196 | |||
186 | /* | 197 | /* |
187 | * check if peer with peer_number is in peer array. | 198 | * check if peer with peer_number is in peer array. |
188 | * | 199 | * |
@@ -942,7 +953,7 @@ int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int p | |||
942 | */ | 953 | */ |
943 | int group_get_type(const Group_Chats *g_c, uint32_t groupnumber) | 954 | int group_get_type(const Group_Chats *g_c, uint32_t groupnumber) |
944 | { | 955 | { |
945 | Group_c *g = get_group_c(g_c, groupnumber); | 956 | const Group_c *g = get_group_c(g_c, groupnumber); |
946 | 957 | ||
947 | if (!g) { | 958 | if (!g) { |
948 | return -1; | 959 | return -1; |
@@ -951,6 +962,26 @@ int group_get_type(const Group_Chats *g_c, uint32_t groupnumber) | |||
951 | return g->identifier[0]; | 962 | return g->identifier[0]; |
952 | } | 963 | } |
953 | 964 | ||
965 | /* Copies the unique id of group_chat[groupnumber] into uid. | ||
966 | * | ||
967 | * return false on failure. | ||
968 | * return true on success. | ||
969 | */ | ||
970 | bool conference_get_uid(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *uid) | ||
971 | { | ||
972 | const Group_c *g = get_group_c(g_c, groupnumber); | ||
973 | |||
974 | if (!g) { | ||
975 | return false; | ||
976 | } | ||
977 | |||
978 | if (uid != nullptr) { | ||
979 | memcpy(uid, g->identifier + 1, sizeof(g->identifier) - 1); | ||
980 | } | ||
981 | |||
982 | return true; | ||
983 | } | ||
984 | |||
954 | /* Send a group packet to friendcon_id. | 985 | /* Send a group packet to friendcon_id. |
955 | * | 986 | * |
956 | * return 1 on success | 987 | * return 1 on success |
@@ -2504,7 +2535,7 @@ void kill_groupchats(Group_Chats *g_c) | |||
2504 | * You should use this to determine how much memory to allocate | 2535 | * You should use this to determine how much memory to allocate |
2505 | * for copy_chatlist. | 2536 | * for copy_chatlist. |
2506 | */ | 2537 | */ |
2507 | uint32_t count_chatlist(Group_Chats *g_c) | 2538 | uint32_t count_chatlist(const Group_Chats *g_c) |
2508 | { | 2539 | { |
2509 | uint32_t ret = 0; | 2540 | uint32_t ret = 0; |
2510 | 2541 | ||
@@ -2522,7 +2553,7 @@ uint32_t count_chatlist(Group_Chats *g_c) | |||
2522 | * Otherwise, returns the number of elements copied. | 2553 | * Otherwise, returns the number of elements copied. |
2523 | * If the array was too small, the contents | 2554 | * If the array was too small, the contents |
2524 | * of out_list will be truncated to list_size. */ | 2555 | * of out_list will be truncated to list_size. */ |
2525 | uint32_t copy_chatlist(Group_Chats *g_c, uint32_t *out_list, uint32_t list_size) | 2556 | uint32_t copy_chatlist(const Group_Chats *g_c, uint32_t *out_list, uint32_t list_size) |
2526 | { | 2557 | { |
2527 | if (!out_list) { | 2558 | if (!out_list) { |
2528 | return 0; | 2559 | return 0; |
diff --git a/toxcore/group.h b/toxcore/group.h index b2a297f9..9b4541c4 100644 --- a/toxcore/group.h +++ b/toxcore/group.h | |||
@@ -331,14 +331,14 @@ int send_group_lossy_packet(const Group_Chats *g_c, uint32_t groupnumber, const | |||
331 | * You should use this to determine how much memory to allocate | 331 | * You should use this to determine how much memory to allocate |
332 | * for copy_chatlist. | 332 | * for copy_chatlist. |
333 | */ | 333 | */ |
334 | uint32_t count_chatlist(Group_Chats *g_c); | 334 | uint32_t count_chatlist(const Group_Chats *g_c); |
335 | 335 | ||
336 | /* Copy a list of valid chat IDs into the array out_list. | 336 | /* Copy a list of valid chat IDs into the array out_list. |
337 | * If out_list is NULL, returns 0. | 337 | * If out_list is NULL, returns 0. |
338 | * Otherwise, returns the number of elements copied. | 338 | * Otherwise, returns the number of elements copied. |
339 | * If the array was too small, the contents | 339 | * If the array was too small, the contents |
340 | * of out_list will be truncated to list_size. */ | 340 | * of out_list will be truncated to list_size. */ |
341 | uint32_t copy_chatlist(Group_Chats *g_c, uint32_t *out_list, uint32_t list_size); | 341 | uint32_t copy_chatlist(const Group_Chats *g_c, uint32_t *out_list, uint32_t list_size); |
342 | 342 | ||
343 | /* return the type of groupchat (GROUPCHAT_TYPE_) that groupnumber is. | 343 | /* return the type of groupchat (GROUPCHAT_TYPE_) that groupnumber is. |
344 | * | 344 | * |
@@ -347,6 +347,15 @@ uint32_t copy_chatlist(Group_Chats *g_c, uint32_t *out_list, uint32_t list_size) | |||
347 | */ | 347 | */ |
348 | int group_get_type(const Group_Chats *g_c, uint32_t groupnumber); | 348 | int group_get_type(const Group_Chats *g_c, uint32_t groupnumber); |
349 | 349 | ||
350 | /* Copies the unique id of group_chat[groupnumber] into uid. | ||
351 | * | ||
352 | * return false on failure. | ||
353 | * return true on success. | ||
354 | */ | ||
355 | bool conference_get_uid(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *uid); | ||
356 | |||
357 | int32_t conference_by_uid(const Group_Chats *g_c, const uint8_t *uid); | ||
358 | |||
350 | /* Send current name (set in messenger) to all online groups. | 359 | /* Send current name (set in messenger) to all online groups. |
351 | */ | 360 | */ |
352 | void send_name_all_groups(Group_Chats *g_c); | 361 | void send_name_all_groups(Group_Chats *g_c); |
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; | |||
241 | const SECRET_KEY_SIZE = 32; | 244 | const SECRET_KEY_SIZE = 32; |
242 | 245 | ||
243 | /** | 246 | /** |
247 | * The size of a Tox Conference unique id in bytes. | ||
248 | */ | ||
249 | const 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 | */ |
246 | const NOSPAM_SIZE = sizeof(uint32_t); | 254 | const 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; | |||
2644 | typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; | 2678 | typedef TOX_ERR_CONFERENCE_NEW Tox_Err_Conference_New; |
2645 | typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; | 2679 | typedef TOX_ERR_CONFERENCE_DELETE Tox_Err_Conference_Delete; |
2646 | typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; | 2680 | typedef TOX_ERR_CONFERENCE_PEER_QUERY Tox_Err_Conference_Peer_Query; |
2681 | typedef TOX_ERR_CONFERENCE_BY_UID Tox_Err_Conference_By_Uid; | ||
2647 | typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; | 2682 | typedef TOX_ERR_CONFERENCE_INVITE Tox_Err_Conference_Invite; |
2648 | typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; | 2683 | typedef TOX_ERR_CONFERENCE_JOIN Tox_Err_Conference_Join; |
2649 | typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; | 2684 | typedef TOX_ERR_CONFERENCE_SEND_MESSAGE Tox_Err_Conference_Send_Message; |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 4c764aeb..cae2dcb3 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -1453,6 +1453,31 @@ Tox_Conference_Type tox_conference_get_type(const Tox *tox, uint32_t conference_ | |||
1453 | return (Tox_Conference_Type)ret; | 1453 | return (Tox_Conference_Type)ret; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | bool tox_conference_get_uid(const Tox *tox, uint32_t conference_number, uint8_t *uid /* TOX_CONFERENCE_ID_SIZE bytes */) | ||
1457 | { | ||
1458 | const Messenger *m = tox; | ||
1459 | return conference_get_uid((Group_Chats *)m->conferences_object, conference_number, uid); | ||
1460 | } | ||
1461 | |||
1462 | uint32_t tox_conference_by_uid(const Tox *tox, const uint8_t *uid, Tox_Err_Conference_By_Uid *error) | ||
1463 | { | ||
1464 | if (!uid) { | ||
1465 | SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_BY_UID_NULL); | ||
1466 | return UINT32_MAX; | ||
1467 | } | ||
1468 | |||
1469 | const Messenger *m = tox; | ||
1470 | int32_t ret = conference_by_uid((Group_Chats *)m->conferences_object, uid); | ||
1471 | |||
1472 | if (ret == -1) { | ||
1473 | SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_BY_UID_NOT_FOUND); | ||
1474 | return UINT32_MAX; | ||
1475 | } | ||
1476 | |||
1477 | SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_BY_UID_OK); | ||
1478 | return ret; | ||
1479 | } | ||
1480 | |||
1456 | static void set_custom_packet_error(int ret, Tox_Err_Friend_Custom_Packet *error) | 1481 | static void set_custom_packet_error(int ret, Tox_Err_Friend_Custom_Packet *error) |
1457 | { | 1482 | { |
1458 | switch (ret) { | 1483 | switch (ret) { |
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; |