diff options
author | Jfreegman <jfreegman@gmail.com> | 2016-09-17 17:32:25 -0400 |
---|---|---|
committer | Jfreegman <jfreegman@gmail.com> | 2016-09-17 19:11:28 -0400 |
commit | 8e43ca834cc0a5b2f904ce2589154c2f17bd12ce (patch) | |
tree | e88701e5dfe6a623c7fe7f60ba2ddb304ffadc07 /toxcore/tox.h | |
parent | c0397a0a4614671679d409c428b47549a01fdf7f (diff) |
Complete old groupchat conversion to new API
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r-- | toxcore/tox.h | 419 |
1 files changed, 318 insertions, 101 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h index 7b04bb14..268ae779 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -344,7 +344,7 @@ typedef enum TOX_USER_STATUS { | |||
344 | 344 | ||
345 | 345 | ||
346 | /** | 346 | /** |
347 | * Represents message types for tox_friend_send_message and group chat | 347 | * Represents message types for tox_friend_send_message and conference |
348 | * messages. | 348 | * messages. |
349 | */ | 349 | */ |
350 | typedef enum TOX_MESSAGE_TYPE { | 350 | typedef enum TOX_MESSAGE_TYPE { |
@@ -2268,27 +2268,12 @@ void tox_callback_file_recv_chunk(Tox *tox, tox_file_recv_chunk_cb *callback); | |||
2268 | 2268 | ||
2269 | /******************************************************************************* | 2269 | /******************************************************************************* |
2270 | * | 2270 | * |
2271 | * :: Group chat management | 2271 | * :: Conference management |
2272 | * | 2272 | * |
2273 | ******************************************************************************/ | 2273 | ******************************************************************************/ |
2274 | 2274 | ||
2275 | 2275 | ||
2276 | 2276 | ||
2277 | typedef enum TOX_ERR_CONFERENCE { | ||
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 | /** | 2277 | /** |
2293 | * Conference types for the conference_invite event. | 2278 | * Conference types for the conference_invite event. |
2294 | */ | 2279 | */ |
@@ -2329,188 +2314,420 @@ typedef void tox_conference_invite_cb(Tox *tox, uint32_t friend_number, TOX_CONF | |||
2329 | void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback, void *user_data); | 2314 | void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback, void *user_data); |
2330 | 2315 | ||
2331 | /** | 2316 | /** |
2332 | * TODO | 2317 | * @param conference_number The conference number of the conference the message is intended for. |
2318 | * @param peer_number The ID of the peer who sent the message. | ||
2319 | * @param type The type of message (normal, action, ...). | ||
2320 | * @param message The message data. | ||
2321 | * @param length The length of the message. | ||
2333 | */ | 2322 | */ |
2334 | typedef void tox_conference_message_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, TOX_MESSAGE_TYPE type, | 2323 | typedef void tox_conference_message_cb(Tox *tox, uint32_t conference_number, uint32_t peer_number, |
2335 | const uint8_t *message, size_t length, void *user_data); | 2324 | TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *user_data); |
2336 | 2325 | ||
2337 | 2326 | ||
2338 | /** | 2327 | /** |
2339 | * Set the callback for the `conference_message` event. Pass NULL to unset. | 2328 | * Set the callback for the `conference_message` event. Pass NULL to unset. |
2340 | * | 2329 | * |
2341 | * Set the callback for group messages. | 2330 | * This event is triggered when the client receives a conference message. |
2342 | */ | 2331 | */ |
2343 | void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback, void *user_data); | 2332 | void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback, void *user_data); |
2344 | 2333 | ||
2345 | /** | 2334 | /** |
2346 | * TODO | 2335 | * @param conference_number The conference number of the conference the title change is intended for. |
2336 | * @param peer_number The ID of the peer who changed the title. | ||
2337 | * @param title The title data. | ||
2338 | * @param length The title length. | ||
2347 | */ | 2339 | */ |
2348 | typedef void tox_conference_title_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, const uint8_t *title, | 2340 | typedef void tox_conference_title_cb(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, |
2349 | size_t length, void *user_data); | 2341 | size_t length, void *user_data); |
2350 | 2342 | ||
2351 | 2343 | ||
2352 | /** | 2344 | /** |
2353 | * Set the callback for the `conference_title` event. Pass NULL to unset. | 2345 | * Set the callback for the `conference_title` event. Pass NULL to unset. |
2354 | * | 2346 | * |
2355 | * Set callback function for title changes. | 2347 | * This event is triggered when a peer changes the conference title. |
2356 | * | 2348 | * |
2357 | * if peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the group) | 2349 | * If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference). |
2358 | */ | 2350 | */ |
2359 | void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback, void *user_data); | 2351 | void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback, void *user_data); |
2360 | 2352 | ||
2361 | typedef enum TOX_CONFERENCE_CHANGE { | 2353 | /** |
2354 | * Peer list state change types. | ||
2355 | */ | ||
2356 | typedef enum TOX_CONFERENCE_STATE_CHANGE { | ||
2362 | 2357 | ||
2363 | /** | 2358 | /** |
2364 | * TODO: Generate doc | 2359 | * A peer has joined the conference. |
2365 | */ | 2360 | */ |
2366 | TOX_CONFERENCE_CHANGE_PEER_ADD, | 2361 | TOX_CONFERENCE_STATE_CHANGE_PEER_JOIN, |
2367 | 2362 | ||
2368 | /** | 2363 | /** |
2369 | * TODO: Generate doc | 2364 | * A peer has exited the conference. |
2370 | */ | 2365 | */ |
2371 | TOX_CONFERENCE_CHANGE_PEER_DEL, | 2366 | TOX_CONFERENCE_STATE_CHANGE_PEER_EXIT, |
2372 | 2367 | ||
2373 | /** | 2368 | /** |
2374 | * TODO: Generate doc | 2369 | * A peer has changed their name. |
2375 | */ | 2370 | */ |
2376 | TOX_CONFERENCE_CHANGE_PEER_NAME, | 2371 | TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE, |
2377 | 2372 | ||
2378 | } TOX_CONFERENCE_CHANGE; | 2373 | } TOX_CONFERENCE_STATE_CHANGE; |
2379 | 2374 | ||
2380 | 2375 | ||
2381 | /** | 2376 | /** |
2382 | * TODO | 2377 | * @param conference_number The conference number of the conference the title change is intended for. |
2378 | * @param peer_number The ID of the peer who changed the title. | ||
2379 | * @param change The type of change (one of TOX_CONFERENCE_STATE_CHANGE). | ||
2383 | */ | 2380 | */ |
2384 | typedef void tox_conference_namelist_change_cb(Tox *tox, uint32_t group_number, uint32_t peer_number, | 2381 | typedef void tox_conference_namelist_change_cb(Tox *tox, uint32_t conference_number, uint32_t peer_number, |
2385 | TOX_CONFERENCE_CHANGE change, void *user_data); | 2382 | TOX_CONFERENCE_STATE_CHANGE change, void *user_data); |
2386 | 2383 | ||
2387 | 2384 | ||
2388 | /** | 2385 | /** |
2389 | * Set the callback for the `conference_namelist_change` event. Pass NULL to unset. | 2386 | * Set the callback for the `conference_namelist_change` event. Pass NULL to unset. |
2390 | * | 2387 | * |
2391 | * Set callback function for peer name list changes. | 2388 | * This event is triggered when the peer list changes (name change, peer join, peer exit). |
2392 | * | ||
2393 | * It gets called every time the name list changes(new peer/name, deleted peer) | ||
2394 | */ | 2389 | */ |
2395 | void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback, void *user_data); | 2390 | void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback, void *user_data); |
2396 | 2391 | ||
2392 | typedef enum TOX_ERR_CONFERENCE_NEW { | ||
2393 | |||
2394 | /** | ||
2395 | * The function returned successfully. | ||
2396 | */ | ||
2397 | TOX_ERR_CONFERENCE_NEW_OK, | ||
2398 | |||
2399 | /** | ||
2400 | * The conference instance failed to initialize. | ||
2401 | */ | ||
2402 | TOX_ERR_CONFERENCE_NEW_INIT, | ||
2403 | |||
2404 | } TOX_ERR_CONFERENCE_NEW; | ||
2405 | |||
2406 | |||
2397 | /** | 2407 | /** |
2398 | * Creates a new groupchat. | 2408 | * Creates a new conference. |
2409 | * | ||
2410 | * This function creates a new text conference. | ||
2399 | * | 2411 | * |
2400 | * @return the group number. | 2412 | * @return conference number on success, or UINT32_MAX on failure. |
2401 | */ | 2413 | */ |
2402 | uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE *error); | 2414 | uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE_NEW *error); |
2415 | |||
2416 | typedef enum TOX_ERR_CONFERENCE_DELETE { | ||
2417 | |||
2418 | /** | ||
2419 | * The function returned successfully. | ||
2420 | */ | ||
2421 | TOX_ERR_CONFERENCE_DELETE_OK, | ||
2422 | |||
2423 | /** | ||
2424 | * The conference number passed did not designate a valid conference. | ||
2425 | */ | ||
2426 | TOX_ERR_CONFERENCE_DELETE_CONFERENCE_NOT_FOUND, | ||
2427 | |||
2428 | } TOX_ERR_CONFERENCE_DELETE; | ||
2429 | |||
2403 | 2430 | ||
2404 | /** | 2431 | /** |
2405 | * Delete a groupchat. | 2432 | * This function deletes a conference. |
2433 | * | ||
2434 | * @param conference_number The conference number of the conference to be deleted. | ||
2406 | * | 2435 | * |
2407 | * @return true on success. | 2436 | * @return true on success. |
2408 | */ | 2437 | */ |
2409 | bool tox_conference_delete(Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | 2438 | bool tox_conference_delete(Tox *tox, uint32_t conference_number, TOX_ERR_CONFERENCE_DELETE *error); |
2410 | 2439 | ||
2411 | /** | 2440 | /** |
2412 | * Return the number of peers in the group chat. | 2441 | * Error codes for peer info queries. |
2413 | */ | 2442 | */ |
2414 | uint32_t tox_conference_peer_count(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | 2443 | typedef enum TOX_ERR_CONFERENCE_PEER_QUERY { |
2444 | |||
2445 | /** | ||
2446 | * The function returned successfully. | ||
2447 | */ | ||
2448 | TOX_ERR_CONFERENCE_PEER_QUERY_OK, | ||
2449 | |||
2450 | /** | ||
2451 | * The conference number passed did not designate a valid conference. | ||
2452 | */ | ||
2453 | TOX_ERR_CONFERENCE_PEER_QUERY_CONFERENCE_NOT_FOUND, | ||
2454 | |||
2455 | /** | ||
2456 | * The peer number passed did not designate a valid peer. | ||
2457 | */ | ||
2458 | TOX_ERR_CONFERENCE_PEER_QUERY_PEER_NOT_FOUND, | ||
2459 | |||
2460 | /** | ||
2461 | * The client is not connected to the conference. | ||
2462 | */ | ||
2463 | TOX_ERR_CONFERENCE_PEER_QUERY_NO_CONNECTION, | ||
2464 | |||
2465 | } TOX_ERR_CONFERENCE_PEER_QUERY; | ||
2415 | 2466 | ||
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 | 2467 | ||
2419 | /** | 2468 | /** |
2420 | * Copy the name of peer_number who is in group_number to name. | 2469 | * Return the number of peers in the conference. Return value is unspecified on failure. |
2470 | */ | ||
2471 | uint32_t tox_conference_peer_count(const Tox *tox, uint32_t conference_number, TOX_ERR_CONFERENCE_PEER_QUERY *error); | ||
2472 | |||
2473 | /** | ||
2474 | * Return the length of the peer's name. Return value is unspecified on failure. | ||
2475 | */ | ||
2476 | size_t tox_conference_peer_get_name_size(const Tox *tox, uint32_t conference_number, uint32_t peer_number, | ||
2477 | TOX_ERR_CONFERENCE_PEER_QUERY *error); | ||
2478 | |||
2479 | /** | ||
2480 | * Copy the name of peer_number who is in conference_number to name. | ||
2421 | * name must be at least TOX_MAX_NAME_LENGTH long. | 2481 | * name must be at least TOX_MAX_NAME_LENGTH long. |
2422 | * | 2482 | * |
2423 | * return length of name if success | 2483 | * @return true on success. |
2424 | * return -1 if failure | ||
2425 | */ | 2484 | */ |
2426 | bool tox_conference_peer_get_name(const Tox *tox, uint32_t group_number, uint32_t peer_number, uint8_t *name, | 2485 | bool tox_conference_peer_get_name(const Tox *tox, uint32_t conference_number, uint32_t peer_number, uint8_t *name, |
2427 | TOX_ERR_CONFERENCE *error); | 2486 | TOX_ERR_CONFERENCE_PEER_QUERY *error); |
2428 | 2487 | ||
2429 | /** | 2488 | /** |
2430 | * Copy the public key of peer_number who is in group_number to public_key. | 2489 | * Copy the public key of peer_number who is in conference_number to public_key. |
2431 | * public_key must be TOX_PUBLIC_KEY_SIZE long. | 2490 | * public_key must be TOX_PUBLIC_KEY_SIZE long. |
2432 | * | 2491 | * |
2433 | * returns 0 on success | 2492 | * @return true on success. |
2434 | * returns -1 on failure | ||
2435 | */ | 2493 | */ |
2436 | bool tox_conference_peer_get_public_key(const Tox *tox, uint32_t group_number, uint32_t peer_number, | 2494 | bool tox_conference_peer_get_public_key(const Tox *tox, uint32_t conference_number, uint32_t peer_number, |
2437 | uint8_t *public_key, TOX_ERR_CONFERENCE *error); | 2495 | uint8_t *public_key, TOX_ERR_CONFERENCE_PEER_QUERY *error); |
2438 | 2496 | ||
2439 | /** | 2497 | /** |
2440 | * Check if the current peer_number corresponds to ours. | 2498 | * Return true if passed peer_number corresponds to our own. |
2441 | * | ||
2442 | * return 1 if the peer_number corresponds to ours. | ||
2443 | * return 0 on failure. | ||
2444 | */ | 2499 | */ |
2445 | bool tox_conference_peer_number_is_ours(const Tox *tox, uint32_t group_number, uint32_t peer_number); | 2500 | bool tox_conference_peer_number_is_ours(const Tox *tox, uint32_t conference_number, uint32_t peer_number, |
2501 | TOX_ERR_CONFERENCE_PEER_QUERY *error); | ||
2502 | |||
2503 | typedef enum TOX_ERR_CONFERENCE_INVITE { | ||
2504 | |||
2505 | /** | ||
2506 | * The function returned successfully. | ||
2507 | */ | ||
2508 | TOX_ERR_CONFERENCE_INVITE_OK, | ||
2509 | |||
2510 | /** | ||
2511 | * The conference number passed did not designate a valid conference. | ||
2512 | */ | ||
2513 | TOX_ERR_CONFERENCE_INVITE_CONFERENCE_NOT_FOUND, | ||
2514 | |||
2515 | /** | ||
2516 | * The invite packet failed to send. | ||
2517 | */ | ||
2518 | TOX_ERR_CONFERENCE_INVITE_FAIL_SEND, | ||
2519 | |||
2520 | } TOX_ERR_CONFERENCE_INVITE; | ||
2521 | |||
2446 | 2522 | ||
2447 | /** | 2523 | /** |
2448 | * invite friend_number to group_number | 2524 | * Invites a friend to a conference. |
2449 | * return 0 on success | 2525 | * |
2450 | * return -1 on failure | 2526 | * @param friend_number The friend number of the friend we want to invite. |
2527 | * @param conference_number The conference number of the conference we want to invite the friend to. | ||
2528 | * | ||
2529 | * @return true on success. | ||
2451 | */ | 2530 | */ |
2452 | bool tox_conference_invite(Tox *tox, uint32_t friend_number, uint32_t group_number, TOX_ERR_CONFERENCE *error); | 2531 | bool tox_conference_invite(Tox *tox, uint32_t friend_number, uint32_t conference_number, |
2532 | TOX_ERR_CONFERENCE_INVITE *error); | ||
2533 | |||
2534 | typedef enum TOX_ERR_CONFERENCE_JOIN { | ||
2535 | |||
2536 | /** | ||
2537 | * The function returned successfully. | ||
2538 | */ | ||
2539 | TOX_ERR_CONFERENCE_JOIN_OK, | ||
2540 | |||
2541 | /** | ||
2542 | * The cookie passed has an invalid length. | ||
2543 | */ | ||
2544 | TOX_ERR_CONFERENCE_JOIN_INVALID_LENGTH, | ||
2545 | |||
2546 | /** | ||
2547 | * The conference is not the expected type. This indicates an invalid cookie. | ||
2548 | */ | ||
2549 | TOX_ERR_CONFERENCE_JOIN_WRONG_TYPE, | ||
2550 | |||
2551 | /** | ||
2552 | * The friend number passed does not designate a valid friend. | ||
2553 | */ | ||
2554 | TOX_ERR_CONFERENCE_JOIN_FRIEND_NOT_FOUND, | ||
2555 | |||
2556 | /** | ||
2557 | * Client is already in this conference. | ||
2558 | */ | ||
2559 | TOX_ERR_CONFERENCE_JOIN_DUPLICATE, | ||
2560 | |||
2561 | /** | ||
2562 | * Conference instance failed to initialize. | ||
2563 | */ | ||
2564 | TOX_ERR_CONFERENCE_JOIN_INIT_FAIL, | ||
2565 | |||
2566 | /** | ||
2567 | * The join packet failed to send. | ||
2568 | */ | ||
2569 | TOX_ERR_CONFERENCE_JOIN_FAIL_SEND, | ||
2570 | |||
2571 | } TOX_ERR_CONFERENCE_JOIN; | ||
2572 | |||
2453 | 2573 | ||
2454 | /** | 2574 | /** |
2455 | * Join a group (you need to have been invited first.) using cookie of length obtained | 2575 | * Joins a conference that the client has been invited to. |
2456 | * in the group invite callback. | ||
2457 | * | 2576 | * |
2458 | * returns group number on success | 2577 | * @param friend_number The friend number of the friend who sent the invite. |
2459 | * returns -1 on failure. | 2578 | * @param cookie Received via the `conference_invite` event. |
2579 | * @param length The size of cookie. | ||
2580 | * | ||
2581 | * @return conference number on success, UINT32_MAX on failure. | ||
2460 | */ | 2582 | */ |
2461 | uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length, | 2583 | uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *cookie, size_t length, |
2462 | TOX_ERR_CONFERENCE *error); | 2584 | TOX_ERR_CONFERENCE_JOIN *error); |
2585 | |||
2586 | typedef enum TOX_ERR_CONFERENCE_SEND_MESSAGE { | ||
2587 | |||
2588 | /** | ||
2589 | * The function returned successfully. | ||
2590 | */ | ||
2591 | TOX_ERR_CONFERENCE_SEND_MESSAGE_OK, | ||
2592 | |||
2593 | /** | ||
2594 | * The conference number passed did not designate a valid conference. | ||
2595 | */ | ||
2596 | TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND, | ||
2597 | |||
2598 | /** | ||
2599 | * The message is too long. | ||
2600 | */ | ||
2601 | TOX_ERR_CONFERENCE_SEND_MESSAGE_TOO_LONG, | ||
2602 | |||
2603 | /** | ||
2604 | * The client is not connected to the conference. | ||
2605 | */ | ||
2606 | TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION, | ||
2607 | |||
2608 | /** | ||
2609 | * The message packet failed to send. | ||
2610 | */ | ||
2611 | TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND, | ||
2612 | |||
2613 | } TOX_ERR_CONFERENCE_SEND_MESSAGE; | ||
2614 | |||
2463 | 2615 | ||
2464 | /** | 2616 | /** |
2465 | * send a group message | 2617 | * Send a text chat message to the conference. |
2466 | * return 0 on success | 2618 | * |
2467 | * return -1 on failure | 2619 | * This function creates a conference message packet and pushes it into the send |
2620 | * queue. | ||
2621 | * | ||
2622 | * The message length may not exceed TOX_MAX_MESSAGE_LENGTH. Larger messages | ||
2623 | * must be split by the client and sent as separate messages. Other clients can | ||
2624 | * then reassemble the fragments. | ||
2625 | * | ||
2626 | * @param conference_number The conference number of the conference the message is intended for. | ||
2627 | * @param type Message type (normal, action, ...). | ||
2628 | * @param message A non-NULL pointer to the first element of a byte array | ||
2629 | * containing the message text. | ||
2630 | * @param length Length of the message to be sent. | ||
2631 | * | ||
2632 | * @return true on success. | ||
2468 | */ | 2633 | */ |
2469 | bool tox_conference_send_message(Tox *tox, uint32_t group_number, TOX_MESSAGE_TYPE type, const uint8_t *message, | 2634 | bool tox_conference_send_message(Tox *tox, uint32_t conference_number, TOX_MESSAGE_TYPE type, const uint8_t *message, |
2470 | size_t length, TOX_ERR_CONFERENCE *error); | 2635 | size_t length, TOX_ERR_CONFERENCE_SEND_MESSAGE *error); |
2636 | |||
2637 | typedef enum TOX_ERR_CONFERENCE_TITLE { | ||
2638 | |||
2639 | /** | ||
2640 | * The function returned successfully. | ||
2641 | */ | ||
2642 | TOX_ERR_CONFERENCE_TITLE_OK, | ||
2643 | |||
2644 | /** | ||
2645 | * The conference number passed did not designate a valid conference. | ||
2646 | */ | ||
2647 | TOX_ERR_CONFERENCE_TITLE_CONFERENCE_NOT_FOUND, | ||
2471 | 2648 | ||
2472 | size_t tox_conference_get_title_size(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | 2649 | /** |
2650 | * The title is too long or empty. | ||
2651 | */ | ||
2652 | TOX_ERR_CONFERENCE_TITLE_INVALID_LENGTH, | ||
2653 | |||
2654 | /** | ||
2655 | * The title packet failed to send. | ||
2656 | */ | ||
2657 | TOX_ERR_CONFERENCE_TITLE_FAIL_SEND, | ||
2658 | |||
2659 | } TOX_ERR_CONFERENCE_TITLE; | ||
2660 | |||
2661 | |||
2662 | /** | ||
2663 | * Return the length of the conference title. Return value is unspecified on failure. | ||
2664 | * | ||
2665 | * The return value is equal to the `length` argument received by the last | ||
2666 | * `conference_title` callback. | ||
2667 | */ | ||
2668 | size_t tox_conference_get_title_size(const Tox *tox, uint32_t conference_number, TOX_ERR_CONFERENCE_TITLE *error); | ||
2473 | 2669 | ||
2474 | /** | 2670 | /** |
2475 | * Get group title from group_number and put it in title. | 2671 | * Write the title designated by the given conference number to a byte array. |
2476 | * title needs to be a valid memory location with a max_length size of at least MAX_NAME_LENGTH (128) bytes. | 2672 | * |
2673 | * Call tox_conference_get_title_size to determine the allocation size for the `title` parameter. | ||
2477 | * | 2674 | * |
2478 | * return length of copied title if success. | 2675 | * The data written to `title` is equal to the data received by the last |
2479 | * return -1 if failure. | 2676 | * `conference_title` callback. |
2677 | * | ||
2678 | * @param title A valid memory region large enough to store the title. | ||
2679 | * If this parameter is NULL, this function has no effect. | ||
2680 | * | ||
2681 | * @return true on success. | ||
2480 | */ | 2682 | */ |
2481 | bool tox_conference_get_title(const Tox *tox, uint32_t group_number, uint8_t *title, TOX_ERR_CONFERENCE *error); | 2683 | bool tox_conference_get_title(const Tox *tox, uint32_t conference_number, uint8_t *title, |
2684 | TOX_ERR_CONFERENCE_TITLE *error); | ||
2482 | 2685 | ||
2483 | /** | 2686 | /** |
2484 | * set the group's title, limited to MAX_NAME_LENGTH | 2687 | * Set the conference title and broadcast it to the rest of the conference. |
2485 | * return 0 on success | 2688 | * |
2486 | * return -1 on failure | 2689 | * Title length cannot be longer than TOX_MAX_NAME_LENGTH. |
2690 | * | ||
2691 | * @return true on success. | ||
2487 | */ | 2692 | */ |
2488 | bool tox_conference_set_title(Tox *tox, uint32_t group_number, const uint8_t *title, size_t length, | 2693 | bool tox_conference_set_title(Tox *tox, uint32_t conference_number, const uint8_t *title, size_t length, |
2489 | TOX_ERR_CONFERENCE *error); | 2694 | TOX_ERR_CONFERENCE_TITLE *error); |
2490 | 2695 | ||
2491 | /** | 2696 | /** |
2492 | * Return the number of chats in the instance m. | 2697 | * Return the number of conferences in the Tox instance. |
2493 | * You should use this to determine how much memory to allocate | 2698 | * This should be used to determine how much memory to allocate for `tox_conference_get_chatlist`. |
2494 | * for copy_chatlist. | ||
2495 | */ | 2699 | */ |
2496 | size_t tox_conference_get_chatlist_size(const Tox *tox); | 2700 | size_t tox_conference_get_chatlist_size(const Tox *tox); |
2497 | 2701 | ||
2498 | /** | 2702 | /** |
2499 | * Copy a list of valid chat IDs into the array out_list. | 2703 | * Copy a list of valid conference IDs into the array chatlist. Determine how much space |
2500 | * If out_list is NULL, returns 0. | 2704 | * to allocate for the array with the `tox_conference_get_chatlist_size` function. |
2501 | * Otherwise, returns the number of elements copied. | 2705 | * |
2502 | * If the array was too small, the contents | 2706 | * @return The number of elements copied to the array, or 0 if chatlist is set to NULL. |
2503 | * of out_list will be truncated to list_size. | ||
2504 | */ | 2707 | */ |
2505 | void tox_conference_get_chatlist(const Tox *tox, uint32_t *chatlist); | 2708 | void tox_conference_get_chatlist(const Tox *tox, uint32_t *chatlist); |
2506 | 2709 | ||
2507 | /** | 2710 | /** |
2508 | * return the type of groupchat (TOX_CONFERENCE_TYPE) that group_number is. | 2711 | * Returns the type of conference (TOX_CONFERENCE_TYPE) that conference_number is. Return value is |
2509 | * | 2712 | * unspecified on failure. |
2510 | * return -1 on failure. | ||
2511 | * return type on success. | ||
2512 | */ | 2713 | */ |
2513 | TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t group_number, TOX_ERR_CONFERENCE *error); | 2714 | typedef enum TOX_ERR_CONFERENCE_GET_TYPE { |
2715 | |||
2716 | /** | ||
2717 | * The function returned successfully. | ||
2718 | */ | ||
2719 | TOX_ERR_CONFERENCE_GET_TYPE_OK, | ||
2720 | |||
2721 | /** | ||
2722 | * The conference number passed did not designate a valid conference. | ||
2723 | */ | ||
2724 | TOX_ERR_CONFERENCE_GET_TYPE_CONFERENCE_NOT_FOUND, | ||
2725 | |||
2726 | } TOX_ERR_CONFERENCE_GET_TYPE; | ||
2727 | |||
2728 | |||
2729 | TOX_CONFERENCE_TYPE tox_conference_get_type(const Tox *tox, uint32_t conference_number, | ||
2730 | TOX_ERR_CONFERENCE_GET_TYPE *error); | ||
2514 | 2731 | ||
2515 | 2732 | ||
2516 | /******************************************************************************* | 2733 | /******************************************************************************* |