diff options
Diffstat (limited to 'src/include/gnunet_messenger_service.h')
-rw-r--r-- | src/include/gnunet_messenger_service.h | 319 |
1 files changed, 241 insertions, 78 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index f8bbc7398..3f039f944 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2022 GNUnet e.V. | 3 | Copyright (C) 2020--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -39,21 +39,14 @@ extern "C" { | |||
39 | #endif | 39 | #endif |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "platform.h" | 42 | #include "gnunet_util_lib.h" |
43 | #include "gnunet_configuration_lib.h" | ||
44 | #include "gnunet_crypto_lib.h" | ||
45 | #include "gnunet_identity_service.h" | ||
46 | #include "gnunet_mq_lib.h" | ||
47 | #include "gnunet_protocols.h" | ||
48 | #include "gnunet_scheduler_lib.h" | ||
49 | #include "gnunet_time_lib.h" | ||
50 | 43 | ||
51 | /** | 44 | /** |
52 | * Version number of GNUnet Messenger API. | 45 | * Version number of GNUnet Messenger API. |
53 | * | 46 | * |
54 | * Current version of the Messenger: 0.1 | 47 | * Current version of the Messenger: 0.4 |
55 | */ | 48 | */ |
56 | #define GNUNET_MESSENGER_VERSION 0x00000001 | 49 | #define GNUNET_MESSENGER_VERSION 0x00000004 |
57 | 50 | ||
58 | /** | 51 | /** |
59 | * Identifier of GNUnet MESSENGER Service. | 52 | * Identifier of GNUnet MESSENGER Service. |
@@ -91,12 +84,12 @@ struct GNUNET_MESSENGER_RoomEntryRecord | |||
91 | /** | 84 | /** |
92 | * The hash identifying the port of the room. | 85 | * The hash identifying the port of the room. |
93 | */ | 86 | */ |
94 | struct GNUNET_HashCode key; | 87 | struct GNUNET_HashCode key GNUNET_PACKED; |
95 | }; | 88 | }; |
96 | 89 | ||
97 | GNUNET_NETWORK_STRUCT_END | 90 | GNUNET_NETWORK_STRUCT_END |
98 | 91 | ||
99 | GNUNET_NETWORK_STRUCT_BEGIN | 92 | GNUNET_NETWORK_STRUCT_BEGIN |
100 | 93 | ||
101 | /** | 94 | /** |
102 | * A room details record specifies a custom name for a given room and | 95 | * A room details record specifies a custom name for a given room and |
@@ -107,7 +100,7 @@ struct GNUNET_MESSENGER_RoomDetailsRecord | |||
107 | /** | 100 | /** |
108 | * The custom name for the room. | 101 | * The custom name for the room. |
109 | */ | 102 | */ |
110 | char name [256]; | 103 | char name[256]; |
111 | 104 | ||
112 | /** | 105 | /** |
113 | * The flags of the room. | 106 | * The flags of the room. |
@@ -198,6 +191,26 @@ enum GNUNET_MESSENGER_MessageKind | |||
198 | GNUNET_MESSENGER_KIND_DELETE = 15, | 191 | GNUNET_MESSENGER_KIND_DELETE = 15, |
199 | 192 | ||
200 | /** | 193 | /** |
194 | * The connection kind. The message contains a #GNUNET_MESSENGER_MessageConnection body. | ||
195 | */ | ||
196 | GNUNET_MESSENGER_KIND_CONNECTION = 16, | ||
197 | |||
198 | /** | ||
199 | * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body. | ||
200 | */ | ||
201 | GNUNET_MESSENGER_KIND_TICKET = 17, | ||
202 | |||
203 | /** | ||
204 | * The transcript kind. The message contains a #GNUNET_MESSENGER_MessageTranscript body. | ||
205 | */ | ||
206 | GNUNET_MESSENGER_KIND_TRANSCRIPT = 18, | ||
207 | |||
208 | /** | ||
209 | * The tag kind. The message contains a #GNUNET_MESSENGER_MessageTag body. | ||
210 | */ | ||
211 | GNUNET_MESSENGER_KIND_TAG = 19, | ||
212 | |||
213 | /** | ||
201 | * The unknown kind. The message contains an unknown body. | 214 | * The unknown kind. The message contains an unknown body. |
202 | */ | 215 | */ |
203 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 | 216 | GNUNET_MESSENGER_KIND_UNKNOWN = 0 |
@@ -225,7 +238,7 @@ struct GNUNET_MESSENGER_MessageHeader | |||
225 | /** | 238 | /** |
226 | * The signature of the senders private key. | 239 | * The signature of the senders private key. |
227 | */ | 240 | */ |
228 | struct GNUNET_IDENTITY_Signature signature; | 241 | struct GNUNET_CRYPTO_Signature signature; |
229 | 242 | ||
230 | /** | 243 | /** |
231 | * The timestamp of the message. | 244 | * The timestamp of the message. |
@@ -257,11 +270,6 @@ struct GNUNET_MESSENGER_MessageHeader | |||
257 | struct GNUNET_MESSENGER_MessageInfo | 270 | struct GNUNET_MESSENGER_MessageInfo |
258 | { | 271 | { |
259 | /** | 272 | /** |
260 | * The senders key to verify its signatures. | ||
261 | */ | ||
262 | struct GNUNET_IDENTITY_PublicKey host_key; | ||
263 | |||
264 | /** | ||
265 | * The version of GNUnet Messenger API. | 273 | * The version of GNUnet Messenger API. |
266 | * | 274 | * |
267 | * The sixteen lower bits represent the lower version number while the sixteen higher bits | 275 | * The sixteen lower bits represent the lower version number while the sixteen higher bits |
@@ -282,7 +290,7 @@ struct GNUNET_MESSENGER_MessageJoin | |||
282 | /** | 290 | /** |
283 | * The senders public key to verify its signatures. | 291 | * The senders public key to verify its signatures. |
284 | */ | 292 | */ |
285 | struct GNUNET_IDENTITY_PublicKey key; | 293 | struct GNUNET_CRYPTO_PublicKey key; |
286 | }; | 294 | }; |
287 | 295 | ||
288 | /** | 296 | /** |
@@ -320,7 +328,7 @@ struct GNUNET_MESSENGER_MessageKey | |||
320 | /** | 328 | /** |
321 | * The new public key which replaces the current senders public key. | 329 | * The new public key which replaces the current senders public key. |
322 | */ | 330 | */ |
323 | struct GNUNET_IDENTITY_PublicKey key; | 331 | struct GNUNET_CRYPTO_PublicKey key; |
324 | }; | 332 | }; |
325 | 333 | ||
326 | /** | 334 | /** |
@@ -499,6 +507,87 @@ struct GNUNET_MESSENGER_MessageDelete | |||
499 | }; | 507 | }; |
500 | 508 | ||
501 | /** | 509 | /** |
510 | * A connection message body | ||
511 | * This allows to tell others about connection information about a peer. | ||
512 | * | ||
513 | * Message-body-size: 8 bytes | ||
514 | */ | ||
515 | struct GNUNET_MESSENGER_MessageConnection | ||
516 | { | ||
517 | /** | ||
518 | * The amount of connections of a peer. | ||
519 | */ | ||
520 | uint32_t amount; | ||
521 | |||
522 | /** | ||
523 | * The flags about the connections of a peer. | ||
524 | */ | ||
525 | uint32_t flags; | ||
526 | }; | ||
527 | |||
528 | /** | ||
529 | * A ticket message body | ||
530 | * This allows to exchange ticket identifiers with an audience. | ||
531 | * | ||
532 | * Message-body-size: 0+ bytes | ||
533 | */ | ||
534 | struct GNUNET_MESSENGER_MessageTicket | ||
535 | { | ||
536 | /** | ||
537 | * The identifier of a ticket. | ||
538 | */ | ||
539 | char *identifier; | ||
540 | }; | ||
541 | |||
542 | /** | ||
543 | * A transcript message body | ||
544 | * This allows reading the content of a sent private message. | ||
545 | * | ||
546 | * Message-body-size: 68+ | ||
547 | */ | ||
548 | struct GNUNET_MESSENGER_MessageTranscript | ||
549 | { | ||
550 | /** | ||
551 | * The hash of the original message. | ||
552 | */ | ||
553 | struct GNUNET_HashCode hash; | ||
554 | |||
555 | /** | ||
556 | * The key from the recipient of the original message. | ||
557 | */ | ||
558 | struct GNUNET_CRYPTO_PublicKey key; | ||
559 | |||
560 | /** | ||
561 | * The length of the transcribed message. | ||
562 | */ | ||
563 | uint16_t length; | ||
564 | |||
565 | /** | ||
566 | * The data of the transcribed message. | ||
567 | */ | ||
568 | char *data; | ||
569 | }; | ||
570 | |||
571 | /** | ||
572 | * A tag message body | ||
573 | * This allows tagging a message with a custom tag. | ||
574 | * | ||
575 | * Message-body-size: 32+ | ||
576 | */ | ||
577 | struct GNUNET_MESSENGER_MessageTag | ||
578 | { | ||
579 | /** | ||
580 | * The hash of the message to tag. | ||
581 | */ | ||
582 | struct GNUNET_HashCode hash; | ||
583 | |||
584 | /** | ||
585 | * The custom tag. | ||
586 | */ | ||
587 | char *tag; | ||
588 | }; | ||
589 | |||
590 | /** | ||
502 | * The unified body of a #GNUNET_MESSENGER_Message. | 591 | * The unified body of a #GNUNET_MESSENGER_Message. |
503 | */ | 592 | */ |
504 | struct GNUNET_MESSENGER_MessageBody | 593 | struct GNUNET_MESSENGER_MessageBody |
@@ -520,6 +609,10 @@ struct GNUNET_MESSENGER_MessageBody | |||
520 | struct GNUNET_MESSENGER_MessageFile file; | 609 | struct GNUNET_MESSENGER_MessageFile file; |
521 | struct GNUNET_MESSENGER_MessagePrivate privacy; | 610 | struct GNUNET_MESSENGER_MessagePrivate privacy; |
522 | struct GNUNET_MESSENGER_MessageDelete deletion; | 611 | struct GNUNET_MESSENGER_MessageDelete deletion; |
612 | struct GNUNET_MESSENGER_MessageConnection connection; | ||
613 | struct GNUNET_MESSENGER_MessageTicket ticket; | ||
614 | struct GNUNET_MESSENGER_MessageTranscript transcript; | ||
615 | struct GNUNET_MESSENGER_MessageTag tag; | ||
523 | }; | 616 | }; |
524 | }; | 617 | }; |
525 | 618 | ||
@@ -540,7 +633,7 @@ struct GNUNET_MESSENGER_Message | |||
540 | }; | 633 | }; |
541 | 634 | ||
542 | /** | 635 | /** |
543 | * Enum for the different supported flags used by message handling | 636 | * Enum for the different supported flags used by message handling. |
544 | * Compatible flags can be OR'ed together. | 637 | * Compatible flags can be OR'ed together. |
545 | */ | 638 | */ |
546 | enum GNUNET_MESSENGER_MessageFlags | 639 | enum GNUNET_MESSENGER_MessageFlags |
@@ -559,18 +652,44 @@ enum GNUNET_MESSENGER_MessageFlags | |||
559 | * The private flag. The flag indicates that the message was privately encrypted. | 652 | * The private flag. The flag indicates that the message was privately encrypted. |
560 | */ | 653 | */ |
561 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, | 654 | GNUNET_MESSENGER_FLAG_PRIVATE = 2, |
655 | |||
656 | /** | ||
657 | * The peer flag. The flag indicates that the message was sent by a peer and not a member. | ||
658 | */ | ||
659 | GNUNET_MESSENGER_FLAG_PEER = 4, | ||
660 | |||
661 | /** | ||
662 | * The recent flag. The flag indicates that the message was recently handled by the service. | ||
663 | */ | ||
664 | GNUNET_MESSENGER_FLAG_RECENT = 8, | ||
665 | |||
666 | /** | ||
667 | * The update flag. The flag indicates that the message was updated by the client. | ||
668 | */ | ||
669 | GNUNET_MESSENGER_FLAG_UPDATE = 16, | ||
670 | |||
671 | /** | ||
672 | * The delete flag. The flag indicates that the message was deleted by the service. | ||
673 | */ | ||
674 | GNUNET_MESSENGER_FLAG_DELETE = 32, | ||
562 | }; | 675 | }; |
563 | 676 | ||
564 | /** | 677 | /** |
565 | * Method called whenever the EGO of a <i>handle</i> changes or if the first connection fails | 678 | * Enum for the different supported flags used to specify connection handling. |
566 | * to load a valid EGO and the anonymous key pair will be used instead. | 679 | * Compatible flags can be OR'ed together. |
567 | * | ||
568 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect | ||
569 | * @param[in/out] handle Messenger handle | ||
570 | */ | 680 | */ |
571 | typedef void | 681 | enum GNUNET_MESSENGER_ConnectionFlags |
572 | (*GNUNET_MESSENGER_IdentityCallback) (void *cls, | 682 | { |
573 | struct GNUNET_MESSENGER_Handle *handle); | 683 | /** |
684 | * The none flag. The flag indicates that the connection is not affected by any modifications. | ||
685 | */ | ||
686 | GNUNET_MESSENGER_FLAG_CONNECTION_NONE = 0,/**< GNUNET_MESSENGER_FLAG_CONNECTION_NONE */ | ||
687 | |||
688 | /** | ||
689 | * The auto flag. The flag indicates that a peer will automatically handle routing. | ||
690 | */ | ||
691 | GNUNET_MESSENGER_FLAG_CONNECTION_AUTO = 1,/**< GNUNET_MESSENGER_FLAG_CONNECTION_AUTO */ | ||
692 | }; | ||
574 | 693 | ||
575 | /** | 694 | /** |
576 | * Method called whenever a message is sent or received from a <i>room</i>. | 695 | * Method called whenever a message is sent or received from a <i>room</i>. |
@@ -581,6 +700,7 @@ typedef void | |||
581 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect | 700 | * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect |
582 | * @param[in] room Room handle | 701 | * @param[in] room Room handle |
583 | * @param[in] sender Sender of message | 702 | * @param[in] sender Sender of message |
703 | * @param[in] recipient Recipient of message | ||
584 | * @param[in] message Newly received or sent message | 704 | * @param[in] message Newly received or sent message |
585 | * @param[in] hash Hash identifying the message | 705 | * @param[in] hash Hash identifying the message |
586 | * @param[in] flags Flags of the message | 706 | * @param[in] flags Flags of the message |
@@ -588,8 +708,12 @@ typedef void | |||
588 | typedef void | 708 | typedef void |
589 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, | 709 | (*GNUNET_MESSENGER_MessageCallback) (void *cls, |
590 | struct GNUNET_MESSENGER_Room *room, | 710 | struct GNUNET_MESSENGER_Room *room, |
591 | const struct GNUNET_MESSENGER_Contact *sender, | 711 | const struct |
592 | const struct GNUNET_MESSENGER_Message *message, | 712 | GNUNET_MESSENGER_Contact *sender, |
713 | const struct | ||
714 | GNUNET_MESSENGER_Contact *recipient, | ||
715 | const struct | ||
716 | GNUNET_MESSENGER_Message *message, | ||
593 | const struct GNUNET_HashCode *hash, | 717 | const struct GNUNET_HashCode *hash, |
594 | enum GNUNET_MESSENGER_MessageFlags flags); | 718 | enum GNUNET_MESSENGER_MessageFlags flags); |
595 | 719 | ||
@@ -601,49 +725,34 @@ typedef void | |||
601 | * @param[in] room Room handle | 725 | * @param[in] room Room handle |
602 | * @param[in] contact Contact handle | 726 | * @param[in] contact Contact handle |
603 | */ | 727 | */ |
604 | typedef int | 728 | typedef enum GNUNET_GenericReturnValue |
605 | (*GNUNET_MESSENGER_MemberCallback) (void* cls, | 729 | (*GNUNET_MESSENGER_MemberCallback) (void *cls, |
606 | struct GNUNET_MESSENGER_Room *room, | 730 | struct GNUNET_MESSENGER_Room *room, |
607 | const struct GNUNET_MESSENGER_Contact *contact); | 731 | const struct |
732 | GNUNET_MESSENGER_Contact *contact); | ||
608 | 733 | ||
609 | /** | 734 | /** |
610 | * Set up a handle for the messenger related functions and connects to all necessary services. It will look up the ego | 735 | * Set up a handle for the messenger related functions and connects to all necessary services. It will use the |
611 | * key identified by its <i>name</i> and use it for signing all messages from the handle. | 736 | * a custom name in combination of a private key provided for signing all messages from the handle. |
612 | * | 737 | * |
613 | * @param[in] cfg Configuration to use | 738 | * @param[in] cfg Configuration to use |
614 | * @param[in] name Name to look up an ego or NULL to stay anonymous | 739 | * @param[in] name Name or NULL |
615 | * @param[in] identity_callback Function called when the EGO of the handle changes | 740 | * @param[in] key Private key or NULL to stay anonymous |
616 | * @param[in/out] identity_cls Closure for the <i>identity_callback</i> handler | ||
617 | * @param[in] msg_callback Function called when a new message is sent or received | 741 | * @param[in] msg_callback Function called when a new message is sent or received |
618 | * @param[in/out] msg_cls Closure for the <i>msg_callback</i> handler | 742 | * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler |
619 | * @return Messenger handle to use, NULL on error | 743 | * @return Messenger handle to use, NULL on error |
620 | */ | 744 | */ |
621 | struct GNUNET_MESSENGER_Handle* | 745 | struct GNUNET_MESSENGER_Handle* |
622 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 746 | GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
623 | const char *name, | 747 | const char *name, |
624 | GNUNET_MESSENGER_IdentityCallback identity_callback, | 748 | const struct GNUNET_CRYPTO_PrivateKey *key, |
625 | void *identity_cls, | ||
626 | GNUNET_MESSENGER_MessageCallback msg_callback, | 749 | GNUNET_MESSENGER_MessageCallback msg_callback, |
627 | void *msg_cls); | 750 | void *msg_cls); |
628 | 751 | ||
629 | /** | 752 | /** |
630 | * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All | ||
631 | * participated rooms get informed about the key renewal. The handle requires a set name for this function to work and | ||
632 | * it needs to be unused by other egos. | ||
633 | * | ||
634 | * Keep in mind that this will fully delete the old ego key (if any is used) even if any other service wants to use it | ||
635 | * as default. | ||
636 | * | ||
637 | * @param[in/out] handle Messenger handle to use | ||
638 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
639 | */ | ||
640 | int | ||
641 | GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle); | ||
642 | |||
643 | /** | ||
644 | * Disconnect all of the messengers used services and clears up its used memory. | 753 | * Disconnect all of the messengers used services and clears up its used memory. |
645 | * | 754 | * |
646 | * @param[in/out] handle Messenger handle to use | 755 | * @param[in,out] handle Messenger handle to use |
647 | */ | 756 | */ |
648 | void | 757 | void |
649 | GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle); | 758 | GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle); |
@@ -658,15 +767,14 @@ const char* | |||
658 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); | 767 | GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); |
659 | 768 | ||
660 | /** | 769 | /** |
661 | * Set the name for the messenger. This will rename the currently used ego and move all stored files related to the current | 770 | * Set the name for the messenger handle and sends messages renaming your contact in currently |
662 | * name to its new directory. If anything fails during this process the function returns #GNUNET_NO and the name for | 771 | * open rooms. |
663 | * the messenger won't change as specified. | ||
664 | * | 772 | * |
665 | * @param[in/out] handle Messenger handle to use | 773 | * @param[in,out] handle Messenger handle to use |
666 | * @param[in] name Name for the messenger to change to | 774 | * @param[in] name Name for the messenger to change to |
667 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | 775 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL |
668 | */ | 776 | */ |
669 | int | 777 | enum GNUNET_GenericReturnValue |
670 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, | 778 | GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, |
671 | const char *name); | 779 | const char *name); |
672 | 780 | ||
@@ -674,12 +782,25 @@ GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, | |||
674 | * Get the public key used by the messenger or NULL if the anonymous key was used. | 782 | * Get the public key used by the messenger or NULL if the anonymous key was used. |
675 | * | 783 | * |
676 | * @param[in] handle Messenger handle to use | 784 | * @param[in] handle Messenger handle to use |
677 | * @return Used ego's public key or NULL | 785 | * @return Used public key or NULL |
678 | */ | 786 | */ |
679 | const struct GNUNET_IDENTITY_PublicKey* | 787 | const struct GNUNET_CRYPTO_PublicKey* |
680 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | 788 | GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); |
681 | 789 | ||
682 | /** | 790 | /** |
791 | * Set the private key used by the messenger or NULL if the anonymous key should be | ||
792 | * used instead. The currently used key will be replaced and the change will get signed | ||
793 | * accordingly to be verified by all contacts. | ||
794 | * | ||
795 | * @param[in,out] handle Messenger handle to use | ||
796 | * @param[in] key Private key to change to or NULL | ||
797 | * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL | ||
798 | */ | ||
799 | enum GNUNET_GenericReturnValue | ||
800 | GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, | ||
801 | const struct GNUNET_CRYPTO_PrivateKey *key); | ||
802 | |||
803 | /** | ||
683 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet | 804 | * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet |
684 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. | 805 | * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. |
685 | * | 806 | * |
@@ -691,7 +812,7 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); | |||
691 | * | 812 | * |
692 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) | 813 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) |
693 | * | 814 | * |
694 | * @param[in/out] handle Messenger handle to use | 815 | * @param[in,out] handle Messenger handle to use |
695 | * @param[in] key Hash identifying the port | 816 | * @param[in] key Hash identifying the port |
696 | * @return Room handle, NULL on error | 817 | * @return Room handle, NULL on error |
697 | */ | 818 | */ |
@@ -712,7 +833,7 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, | |||
712 | * | 833 | * |
713 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) | 834 | * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) |
714 | * | 835 | * |
715 | * @param[in/out] handle Messenger handle to use | 836 | * @param[in,out] handle Messenger handle to use |
716 | * @param[in] door Peer identity of an open <b>door</b> | 837 | * @param[in] door Peer identity of an open <b>door</b> |
717 | * @param[in] key Hash identifying the port | 838 | * @param[in] key Hash identifying the port |
718 | * @return Room handle, NULL on error | 839 | * @return Room handle, NULL on error |
@@ -729,7 +850,7 @@ GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, | |||
729 | * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one | 850 | * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one |
730 | * or open the room on their own. ) | 851 | * or open the room on their own. ) |
731 | * | 852 | * |
732 | * @param[in/out] room Room handle | 853 | * @param[in,out] room Room handle |
733 | */ | 854 | */ |
734 | void | 855 | void |
735 | GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); | 856 | GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); |
@@ -774,25 +895,51 @@ GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, | |||
774 | const struct GNUNET_HashCode *hash); | 895 | const struct GNUNET_HashCode *hash); |
775 | 896 | ||
776 | /** | 897 | /** |
898 | * Get the contact of a member in a <i>room</i> which has been targeted as recipient of a specific message identified | ||
899 | * with a given <i>hash</i>. | ||
900 | * | ||
901 | * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed. | ||
902 | * | ||
903 | * @param[in] room Room handle | ||
904 | * @param[in] hash Hash identifying a message | ||
905 | * @return Contact handle, NULL otherwise | ||
906 | */ | ||
907 | const struct GNUNET_MESSENGER_Contact* | ||
908 | GNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room, | ||
909 | const struct GNUNET_HashCode *hash); | ||
910 | |||
911 | /** | ||
777 | * Get the name used by the <i>contact</i>. | 912 | * Get the name used by the <i>contact</i>. |
778 | * | 913 | * |
779 | * @param[in] contact Contact handle | 914 | * @param[in] contact Contact handle |
780 | * @return Name of <i>contact</i> or NULL | 915 | * @return Name of <i>contact</i> or NULL |
781 | */ | 916 | */ |
782 | const char* | 917 | const char* |
783 | GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact); | 918 | GNUNET_MESSENGER_contact_get_name (const struct |
919 | GNUNET_MESSENGER_Contact *contact); | ||
784 | 920 | ||
785 | /** | 921 | /** |
786 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. | 922 | * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. |
787 | * | 923 | * |
788 | * @param[in] contact Contact handle | 924 | * @param[in] contact Contact handle |
789 | * @return Public key of the ego used by <i>contact</i> or NULL | 925 | * @return Public key used by <i>contact</i> or NULL |
790 | */ | 926 | */ |
791 | const struct GNUNET_IDENTITY_PublicKey* | 927 | const struct GNUNET_CRYPTO_PublicKey* |
792 | GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact); | 928 | GNUNET_MESSENGER_contact_get_key (const struct |
929 | GNUNET_MESSENGER_Contact *contact); | ||
793 | 930 | ||
794 | /** | 931 | /** |
795 | * Send a <i>message</i> into a </i>room</i>. If you opened the <i>room</i> all entered members will receive the | 932 | * Get the locally unique id of the <i>contact</i>. |
933 | * | ||
934 | * @param[in] contact Contact handle | ||
935 | * @return Locally unique contact id or zero | ||
936 | */ | ||
937 | size_t | ||
938 | GNUNET_MESSENGER_contact_get_id (const struct | ||
939 | GNUNET_MESSENGER_Contact *contact); | ||
940 | |||
941 | /** | ||
942 | * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the | ||
796 | * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the | 943 | * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the |
797 | * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively | 944 | * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively |
798 | * as long as the <i>message</i> is unknown to them. | 945 | * as long as the <i>message</i> is unknown to them. |
@@ -805,14 +952,30 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact | |||
805 | * | 952 | * |
806 | * Sending a message to all members in a given room can be done by providing NULL as contact. | 953 | * Sending a message to all members in a given room can be done by providing NULL as contact. |
807 | * | 954 | * |
808 | * @param[in/out] room Room handle | 955 | * @param[in,out] room Room handle |
809 | * @param[in] message New message to send | 956 | * @param[in,out] message New message to send |
810 | * @param[in] contact Contact or NULL | 957 | * @param[in] contact Contact or NULL |
811 | */ | 958 | */ |
812 | void | 959 | void |
813 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, | 960 | GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, |
814 | const struct GNUNET_MESSENGER_Message *message, | 961 | const struct GNUNET_MESSENGER_Message *message, |
815 | const struct GNUNET_MESSENGER_Contact* contact); | 962 | const struct GNUNET_MESSENGER_Contact *contact); |
963 | |||
964 | /** | ||
965 | * Delete a message identified by its <i>hash</i> from a <i>room</i>. A deletion will be propagated to all members | ||
966 | * of the room as with any other sent message. Notice that a deletion will only request other members of the room | ||
967 | * to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored. | ||
968 | * | ||
969 | * Depending on the implementation other clients may also ignore your deletion request in other circumstances. | ||
970 | * | ||
971 | * @param[in,out] room Room handle | ||
972 | * @param[in] message Message to delete | ||
973 | * @param[in] delay Delay to delete the message | ||
974 | */ | ||
975 | void | ||
976 | GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, | ||
977 | const struct GNUNET_HashCode *hash, | ||
978 | const struct GNUNET_TIME_Relative delay); | ||
816 | 979 | ||
817 | /** | 980 | /** |
818 | * Get the message in a <i>room</i> identified by its <i>hash</i>. | 981 | * Get the message in a <i>room</i> identified by its <i>hash</i>. |
@@ -838,7 +1001,7 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, | |||
838 | int | 1001 | int |
839 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, | 1002 | GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, |
840 | GNUNET_MESSENGER_MemberCallback callback, | 1003 | GNUNET_MESSENGER_MemberCallback callback, |
841 | void* cls); | 1004 | void *cls); |
842 | 1005 | ||
843 | #if 0 /* keep Emacsens' auto-indent happy */ | 1006 | #if 0 /* keep Emacsens' auto-indent happy */ |
844 | { | 1007 | { |