aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_messenger_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_messenger_service.h')
-rw-r--r--src/include/gnunet_messenger_service.h451
1 files changed, 365 insertions, 86 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h
index 0576e239f..1bc68b87b 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 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,19 +39,21 @@ extern "C" {
39#endif 39#endif
40#endif 40#endif
41 41
42#include "platform.h" 42#include "gnunet_common.h"
43#include "gnunet_configuration_lib.h" 43#include "gnunet_configuration_lib.h"
44#include "gnunet_crypto_lib.h"
45#include "gnunet_identity_service.h" 44#include "gnunet_identity_service.h"
46#include "gnunet_mq_lib.h" 45#include "gnunet_reclaim_lib.h"
47#include "gnunet_protocols.h" 46#include "gnunet_reclaim_service.h"
48#include "gnunet_scheduler_lib.h" 47#include "gnunet_scheduler_lib.h"
49#include "gnunet_time_lib.h" 48#include "gnunet_time_lib.h"
49#include "gnunet_util_lib.h"
50 50
51/** 51/**
52 * Version number of GNUnet Messenger API. 52 * Version number of GNUnet Messenger API.
53 *
54 * Current version of the Messenger: 0.3
53 */ 55 */
54#define GNUNET_MESSENGER_VERSION 0x00000001 56#define GNUNET_MESSENGER_VERSION 0x00000003
55 57
56/** 58/**
57 * Identifier of GNUnet MESSENGER Service. 59 * Identifier of GNUnet MESSENGER Service.
@@ -73,6 +75,48 @@ struct GNUNET_MESSENGER_Room;
73 */ 75 */
74struct GNUNET_MESSENGER_Contact; 76struct GNUNET_MESSENGER_Contact;
75 77
78GNUNET_NETWORK_STRUCT_BEGIN
79
80/**
81 * A room entry record specifies which peer is hosting a given room and
82 * may also specify the key to enter it.
83 */
84struct GNUNET_MESSENGER_RoomEntryRecord
85{
86 /**
87 * The peer identity of an open door to a room.
88 */
89 struct GNUNET_PeerIdentity door;
90
91 /**
92 * The hash identifying the port of the room.
93 */
94 struct GNUNET_HashCode key;
95};
96
97GNUNET_NETWORK_STRUCT_END
98
99 GNUNET_NETWORK_STRUCT_BEGIN
100
101/**
102 * A room details record specifies a custom name for a given room and
103 * some additional space for flags.
104 */
105struct GNUNET_MESSENGER_RoomDetailsRecord
106{
107 /**
108 * The custom name for the room.
109 */
110 char name[256];
111
112 /**
113 * The flags of the room.
114 */
115 uint32_t flags;
116};
117
118GNUNET_NETWORK_STRUCT_END
119
76/** 120/**
77 * Enum for the different supported kinds of messages 121 * Enum for the different supported kinds of messages
78 */ 122 */
@@ -154,6 +198,26 @@ enum GNUNET_MESSENGER_MessageKind
154 GNUNET_MESSENGER_KIND_DELETE = 15, 198 GNUNET_MESSENGER_KIND_DELETE = 15,
155 199
156 /** 200 /**
201 * The connection kind. The message contains a #GNUNET_MESSENGER_MessageConnection body.
202 */
203 GNUNET_MESSENGER_KIND_CONNECTION = 16,
204
205 /**
206 * The ticket kind. The message contains a #GNUNET_MESSENGER_MessageTicket body.
207 */
208 GNUNET_MESSENGER_KIND_TICKET = 17,
209
210 /**
211 * The transcript kind. The message contains a #GNUNET_MESSENGER_MessageTranscript body.
212 */
213 GNUNET_MESSENGER_KIND_TRANSCRIPT = 18,
214
215 /**
216 * The tag kind. The message contains a #GNUNET_MESSENGER_MessageTag body.
217 */
218 GNUNET_MESSENGER_KIND_TAG = 19,
219
220 /**
157 * The unknown kind. The message contains an unknown body. 221 * The unknown kind. The message contains an unknown body.
158 */ 222 */
159 GNUNET_MESSENGER_KIND_UNKNOWN = 0 223 GNUNET_MESSENGER_KIND_UNKNOWN = 0
@@ -181,7 +245,7 @@ struct GNUNET_MESSENGER_MessageHeader
181 /** 245 /**
182 * The signature of the senders private key. 246 * The signature of the senders private key.
183 */ 247 */
184 struct GNUNET_IDENTITY_Signature signature; 248 struct GNUNET_CRYPTO_Signature signature;
185 249
186 /** 250 /**
187 * The timestamp of the message. 251 * The timestamp of the message.
@@ -213,12 +277,11 @@ struct GNUNET_MESSENGER_MessageHeader
213struct GNUNET_MESSENGER_MessageInfo 277struct GNUNET_MESSENGER_MessageInfo
214{ 278{
215 /** 279 /**
216 * The senders key to verify its signatures.
217 */
218 struct GNUNET_IDENTITY_PublicKey host_key;
219
220 /**
221 * The version of GNUnet Messenger API. 280 * The version of GNUnet Messenger API.
281 *
282 * The sixteen lower bits represent the lower version number while the sixteen higher bits
283 * represent the higher version number. A different higher version number implies incompatibility
284 * to lower versions while differences in the lower version can still be supported potentially.
222 */ 285 */
223 uint32_t messenger_version; 286 uint32_t messenger_version;
224}; 287};
@@ -234,7 +297,7 @@ struct GNUNET_MESSENGER_MessageJoin
234 /** 297 /**
235 * The senders public key to verify its signatures. 298 * The senders public key to verify its signatures.
236 */ 299 */
237 struct GNUNET_IDENTITY_PublicKey key; 300 struct GNUNET_CRYPTO_PublicKey key;
238}; 301};
239 302
240/** 303/**
@@ -272,7 +335,7 @@ struct GNUNET_MESSENGER_MessageKey
272 /** 335 /**
273 * The new public key which replaces the current senders public key. 336 * The new public key which replaces the current senders public key.
274 */ 337 */
275 struct GNUNET_IDENTITY_PublicKey key; 338 struct GNUNET_CRYPTO_PublicKey key;
276}; 339};
277 340
278/** 341/**
@@ -451,6 +514,87 @@ struct GNUNET_MESSENGER_MessageDelete
451}; 514};
452 515
453/** 516/**
517 * A connection message body
518 * This allows to tell others about connection information about a peer.
519 *
520 * Message-body-size: 8 bytes
521 */
522struct GNUNET_MESSENGER_MessageConnection
523{
524 /**
525 * The amount of connections of a peer.
526 */
527 uint32_t amount;
528
529 /**
530 * The flags about the connections of a peer.
531 */
532 uint32_t flags;
533};
534
535/**
536 * A ticket message body
537 * This allows to exchange ticket identifiers with an audience.
538 *
539 * Message-body-size: 32 bytes
540 */
541struct GNUNET_MESSENGER_MessageTicket
542{
543 /**
544 * The identifier of a RECLAIM ticket.
545 */
546 struct GNUNET_RECLAIM_Identifier identifier;
547};
548
549/**
550 * A transcript message body
551 * This allows reading the content of a sent private message.
552 *
553 * Message-body-size: 68+
554 */
555struct GNUNET_MESSENGER_MessageTranscript
556{
557 /**
558 * The hash of the original message.
559 */
560 struct GNUNET_HashCode hash;
561
562 /**
563 * The key from the recipient of the original message.
564 */
565 struct GNUNET_CRYPTO_PublicKey key;
566
567 /**
568 * The length of the transcribed message.
569 */
570 uint16_t length;
571
572 /**
573 * The data of the transcribed message.
574 */
575 char *data;
576};
577
578/**
579 * A tag message body
580 * This allows tagging a message with a custom tag.
581 *
582 * Message-body-size: 32+
583 */
584struct GNUNET_MESSENGER_MessageTag
585{
586 /**
587 * The hash of the message to tag.
588 */
589 struct GNUNET_HashCode hash;
590
591 /**
592 * The custom tag.
593 */
594 char *tag;
595};
596
597/**
454 * The unified body of a #GNUNET_MESSENGER_Message. 598 * The unified body of a #GNUNET_MESSENGER_Message.
455 */ 599 */
456struct GNUNET_MESSENGER_MessageBody 600struct GNUNET_MESSENGER_MessageBody
@@ -470,8 +614,12 @@ struct GNUNET_MESSENGER_MessageBody
470 struct GNUNET_MESSENGER_MessageInvite invite; 614 struct GNUNET_MESSENGER_MessageInvite invite;
471 struct GNUNET_MESSENGER_MessageText text; 615 struct GNUNET_MESSENGER_MessageText text;
472 struct GNUNET_MESSENGER_MessageFile file; 616 struct GNUNET_MESSENGER_MessageFile file;
473 struct GNUNET_MESSENGER_MessagePrivate private; 617 struct GNUNET_MESSENGER_MessagePrivate privacy;
474 struct GNUNET_MESSENGER_MessageDelete delete; 618 struct GNUNET_MESSENGER_MessageDelete deletion;
619 struct GNUNET_MESSENGER_MessageConnection connection;
620 struct GNUNET_MESSENGER_MessageTicket ticket;
621 struct GNUNET_MESSENGER_MessageTranscript transcript;
622 struct GNUNET_MESSENGER_MessageTag tag;
475 }; 623 };
476}; 624};
477 625
@@ -492,7 +640,8 @@ struct GNUNET_MESSENGER_Message
492}; 640};
493 641
494/** 642/**
495 * Enum for the different supported flags used by message handling 643 * Enum for the different supported flags used by message handling.
644 * Compatible flags can be OR'ed together.
496 */ 645 */
497enum GNUNET_MESSENGER_MessageFlags 646enum GNUNET_MESSENGER_MessageFlags
498{ 647{
@@ -502,38 +651,76 @@ enum GNUNET_MESSENGER_MessageFlags
502 GNUNET_MESSENGER_FLAG_NONE = 0, 651 GNUNET_MESSENGER_FLAG_NONE = 0,
503 652
504 /** 653 /**
654 * The sent flag. The flag indicates that the message was sent by the client.
655 */
656 GNUNET_MESSENGER_FLAG_SENT = 1,
657
658 /**
505 * The private flag. The flag indicates that the message was privately encrypted. 659 * The private flag. The flag indicates that the message was privately encrypted.
506 */ 660 */
507 GNUNET_MESSENGER_FLAG_PRIVATE = 1, 661 GNUNET_MESSENGER_FLAG_PRIVATE = 2,
662
663 /**
664 * The peer flag. The flag indicates that the message was sent by a peer and not a member.
665 */
666 GNUNET_MESSENGER_FLAG_PEER = 4,
667
668 /**
669 * The recent flag. The flag indicates that the message was recently handled by the service.
670 */
671 GNUNET_MESSENGER_FLAG_RECENT = 8,
672
673 /**
674 * The update flag. The flag indicates that the message was updated by the client.
675 */
676 GNUNET_MESSENGER_FLAG_UPDATE = 16,
677
678 /**
679 * The delete flag. The flag indicates that the message was deleted by the service.
680 */
681 GNUNET_MESSENGER_FLAG_DELETE = 32,
508}; 682};
509 683
510/** 684/**
511 * Method called whenever the EGO of a <i>handle</i> changes or if the first connection fails 685 * Enum for the different supported flags used to specify connection handling.
512 * to load a valid EGO and the anonymous key pair will be used instead. 686 * Compatible flags can be OR'ed together.
513 *
514 * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect
515 * @param[in/out] handle Messenger handle
516 */ 687 */
517typedef void 688enum GNUNET_MESSENGER_ConnectionFlags
518(*GNUNET_MESSENGER_IdentityCallback) (void *cls, struct GNUNET_MESSENGER_Handle *handle); 689{
690 /**
691 * The none flag. The flag indicates that the connection is not affected by any modifications.
692 */
693 GNUNET_MESSENGER_FLAG_CONNECTION_NONE = 0,/**< GNUNET_MESSENGER_FLAG_CONNECTION_NONE */
694
695 /**
696 * The auto flag. The flag indicates that a peer will automatically handle routing.
697 */
698 GNUNET_MESSENGER_FLAG_CONNECTION_AUTO = 1,/**< GNUNET_MESSENGER_FLAG_CONNECTION_AUTO */
699};
519 700
520/** 701/**
521 * Method called whenever a message is sent or received from a <i>room</i>. 702 * Method called whenever a message is sent or received from a <i>room</i>.
522 * 703 *
523 * The flag <i>private_message</i> will be #GNUNET_YES if a message was 704 * The <i>flags</i> will indicate with a bitmask if a message was
524 * received privately, otherwise #GNUNET_NO. 705 * received privately or if the message was sent by the client.
525 * 706 *
526 * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect 707 * @param[in/out] cls Closure from #GNUNET_MESSENGER_connect
527 * @param[in] room Room handle 708 * @param[in] room Room handle
528 * @param[in] sender Sender of message 709 * @param[in] sender Sender of message
710 * @param[in] recipient Recipient of message
529 * @param[in] message Newly received or sent message 711 * @param[in] message Newly received or sent message
530 * @param[in] hash Hash identifying the message 712 * @param[in] hash Hash identifying the message
531 * @param[in] flags Flags of the message 713 * @param[in] flags Flags of the message
532 */ 714 */
533typedef void 715typedef void
534(*GNUNET_MESSENGER_MessageCallback) (void *cls, struct GNUNET_MESSENGER_Room *room, 716(*GNUNET_MESSENGER_MessageCallback) (void *cls,
535 const struct GNUNET_MESSENGER_Contact *sender, 717 struct GNUNET_MESSENGER_Room *room,
536 const struct GNUNET_MESSENGER_Message *message, 718 const struct
719 GNUNET_MESSENGER_Contact *sender,
720 const struct
721 GNUNET_MESSENGER_Contact *recipient,
722 const struct
723 GNUNET_MESSENGER_Message *message,
537 const struct GNUNET_HashCode *hash, 724 const struct GNUNET_HashCode *hash,
538 enum GNUNET_MESSENGER_MessageFlags flags); 725 enum GNUNET_MESSENGER_MessageFlags flags);
539 726
@@ -545,45 +732,34 @@ typedef void
545 * @param[in] room Room handle 732 * @param[in] room Room handle
546 * @param[in] contact Contact handle 733 * @param[in] contact Contact handle
547 */ 734 */
548typedef int 735typedef enum GNUNET_GenericReturnValue
549(*GNUNET_MESSENGER_MemberCallback) (void* cls, struct GNUNET_MESSENGER_Room *room, 736(*GNUNET_MESSENGER_MemberCallback) (void *cls,
550 const struct GNUNET_MESSENGER_Contact *contact); 737 struct GNUNET_MESSENGER_Room *room,
738 const struct
739 GNUNET_MESSENGER_Contact *contact);
551 740
552/** 741/**
553 * Set up a handle for the messenger related functions and connects to all necessary services. It will look up the ego 742 * Set up a handle for the messenger related functions and connects to all necessary services. It will use the
554 * key identified by its <i>name</i> and use it for signing all messages from the handle. 743 * a custom name in combination of a private key provided for signing all messages from the handle.
555 * 744 *
556 * @param[in] cfg Configuration to use 745 * @param[in] cfg Configuration to use
557 * @param[in] name Name to look up an ego or NULL to stay anonymous 746 * @param[in] name Name or NULL
558 * @param[in] identity_callback Function called when the EGO of the handle changes 747 * @param[in] key Private key or NULL to stay anonymous
559 * @param[in/out] identity_cls Closure for the <i>identity_callback</i> handler
560 * @param[in] msg_callback Function called when a new message is sent or received 748 * @param[in] msg_callback Function called when a new message is sent or received
561 * @param[in/out] msg_cls Closure for the <i>msg_callback</i> handler 749 * @param[in,out] msg_cls Closure for the <i>msg_callback</i> handler
562 * @return Messenger handle to use, NULL on error 750 * @return Messenger handle to use, NULL on error
563 */ 751 */
564struct GNUNET_MESSENGER_Handle* 752struct GNUNET_MESSENGER_Handle*
565GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, 753GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
566 GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, 754 const char *name,
567 GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls); 755 const struct GNUNET_CRYPTO_PrivateKey *key,
568 756 GNUNET_MESSENGER_MessageCallback msg_callback,
569/** 757 void *msg_cls);
570 * Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All
571 * participated rooms get informed about the key renewal. The handle requires a set name for this function to work and
572 * it needs to be unused by other egos.
573 *
574 * 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
575 * as default.
576 *
577 * @param[in/out] handle Messenger handle to use
578 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
579 */
580int
581GNUNET_MESSENGER_update (struct GNUNET_MESSENGER_Handle *handle);
582 758
583/** 759/**
584 * Disconnect all of the messengers used services and clears up its used memory. 760 * Disconnect all of the messengers used services and clears up its used memory.
585 * 761 *
586 * @param[in/out] handle Messenger handle to use 762 * @param[in,out] handle Messenger handle to use
587 */ 763 */
588void 764void
589GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle); 765GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle);
@@ -598,27 +774,40 @@ const char*
598GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle); 774GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle);
599 775
600/** 776/**
601 * Set the name for the messenger. This will rename the currently used ego and move all stored files related to the current 777 * Set the name for the messenger handle and sends messages renaming your contact in currently
602 * name to its new directory. If anything fails during this process the function returns #GNUNET_NO and the name for 778 * open rooms.
603 * the messenger won't change as specified.
604 * 779 *
605 * @param[in/out] handle Messenger handle to use 780 * @param[in,out] handle Messenger handle to use
606 * @param[in] name Name for the messenger to change to 781 * @param[in] name Name for the messenger to change to
607 * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL 782 * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL
608 */ 783 */
609int 784enum GNUNET_GenericReturnValue
610GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name); 785GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
786 const char *name);
611 787
612/** 788/**
613 * Get the public key used by the messenger or NULL if the anonymous key was used. 789 * Get the public key used by the messenger or NULL if the anonymous key was used.
614 * 790 *
615 * @param[in] handle Messenger handle to use 791 * @param[in] handle Messenger handle to use
616 * @return Used ego's public key or NULL 792 * @return Used public key or NULL
617 */ 793 */
618const struct GNUNET_IDENTITY_PublicKey* 794const struct GNUNET_CRYPTO_PublicKey*
619GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle); 795GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
620 796
621/** 797/**
798 * Set the private key used by the messenger or NULL if the anonymous key should be
799 * used instead. The currently used key will be replaced and the change will get signed
800 * accordingly to be verified by all contacts.
801 *
802 * @param[in,out] handle Messenger handle to use
803 * @param[in] key Private key to change to or NULL
804 * @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL
805 */
806enum GNUNET_GenericReturnValue
807GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle,
808 const struct GNUNET_CRYPTO_PrivateKey *key);
809
810/**
622 * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet 811 * Open a room to send and receive messages. The room will use the specified <i>key</i> as port for the underlying cadet
623 * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>. 812 * service. Opening a room results in opening the port for incoming connections as possible <b>door</b>.
624 * 813 *
@@ -630,12 +819,13 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
630 * 819 *
631 * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) 820 * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. )
632 * 821 *
633 * @param[in/out] handle Messenger handle to use 822 * @param[in,out] handle Messenger handle to use
634 * @param[in] key Hash identifying the port 823 * @param[in] key Hash identifying the port
635 * @return Room handle, NULL on error 824 * @return Room handle, NULL on error
636 */ 825 */
637struct GNUNET_MESSENGER_Room* 826struct GNUNET_MESSENGER_Room*
638GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); 827GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle,
828 const struct GNUNET_HashCode *key);
639 829
640/** 830/**
641 * Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room. 831 * Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room.
@@ -650,28 +840,55 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct
650 * 840 *
651 * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. ) 841 * ( All <b>doors</b> form a ring structured network to shorten the latency sending and receiving messages. )
652 * 842 *
653 * @param[in/out] handle Messenger handle to use 843 * @param[in,out] handle Messenger handle to use
654 * @param[in] door Peer identity of an open <b>door</b> 844 * @param[in] door Peer identity of an open <b>door</b>
655 * @param[in] key Hash identifying the port 845 * @param[in] key Hash identifying the port
656 * @return Room handle, NULL on error 846 * @return Room handle, NULL on error
657 */ 847 */
658struct GNUNET_MESSENGER_Room* 848struct GNUNET_MESSENGER_Room*
659GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, 849GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle,
850 const struct GNUNET_PeerIdentity *door,
660 const struct GNUNET_HashCode *key); 851 const struct GNUNET_HashCode *key);
661 852
662/** 853/**
663 * Close a room which was entered, opened or both in various order and variety. Closing a room will destroy all connections 854 * Close a <i>room</i> which was entered, opened or both in various order and variety. Closing a room will destroy all
664 * from your peer to another and the other way around. 855 * connections from your peer to another and the other way around.
665 * 856 *
666 * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one 857 * ( After a member closes a <b>door</b>, all members entered through that specific <b>door</b> have to use another one
667 * or open the room on their own. ) 858 * or open the room on their own. )
668 * 859 *
669 * @param[in/out] room Room handle 860 * @param[in,out] room Room handle
670 */ 861 */
671void 862void
672GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room); 863GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room);
673 864
674/** 865/**
866 * Searches for a specific <i>contact</i> in a given <i>room</i> and calls a selected <i>callback</i> with a given
867 * closure for each of them containing the contact as a member. The callback will receive a room matching the condition
868 * and the given contact. The function returns the amount of rooms iterated with the given callback.
869 *
870 * @param[in] handle Messenger handle to use
871 * @param[in] contact Contact handle
872 * @param[in] callback Function called for each room
873 * @param[in] cls Closure for the <i>callback</i> handler
874 * @return Amount of rooms iterated
875 */
876int
877GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle,
878 const struct GNUNET_MESSENGER_Contact *contact,
879 GNUNET_MESSENGER_MemberCallback callback,
880 void *cls);
881
882/**
883 * Get the key of a given <i>room</i>.
884 *
885 * @param[in] room Room handle
886 * @return Hash identifying the port or NULL on failure
887 */
888const struct GNUNET_HashCode*
889GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room);
890
891/**
675 * Get the contact of a member in a <i>room</i> which sent a specific message identified with a given <i>hash</i>. 892 * Get the contact of a member in a <i>room</i> which sent a specific message identified with a given <i>hash</i>.
676 * 893 *
677 * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed. 894 * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.
@@ -680,8 +897,23 @@ GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room);
680 * @param[in] hash Hash identifying a message 897 * @param[in] hash Hash identifying a message
681 * @return Contact handle, NULL otherwise 898 * @return Contact handle, NULL otherwise
682 */ 899 */
683struct GNUNET_MESSENGER_Contact* 900const struct GNUNET_MESSENGER_Contact*
684GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); 901GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room,
902 const struct GNUNET_HashCode *hash);
903
904/**
905 * Get the contact of a member in a <i>room</i> which has been targeted as recipient of a specific message identified
906 * with a given <i>hash</i>.
907 *
908 * Notice that contacts are independent of rooms but will be removed if all rooms containing these contacts get closed.
909 *
910 * @param[in] room Room handle
911 * @param[in] hash Hash identifying a message
912 * @return Contact handle, NULL otherwise
913 */
914const struct GNUNET_MESSENGER_Contact*
915GNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room,
916 const struct GNUNET_HashCode *hash);
685 917
686/** 918/**
687 * Get the name used by the <i>contact</i>. 919 * Get the name used by the <i>contact</i>.
@@ -690,19 +922,31 @@ GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const str
690 * @return Name of <i>contact</i> or NULL 922 * @return Name of <i>contact</i> or NULL
691 */ 923 */
692const char* 924const char*
693GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact); 925GNUNET_MESSENGER_contact_get_name (const struct
926 GNUNET_MESSENGER_Contact *contact);
694 927
695/** 928/**
696 * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used. 929 * Get the public key used by the <i>contact</i> or NULL if the anonymous key was used.
697 * 930 *
698 * @param[in] contact Contact handle 931 * @param[in] contact Contact handle
699 * @return Public key of the ego used by <i>contact</i> or NULL 932 * @return Public key used by <i>contact</i> or NULL
700 */ 933 */
701const struct GNUNET_IDENTITY_PublicKey* 934const struct GNUNET_CRYPTO_PublicKey*
702GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact); 935GNUNET_MESSENGER_contact_get_key (const struct
936 GNUNET_MESSENGER_Contact *contact);
703 937
704/** 938/**
705 * Send a <i>message</i> into a </i>room</i>. If you opened the <i>room</i> all entered members will receive the 939 * Get the locally unique id of the <i>contact</i>.
940 *
941 * @param[in] contact Contact handle
942 * @return Locally unique contact id or zero
943 */
944size_t
945GNUNET_MESSENGER_contact_get_id (const struct
946 GNUNET_MESSENGER_Contact *contact);
947
948/**
949 * Send a <i>message</i> into a <i>room</i>. If you opened the <i>room</i> all entered members will receive the
706 * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the 950 * <i>message</i>. If you entered the <i>room</i> through a <b>door</b> all so entered <b>doors</b> will receive the
707 * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively 951 * <i>message</i> as well. All members receiving the <i>message</i> will also propagate this <i>message</i> recursively
708 * as long as the <i>message</i> is unknown to them. 952 * as long as the <i>message</i> is unknown to them.
@@ -715,13 +959,30 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact
715 * 959 *
716 * Sending a message to all members in a given room can be done by providing NULL as contact. 960 * Sending a message to all members in a given room can be done by providing NULL as contact.
717 * 961 *
718 * @param[in/out] room Room handle 962 * @param[in,out] room Room handle
719 * @param[in] message New message to send 963 * @param[in,out] message New message to send
720 * @param[in] contact Contact or NULL 964 * @param[in] contact Contact or NULL
721 */ 965 */
722void 966void
723GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, 967GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
724 const struct GNUNET_MESSENGER_Contact* contact); 968 const struct GNUNET_MESSENGER_Message *message,
969 const struct GNUNET_MESSENGER_Contact *contact);
970
971/**
972 * Delete a message identified by its <i>hash</i> from a <i>room</i>. A deletion will be propagated to all members
973 * of the room as with any other sent message. Notice that a deletion will only request other members of the room
974 * to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored.
975 *
976 * Depending on the implementation other clients may also ignore your deletion request in other circumstances.
977 *
978 * @param[in,out] room Room handle
979 * @param[in] message Message to delete
980 * @param[in] delay Delay to delete the message
981 */
982void
983GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room,
984 const struct GNUNET_HashCode *hash,
985 const struct GNUNET_TIME_Relative delay);
725 986
726/** 987/**
727 * Get the message in a <i>room</i> identified by its <i>hash</i>. 988 * Get the message in a <i>room</i> identified by its <i>hash</i>.
@@ -731,7 +992,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct
731 * @return Message struct or NULL if no message with that hash is known 992 * @return Message struct or NULL if no message with that hash is known
732 */ 993 */
733const struct GNUNET_MESSENGER_Message* 994const struct GNUNET_MESSENGER_Message*
734GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); 995GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room,
996 const struct GNUNET_HashCode *hash);
735 997
736/** 998/**
737 * Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i> 999 * Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i>
@@ -744,8 +1006,25 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const st
744 * @return Amount of members iterated 1006 * @return Amount of members iterated
745 */ 1007 */
746int 1008int
747GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, 1009GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
748 void* cls); 1010 GNUNET_MESSENGER_MemberCallback callback,
1011 void *cls);
1012
1013/**
1014 * Send a <i>ticket</i> into a <i>room</i>. The ticket will automatically be converted
1015 * into a message to be sent only to its audience as a private message.
1016 *
1017 * A ticket can only be sent with this function if its issuer's public key is the one
1018 * being used by the messenger. The audience's public key is not allowed to be the
1019 * anonymous public key. The room needs to contain a member using the audience's public
1020 * key.
1021 *
1022 * @param[in,out] room Room handle
1023 * @param[in] ticket Ticket to send
1024 */
1025void
1026GNUNET_MESSENGER_send_ticket (struct GNUNET_MESSENGER_Room *room,
1027 const struct GNUNET_RECLAIM_Ticket *ticket);
749 1028
750#if 0 /* keep Emacsens' auto-indent happy */ 1029#if 0 /* keep Emacsens' auto-indent happy */
751{ 1030{