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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Gabor X Toth
23 * @author Christian Grothoff
26 * Social service; implements social interactions through the PSYC service.
29 /** @defgroup social Social service
30 Social interactions through the PSYC service.
34 The social service provides an API for social interactions based on a one-to-many messaging model.
35 It manages subscriptions of applications to places, provides messaging functionality in places,
36 allows access to the local message history and manages the GNS zone of _egos_ (user identities).
38 The service stores private and public keys of subscribed places, as well as files received in subscribed places.
40 # Concepts and terminology
44 An _ego_ is an identity of a user, a private-public key pair.
45 A _nym_ is an identity of another user in the network, identified by its public key.
46 Each user can have multiple identities.
48 struct GNUNET_SOCIAL_Ego and struct GNUNET_SOCIAL_Nym represents one of these identities.
52 A _place_ is where social interactions happen. It is owned and created by an _ego_.
53 Creating a new place happens by an _ego_ entering a new place as a _host_,
54 where _guests_ can enter later to receive messages sent to the place.
56 A place is identified by its public key.
58 - struct GNUNET_SOCIAL_Host represents a place entered as host,
59 - struct GNUNET_SOCIAL_Guest is used for a place entered as guest.
60 - A struct GNUNET_SOCIAL_Place can be obtained for both a host and guest place
61 using GNUNET_SOCIAL_host_get_place() and GNUNET_SOCIAL_guest_get_place()
62 and can be used with API functions common to hosts and guests.
66 Messages sent to places are stored locally by the PSYCstore service, and can be queried any time.
67 GNUNET_SOCIAL_history_replay_latest() retrieves the latest N messages sent to the place,
68 while GNUNET_SOCIAL_history_replay() is used to query a given message ID range.
72 The GNU Name System is used for assigning human-readable names to nyms and places.
73 There's a _GNS zone_ corresponding to each _nym_.
74 An _ego_ can publish PKEY and PLACE records in its own zone, pointing to nyms and places, respectively.
76 ## Announcement, talk request
78 The host can _announce_ messages to the place, using GNUNET_SOCIAL_host_announce().
79 Guests can send _talk_ requests to the host, using GNUNET_SOCIAL_guest_talk().
80 The host receives talk requests of guests and can _relay_ them to the place,
81 or process it using a message handler function.
85 ## Connecting to the service
87 A client first establishes an _application connection_ to the service using
88 GNUNET_SOCIAL_app_connect() providing its _application ID_, then receives the
89 public keys of subscribed places and available egos and in response.
91 ## Reconnecting to places
93 Then the application can reconnect to its subscribed places by establishing
94 _place connections_ with GNUNET_SOCIAL_host_enter_reconnect() and
95 GNUNET_SOCIAL_guest_enter_reconnect().
97 ## Subscribing to a place
99 Entering and subscribing a new host or guest place is done using
100 GNUNET_SOCIAL_host_enter() and GNUNET_SOCIAL_guest_enter().
102 ## Disconnecting from a place
104 An application can disconnect from a place while the social service keeps its
105 network connection active, using GNUNET_SOCIAL_host_disconnect() and
106 GNUNET_SOCIAL_guest_disconnect().
110 To permanently leave a place, see GNUNET_SOCIAL_host_leave() and GNUNET_SOCIAL_guest_leave().
111 When leaving a place its network connections are closed and all applications are unsubscribed from the place.
117 A message sent to the place.
122 Message ID this message is in reply to.
125 Thread ID, the first message ID in the thread.
131 Signature of the message body and its variables by the author.
139 Notification about a place.
141 TODO: Applications can decide to auto-subscribe to certain places,
142 e.g. files under a given size.
149 GNS name of the place in a globally unique .zkey zone
159 ##### _list_peer_relays
160 List of peer IDs of relays
162 ## _notice_place_file
164 Notification about a place hosting a file.
168 The environment of _notice_place above, plus the following:
179 #### _description_file
184 Messages with a _file method contain a file,
185 which is saved to disk upon receipt at the following location:
186 $GNUNET_DATA_HOME/social/files/<H(place_pub)>/<message_id>
199 #### _description_file
206 #ifndef GNUNET_SOCIAL_SERVICE_H
207 #define GNUNET_SOCIAL_SERVICE_H
212 #if 0 /* keep Emacsens' auto-indent happy */
218 #include "gnunet_util_lib.h"
219 #include "gnunet_psyc_util_lib.h"
220 #include "gnunet_identity_service.h"
221 #include "gnunet_namestore_service.h"
222 #include "gnunet_psyc_service.h"
226 * Version number of GNUnet Social API.
228 #define GNUNET_SOCIAL_VERSION 0x00000000
231 * Maximum size of client ID including '\0' terminator.
233 #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256
235 enum GNUNET_SOCIAL_MsgProcFlags {
236 GNUNET_SOCIAL_MSG_PROC_NONE = 0,
237 GNUNET_SOCIAL_MSG_PROC_RELAY = 1,
238 GNUNET_SOCIAL_MSG_PROC_SAVE= 2,
242 * Handle for an application.
244 struct GNUNET_SOCIAL_App;
247 * Handle for an ego (own identity)
249 struct GNUNET_SOCIAL_Ego;
252 * Handle for a pseudonym of another user in the network.
254 struct GNUNET_SOCIAL_Nym;
257 * Handle for a place where social interactions happen.
259 struct GNUNET_SOCIAL_Place;
262 * Host handle for a place that we entered.
264 struct GNUNET_SOCIAL_Host;
267 * Guest handle for place that we entered.
269 struct GNUNET_SOCIAL_Guest;
272 * Handle that can be used to reconnect to a place as host.
274 struct GNUNET_SOCIAL_HostConnection;
277 * Handle that can be used to reconnect to a place as guest.
279 struct GNUNET_SOCIAL_GuestConnection;
282 * Notification about an available identity.
292 (*GNUNET_SOCIAL_AppEgoCallback) (void *cls,
293 struct GNUNET_SOCIAL_Ego *ego,
294 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
299 * Entry status of a place.
301 enum GNUNET_SOCIAL_PlaceState
304 * Place was once entered but left since.
306 GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0,
308 * Place is entered but not subscribed.
310 GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1,
312 * Place is entered and subscribed.
314 GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2,
319 * Notification about a home.
324 * Host connection, to be used with GNUNET_SOCIAL_host_enter_reconnect()
326 * Ego used to enter the place.
327 * @param place_pub_key
328 * Public key of the place.
330 * @see enum GNUNET_SOCIAL_PlaceState
333 (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls,
334 struct GNUNET_SOCIAL_HostConnection *hconn,
335 struct GNUNET_SOCIAL_Ego *ego,
336 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
337 enum GNUNET_SOCIAL_PlaceState place_state);
340 * Notification about a place.
345 * Guest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect()
347 * Ego used to enter the place.
348 * @param place_pub_key
349 * Public key of the place.
351 * @see enum GNUNET_SOCIAL_PlaceState
354 (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls,
355 struct GNUNET_SOCIAL_GuestConnection *gconn,
356 struct GNUNET_SOCIAL_Ego *ego,
357 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
358 enum GNUNET_SOCIAL_PlaceState place_state);
362 * Establish application connection to the social service.
364 * The @host_place_cb and @guest_place_cb functions are
365 * initially called for each entered places,
366 * then later each time a new place is entered with the current app ID.
371 * Function to notify about an available ego.
373 * Function to notify about a place entered as host.
375 * Function to notify about a place entered as guest.
377 * Closure for the callbacks.
379 * @return Handle that can be used to stop listening.
381 struct GNUNET_SOCIAL_App *
382 GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
384 GNUNET_SOCIAL_AppEgoCallback ego_cb,
385 GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
386 GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
397 GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app);
401 * Get the public key of @a ego.
406 * @return Public key of ego.
408 const struct GNUNET_CRYPTO_EcdsaPublicKey *
409 GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego);
413 * Get the name of @a ego.
418 * @return Public key of @a ego.
421 GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego);
425 * Get the public key of a @a nym.
427 * Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().
430 * Pseudonym to map to a cryptographic identifier.
432 * @return Public key of nym.
434 const struct GNUNET_CRYPTO_EcdsaPublicKey *
435 GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym);
439 * Get the hash of the public key of a @a nym.
442 * Pseudonym to map to a cryptographic identifier.
444 * @return Hash of the public key of nym.
446 const struct GNUNET_HashCode *
447 GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
451 * Function called asking for nym to be admitted to the place.
453 * Should call either GNUNET_SOCIAL_host_admit() or
454 * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
455 * cannot decide, it is fine to call neither function, in which case hopefully
456 * some other host of the place exists that will make the decision. The @a nym
457 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
460 * @param cls Closure.
461 * @param nym Handle for the user who wants to enter.
462 * @param method_name Method name in the entry request.
463 * @param variable_count Number of elements in the @a variables array.
464 * @param variables Variables present in the message.
465 * @param data_size Number of bytes in @a data.
466 * @param data Payload given on enter (e.g. a password).
469 (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
470 struct GNUNET_SOCIAL_Nym *nym,
471 const char *method_name,
472 struct GNUNET_PSYC_Environment *env,
478 * Function called when a @a nym leaves the place.
480 * This is also called if the @a nym was never given permission to enter
481 * (i.e. the @a nym stopped asking to get in).
486 * Handle for the user who left.
489 (*GNUNET_SOCIAL_FarewellCallback) (void *cls,
490 const struct GNUNET_SOCIAL_Nym *nym,
491 struct GNUNET_PSYC_Environment *env);
495 * Function called after the host entered a home.
500 * #GNUNET_OK on success, or
501 * #GNUNET_SYSERR on error.
502 * @param place_pub_key
503 * Public key of home.
504 * @param max_message_id
505 * Last message ID sent to the channel.
506 * Or 0 if no messages have been sent to the place yet.
509 (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, int result,
510 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
511 uint64_t max_message_id);
515 * Enter a place as host.
517 * A place is created upon first entering, and it is active until permanently
518 * left using GNUNET_SOCIAL_host_leave().
521 * Configuration to contact the social service.
523 * Identity of the host.
525 * Private-public key pair of the place.
526 * NULL for ephemeral places.
528 * Policy specifying entry and history restrictions for the place.
530 * Slicer to handle incoming messages.
532 * Function called when the place is entered and ready to use.
533 * @param answer_door_cb
534 * Function to handle new nyms that want to enter.
536 * Function to handle departing nyms.
538 * Closure for the callbacks.
540 * @return Handle for the host.
542 struct GNUNET_SOCIAL_Host *
543 GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
544 const struct GNUNET_SOCIAL_Ego *ego,
545 enum GNUNET_PSYC_Policy policy,
546 struct GNUNET_PSYC_Slicer *slicer,
547 GNUNET_SOCIAL_HostEnterCallback enter_cb,
548 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
549 GNUNET_SOCIAL_FarewellCallback farewell_cb,
554 * Reconnect to an already entered place as host.
557 * Host connection handle.
558 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
560 * Slicer to handle incoming messages.
562 * Function called when the place is entered and ready to use.
563 * @param answer_door_cb
564 * Function to handle new nyms that want to enter.
566 * Function to handle departing nyms.
568 * Closure for the callbacks.
570 * @return Handle for the host.
572 struct GNUNET_SOCIAL_Host *
573 GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
574 struct GNUNET_PSYC_Slicer *slicer,
575 GNUNET_SOCIAL_HostEnterCallback enter_cb,
576 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
577 GNUNET_SOCIAL_FarewellCallback farewell_cb,
582 * Decision whether to admit @a nym into the place or refuse entry.
587 * Handle for the entity that wanted to enter.
589 * #GNUNET_YES if @a nym is admitted,
590 * #GNUNET_NO if @a nym is refused entry,
591 * #GNUNET_SYSERR if we cannot answer the request.
593 * Method name for the rejection message.
595 * Environment containing variables for the message, or NULL.
597 * Data for the rejection message to send back.
599 * Number of bytes in @a data for method.
600 * @return #GNUNET_OK on success,
601 * #GNUNET_SYSERR if the message is too large.
604 GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
605 struct GNUNET_SOCIAL_Nym *nym,
607 const struct GNUNET_PSYC_Message *entry_resp);
611 * Throw @a nym out of the place.
613 * Sends a _notice_place_leave announcement to the home.
615 * The @a nym reference will remain valid until the
616 * #GNUNET_SOCIAL_FarewellCallback is invoked,
617 * which should be very soon after this call.
622 * Handle for the entity to be ejected.
624 * Environment for the message or NULL.
625 * _nym is set to @e nym regardless whether an @e env is provided.
628 GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
629 const struct GNUNET_SOCIAL_Nym *nym,
630 struct GNUNET_PSYC_Environment *env);
634 * Flags for announcements by a host.
636 enum GNUNET_SOCIAL_AnnounceFlags
638 GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
641 * Whether this announcement removes all objects from the place.
643 * New objects can be still added to the now empty place using the @e env
644 * parameter of the same announcement.
646 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
651 * Handle for an announcement request.
653 struct GNUNET_SOCIAL_Announcement;
657 * Send a message to all nyms that are present in the place.
659 * This function is restricted to the host. Nyms can only send requests
660 * to the host who can decide to relay it to everyone in the place.
665 * Method to use for the announcement.
667 * Environment containing variables for the message and operations
668 * on objects of the place.
669 * Has to remain available until the first call to @a notify_data.
672 * Function to call to get the payload of the announcement.
673 * @param notify_data_cls
674 * Closure for @a notify.
676 * Flags for this announcement.
678 * @return NULL on error (another announcement already in progress?).
680 struct GNUNET_SOCIAL_Announcement *
681 GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
682 const char *method_name,
683 const struct GNUNET_PSYC_Environment *env,
684 GNUNET_PSYC_TransmitNotifyData notify_data,
685 void *notify_data_cls,
686 enum GNUNET_SOCIAL_AnnounceFlags flags);
690 * Resume transmitting announcement.
693 * The announcement to resume.
696 GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
700 * Cancel announcement.
703 * The announcement to cancel.
706 GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
710 * Allow relaying messages from guests matching a given @a method_prefix.
714 * @param method_prefix
715 * Method prefix to allow.
718 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
719 const char *method_prefix);
723 * Allow relaying changes to objects of the place.
725 * Only applies to messages with an allowed method name.
726 * @see GNUNET_SCOIAL_host_relay_allow_method()
730 * @param object_prefix
731 * Object prefix to allow modifying.
734 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
735 const char *object_prefix);
739 * Stop relaying messages from guests.
741 * Remove all allowed relay rules.
747 GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host);
751 * Obtain handle for a hosted place.
753 * The returned handle can be used to access the place API.
756 * Handle for the host.
758 * @return Handle for the hosted place, valid as long as @a host is valid.
760 struct GNUNET_SOCIAL_Place *
761 GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
765 * Disconnect from a home.
767 * Invalidates host handle.
770 * The host to disconnect.
771 * @param disconnect_cb
772 * Function called after disconnected from the service.
774 * Closure for @a disconnect_cb.
777 GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
778 GNUNET_ContinuationCallback disconnect_cb,
783 * Stop hosting a home.
785 * Sends a _notice_place_closed announcement to the home.
786 * Invalidates host handle.
791 * Environment for the message or NULL.
792 * @param disconnect_cb
793 * Function called after the host left the place
794 * and disconnected from the service.
796 * Closure for @a disconnect_cb.
799 GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
800 const struct GNUNET_PSYC_Environment *env,
801 GNUNET_ContinuationCallback disconnect_cb,
806 * Function called after the guest entered the local copy of the place.
808 * History and object query functions can be used after this call,
809 * but new messages can't be sent or received.
814 * #GNUNET_OK on success, or
815 * #GNUNET_SYSERR on error, e.g. could not connect to the service, or
816 * could not resolve GNS name.
817 * @param max_message_id
818 * Last message ID sent to the place.
819 * Or 0 if no messages have been sent to the place yet.
822 (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result,
823 uint64_t max_message_id);
827 * Function called upon a guest receives a decision about entry to the place.
830 * Is the guest admitted to the place?
831 * #GNUNET_YES if admitted,
832 * #GNUNET_NO if refused entry,
833 * #GNUNET_SYSERR if the request could not be answered.
835 * Entry response message.
838 (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
840 const struct GNUNET_PSYC_Message *entry_resp);
844 * Request entry to a place as a guest.
847 * Application handle.
849 * Identity of the guest.
850 * @param place_pub_key
851 * Public key of the place to enter.
853 * Flags for the entry.
855 * Peer identity of the origin of the underlying multicast group.
857 * Number of elements in the @a relays array.
859 * Relays for the underlying multicast group.
861 * Method name for the message.
863 * Environment containing variables for the message, or NULL.
865 * Payload for the message to give to the enter callback.
867 * Number of bytes in @a data.
869 * Slicer to use for processing incoming requests from guests.
871 * @return NULL on errors, otherwise handle for the guest.
873 struct GNUNET_SOCIAL_Guest *
874 GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
875 const struct GNUNET_SOCIAL_Ego *ego,
876 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
877 enum GNUNET_PSYC_SlaveJoinFlags flags,
878 const struct GNUNET_PeerIdentity *origin,
879 uint32_t relay_count,
880 const struct GNUNET_PeerIdentity *relays,
881 const struct GNUNET_PSYC_Message *entry_msg,
882 struct GNUNET_PSYC_Slicer *slicer,
883 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
884 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
889 * Request entry to a place by name as a guest.
892 * Application handle.
894 * Identity of the guest.
896 * GNS name of the place to enter. Either in the form of
897 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
898 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
899 * nym's public key 'NYMPUBKEY', and can be used to request entry to a
900 * pseudonym's place directly.
902 * Password to decrypt the record, or NULL for cleartext records.
904 * Entry request message.
906 * Slicer to use for processing incoming requests from guests.
907 * @param local_enter_cb
908 * Called upon connection established to the social service.
909 * @param entry_decision_cb
910 * Called upon receiving entry decision.
912 * @return NULL on errors, otherwise handle for the guest.
914 struct GNUNET_SOCIAL_Guest *
915 GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
916 const struct GNUNET_SOCIAL_Ego *ego,
917 const char *gns_name,
918 const char *password,
919 const struct GNUNET_PSYC_Message *join_msg,
920 struct GNUNET_PSYC_Slicer *slicer,
921 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
922 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
927 * Reconnect to an already entered place as guest.
930 * Guest connection handle.
931 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
933 * Flags for the entry.
935 * Slicer to use for processing incoming requests from guests.
936 * @param local_enter_cb
937 * Called upon connection established to the social service.
938 * @param entry_decision_cb
939 * Called upon receiving entry decision.
941 * @return NULL on errors, otherwise handle for the guest.
943 struct GNUNET_SOCIAL_Guest *
944 GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
945 enum GNUNET_PSYC_SlaveJoinFlags flags,
946 struct GNUNET_PSYC_Slicer *slicer,
947 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
952 * Flags for talking to the host of a place.
954 enum GNUNET_SOCIAL_TalkFlags
956 GNUNET_SOCIAL_TALK_NONE = 0
963 struct GNUNET_SOCIAL_TalkRequest;
967 * Talk to the host of the place.
970 * Place where we want to talk to the host.
972 * Method to invoke on the host.
974 * Environment containing variables for the message, or NULL.
976 * Function to use to get the payload for the method.
977 * @param notify_data_cls
978 * Closure for @a notify_data.
980 * Flags for the message being sent.
982 * @return NULL if we are already trying to talk to the host,
983 * otherwise handle to cancel the request.
985 struct GNUNET_SOCIAL_TalkRequest *
986 GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
987 const char *method_name,
988 const struct GNUNET_PSYC_Environment *env,
989 GNUNET_PSYC_TransmitNotifyData notify_data,
990 void *notify_data_cls,
991 enum GNUNET_SOCIAL_TalkFlags flags);
995 * Resume talking to the host of the place.
998 * Talk request to resume.
1001 GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
1005 * Cancel talking to the host of the place.
1008 * Talk request to cancel.
1011 GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
1015 * Disconnect from a place.
1017 * Invalidates guest handle.
1020 * The guest to disconnect.
1021 * @param disconnect_cb
1022 * Function called after disconnected from the service.
1024 * Closure for @a disconnect_cb.
1027 GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
1028 GNUNET_ContinuationCallback disconnect_cb,
1033 * Leave a place temporarily or permanently.
1035 * Notifies the owner of the place about leaving, and destroys the place handle.
1040 * Optional environment for the leave message if @a keep_active
1041 * is #GNUNET_NO. NULL if not needed.
1042 * @param disconnect_cb
1043 * Called upon disconnecting from the social service.
1046 GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
1047 struct GNUNET_PSYC_Environment *env,
1048 GNUNET_ContinuationCallback disconnect_cb,
1053 * Obtain handle for a place entered as guest.
1055 * The returned handle can be used to access the place API.
1057 * @param guest Handle for the guest.
1059 * @return Handle for the place, valid as long as @a guest is valid.
1061 struct GNUNET_SOCIAL_Place *
1062 GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
1066 * A history request.
1068 struct GNUNET_SOCIAL_HistoryRequest;
1072 * Set message processing @a flags for a @a method_prefix.
1076 * @param method_prefix
1077 * Method prefix @a flags apply to.
1079 * The flags that apply to a matching @a method_prefix.
1082 GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc,
1083 const char *method_prefix,
1084 enum GNUNET_SOCIAL_MsgProcFlags flags);
1087 * Clear all message processing flags previously set for this place.
1090 GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc);
1094 * Learn about the history of a place.
1096 * Messages are returned through the @a slicer function
1097 * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1100 * Place we want to learn more about.
1101 * @param start_message_id
1102 * First historic message we are interested in.
1103 * @param end_message_id
1104 * Last historic message we are interested in (inclusive).
1105 * @param method_prefix
1106 * Only retrieve messages with this method prefix.
1108 * OR'ed GNUNET_PSYC_HistoryReplayFlags
1110 * Slicer to use for retrieved messages.
1111 * Can be the same as the slicer of the place.
1113 * Function called after all messages retrieved.
1114 * NULL if not needed.
1115 * @param cls Closure for @a result_cb.
1117 struct GNUNET_SOCIAL_HistoryRequest *
1118 GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1119 uint64_t start_message_id,
1120 uint64_t end_message_id,
1121 const char *method_prefix,
1123 struct GNUNET_PSYC_Slicer *slicer,
1124 GNUNET_ResultCallback result_cb,
1129 * Learn about the history of a place.
1131 * Sends messages through the slicer function of the place where
1132 * start_message_id <= message_id <= end_message_id.
1133 * The messages will have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1135 * To get the latest message, use 0 for both the start and end message ID.
1138 * Place we want to learn more about.
1139 * @param message_limit
1140 * Maximum number of historic messages we are interested in.
1142 * Function called after all messages retrieved.
1143 * NULL if not needed.
1144 * @param cls Closure for @a result_cb.
1146 struct GNUNET_SOCIAL_HistoryRequest *
1147 GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
1148 uint64_t message_limit,
1149 const char *method_prefix,
1151 struct GNUNET_PSYC_Slicer *slicer,
1152 GNUNET_ResultCallback result_cb,
1156 * Cancel learning about the history of a place.
1159 * History lesson to cancel.
1162 GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
1165 struct GNUNET_SOCIAL_LookHandle;
1169 * Look at a particular object in the place.
1171 * The best matching object is returned (its name might be less specific than
1172 * what was requested).
1175 * The place to look the object at.
1177 * Full name of the object.
1179 * Set to the size of the returned value.
1181 * @return NULL if there is no such object at this place.
1183 struct GNUNET_SOCIAL_LookHandle *
1184 GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc,
1185 const char *full_name,
1186 GNUNET_PSYC_StateVarCallback var_cb,
1187 GNUNET_ResultCallback result_cb,
1191 * Look for objects in the place with a matching name prefix.
1194 * The place to look its objects at.
1195 * @param name_prefix
1196 * Look at objects with names beginning with this value.
1198 * Function to call for each object found.
1200 * Closure for callback function.
1202 * @return Handle that can be used to stop looking at objects.
1204 struct GNUNET_SOCIAL_LookHandle *
1205 GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc,
1206 const char *name_prefix,
1207 GNUNET_PSYC_StateVarCallback var_cb,
1208 GNUNET_ResultCallback result_cb,
1213 * Stop looking at objects.
1215 * @param lh Look handle to stop.
1218 GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
1222 * Advertise a @e place in the GNS zone of @a ego.
1225 * Application handle.
1228 * @param place_pub_key
1229 * Public key of place to add.
1231 * The name for the PLACE record to put in the zone.
1233 * Password used to encrypt the record or NULL to keep it cleartext.
1234 * @param relay_count
1235 * Number of elements in the @a relays array.
1237 * List of relays to put in the PLACE record to advertise
1238 * as entry points to the place in addition to the origin.
1239 * @param expiration_time
1240 * Expiration time of the record, use 0 to remove the record.
1242 * Function called with the result of the operation.
1244 * Closure for @a result_cb
1246 * @return #GNUNET_OK if the request was sent,
1247 * #GNUNET_SYSERR on error, e.g. the name/password is too long.
1250 GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
1251 const struct GNUNET_SOCIAL_Ego *ego,
1253 const char *password,
1254 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1255 const struct GNUNET_PeerIdentity *origin,
1256 uint32_t relay_count,
1257 const struct GNUNET_PeerIdentity *relays,
1258 struct GNUNET_TIME_Absolute expiration_time,
1259 GNUNET_ResultCallback result_cb,
1264 * Add public key to the GNS zone of the @e ego.
1271 * The name for the PKEY record to put in the zone.
1272 * @param nym_pub_key
1273 * Public key of nym to add.
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 is too long.
1285 GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
1286 const struct GNUNET_SOCIAL_Ego *ego,
1288 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
1289 struct GNUNET_TIME_Absolute expiration_time,
1290 GNUNET_ResultCallback result_cb,
1294 #if 0 /* keep Emacsens' auto-indent happy */
1301 /* ifndef GNUNET_SOCIAL_SERVICE_H */
1304 /** @} */ /* end of group */