2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @author Gabor X Toth
18 * @author Christian Grothoff
21 * Social service; implements social interactions through the PSYC service.
24 /** @defgroup social Social service
25 Social interactions through the PSYC service.
29 The social service provides an API for social interactions based on a one-to-many messaging model.
30 It manages subscriptions of applications to places, provides messaging functionality in places,
31 allows access to the local message history and manages the GNS zone of _egos_ (user identities).
33 The service stores private and public keys of subscribed places, as well as files received in subscribed places.
35 # Concepts and terminology
39 An _ego_ is an identity of a user, a private-public key pair.
40 A _nym_ is an identity of another user in the network, identified by its public key.
41 Each user can have multiple identities.
43 struct GNUNET_SOCIAL_Ego and struct GNUNET_SOCIAL_Nym represents one of these identities.
47 A _place_ is where social interactions happen. It is owned and created by an _ego_.
48 Creating a new place happens by an _ego_ entering a new place as a _host_,
49 where _guests_ can enter later to receive messages sent to the place.
51 A place is identified by its public key.
53 - struct GNUNET_SOCIAL_Host represents a place entered as host,
54 - struct GNUNET_SOCIAL_Guest is used for a place entered as guest.
55 - A struct GNUNET_SOCIAL_Place can be obtained for both a host and guest place
56 using GNUNET_SOCIAL_host_get_place() and GNUNET_SOCIAL_guest_get_place()
57 and can be used with API functions common to hosts and guests.
61 Messages sent to places are stored locally by the PSYCstore service, and can be queried any time.
62 GNUNET_SOCIAL_history_replay_latest() retrieves the latest N messages sent to the place,
63 while GNUNET_SOCIAL_history_replay() is used to query a given message ID range.
67 The GNU Name System is used for assigning human-readable names to nyms and places.
68 There's a _GNS zone_ corresponding to each _nym_.
69 An _ego_ can publish PKEY and PLACE records in its own zone, pointing to nyms and places, respectively.
71 ## Announcement, talk request
73 The host can _announce_ messages to the place, using GNUNET_SOCIAL_host_announce().
74 Guests can send _talk_ requests to the host, using GNUNET_SOCIAL_guest_talk().
75 The host receives talk requests of guests and can _relay_ them to the place,
76 or process it using a message handler function.
80 ## Connecting to the service
82 A client first establishes an _application connection_ to the service using
83 GNUNET_SOCIAL_app_connect() providing its _application ID_, then receives the
84 public keys of subscribed places and available egos in response.
86 ## Reconnecting to places
88 Then the application can reconnect to its subscribed places by establishing
89 _place connections_ with GNUNET_SOCIAL_host_enter_reconnect() and
90 GNUNET_SOCIAL_guest_enter_reconnect().
92 ## Subscribing to a place
94 Entering and subscribing a new host or guest place is done using
95 GNUNET_SOCIAL_host_enter() and GNUNET_SOCIAL_guest_enter().
97 ## Disconnecting from a place
99 An application can disconnect from a place while the social service keeps its
100 network connection active, using GNUNET_SOCIAL_host_disconnect() and
101 GNUNET_SOCIAL_guest_disconnect().
105 To permanently leave a place, see GNUNET_SOCIAL_host_leave() and GNUNET_SOCIAL_guest_leave().
106 When leaving a place its network connections are closed and all applications are unsubscribed from the place.
112 Human conversation in a private or public place.
117 Message ID this message is in reply to.
120 Thread ID, the first message ID in the thread.
125 FIXME: Are nyms a different data type from egos and person entities?
126 Do they have a different format than any other entity address?
127 Questions and thoughts on how to fix this in "questions.org"
130 Signature of the message body and its variables by the author.
138 Notification about a place.
140 TODO: Applications can decide to auto-subscribe to certain places,
141 e.g. files under a given size.
148 GNS name of the place in a globally unique .zkey zone
150 FIXME: A custom _gns PSYC data type should be avoidable by parsing
151 and interpreting PSYC uniforms appropriately.
152 Thoughts on this in "questions.org"
159 FIXME: _key_pub can't be the data type for GNUnet-specific cryptographic
160 addressing. Questions and thoughts on how to fix this in "questions.org"
165 ##### _list_peer_relays
166 List of peer IDs of relays
168 ## _notice_place_file
170 Notification about a place hosting a file.
174 The environment of _notice_place above, plus the following:
185 #### _description_file
190 Messages with a _file method contain a file,
191 which is saved to disk upon reception at the following location:
192 $GNUNET_DATA_HOME/social/files/<H(place_pub)>/<H(message_id)>
205 #### _description_file
212 #ifndef GNUNET_SOCIAL_SERVICE_H
213 #define GNUNET_SOCIAL_SERVICE_H
218 #if 0 /* keep Emacsens' auto-indent happy */
224 #include "gnunet_util_lib.h"
225 #include "gnunet_psyc_util_lib.h"
226 #include "gnunet_identity_service.h"
227 #include "gnunet_namestore_service.h"
228 #include "gnunet_psyc_service.h"
232 * Version number of GNUnet Social API.
234 #define GNUNET_SOCIAL_VERSION 0x00000000
237 * Maximum size of client ID including '\0' terminator.
239 #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256
241 enum GNUNET_SOCIAL_MsgProcFlags {
242 GNUNET_SOCIAL_MSG_PROC_NONE = 0,
243 GNUNET_SOCIAL_MSG_PROC_RELAY = 1,
244 GNUNET_SOCIAL_MSG_PROC_SAVE= 2,
248 * Handle for an application.
250 struct GNUNET_SOCIAL_App;
253 * Handle for an ego (own identity)
255 struct GNUNET_SOCIAL_Ego;
258 * Handle for a pseudonym of another user in the network.
260 struct GNUNET_SOCIAL_Nym;
263 * Handle for a place where social interactions happen.
265 struct GNUNET_SOCIAL_Place;
268 * Host handle for a place that we entered.
270 struct GNUNET_SOCIAL_Host;
273 * Guest handle for place that we entered.
275 struct GNUNET_SOCIAL_Guest;
278 * Handle that can be used to reconnect to a place as host.
280 struct GNUNET_SOCIAL_HostConnection;
283 * Handle that can be used to reconnect to a place as guest.
285 struct GNUNET_SOCIAL_GuestConnection;
288 * Notification about an available identity.
298 (*GNUNET_SOCIAL_AppEgoCallback) (void *cls,
299 struct GNUNET_SOCIAL_Ego *ego,
300 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
305 * Entry status of a place per application.
307 enum GNUNET_SOCIAL_AppPlaceState
310 * The place was once entered by the ego, but left since.
311 * It's possible to establish a local connection to the place
312 * without re-entering to fetch history from the PSYCstore.
313 * @see enum GNUNET_PSYC_SlaveJoinFlags and GNUNET_SOCIAL_guest_enter()
315 GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0,
318 * The place is entered by the ego,
319 * but this application is not subscribed to it.
321 GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1,
324 * The place is entered by the ego and
325 * and this application is subscribed to it.
327 GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2,
332 * Called after receiving initial list of egos and places.
335 (*GNUNET_SOCIAL_AppConnectedCallback) (void *cls);
339 * Notification about a home.
344 * Host connection, to be used with GNUNET_SOCIAL_host_enter_reconnect()
346 * Ego used to enter the place.
347 * @param place_pub_key
348 * Public key of the place.
350 * @see enum GNUNET_SOCIAL_AppPlaceState
353 (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls,
354 struct GNUNET_SOCIAL_HostConnection *hconn,
355 struct GNUNET_SOCIAL_Ego *ego,
356 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
357 enum GNUNET_SOCIAL_AppPlaceState place_state);
360 * Notification about a place.
365 * Guest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect()
367 * Ego used to enter the place.
368 * @param place_pub_key
369 * Public key of the place.
371 * @see enum GNUNET_SOCIAL_AppPlaceState
374 (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls,
375 struct GNUNET_SOCIAL_GuestConnection *gconn,
376 struct GNUNET_SOCIAL_Ego *ego,
377 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
378 enum GNUNET_SOCIAL_AppPlaceState place_state);
382 * Establish application connection to the social service.
384 * The @host_cb and @guest_cb functions are
385 * initially called for each entered places,
386 * then later each time a new place is entered with the current app ID.
391 * Function to notify about an available ego.
393 * Function to notify about a place entered as host.
395 * Function to notify about a place entered as guest.
397 * Closure for the callbacks.
399 * @return Handle that can be used to stop listening.
401 struct GNUNET_SOCIAL_App *
402 GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
404 GNUNET_SOCIAL_AppEgoCallback ego_cb,
405 GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
406 GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
407 GNUNET_SOCIAL_AppConnectedCallback connected_cb,
415 * Application handle.
416 * @param disconnect_cb
417 * Disconnect callback.
418 * @param disconnect_cls
419 * Disconnect closure.
422 GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app,
423 GNUNET_ContinuationCallback disconnect_cb,
424 void *disconnect_cls);
428 * Get the public key of @a ego.
433 * @return Public key of ego.
435 const struct GNUNET_CRYPTO_EcdsaPublicKey *
436 GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego);
440 * Get the name of @a ego.
445 * @return Public key of @a ego.
448 GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego);
452 * Get the public key of a @a nym.
454 * Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().
457 * Pseudonym to map to a cryptographic identifier.
459 * @return Public key of nym.
461 const struct GNUNET_CRYPTO_EcdsaPublicKey *
462 GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym);
466 * Get the hash of the public key of a @a nym.
469 * Pseudonym to map to a cryptographic identifier.
471 * @return Hash of the public key of nym.
473 const struct GNUNET_HashCode *
474 GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
478 * Function called asking for nym to be admitted to the place.
480 * Should call either GNUNET_SOCIAL_host_admit() or
481 * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
482 * cannot decide, it is fine to call neither function, in which case hopefully
483 * some other host of the place exists that will make the decision. The @a nym
484 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
490 * Handle for the user who wants to enter.
492 * Method name in the entry request.
493 * @param variable_count
494 * Number of elements in the @a variables array.
496 * Variables present in the message.
498 * Payload given on enter (e.g. a password).
500 * Number of bytes in @a data.
503 (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
504 struct GNUNET_SOCIAL_Nym *nym,
505 const char *method_name,
506 struct GNUNET_PSYC_Environment *env,
512 * Function called when a @a nym leaves the place.
514 * This is also called if the @a nym was never given permission to enter
515 * (i.e. the @a nym stopped asking to get in).
520 * Handle for the user who left.
523 (*GNUNET_SOCIAL_FarewellCallback) (void *cls,
524 const struct GNUNET_SOCIAL_Nym *nym,
525 struct GNUNET_PSYC_Environment *env);
529 * Function called after the host entered a home.
534 * #GNUNET_OK on success, or
535 * #GNUNET_SYSERR on error.
536 * @param place_pub_key
537 * Public key of home.
538 * @param max_message_id
539 * Last message ID sent to the channel.
540 * Or 0 if no messages have been sent to the place yet.
543 (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, int result,
544 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
545 uint64_t max_message_id);
549 * Enter a place as host.
551 * A place is created upon first entering, and it is active until permanently
552 * left using GNUNET_SOCIAL_host_leave().
555 * Configuration to contact the social service.
557 * Identity of the host.
559 * Private-public key pair of the place.
560 * NULL for ephemeral places.
562 * Policy specifying entry and history restrictions for the place.
564 * Slicer to handle incoming messages.
566 * Function called when the place is entered and ready to use.
567 * @param answer_door_cb
568 * Function to handle new nyms that want to enter.
570 * Function to handle departing nyms.
572 * Closure for the callbacks.
574 * @return Handle for the host.
576 struct GNUNET_SOCIAL_Host *
577 GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
578 const struct GNUNET_SOCIAL_Ego *ego,
579 enum GNUNET_PSYC_Policy policy,
580 struct GNUNET_PSYC_Slicer *slicer,
581 GNUNET_SOCIAL_HostEnterCallback enter_cb,
582 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
583 GNUNET_SOCIAL_FarewellCallback farewell_cb,
588 * Reconnect to an already entered place as host.
591 * Host connection handle.
592 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
594 * Slicer to handle incoming messages.
596 * Function called when the place is entered and ready to use.
597 * @param answer_door_cb
598 * Function to handle new nyms that want to enter.
600 * Function to handle departing nyms.
602 * Closure for the callbacks.
604 * @return Handle for the host.
606 struct GNUNET_SOCIAL_Host *
607 GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
608 struct GNUNET_PSYC_Slicer *slicer,
609 GNUNET_SOCIAL_HostEnterCallback enter_cb,
610 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
611 GNUNET_SOCIAL_FarewellCallback farewell_cb,
616 * Decision whether to admit @a nym into the place or refuse entry.
621 * Handle for the entity that wanted to enter.
623 * #GNUNET_YES if @a nym is admitted,
624 * #GNUNET_NO if @a nym is refused entry,
625 * #GNUNET_SYSERR if we cannot answer the request.
627 * Entry response message, or NULL.
628 * @return #GNUNET_OK on success,
629 * #GNUNET_SYSERR if the message is too large.
632 GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
633 struct GNUNET_SOCIAL_Nym *nym,
635 const struct GNUNET_PSYC_Message *entry_resp);
639 * Throw @a nym out of the place.
641 * Sends a _notice_place_leave announcement to the home.
643 * The @a nym reference will remain valid until the
644 * #GNUNET_SOCIAL_FarewellCallback is invoked,
645 * which should be very soon after this call.
650 * Handle for the entity to be ejected.
652 * Environment for the message or NULL.
653 * _nym is set to @e nym regardless whether an @e env is provided.
656 GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
657 const struct GNUNET_SOCIAL_Nym *nym,
658 struct GNUNET_PSYC_Environment *env);
662 * Flags for announcements by a host.
664 enum GNUNET_SOCIAL_AnnounceFlags
666 GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
669 * Whether this announcement removes all objects from the place.
671 * New objects can be still added to the now empty place using the @e env
672 * parameter of the same announcement.
674 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
679 * Handle for an announcement request.
681 struct GNUNET_SOCIAL_Announcement;
685 * Send a message to all nyms that are present in the place.
687 * This function is restricted to the host. Nyms can only send requests
688 * to the host who can decide to relay it to everyone in the place.
693 * Method to use for the announcement.
695 * Environment containing variables for the message and operations
696 * on objects of the place.
697 * Has to remain available until the first call to @a notify_data.
700 * Function to call to get the payload of the announcement.
701 * @param notify_data_cls
702 * Closure for @a notify.
704 * Flags for this announcement.
706 * @return NULL on error (another announcement already in progress?).
708 struct GNUNET_SOCIAL_Announcement *
709 GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
710 const char *method_name,
711 const struct GNUNET_PSYC_Environment *env,
712 GNUNET_PSYC_TransmitNotifyData notify_data,
713 void *notify_data_cls,
714 enum GNUNET_SOCIAL_AnnounceFlags flags);
718 * Resume transmitting announcement.
721 * The announcement to resume.
724 GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
728 * Cancel announcement.
731 * The announcement to cancel.
734 GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
738 * Allow relaying messages from guests matching a given @a method_prefix.
742 * @param method_prefix
743 * Method prefix to allow.
746 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
747 const char *method_prefix);
751 * Allow relaying changes to objects of the place.
753 * Only applies to messages with an allowed method name.
754 * @see GNUNET_SCOIAL_host_relay_allow_method()
758 * @param object_prefix
759 * Object prefix to allow modifying.
762 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
763 const char *object_prefix);
767 * Stop relaying messages from guests.
769 * Remove all allowed relay rules.
775 GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host);
779 * Obtain handle for a hosted place.
781 * The returned handle can be used to access the place API.
784 * Handle for the host.
786 * @return Handle for the hosted place, valid as long as @a host is valid.
788 struct GNUNET_SOCIAL_Place *
789 GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
793 * Disconnect from a home.
795 * Invalidates host handle.
798 * The host to disconnect.
799 * @param disconnect_cb
800 * Function called after disconnected from the service.
802 * Closure for @a disconnect_cb.
805 GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
806 GNUNET_ContinuationCallback disconnect_cb,
811 * Stop hosting a home.
813 * Sends a _notice_place_closing announcement to the home.
814 * Invalidates host handle.
819 * Environment for the message or NULL.
820 * @param disconnect_cb
821 * Function called after the host left the place
822 * and disconnected from the service.
824 * Closure for @a disconnect_cb.
827 GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
828 const struct GNUNET_PSYC_Environment *env,
829 GNUNET_ContinuationCallback disconnect_cb,
834 * Function called after the guest entered the local copy of the place.
836 * History and object query functions can be used after this call,
837 * but new messages can't be sent or received.
842 * #GNUNET_OK on success, or
843 * #GNUNET_SYSERR on error, e.g. could not connect to the service, or
844 * could not resolve GNS name.
845 * @param place_pub_key
846 * Public key of place.
847 * @param max_message_id
848 * Last message ID sent to the place.
849 * Or 0 if no messages have been sent to the place yet.
852 (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result,
853 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
854 uint64_t max_message_id);
858 * Function called upon a guest receives a decision about entry to the place.
861 * Is the guest admitted to the place?
862 * #GNUNET_YES if admitted,
863 * #GNUNET_NO if refused entry,
864 * #GNUNET_SYSERR if the request could not be answered.
866 * Entry response message.
869 (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
871 const struct GNUNET_PSYC_Message *entry_resp);
875 * Request entry to a place as a guest.
878 * Application handle.
880 * Identity of the guest.
881 * @param place_pub_key
882 * Public key of the place to enter.
884 * Flags for the entry.
886 * Peer identity of the origin of the underlying multicast group.
888 * Number of elements in the @a relays array.
890 * Relays for the underlying multicast group.
894 * Slicer to use for processing incoming requests from guests.
896 * @return NULL on errors, otherwise handle for the guest.
898 struct GNUNET_SOCIAL_Guest *
899 GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
900 const struct GNUNET_SOCIAL_Ego *ego,
901 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
902 enum GNUNET_PSYC_SlaveJoinFlags flags,
903 const struct GNUNET_PeerIdentity *origin,
904 uint32_t relay_count,
905 const struct GNUNET_PeerIdentity *relays,
906 const struct GNUNET_PSYC_Message *entry_msg,
907 struct GNUNET_PSYC_Slicer *slicer,
908 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
909 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
914 * Request entry to a place by name as a guest.
917 * Application handle.
919 * Identity of the guest.
921 * GNS name of the place to enter. Either in the form of
922 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
923 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
924 * nym's public key 'NYMPUBKEY', and can be used to request entry to a
925 * pseudonym's place directly.
927 * Password to decrypt the record, or NULL for cleartext records.
929 * Entry request message.
931 * Slicer to use for processing incoming requests from guests.
932 * @param local_enter_cb
933 * Called upon connection established to the social service.
934 * @param entry_decision_cb
935 * Called upon receiving entry decision.
937 * @return NULL on errors, otherwise handle for the guest.
939 struct GNUNET_SOCIAL_Guest *
940 GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
941 const struct GNUNET_SOCIAL_Ego *ego,
942 const char *gns_name,
943 const char *password,
944 const struct GNUNET_PSYC_Message *join_msg,
945 struct GNUNET_PSYC_Slicer *slicer,
946 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
947 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
952 * Reconnect to an already entered place as guest.
955 * Guest connection handle.
956 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
958 * Flags for the entry.
960 * Slicer to use for processing incoming requests from guests.
961 * @param local_enter_cb
962 * Called upon connection established to the social service.
963 * @param entry_decision_cb
964 * Called upon receiving entry decision.
966 * @return NULL on errors, otherwise handle for the guest.
968 struct GNUNET_SOCIAL_Guest *
969 GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
970 enum GNUNET_PSYC_SlaveJoinFlags flags,
971 struct GNUNET_PSYC_Slicer *slicer,
972 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
977 * Flags for talking to the host of a place.
979 enum GNUNET_SOCIAL_TalkFlags
981 GNUNET_SOCIAL_TALK_NONE = 0
988 struct GNUNET_SOCIAL_TalkRequest;
992 * Talk to the host of the place.
995 * Place where we want to talk to the host.
997 * Method to invoke on the host.
999 * Environment containing variables for the message, or NULL.
1000 * @param notify_data
1001 * Function to use to get the payload for the method.
1002 * @param notify_data_cls
1003 * Closure for @a notify_data.
1005 * Flags for the message being sent.
1007 * @return NULL if we are already trying to talk to the host,
1008 * otherwise handle to cancel the request.
1010 struct GNUNET_SOCIAL_TalkRequest *
1011 GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
1012 const char *method_name,
1013 const struct GNUNET_PSYC_Environment *env,
1014 GNUNET_PSYC_TransmitNotifyData notify_data,
1015 void *notify_data_cls,
1016 enum GNUNET_SOCIAL_TalkFlags flags);
1020 * Resume talking to the host of the place.
1023 * Talk request to resume.
1026 GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
1030 * Cancel talking to the host of the place.
1033 * Talk request to cancel.
1036 GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
1040 * Disconnect from a place.
1042 * Invalidates guest handle.
1045 * The guest to disconnect.
1046 * @param disconnect_cb
1047 * Function called after disconnected from the service.
1049 * Closure for @a disconnect_cb.
1052 GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
1053 GNUNET_ContinuationCallback disconnect_cb,
1058 * Leave a place temporarily or permanently.
1060 * Notifies the owner of the place about leaving, and destroys the place handle.
1065 * Optional environment for the leave message if @a keep_active
1066 * is #GNUNET_NO. NULL if not needed.
1067 * @param disconnect_cb
1068 * Called upon disconnecting from the social service.
1071 GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
1072 struct GNUNET_PSYC_Environment *env,
1073 GNUNET_ContinuationCallback disconnect_cb,
1078 * Obtain handle for a place entered as guest.
1080 * The returned handle can be used to access the place API.
1082 * @param guest Handle for the guest.
1084 * @return Handle for the place, valid as long as @a guest is valid.
1086 struct GNUNET_SOCIAL_Place *
1087 GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
1091 * A history request.
1093 struct GNUNET_SOCIAL_HistoryRequest;
1097 * Get the public key of a place.
1102 * @return Public key of the place.
1104 const struct GNUNET_CRYPTO_EddsaPublicKey *
1105 GNUNET_SOCIAL_place_get_pub_key (const struct GNUNET_SOCIAL_Place *plc);
1109 * Set message processing @a flags for a @a method_prefix.
1113 * @param method_prefix
1114 * Method prefix @a flags apply to.
1116 * The flags that apply to a matching @a method_prefix.
1119 GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc,
1120 const char *method_prefix,
1121 enum GNUNET_SOCIAL_MsgProcFlags flags);
1124 * Clear all message processing flags previously set for this place.
1127 GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc);
1131 * Learn about the history of a place.
1133 * Messages are returned through the @a slicer function
1134 * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1137 * Place we want to learn more about.
1138 * @param start_message_id
1139 * First historic message we are interested in.
1140 * @param end_message_id
1141 * Last historic message we are interested in (inclusive).
1142 * @param method_prefix
1143 * Only retrieve messages with this method prefix.
1145 * OR'ed GNUNET_PSYC_HistoryReplayFlags
1147 * Slicer to use for retrieved messages.
1148 * Can be the same as the slicer of the place.
1150 * Function called after all messages retrieved.
1151 * NULL if not needed.
1152 * @param cls Closure for @a result_cb.
1154 struct GNUNET_SOCIAL_HistoryRequest *
1155 GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1156 uint64_t start_message_id,
1157 uint64_t end_message_id,
1158 const char *method_prefix,
1160 struct GNUNET_PSYC_Slicer *slicer,
1161 GNUNET_ResultCallback result_cb,
1166 * Learn about the history of a place.
1168 * Sends messages through the slicer function of the place where
1169 * start_message_id <= message_id <= end_message_id.
1170 * The messages will have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1172 * To get the latest message, use 0 for both the start and end message ID.
1175 * Place we want to learn more about.
1176 * @param message_limit
1177 * Maximum number of historic messages we are interested in.
1179 * Function called after all messages retrieved.
1180 * NULL if not needed.
1181 * @param cls Closure for @a result_cb.
1183 struct GNUNET_SOCIAL_HistoryRequest *
1184 GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
1185 uint64_t message_limit,
1186 const char *method_prefix,
1188 struct GNUNET_PSYC_Slicer *slicer,
1189 GNUNET_ResultCallback result_cb,
1193 * Cancel learning about the history of a place.
1196 * History lesson to cancel.
1199 GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
1202 struct GNUNET_SOCIAL_LookHandle;
1206 * Look at a particular object in the place.
1208 * The best matching object is returned (its name might be less specific than
1209 * what was requested).
1212 * The place to look the object at.
1214 * Full name of the object.
1216 * @return NULL if there is no such object at this place.
1218 struct GNUNET_SOCIAL_LookHandle *
1219 GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc,
1220 const char *full_name,
1221 GNUNET_PSYC_StateVarCallback var_cb,
1222 GNUNET_ResultCallback result_cb,
1226 * Look for objects in the place with a matching name prefix.
1229 * The place to look its objects at.
1230 * @param name_prefix
1231 * Look at objects with names beginning with this value.
1233 * Function to call for each object found.
1235 * Closure for callback function.
1237 * @return Handle that can be used to stop looking at objects.
1239 struct GNUNET_SOCIAL_LookHandle *
1240 GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc,
1241 const char *name_prefix,
1242 GNUNET_PSYC_StateVarCallback var_cb,
1243 GNUNET_ResultCallback result_cb,
1248 * Stop looking at objects.
1250 * @param lh Look handle to stop.
1253 GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
1257 * Advertise a @e place in the GNS zone of @a ego.
1260 * Application handle.
1263 * @param place_pub_key
1264 * Public key of place to add.
1266 * The name for the PLACE record to put in the zone.
1268 * Password used to encrypt the record or NULL to keep it cleartext.
1269 * @param relay_count
1270 * Number of elements in the @a relays array.
1272 * List of relays to put in the PLACE record to advertise
1273 * as entry points to the place in addition to the origin.
1274 * @param expiration_time
1275 * Expiration time of the record, use 0 to remove the record.
1277 * Function called with the result of the operation.
1279 * Closure for @a result_cb
1281 * @return #GNUNET_OK if the request was sent,
1282 * #GNUNET_SYSERR on error, e.g. the name/password is too long.
1285 GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
1286 const struct GNUNET_SOCIAL_Ego *ego,
1288 const char *password,
1289 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1290 const struct GNUNET_PeerIdentity *origin,
1291 uint32_t relay_count,
1292 const struct GNUNET_PeerIdentity *relays,
1293 struct GNUNET_TIME_Absolute expiration_time,
1294 GNUNET_ResultCallback result_cb,
1299 * Add public key to the GNS zone of the @e ego.
1306 * The name for the PKEY record to put in the zone.
1307 * @param nym_pub_key
1308 * Public key of nym to add.
1309 * @param expiration_time
1310 * Expiration time of the record, use 0 to remove the record.
1312 * Function called with the result of the operation.
1314 * Closure for @a result_cb
1316 * @return #GNUNET_OK if the request was sent,
1317 * #GNUNET_SYSERR on error, e.g. the name is too long.
1320 GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
1321 const struct GNUNET_SOCIAL_Ego *ego,
1323 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
1324 struct GNUNET_TIME_Absolute expiration_time,
1325 GNUNET_ResultCallback result_cb,
1329 #if 0 /* keep Emacsens' auto-indent happy */
1336 /* ifndef GNUNET_SOCIAL_SERVICE_H */
1339 /** @} */ /* end of group */