diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-07 17:18:19 +0100 |
---|---|---|
committer | Jfreegman <jfreegman@gmail.com> | 2016-09-17 19:11:28 -0400 |
commit | c0397a0a4614671679d409c428b47549a01fdf7f (patch) | |
tree | 525f0efd2241dc921588949598cd8a1767d19425 /toxcore/tox.h | |
parent | 21f8db12c45bd56293262cd4abfb73cd9abec821 (diff) |
ApiDSL'ing old group chats (now: conference).
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r-- | toxcore/tox.h | 237 |
1 files changed, 232 insertions, 5 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h index 61c4227a..7b04bb14 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -2274,14 +2274,243 @@ void tox_callback_file_recv_chunk(Tox *tox, tox_file_recv_chunk_cb *callback); | |||
2274 | 2274 | ||
2275 | 2275 | ||
2276 | 2276 | ||
2277 | typedef enum TOX_ERR_CONFERENCE { | ||
2277 | 2278 | ||
2278 | /******************************************************************************* | 2279 | /** |
2280 | * The function returned successfully. | ||
2281 | */ | ||
2282 | TOX_ERR_CONFERENCE_OK, | ||
2283 | |||
2284 | /** | ||
2285 | * Some error occurred. | ||
2286 | */ | ||
2287 | TOX_ERR_CONFERENCE_FAILURE, | ||
2288 | |||
2289 | } TOX_ERR_CONFERENCE; | ||
2290 | |||
2291 | |||
2292 | /** | ||
2293 | * Conference types for the conference_invite event. | ||
2294 | */ | ||
2295 | typedef enum TOX_CONFERENCE_TYPE { | ||
2296 | |||
2297 | /** | ||
2298 | * Text-only conferences that must be accepted with the tox_conference_join function. | ||
2299 | */ | ||
2300 | TOX_CONFERENCE_TYPE_TEXT, | ||
2301 | |||
2302 | /** | ||
2303 | * Video conference. The function to accept these is in toxav. | ||
2304 | */ | ||
2305 | TOX_CONFERENCE_TYPE_AV, | ||
2306 | |||
2307 | } TOX_CONFERENCE_TYPE; | ||
2308 | |||
2309 | |||
2310 | /** | ||
2311 | * The invitation will remain valid until the inviting friend goes offline | ||
2312 | * or exits the conference. | ||
2279 | * | 2313 | * |
2280 | * :: Group chat message sending and receiving | 2314 | * @param friend_number The friend who invited us. |
2315 | * @param type The conference type (text only or audio/video). | ||
2316 | * @param cookie A piece of data of variable length required to join the | ||
2317 | * conference. | ||
2318 | * @param length The length of the cookie. | ||
2319 | */ | ||
2320 | typedef void tox_conference_invite_cb(Tox *tox, uint32_t friend_number, TOX_CONFERENCE_TYPE type, const uint8_t *cookie, | ||
2321 | size_t length, void *user_data); | ||
2322 | |||
2323 | |||
2324 | /** | ||
2325 | * Set the callback for the `conference_invite` event. Pass NULL to unset. | ||
2281 | * | 2326 | * |
2282 | ******************************************************************************/ | 2327 | * This event is triggered when the client is invited to join a conference. |
2328 | */ | ||
2329 | void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback, void *user_data); | ||
2330 | |||
2331 | /** | ||
2332 | * TODO | ||
2333 | */ | ||
2334 | typedef void tox_conference_message_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, TOX_MESSAGE_TYPE type, | ||
2335 | const uint8_t *message, size_t length, void *user_data); | ||
2336 | |||
2337 | |||
2338 | /** | ||
2339 | * Set the callback for the `conference_message` event. Pass NULL to unset. | ||
2340 | * | ||
2341 | * Set the callback for group messages. | ||
2342 | */ | ||
2343 | void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback, void *user_data); | ||
2344 | |||
2345 | /** | ||
2346 | * TODO | ||
2347 | */ | ||
2348 | typedef void tox_conference_title_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, const uint8_t *title, | ||
2349 | size_t length, void *user_data); | ||
2350 | |||
2351 | |||
2352 | /** | ||
2353 | * Set the callback for the `conference_title` event. Pass NULL to unset. | ||
2354 | * | ||
2355 | * Set callback function for title changes. | ||
2356 | * | ||
2357 | * if peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the group) | ||
2358 | */ | ||
2359 | void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback, void *user_data); | ||
2360 | |||
2361 | typedef enum TOX_CONFERENCE_CHANGE { | ||
2362 | |||
2363 | /** | ||
2364 | * TODO: Generate doc | ||
2365 | */ | ||
2366 | TOX_CONFERENCE_CHANGE_PEER_ADD, | ||
2367 | |||
2368 | /** | ||
2369 | * TODO: Generate doc | ||
2370 | */ | ||
2371 | TOX_CONFERENCE_CHANGE_PEER_DEL, | ||
2372 | |||
2373 | /** | ||
2374 | * TODO: Generate doc | ||
2375 | */ | ||
2376 | TOX_CONFERENCE_CHANGE_PEER_NAME, | ||
2377 | |||
2378 | } TOX_CONFERENCE_CHANGE; | ||
2379 | |||
2380 | |||
2381 | /** | ||
2382 | * TODO | ||
2383 | */ | ||
2384 | typedef void tox_conference_namelist_change_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, | ||
2385 | TOX_CONFERENCE_CHANGE change, void *user_data); | ||
2386 | |||
2387 | |||
2388 | /** | ||
2389 | * Set the callback for the `conference_namelist_change` event. Pass NULL to unset. | ||
2390 | * | ||
2391 | * Set callback function for peer name list changes. | ||
2392 | * | ||
2393 | * It gets called every time the name list changes(new peer/name, deleted peer) | ||
2394 | */ | ||
2395 | void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback, void *user_data); | ||
2396 | |||
2397 | /** | ||
2398 | * Creates a new groupchat. | ||
2399 | * | ||
2400 | * @return the group number. | ||
2401 | */ | ||
2402 | uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE *error); | ||
2403 | |||
2404 | /** | ||
2405 | * Delete a groupchat. | ||
2406 | * | ||
2407 | * @return true on success. | ||
2408 | */ | ||
2409 | bool tox_conference_delete(Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | ||
2283 | 2410 | ||
2411 | /** | ||
2412 | * Return the number of peers in the group chat. | ||
2413 | */ | ||
2414 | uint32_t tox_conference_peer_count(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | ||
2284 | 2415 | ||
2416 | size_t tox_conference_peer_get_name_size(const Tox *tox, uint32_t group_number, uint32_t peer_number, | ||
2417 | TOX_ERR_CONFERENCE *error); | ||
2418 | |||
2419 | /** | ||
2420 | * Copy the name of peer_number who is in group_number to name. | ||
2421 | * name must be at least TOX_MAX_NAME_LENGTH long. | ||
2422 | * | ||
2423 | * return length of name if success | ||
2424 | * return -1 if failure | ||
2425 | */ | ||
2426 | bool tox_conference_peer_get_name(const Tox *tox, uint32_t group_number, uint32_t peer_number, uint8_t *name, | ||
2427 | TOX_ERR_CONFERENCE *error); | ||
2428 | |||
2429 | /** | ||
2430 | * Copy the public key of peer_number who is in group_number to public_key. | ||
2431 | * public_key must be TOX_PUBLIC_KEY_SIZE long. | ||
2432 | * | ||
2433 | * returns 0 on success | ||
2434 | * returns -1 on failure | ||
2435 | */ | ||
2436 | bool tox_conference_peer_get_public_key(const Tox *tox, uint32_t group_number, uint32_t peer_number, | ||
2437 | uint8_t *public_key, TOX_ERR_CONFERENCE *error); | ||
2438 | |||
2439 | /** | ||
2440 | * Check if the current peer_number corresponds to ours. | ||
2441 | * | ||
2442 | * return 1 if the peer_number corresponds to ours. | ||
2443 | * return 0 on failure. | ||
2444 | */ | ||
2445 | bool tox_conference_peer_number_is_ours(const Tox *tox, uint32_t group_number, uint32_t peer_number); | ||
2446 | |||
2447 | /** | ||
2448 | * invite friend_number to group_number | ||
2449 | * return 0 on success | ||
2450 | * return -1 on failure | ||
2451 | */ | ||
2452 | bool tox_conference_invite(Tox *tox, uint32_t friend_number, uint32_t group_number, TOX_ERR_CONFERENCE *error); | ||
2453 | |||
2454 | /** | ||
2455 | * Join a group (you need to have been invited first.) using cookie of length obtained | ||
2456 | * in the group invite callback. | ||
2457 | * | ||
2458 | * returns group number on success | ||
2459 | * returns -1 on failure. | ||
2460 | */ | ||
2461 | uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length, | ||
2462 | TOX_ERR_CONFERENCE *error); | ||
2463 | |||
2464 | /** | ||
2465 | * send a group message | ||
2466 | * return 0 on success | ||
2467 | * return -1 on failure | ||
2468 | */ | ||
2469 | bool tox_conference_send_message(Tox *tox, uint32_t group_number, TOX_MESSAGE_TYPE type, const uint8_t *message, | ||
2470 | size_t length, TOX_ERR_CONFERENCE *error); | ||
2471 | |||
2472 | size_t tox_conference_get_title_size(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | ||
2473 | |||
2474 | /** | ||
2475 | * Get group title from group_number and put it in title. | ||
2476 | * title needs to be a valid memory location with a max_length size of at least MAX_NAME_LENGTH (128) bytes. | ||
2477 | * | ||
2478 | * return length of copied title if success. | ||
2479 | * return -1 if failure. | ||
2480 | */ | ||
2481 | bool tox_conference_get_title(const Tox *tox, uint32_t group_number, uint8_t *title, TOX_ERR_CONFERENCE *error); | ||
2482 | |||
2483 | /** | ||
2484 | * set the group's title, limited to MAX_NAME_LENGTH | ||
2485 | * return 0 on success | ||
2486 | * return -1 on failure | ||
2487 | */ | ||
2488 | bool tox_conference_set_title(Tox *tox, uint32_t group_number, const uint8_t *title, size_t length, | ||
2489 | TOX_ERR_CONFERENCE *error); | ||
2490 | |||
2491 | /** | ||
2492 | * Return the number of chats in the instance m. | ||
2493 | * You should use this to determine how much memory to allocate | ||
2494 | * for copy_chatlist. | ||
2495 | */ | ||
2496 | size_t tox_conference_get_chatlist_size(const Tox *tox); | ||
2497 | |||
2498 | /** | ||
2499 | * Copy a list of valid chat IDs into the array out_list. | ||
2500 | * If out_list is NULL, returns 0. | ||
2501 | * Otherwise, returns the number of elements copied. | ||
2502 | * If the array was too small, the contents | ||
2503 | * of out_list will be truncated to list_size. | ||
2504 | */ | ||
2505 | void tox_conference_get_chatlist(const Tox *tox, uint32_t *chatlist); | ||
2506 | |||
2507 | /** | ||
2508 | * return the type of groupchat (TOX_CONFERENCE_TYPE) that group_number is. | ||
2509 | * | ||
2510 | * return -1 on failure. | ||
2511 | * return type on success. | ||
2512 | */ | ||
2513 | TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | ||
2285 | 2514 | ||
2286 | 2515 | ||
2287 | /******************************************************************************* | 2516 | /******************************************************************************* |
@@ -2459,8 +2688,6 @@ uint16_t tox_self_get_udp_port(const Tox *tox, TOX_ERR_GET_PORT *error); | |||
2459 | */ | 2688 | */ |
2460 | uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error); | 2689 | uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error); |
2461 | 2690 | ||
2462 | #include "tox_group.h" | ||
2463 | |||
2464 | #ifdef __cplusplus | 2691 | #ifdef __cplusplus |
2465 | } | 2692 | } |
2466 | #endif | 2693 | #endif |