diff options
Diffstat (limited to 'toxcore/Messenger.h')
-rw-r--r-- | toxcore/Messenger.h | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 4d2b1b20..85f730cf 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #define MAX_NAME_LENGTH 128 | 19 | #define MAX_NAME_LENGTH 128 |
20 | /* TODO(irungentoo): this must depend on other variable. */ | 20 | /* TODO(irungentoo): this must depend on other variable. */ |
21 | #define MAX_STATUSMESSAGE_LENGTH 1007 | 21 | #define MAX_STATUSMESSAGE_LENGTH 1007 |
22 | /* Used for TCP relays in Messenger struct (may need to be % 2 == 0)*/ | 22 | /* Used for TCP relays in Messenger struct (may need to be `% 2 == 0`)*/ |
23 | #define NUM_SAVED_TCP_RELAYS 8 | 23 | #define NUM_SAVED_TCP_RELAYS 8 |
24 | /* This cannot be bigger than 256 */ | 24 | /* This cannot be bigger than 256 */ |
25 | #define MAX_CONCURRENT_FILE_PIPES 256 | 25 | #define MAX_CONCURRENT_FILE_PIPES 256 |
@@ -300,7 +300,7 @@ struct Messenger { | |||
300 | Messenger_Options options; | 300 | Messenger_Options options; |
301 | }; | 301 | }; |
302 | 302 | ||
303 | /* Format: [real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] | 303 | /* Format: `[real_pk (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]` |
304 | * | 304 | * |
305 | * return FRIEND_ADDRESS_SIZE byte address to give to others. | 305 | * return FRIEND_ADDRESS_SIZE byte address to give to others. |
306 | */ | 306 | */ |
@@ -490,40 +490,40 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing); | |||
490 | int m_get_istyping(const Messenger *m, int32_t friendnumber); | 490 | int m_get_istyping(const Messenger *m, int32_t friendnumber); |
491 | 491 | ||
492 | /* Set the function that will be executed when a friend request is received. | 492 | /* Set the function that will be executed when a friend request is received. |
493 | * Function format is function(uint8_t * public_key, uint8_t * data, size_t length) | 493 | * Function format is `function(uint8_t * public_key, uint8_t * data, size_t length)` |
494 | */ | 494 | */ |
495 | void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function); | 495 | void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function); |
496 | 496 | ||
497 | /* Set the function that will be executed when a message from a friend is received. | 497 | /* Set the function that will be executed when a message from a friend is received. |
498 | * Function format is: function(uint32_t friendnumber, unsigned int type, uint8_t * message, uint32_t length) | 498 | * Function format is: `function(uint32_t friendnumber, unsigned int type, uint8_t * message, uint32_t length)` |
499 | */ | 499 | */ |
500 | void m_callback_friendmessage(Messenger *m, m_friend_message_cb *function); | 500 | void m_callback_friendmessage(Messenger *m, m_friend_message_cb *function); |
501 | 501 | ||
502 | /* Set the callback for name changes. | 502 | /* Set the callback for name changes. |
503 | * Function(uint32_t friendnumber, uint8_t *newname, size_t length) | 503 | * `Function(uint32_t friendnumber, uint8_t *newname, size_t length)` |
504 | * You are not responsible for freeing newname. | 504 | * You are not responsible for freeing newname. |
505 | */ | 505 | */ |
506 | void m_callback_namechange(Messenger *m, m_friend_name_cb *function); | 506 | void m_callback_namechange(Messenger *m, m_friend_name_cb *function); |
507 | 507 | ||
508 | /* Set the callback for status message changes. | 508 | /* Set the callback for status message changes. |
509 | * Function(uint32_t friendnumber, uint8_t *newstatus, size_t length) | 509 | * `Function(uint32_t friendnumber, uint8_t *newstatus, size_t length)` |
510 | * | 510 | * |
511 | * You are not responsible for freeing newstatus | 511 | * You are not responsible for freeing newstatus |
512 | */ | 512 | */ |
513 | void m_callback_statusmessage(Messenger *m, m_friend_status_message_cb *function); | 513 | void m_callback_statusmessage(Messenger *m, m_friend_status_message_cb *function); |
514 | 514 | ||
515 | /* Set the callback for status type changes. | 515 | /* Set the callback for status type changes. |
516 | * Function(uint32_t friendnumber, Userstatus kind) | 516 | * `Function(uint32_t friendnumber, Userstatus kind)` |
517 | */ | 517 | */ |
518 | void m_callback_userstatus(Messenger *m, m_friend_status_cb *function); | 518 | void m_callback_userstatus(Messenger *m, m_friend_status_cb *function); |
519 | 519 | ||
520 | /* Set the callback for typing changes. | 520 | /* Set the callback for typing changes. |
521 | * Function(uint32_t friendnumber, uint8_t is_typing) | 521 | * `Function(uint32_t friendnumber, uint8_t is_typing)` |
522 | */ | 522 | */ |
523 | void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function); | 523 | void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function); |
524 | 524 | ||
525 | /* Set the callback for read receipts. | 525 | /* Set the callback for read receipts. |
526 | * Function(uint32_t friendnumber, uint32_t receipt) | 526 | * `Function(uint32_t friendnumber, uint32_t receipt)` |
527 | * | 527 | * |
528 | * If you are keeping a record of returns from m_sendmessage, | 528 | * If you are keeping a record of returns from m_sendmessage, |
529 | * receipt might be one of those values, meaning the message | 529 | * receipt might be one of those values, meaning the message |
@@ -534,14 +534,14 @@ void m_callback_typingchange(Messenger *m, m_friend_typing_cb *function); | |||
534 | void m_callback_read_receipt(Messenger *m, m_friend_read_receipt_cb *function); | 534 | void m_callback_read_receipt(Messenger *m, m_friend_read_receipt_cb *function); |
535 | 535 | ||
536 | /* Set the callback for connection status changes. | 536 | /* Set the callback for connection status changes. |
537 | * function(uint32_t friendnumber, uint8_t status) | 537 | * `function(uint32_t friendnumber, uint8_t status)` |
538 | * | 538 | * |
539 | * Status: | 539 | * Status: |
540 | * 0 -- friend went offline after being previously online. | 540 | * 0 -- friend went offline after being previously online. |
541 | * 1 -- friend went online. | 541 | * 1 -- friend went online. |
542 | * | 542 | * |
543 | * Note that this callback is not called when adding friends, thus the "after | 543 | * Note that this callback is not called when adding friends, thus the |
544 | * being previously online" part. | 544 | * "after being previously online" part. |
545 | * It's assumed that when adding friends, their connection status is offline. | 545 | * It's assumed that when adding friends, their connection status is offline. |
546 | */ | 546 | */ |
547 | void m_callback_connectionstatus(Messenger *m, m_friend_connection_status_cb *function); | 547 | void m_callback_connectionstatus(Messenger *m, m_friend_connection_status_cb *function); |
@@ -556,11 +556,9 @@ void m_callback_connectionstatus_internal_av(Messenger *m, m_friend_connectionst | |||
556 | */ | 556 | */ |
557 | void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function); | 557 | void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function); |
558 | 558 | ||
559 | /**********CONFERENCES************/ | 559 | /** CONFERENCES */ |
560 | 560 | ||
561 | /* Set the callback for conference invites. | 561 | /* Set the callback for conference invites. |
562 | * | ||
563 | * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata) | ||
564 | */ | 562 | */ |
565 | void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function); | 563 | void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function); |
566 | 564 | ||
@@ -571,34 +569,23 @@ void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function | |||
571 | */ | 569 | */ |
572 | int send_conference_invite_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length); | 570 | int send_conference_invite_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length); |
573 | 571 | ||
574 | /****************FILE SENDING*****************/ | 572 | /** FILE SENDING */ |
575 | 573 | ||
576 | 574 | ||
577 | /* Set the callback for file send requests. | 575 | /* Set the callback for file send requests. |
578 | * | ||
579 | * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint32_t filetype, uint64_t filesize, uint8_t *filename, size_t filename_length, void *userdata) | ||
580 | */ | 576 | */ |
581 | void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function); | 577 | void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function); |
582 | 578 | ||
583 | 579 | ||
584 | /* Set the callback for file control requests. | 580 | /* Set the callback for file control requests. |
585 | * | ||
586 | * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, unsigned int control_type, void *userdata) | ||
587 | * | ||
588 | */ | 581 | */ |
589 | void callback_file_control(Messenger *m, m_file_recv_control_cb *function); | 582 | void callback_file_control(Messenger *m, m_file_recv_control_cb *function); |
590 | 583 | ||
591 | /* Set the callback for file data. | 584 | /* Set the callback for file data. |
592 | * | ||
593 | * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, uint8_t *data, size_t length, void *userdata) | ||
594 | * | ||
595 | */ | 585 | */ |
596 | void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function); | 586 | void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function); |
597 | 587 | ||
598 | /* Set the callback for file request chunk. | 588 | /* Set the callback for file request chunk. |
599 | * | ||
600 | * Function(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length, void *userdata) | ||
601 | * | ||
602 | */ | 589 | */ |
603 | void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function); | 590 | void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function); |
604 | 591 | ||
@@ -673,11 +660,9 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
673 | */ | 660 | */ |
674 | uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); | 661 | uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); |
675 | 662 | ||
676 | /*************** A/V related ******************/ | 663 | /** A/V related */ |
677 | 664 | ||
678 | /* Set the callback for msi packets. | 665 | /* Set the callback for msi packets. |
679 | * | ||
680 | * Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata) | ||
681 | */ | 666 | */ |
682 | void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata); | 667 | void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata); |
683 | 668 | ||
@@ -696,7 +681,7 @@ int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, | |||
696 | int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte, | 681 | int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte, |
697 | m_lossy_rtp_packet_cb *function, void *object); | 682 | m_lossy_rtp_packet_cb *function, void *object); |
698 | 683 | ||
699 | /**********************************************/ | 684 | /** CUSTOM PACKETS */ |
700 | 685 | ||
701 | /* Set handlers for custom lossy packets. | 686 | /* Set handlers for custom lossy packets. |
702 | * | 687 | * |
@@ -731,7 +716,7 @@ void custom_lossless_packet_registerhandler(Messenger *m, m_friend_lossless_pack | |||
731 | */ | 716 | */ |
732 | int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length); | 717 | int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length); |
733 | 718 | ||
734 | /**********************************************/ | 719 | /** Messenger constructor/destructor/operations. */ |
735 | 720 | ||
736 | typedef enum Messenger_Error { | 721 | typedef enum Messenger_Error { |
737 | MESSENGER_ERROR_NONE, | 722 | MESSENGER_ERROR_NONE, |
@@ -783,7 +768,7 @@ uint8_t *messenger_save(const Messenger *m, uint8_t *data); | |||
783 | * | 768 | * |
784 | * @param data Data to load. | 769 | * @param data Data to load. |
785 | * @param length Length of data. | 770 | * @param length Length of data. |
786 | * @param type Type of section (STATE_TYPE_*). | 771 | * @param type Type of section (`STATE_TYPE_*`). |
787 | * @param status Result of loading section is stored here if the section is handled. | 772 | * @param status Result of loading section is stored here if the section is handled. |
788 | * @return true iff section handled. | 773 | * @return true iff section handled. |
789 | */ | 774 | */ |