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 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 Human conversation in a private or public place.
122 Message ID this message is in reply to.
125 Thread ID, the first message ID in the thread.
130 FIXME: Are nyms a different data type from egos and person entities?
131 Do they have a different format than any other entity address?
132 Questions and thoughts on how to fix this in "questions.org"
135 Signature of the message body and its variables by the author.
143 Notification about a place.
145 TODO: Applications can decide to auto-subscribe to certain places,
146 e.g. files under a given size.
153 GNS name of the place in a globally unique .zkey zone
155 FIXME: A custom _gns PSYC data type should be avoidable by parsing
156 and interpreting PSYC uniforms appropriately.
157 Thoughts on this in "questions.org"
164 FIXME: _key_pub can't be the data type for GNUnet-specific cryptographic
165 addressing. Questions and thoughts on how to fix this in "questions.org"
170 ##### _list_peer_relays
171 List of peer IDs of relays
173 ## _notice_place_file
175 Notification about a place hosting a file.
179 The environment of _notice_place above, plus the following:
190 #### _description_file
195 Messages with a _file method contain a file,
196 which is saved to disk upon reception at the following location:
197 $GNUNET_DATA_HOME/social/files/<H(place_pub)>/<message_id>
210 #### _description_file
217 #ifndef GNUNET_SOCIAL_SERVICE_H
218 #define GNUNET_SOCIAL_SERVICE_H
223 #if 0 /* keep Emacsens' auto-indent happy */
229 #include "gnunet_util_lib.h"
230 #include "gnunet_psyc_util_lib.h"
231 #include "gnunet_identity_service.h"
232 #include "gnunet_namestore_service.h"
233 #include "gnunet_psyc_service.h"
237 * Version number of GNUnet Social API.
239 #define GNUNET_SOCIAL_VERSION 0x00000000
242 * Maximum size of client ID including '\0' terminator.
244 #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256
246 enum GNUNET_SOCIAL_MsgProcFlags {
247 GNUNET_SOCIAL_MSG_PROC_NONE = 0,
248 GNUNET_SOCIAL_MSG_PROC_RELAY = 1,
249 GNUNET_SOCIAL_MSG_PROC_SAVE= 2,
253 * Handle for an application.
255 struct GNUNET_SOCIAL_App;
258 * Handle for an ego (own identity)
260 struct GNUNET_SOCIAL_Ego;
263 * Handle for a pseudonym of another user in the network.
265 struct GNUNET_SOCIAL_Nym;
268 * Handle for a place where social interactions happen.
270 struct GNUNET_SOCIAL_Place;
273 * Host handle for a place that we entered.
275 struct GNUNET_SOCIAL_Host;
278 * Guest handle for place that we entered.
280 struct GNUNET_SOCIAL_Guest;
283 * Handle that can be used to reconnect to a place as host.
285 struct GNUNET_SOCIAL_HostConnection;
288 * Handle that can be used to reconnect to a place as guest.
290 struct GNUNET_SOCIAL_GuestConnection;
293 * Notification about an available identity.
303 (*GNUNET_SOCIAL_AppEgoCallback) (void *cls,
304 struct GNUNET_SOCIAL_Ego *ego,
305 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
310 * Entry status of a place per application.
312 enum GNUNET_SOCIAL_AppPlaceState
315 * The place was once entered by the ego, but left since.
316 * It's possible to establish a local connection to the place
317 * without re-entering to fetch history from the PSYCstore.
318 * @see enum GNUNET_PSYC_SlaveJoinFlags and GNUNET_SOCIAL_guest_enter()
320 GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0,
323 * The place is entered by the ego,
324 * but this application is not subscribed to it.
326 GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1,
329 * The place is entered by the ego and
330 * and this application is subscribed to it.
332 GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2,
337 * Called after receiving initial list of egos and places.
340 (*GNUNET_SOCIAL_AppConnectedCallback) (void *cls);
344 * Notification about a home.
349 * Host connection, to be used with GNUNET_SOCIAL_host_enter_reconnect()
351 * Ego used to enter the place.
352 * @param place_pub_key
353 * Public key of the place.
355 * @see enum GNUNET_SOCIAL_AppPlaceState
358 (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls,
359 struct GNUNET_SOCIAL_HostConnection *hconn,
360 struct GNUNET_SOCIAL_Ego *ego,
361 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
362 enum GNUNET_SOCIAL_AppPlaceState place_state);
365 * Notification about a place.
370 * Guest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect()
372 * Ego used to enter the place.
373 * @param place_pub_key
374 * Public key of the place.
376 * @see enum GNUNET_SOCIAL_AppPlaceState
379 (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls,
380 struct GNUNET_SOCIAL_GuestConnection *gconn,
381 struct GNUNET_SOCIAL_Ego *ego,
382 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
383 enum GNUNET_SOCIAL_AppPlaceState place_state);
387 * Establish application connection to the social service.
389 * The @host_place_cb and @guest_place_cb functions are
390 * initially called for each entered places,
391 * then later each time a new place is entered with the current app ID.
396 * Function to notify about an available ego.
398 * Function to notify about a place entered as host.
400 * Function to notify about a place entered as guest.
402 * Closure for the callbacks.
404 * @return Handle that can be used to stop listening.
406 struct GNUNET_SOCIAL_App *
407 GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
409 GNUNET_SOCIAL_AppEgoCallback ego_cb,
410 GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
411 GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
412 GNUNET_SOCIAL_AppConnectedCallback connected_cb,
423 GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app);
427 * Get the public key of @a ego.
432 * @return Public key of ego.
434 const struct GNUNET_CRYPTO_EcdsaPublicKey *
435 GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego);
439 * Get the name of @a ego.
444 * @return Public key of @a ego.
447 GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego);
451 * Get the public key of a @a nym.
453 * Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().
456 * Pseudonym to map to a cryptographic identifier.
458 * @return Public key of nym.
460 const struct GNUNET_CRYPTO_EcdsaPublicKey *
461 GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym);
465 * Get the hash of the public key of a @a nym.
468 * Pseudonym to map to a cryptographic identifier.
470 * @return Hash of the public key of nym.
472 const struct GNUNET_HashCode *
473 GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
477 * Function called asking for nym to be admitted to the place.
479 * Should call either GNUNET_SOCIAL_host_admit() or
480 * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
481 * cannot decide, it is fine to call neither function, in which case hopefully
482 * some other host of the place exists that will make the decision. The @a nym
483 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
489 * Handle for the user who wants to enter.
491 * Method name in the entry request.
492 * @param variable_count
493 * Number of elements in the @a variables array.
495 * Variables present in the message.
497 * Payload given on enter (e.g. a password).
499 * Number of bytes in @a data.
502 (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
503 struct GNUNET_SOCIAL_Nym *nym,
504 const char *method_name,
505 struct GNUNET_PSYC_Environment *env,
511 * Function called when a @a nym leaves the place.
513 * This is also called if the @a nym was never given permission to enter
514 * (i.e. the @a nym stopped asking to get in).
519 * Handle for the user who left.
522 (*GNUNET_SOCIAL_FarewellCallback) (void *cls,
523 const struct GNUNET_SOCIAL_Nym *nym,
524 struct GNUNET_PSYC_Environment *env);
528 * Function called after the host entered a home.
533 * #GNUNET_OK on success, or
534 * #GNUNET_SYSERR on error.
535 * @param place_pub_key
536 * Public key of home.
537 * @param max_message_id
538 * Last message ID sent to the channel.
539 * Or 0 if no messages have been sent to the place yet.
542 (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, int result,
543 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
544 uint64_t max_message_id);
548 * Enter a place as host.
550 * A place is created upon first entering, and it is active until permanently
551 * left using GNUNET_SOCIAL_host_leave().
554 * Configuration to contact the social service.
556 * Identity of the host.
558 * Private-public key pair of the place.
559 * NULL for ephemeral places.
561 * Policy specifying entry and history restrictions for the place.
563 * Slicer to handle incoming messages.
565 * Function called when the place is entered and ready to use.
566 * @param answer_door_cb
567 * Function to handle new nyms that want to enter.
569 * Function to handle departing nyms.
571 * Closure for the callbacks.
573 * @return Handle for the host.
575 struct GNUNET_SOCIAL_Host *
576 GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
577 const struct GNUNET_SOCIAL_Ego *ego,
578 enum GNUNET_PSYC_Policy policy,
579 struct GNUNET_PSYC_Slicer *slicer,
580 GNUNET_SOCIAL_HostEnterCallback enter_cb,
581 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
582 GNUNET_SOCIAL_FarewellCallback farewell_cb,
587 * Reconnect to an already entered place as host.
590 * Host connection handle.
591 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
593 * Slicer to handle incoming messages.
595 * Function called when the place is entered and ready to use.
596 * @param answer_door_cb
597 * Function to handle new nyms that want to enter.
599 * Function to handle departing nyms.
601 * Closure for the callbacks.
603 * @return Handle for the host.
605 struct GNUNET_SOCIAL_Host *
606 GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
607 struct GNUNET_PSYC_Slicer *slicer,
608 GNUNET_SOCIAL_HostEnterCallback enter_cb,
609 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
610 GNUNET_SOCIAL_FarewellCallback farewell_cb,
615 * Decision whether to admit @a nym into the place or refuse entry.
620 * Handle for the entity that wanted to enter.
622 * #GNUNET_YES if @a nym is admitted,
623 * #GNUNET_NO if @a nym is refused entry,
624 * #GNUNET_SYSERR if we cannot answer the request.
626 * Entry response message, or NULL.
627 * @return #GNUNET_OK on success,
628 * #GNUNET_SYSERR if the message is too large.
631 GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
632 struct GNUNET_SOCIAL_Nym *nym,
634 const struct GNUNET_PSYC_Message *entry_resp);
638 * Throw @a nym out of the place.
640 * Sends a _notice_place_leave announcement to the home.
642 * The @a nym reference will remain valid until the
643 * #GNUNET_SOCIAL_FarewellCallback is invoked,
644 * which should be very soon after this call.
649 * Handle for the entity to be ejected.
651 * Environment for the message or NULL.
652 * _nym is set to @e nym regardless whether an @e env is provided.
655 GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
656 const struct GNUNET_SOCIAL_Nym *nym,
657 struct GNUNET_PSYC_Environment *env);
661 * Flags for announcements by a host.
663 enum GNUNET_SOCIAL_AnnounceFlags
665 GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
668 * Whether this announcement removes all objects from the place.
670 * New objects can be still added to the now empty place using the @e env
671 * parameter of the same announcement.
673 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
678 * Handle for an announcement request.
680 struct GNUNET_SOCIAL_Announcement;
684 * Send a message to all nyms that are present in the place.
686 * This function is restricted to the host. Nyms can only send requests
687 * to the host who can decide to relay it to everyone in the place.
692 * Method to use for the announcement.
694 * Environment containing variables for the message and operations
695 * on objects of the place.
696 * Has to remain available until the first call to @a notify_data.
699 * Function to call to get the payload of the announcement.
700 * @param notify_data_cls
701 * Closure for @a notify.
703 * Flags for this announcement.
705 * @return NULL on error (another announcement already in progress?).
707 struct GNUNET_SOCIAL_Announcement *
708 GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
709 const char *method_name,
710 const struct GNUNET_PSYC_Environment *env,
711 GNUNET_PSYC_TransmitNotifyData notify_data,
712 void *notify_data_cls,
713 enum GNUNET_SOCIAL_AnnounceFlags flags);
717 * Resume transmitting announcement.
720 * The announcement to resume.
723 GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
727 * Cancel announcement.
730 * The announcement to cancel.
733 GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
737 * Allow relaying messages from guests matching a given @a method_prefix.
741 * @param method_prefix
742 * Method prefix to allow.
745 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
746 const char *method_prefix);
750 * Allow relaying changes to objects of the place.
752 * Only applies to messages with an allowed method name.
753 * @see GNUNET_SCOIAL_host_relay_allow_method()
757 * @param object_prefix
758 * Object prefix to allow modifying.
761 GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
762 const char *object_prefix);
766 * Stop relaying messages from guests.
768 * Remove all allowed relay rules.
774 GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host);
778 * Obtain handle for a hosted place.
780 * The returned handle can be used to access the place API.
783 * Handle for the host.
785 * @return Handle for the hosted place, valid as long as @a host is valid.
787 struct GNUNET_SOCIAL_Place *
788 GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
792 * Disconnect from a home.
794 * Invalidates host handle.
797 * The host to disconnect.
798 * @param disconnect_cb
799 * Function called after disconnected from the service.
801 * Closure for @a disconnect_cb.
804 GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
805 GNUNET_ContinuationCallback disconnect_cb,
810 * Stop hosting a home.
812 * Sends a _notice_place_closing announcement to the home.
813 * Invalidates host handle.
818 * Environment for the message or NULL.
819 * @param disconnect_cb
820 * Function called after the host left the place
821 * and disconnected from the service.
823 * Closure for @a disconnect_cb.
826 GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
827 const struct GNUNET_PSYC_Environment *env,
828 GNUNET_ContinuationCallback disconnect_cb,
833 * Function called after the guest entered the local copy of the place.
835 * History and object query functions can be used after this call,
836 * but new messages can't be sent or received.
841 * #GNUNET_OK on success, or
842 * #GNUNET_SYSERR on error, e.g. could not connect to the service, or
843 * could not resolve GNS name.
844 * @param place_pub_key
845 * Public key of place.
846 * @param max_message_id
847 * Last message ID sent to the place.
848 * Or 0 if no messages have been sent to the place yet.
851 (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result,
852 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
853 uint64_t max_message_id);
857 * Function called upon a guest receives a decision about entry to the place.
860 * Is the guest admitted to the place?
861 * #GNUNET_YES if admitted,
862 * #GNUNET_NO if refused entry,
863 * #GNUNET_SYSERR if the request could not be answered.
865 * Entry response message.
868 (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
870 const struct GNUNET_PSYC_Message *entry_resp);
874 * Request entry to a place as a guest.
877 * Application handle.
879 * Identity of the guest.
880 * @param place_pub_key
881 * Public key of the place to enter.
883 * Flags for the entry.
885 * Peer identity of the origin of the underlying multicast group.
887 * Number of elements in the @a relays array.
889 * Relays for the underlying multicast group.
893 * Slicer to use for processing incoming requests from guests.
895 * @return NULL on errors, otherwise handle for the guest.
897 struct GNUNET_SOCIAL_Guest *
898 GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
899 const struct GNUNET_SOCIAL_Ego *ego,
900 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
901 enum GNUNET_PSYC_SlaveJoinFlags flags,
902 const struct GNUNET_PeerIdentity *origin,
903 uint32_t relay_count,
904 const struct GNUNET_PeerIdentity *relays,
905 const struct GNUNET_PSYC_Message *entry_msg,
906 struct GNUNET_PSYC_Slicer *slicer,
907 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
908 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
913 * Request entry to a place by name as a guest.
916 * Application handle.
918 * Identity of the guest.
920 * GNS name of the place to enter. Either in the form of
921 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
922 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
923 * nym's public key 'NYMPUBKEY', and can be used to request entry to a
924 * pseudonym's place directly.
926 * Password to decrypt the record, or NULL for cleartext records.
928 * Entry request message.
930 * Slicer to use for processing incoming requests from guests.
931 * @param local_enter_cb
932 * Called upon connection established to the social service.
933 * @param entry_decision_cb
934 * Called upon receiving entry decision.
936 * @return NULL on errors, otherwise handle for the guest.
938 struct GNUNET_SOCIAL_Guest *
939 GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
940 const struct GNUNET_SOCIAL_Ego *ego,
941 const char *gns_name,
942 const char *password,
943 const struct GNUNET_PSYC_Message *join_msg,
944 struct GNUNET_PSYC_Slicer *slicer,
945 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
946 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
951 * Reconnect to an already entered place as guest.
954 * Guest connection handle.
955 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
957 * Flags for the entry.
959 * Slicer to use for processing incoming requests from guests.
960 * @param local_enter_cb
961 * Called upon connection established to the social service.
962 * @param entry_decision_cb
963 * Called upon receiving entry decision.
965 * @return NULL on errors, otherwise handle for the guest.
967 struct GNUNET_SOCIAL_Guest *
968 GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
969 enum GNUNET_PSYC_SlaveJoinFlags flags,
970 struct GNUNET_PSYC_Slicer *slicer,
971 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
976 * Flags for talking to the host of a place.
978 enum GNUNET_SOCIAL_TalkFlags
980 GNUNET_SOCIAL_TALK_NONE = 0
987 struct GNUNET_SOCIAL_TalkRequest;
991 * Talk to the host of the place.
994 * Place where we want to talk to the host.
996 * Method to invoke on the host.
998 * Environment containing variables for the message, or NULL.
1000 * Function to use to get the payload for the method.
1001 * @param notify_data_cls
1002 * Closure for @a notify_data.
1004 * Flags for the message being sent.
1006 * @return NULL if we are already trying to talk to the host,
1007 * otherwise handle to cancel the request.
1009 struct GNUNET_SOCIAL_TalkRequest *
1010 GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
1011 const char *method_name,
1012 const struct GNUNET_PSYC_Environment *env,
1013 GNUNET_PSYC_TransmitNotifyData notify_data,
1014 void *notify_data_cls,
1015 enum GNUNET_SOCIAL_TalkFlags flags);
1019 * Resume talking to the host of the place.
1022 * Talk request to resume.
1025 GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
1029 * Cancel talking to the host of the place.
1032 * Talk request to cancel.
1035 GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
1039 * Disconnect from a place.
1041 * Invalidates guest handle.
1044 * The guest to disconnect.
1045 * @param disconnect_cb
1046 * Function called after disconnected from the service.
1048 * Closure for @a disconnect_cb.
1051 GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
1052 GNUNET_ContinuationCallback disconnect_cb,
1057 * Leave a place temporarily or permanently.
1059 * Notifies the owner of the place about leaving, and destroys the place handle.
1064 * Optional environment for the leave message if @a keep_active
1065 * is #GNUNET_NO. NULL if not needed.
1066 * @param disconnect_cb
1067 * Called upon disconnecting from the social service.
1070 GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
1071 struct GNUNET_PSYC_Environment *env,
1072 GNUNET_ContinuationCallback disconnect_cb,
1077 * Obtain handle for a place entered as guest.
1079 * The returned handle can be used to access the place API.
1081 * @param guest Handle for the guest.
1083 * @return Handle for the place, valid as long as @a guest is valid.
1085 struct GNUNET_SOCIAL_Place *
1086 GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
1090 * A history request.
1092 struct GNUNET_SOCIAL_HistoryRequest;
1096 * Get the public key of a place.
1101 * @return Public key of the place.
1103 const struct GNUNET_CRYPTO_EddsaPublicKey *
1104 GNUNET_SOCIAL_place_get_pub_key (const struct GNUNET_SOCIAL_Place *plc);
1108 * Set message processing @a flags for a @a method_prefix.
1112 * @param method_prefix
1113 * Method prefix @a flags apply to.
1115 * The flags that apply to a matching @a method_prefix.
1118 GNUNET_SOCIAL_place_msg_proc_set (struct GNUNET_SOCIAL_Place *plc,
1119 const char *method_prefix,
1120 enum GNUNET_SOCIAL_MsgProcFlags flags);
1123 * Clear all message processing flags previously set for this place.
1126 GNUNET_SOCIAL_place_msg_proc_clear (struct GNUNET_SOCIAL_Place *plc);
1130 * Learn about the history of a place.
1132 * Messages are returned through the @a slicer function
1133 * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1136 * Place we want to learn more about.
1137 * @param start_message_id
1138 * First historic message we are interested in.
1139 * @param end_message_id
1140 * Last historic message we are interested in (inclusive).
1141 * @param method_prefix
1142 * Only retrieve messages with this method prefix.
1144 * OR'ed GNUNET_PSYC_HistoryReplayFlags
1146 * Slicer to use for retrieved messages.
1147 * Can be the same as the slicer of the place.
1149 * Function called after all messages retrieved.
1150 * NULL if not needed.
1151 * @param cls Closure for @a result_cb.
1153 struct GNUNET_SOCIAL_HistoryRequest *
1154 GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1155 uint64_t start_message_id,
1156 uint64_t end_message_id,
1157 const char *method_prefix,
1159 struct GNUNET_PSYC_Slicer *slicer,
1160 GNUNET_ResultCallback result_cb,
1165 * Learn about the history of a place.
1167 * Sends messages through the slicer function of the place where
1168 * start_message_id <= message_id <= end_message_id.
1169 * The messages will have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1171 * To get the latest message, use 0 for both the start and end message ID.
1174 * Place we want to learn more about.
1175 * @param message_limit
1176 * Maximum number of historic messages we are interested in.
1178 * Function called after all messages retrieved.
1179 * NULL if not needed.
1180 * @param cls Closure for @a result_cb.
1182 struct GNUNET_SOCIAL_HistoryRequest *
1183 GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
1184 uint64_t message_limit,
1185 const char *method_prefix,
1187 struct GNUNET_PSYC_Slicer *slicer,
1188 GNUNET_ResultCallback result_cb,
1192 * Cancel learning about the history of a place.
1195 * History lesson to cancel.
1198 GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
1201 struct GNUNET_SOCIAL_LookHandle;
1205 * Look at a particular object in the place.
1207 * The best matching object is returned (its name might be less specific than
1208 * what was requested).
1211 * The place to look the object at.
1213 * Full name of the object.
1215 * @return NULL if there is no such object at this place.
1217 struct GNUNET_SOCIAL_LookHandle *
1218 GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc,
1219 const char *full_name,
1220 GNUNET_PSYC_StateVarCallback var_cb,
1221 GNUNET_ResultCallback result_cb,
1225 * Look for objects in the place with a matching name prefix.
1228 * The place to look its objects at.
1229 * @param name_prefix
1230 * Look at objects with names beginning with this value.
1232 * Function to call for each object found.
1234 * Closure for callback function.
1236 * @return Handle that can be used to stop looking at objects.
1238 struct GNUNET_SOCIAL_LookHandle *
1239 GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc,
1240 const char *name_prefix,
1241 GNUNET_PSYC_StateVarCallback var_cb,
1242 GNUNET_ResultCallback result_cb,
1247 * Stop looking at objects.
1249 * @param lh Look handle to stop.
1252 GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
1256 * Advertise a @e place in the GNS zone of @a ego.
1259 * Application handle.
1262 * @param place_pub_key
1263 * Public key of place to add.
1265 * The name for the PLACE record to put in the zone.
1267 * Password used to encrypt the record or NULL to keep it cleartext.
1268 * @param relay_count
1269 * Number of elements in the @a relays array.
1271 * List of relays to put in the PLACE record to advertise
1272 * as entry points to the place in addition to the origin.
1273 * @param expiration_time
1274 * Expiration time of the record, use 0 to remove the record.
1276 * Function called with the result of the operation.
1278 * Closure for @a result_cb
1280 * @return #GNUNET_OK if the request was sent,
1281 * #GNUNET_SYSERR on error, e.g. the name/password is too long.
1284 GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
1285 const struct GNUNET_SOCIAL_Ego *ego,
1287 const char *password,
1288 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1289 const struct GNUNET_PeerIdentity *origin,
1290 uint32_t relay_count,
1291 const struct GNUNET_PeerIdentity *relays,
1292 struct GNUNET_TIME_Absolute expiration_time,
1293 GNUNET_ResultCallback result_cb,
1298 * Add public key to the GNS zone of the @e ego.
1305 * The name for the PKEY record to put in the zone.
1306 * @param nym_pub_key
1307 * Public key of nym to add.
1308 * @param expiration_time
1309 * Expiration time of the record, use 0 to remove the record.
1311 * Function called with the result of the operation.
1313 * Closure for @a result_cb
1315 * @return #GNUNET_OK if the request was sent,
1316 * #GNUNET_SYSERR on error, e.g. the name is too long.
1319 GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
1320 const struct GNUNET_SOCIAL_Ego *ego,
1322 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
1323 struct GNUNET_TIME_Absolute expiration_time,
1324 GNUNET_ResultCallback result_cb,
1328 #if 0 /* keep Emacsens' auto-indent happy */
1335 /* ifndef GNUNET_SOCIAL_SERVICE_H */
1338 /** @} */ /* end of group */