2 This file is part of GNUnet.
3 Copyright (C) 2013 Christian Grothoff (and other contributing authors)
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 * @file include/gnunet_social_service.h
23 * @brief Social service; implements social interactions using the PSYC service.
24 * @author Gabor X Toth
25 * @author Christian Grothoff
27 #ifndef GNUNET_SOCIAL_SERVICE_H
28 #define GNUNET_SOCIAL_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
39 #include "gnunet_util_lib.h"
40 #include "gnunet_env_lib.h"
41 #include "gnunet_identity_service.h"
42 #include "gnunet_namestore_service.h"
43 #include "gnunet_psyc_service.h"
47 * Version number of GNUnet Social API.
49 #define GNUNET_SOCIAL_VERSION 0x00000000
52 * Maximum size of client ID including '\0' terminator.
54 #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256
57 * Handle for an application.
59 struct GNUNET_SOCIAL_App;
62 * Handle for an ego (own identity)
64 struct GNUNET_SOCIAL_Ego;
67 * Handle for a pseudonym of another user in the network.
69 struct GNUNET_SOCIAL_Nym;
72 * Handle for a place where social interactions happen.
74 struct GNUNET_SOCIAL_Place;
77 * Host handle for a place that we entered.
79 struct GNUNET_SOCIAL_Host;
82 * Guest handle for place that we entered.
84 struct GNUNET_SOCIAL_Guest;
87 * Handle to an implementation of try-and-slice.
89 struct GNUNET_SOCIAL_Slicer;
95 * Handle that can be used to reconnect to a place as host.
97 struct GNUNET_SOCIAL_HostConnection;
100 * Handle that can be used to reconnect to a place as guest.
102 struct GNUNET_SOCIAL_GuestConnection;
105 * Notification about an available identity.
115 (*GNUNET_SOCIAL_AppEgoCallback) (void *cls,
116 struct GNUNET_SOCIAL_Ego *ego,
117 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
122 * Notification about a place entered.
125 (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls,
126 struct GNUNET_SOCIAL_HostConnection *hconn,
127 struct GNUNET_SOCIAL_Ego *ego,
128 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key);
131 h * Notification about a place entered.
134 (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls,
135 struct GNUNET_SOCIAL_GuestConnection *gconn,
136 struct GNUNET_SOCIAL_Ego *ego,
137 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key);
141 * Establish application connection to the social service.
143 * The @host_place_cb and @guest_place_cb functions are
144 * initially called for each entered places,
145 * then later each time a new place is entered with the current app ID.
150 * Function to notify about an available ego.
152 * Function to notify about a place entered as host.
154 * Function to notify about a place entered as guest.
156 * Closure for the callbacks.
158 * @return Handle that can be used to stop listening.
160 struct GNUNET_SOCIAL_App *
161 GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
163 GNUNET_SOCIAL_AppEgoCallback ego_cb,
164 GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
165 GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
176 GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app);
180 * Get the public key of @a ego.
185 * @return Public key of ego.
187 const struct GNUNET_CRYPTO_EcdsaPublicKey *
188 GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego);
192 * Get the name of @a ego.
197 * @return Public key of @a ego.
200 GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego);
204 * Get the public key of a @a nym.
206 * Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().
209 * Pseudonym to map to a cryptographic identifier.
211 * @return Public key of nym.
213 const struct GNUNET_CRYPTO_EcdsaPublicKey *
214 GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym);
218 * Get the hash of the public key of a @a nym.
221 * Pseudonym to map to a cryptographic identifier.
223 * @return Hash of the public key of nym.
225 const struct GNUNET_HashCode *
226 GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
230 * Function called upon receiving a message indicating a call to a @e method.
232 * This function is called one or more times for each message until all data
233 * fragments arrive from the network.
238 * Message part, as it arrived from the network.
240 * Message counter, monotonically increasing from 1.
242 * The sender of the message.
243 * Can be NULL if the message is not connected to a pseudonym.
245 * OR'ed GNUNET_PSYC_MessageFlags
247 * Original method name from PSYC.
248 * May be more specific than the registered method name due to
249 * try-and-slice matching.
252 (*GNUNET_SOCIAL_MethodCallback) (void *cls,
253 const struct GNUNET_PSYC_MessageMethod *msg,
256 const struct GNUNET_SOCIAL_Nym *nym,
257 const char *method_name);
261 * Function called upon receiving a modifier of a message.
266 * Message ID this data fragment belongs to.
268 * Message part, as it arrived from the network.
270 * Operation to perform.
271 * 0 in case of a modifier continuation.
273 * Name of the modifier.
274 * NULL in case of a modifier continuation.
276 * Value of the modifier.
281 (*GNUNET_SOCIAL_ModifierCallback) (void *cls,
282 const struct GNUNET_MessageHeader *msg,
284 enum GNUNET_ENV_Operator oper,
288 uint16_t full_value_size);
292 * Function called upon receiving a data fragment of a message.
297 * Message ID this data fragment belongs to.
299 * Message part, as it arrived from the network.
301 * Byte offset of @a data in the overall data of the method.
303 * Number of bytes in @a data.
305 * Data stream given to the method.
308 * #GNUNET_NO if there are further fragments,
309 * #GNUNET_YES if this is the last fragment,
310 * #GNUNET_SYSERR indicates the message was cancelled by the sender.
313 (*GNUNET_SOCIAL_DataCallback) (void *cls,
314 const struct GNUNET_MessageHeader *msg,
316 uint64_t data_offset,
327 * Message part, as it arrived from the network.
329 * Message ID this data fragment belongs to.
331 * #GNUNET_YES if the message was cancelled,
332 * #GNUNET_NO if the message is complete.
335 (*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls,
336 const struct GNUNET_MessageHeader *msg,
342 * Create a try-and-slice instance.
344 * A slicer processes incoming messages and notifies callbacks about matching
345 * methods or modifiers encountered.
347 * @return A new try-and-slice construct.
349 struct GNUNET_SOCIAL_Slicer *
350 GNUNET_SOCIAL_slicer_create (void);
354 * Add a method to the try-and-slice instance.
356 * The callbacks are called for messages with a matching @a method_name prefix.
359 * The try-and-slice instance to extend.
361 * Name of the given method, use empty string to match all.
363 * Method handler invoked upon a matching message.
365 * Modifier handler, invoked after @a method_cb
366 * for each modifier in the message.
368 * Data handler, invoked after @a modifier_cb for each data fragment.
370 * Invoked upon reaching the end of a matching message.
372 * Closure for the callbacks.
375 GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
376 const char *method_name,
377 GNUNET_SOCIAL_MethodCallback method_cb,
378 GNUNET_SOCIAL_ModifierCallback modifier_cb,
379 GNUNET_SOCIAL_DataCallback data_cb,
380 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
384 * Remove a registered method from the try-and-slice instance.
386 * Removes one matching handler registered with the given
387 * @a method_name and callbacks.
390 * The try-and-slice instance.
392 * Name of the method to remove.
400 * End of message handler.
402 * @return #GNUNET_OK if a method handler was removed,
403 * #GNUNET_NO if no handler matched the given method name and callbacks.
406 GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
407 const char *method_name,
408 GNUNET_SOCIAL_MethodCallback method_cb,
409 GNUNET_SOCIAL_ModifierCallback modifier_cb,
410 GNUNET_SOCIAL_DataCallback data_cb,
411 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
415 * Watch a place for changed objects.
418 * The try-and-slice instance.
419 * @param object_filter
420 * Object prefix to match.
422 * Function to call when encountering a state modifier.
424 * Closure for callback.
427 GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
428 const char *object_filter,
429 GNUNET_SOCIAL_ModifierCallback modifier_cb,
434 * Remove a registered modifier from the try-and-slice instance.
436 * Removes one matching handler registered with the given
437 * @a object_filter and callback.
440 * The try-and-slice instance.
441 * @param object_filter
442 * Object prefix to match.
444 * Function to call when encountering a state modifier changes.
447 GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
448 const char *object_filter,
449 GNUNET_SOCIAL_ModifierCallback modifier_cb);
453 * Destroy a given try-and-slice instance.
459 GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
463 * Function called asking for nym to be admitted to the place.
465 * Should call either GNUNET_SOCIAL_host_admit() or
466 * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
467 * cannot decide, it is fine to call neither function, in which case hopefully
468 * some other host of the place exists that will make the decision. The @a nym
469 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
472 * @param cls Closure.
473 * @param nym Handle for the user who wants to enter.
474 * @param method_name Method name in the entry request.
475 * @param variable_count Number of elements in the @a variables array.
476 * @param variables Variables present in the message.
477 * @param data_size Number of bytes in @a data.
478 * @param data Payload given on enter (e.g. a password).
481 (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
482 struct GNUNET_SOCIAL_Nym *nym,
483 const char *method_name,
484 struct GNUNET_ENV_Environment *env,
490 * Function called when a @a nym leaves the place.
492 * This is also called if the @a nym was never given permission to enter
493 * (i.e. the @a nym stopped asking to get in).
498 * Handle for the user who left.
501 (*GNUNET_SOCIAL_FarewellCallback) (void *cls,
502 const struct GNUNET_SOCIAL_Nym *nym,
503 struct GNUNET_ENV_Environment *env);
507 * Function called after the host entered a home.
512 * #GNUNET_OK on success, or
513 * #GNUNET_SYSERR on error.
514 * @param place_pub_key
515 * Public key of home.
516 * @param max_message_id
517 * Last message ID sent to the channel.
518 * Or 0 if no messages have been sent to the place yet.
521 (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, int result,
522 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
523 uint64_t max_message_id);
527 * Enter a place as host.
529 * A place is created upon first entering, and it is active until permanently
530 * left using GNUNET_SOCIAL_host_leave().
533 * Configuration to contact the social service.
535 * Identity of the host.
537 * Private-public key pair of the place.
538 * NULL for ephemeral places.
540 * Policy specifying entry and history restrictions for the place.
542 * Slicer to handle incoming messages.
544 * Function called when the place is entered and ready to use.
545 * @param answer_door_cb
546 * Function to handle new nyms that want to enter.
548 * Function to handle departing nyms.
550 * Closure for the callbacks.
552 * @return Handle for the host.
554 struct GNUNET_SOCIAL_Host *
555 GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
556 const struct GNUNET_SOCIAL_Ego *ego,
557 enum GNUNET_PSYC_Policy policy,
558 struct GNUNET_SOCIAL_Slicer *slicer,
559 GNUNET_SOCIAL_HostEnterCallback enter_cb,
560 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
561 GNUNET_SOCIAL_FarewellCallback farewell_cb,
566 * Reconnect to an already entered place as host.
569 * Host connection handle.
570 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
572 * Slicer to handle incoming messages.
574 * Function called when the place is entered and ready to use.
575 * @param answer_door_cb
576 * Function to handle new nyms that want to enter.
578 * Function to handle departing nyms.
580 * Closure for the callbacks.
582 * @return Handle for the host.
584 struct GNUNET_SOCIAL_Host *
585 GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
586 struct GNUNET_SOCIAL_Slicer *slicer,
587 GNUNET_SOCIAL_HostEnterCallback enter_cb,
588 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
589 GNUNET_SOCIAL_FarewellCallback farewell_cb,
594 * Decision whether to admit @a nym into the place or refuse entry.
599 * Handle for the entity that wanted to enter.
601 * #GNUNET_YES if @a nym is admitted,
602 * #GNUNET_NO if @a nym is refused entry,
603 * #GNUNET_SYSERR if we cannot answer the request.
605 * Method name for the rejection message.
607 * Environment containing variables for the message, or NULL.
609 * Data for the rejection message to send back.
611 * Number of bytes in @a data for method.
612 * @return #GNUNET_OK on success,
613 * #GNUNET_SYSERR if the message is too large.
616 GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
617 struct GNUNET_SOCIAL_Nym *nym,
619 const struct GNUNET_PSYC_Message *entry_resp);
623 * Throw @a nym out of the place.
625 * Sends a _notice_place_leave announcement to the home.
627 * The @a nym reference will remain valid until the
628 * #GNUNET_SOCIAL_FarewellCallback is invoked,
629 * which should be very soon after this call.
634 * Handle for the entity to be ejected.
636 * Environment for the message or NULL.
637 * _nym is set to @e nym regardless whether an @e env is provided.
640 GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
641 const struct GNUNET_SOCIAL_Nym *nym,
642 struct GNUNET_ENV_Environment *env);
646 * Flags for announcements by a host.
648 enum GNUNET_SOCIAL_AnnounceFlags
650 GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
653 * Whether this announcement removes all objects from the place.
655 * New objects can be still added to the now empty place using the @e env
656 * parameter of the same announcement.
658 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
663 * Handle for an announcement request.
665 struct GNUNET_SOCIAL_Announcement;
669 * Send a message to all nyms that are present in the place.
671 * This function is restricted to the host. Nyms can only send requests
672 * to the host who can decide to relay it to everyone in the place.
677 * Method to use for the announcement.
679 * Environment containing variables for the message and operations
680 * on objects of the place.
681 * Has to remain available until the first call to @a notify_data.
684 * Function to call to get the payload of the announcement.
685 * @param notify_data_cls
686 * Closure for @a notify.
688 * Flags for this announcement.
690 * @return NULL on error (another announcement already in progress?).
692 struct GNUNET_SOCIAL_Announcement *
693 GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
694 const char *method_name,
695 const struct GNUNET_ENV_Environment *env,
696 GNUNET_PSYC_TransmitNotifyData notify_data,
697 void *notify_data_cls,
698 enum GNUNET_SOCIAL_AnnounceFlags flags);
702 * Resume transmitting announcement.
705 * The announcement to resume.
708 GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
712 * Cancel announcement.
715 * The announcement to cancel.
718 GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
722 * Obtain handle for a hosted place.
724 * The returned handle can be used to access the place API.
727 * Handle for the host.
729 * @return Handle for the hosted place, valid as long as @a host is valid.
731 struct GNUNET_SOCIAL_Place *
732 GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
736 * Disconnect from a home.
738 * Invalidates host handle.
741 * The host to disconnect.
742 * @param disconnect_cb
743 * Function called after disconnected from the service.
745 * Closure for @a disconnect_cb.
748 GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
749 GNUNET_ContinuationCallback disconnect_cb,
754 * Stop hosting a home.
756 * Sends a _notice_place_closed announcement to the home.
757 * Invalidates host handle.
762 * Environment for the message or NULL.
763 * @param disconnect_cb
764 * Function called after the host left the place
765 * and disconnected from the service.
767 * Closure for @a disconnect_cb.
770 GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
771 const struct GNUNET_ENV_Environment *env,
772 GNUNET_ContinuationCallback disconnect_cb,
777 * Function called after the guest entered the local copy of the place.
779 * History and object query functions can be used after this call,
780 * but new messages can't be sent or received.
785 * #GNUNET_OK on success, or
786 * #GNUNET_SYSERR on error, e.g. could not connect to the service, or
787 * could not resolve GNS name.
788 * @param max_message_id
789 * Last message ID sent to the place.
790 * Or 0 if no messages have been sent to the place yet.
793 (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result,
794 uint64_t max_message_id);
798 * Function called upon a guest receives a decision about entry to the place.
801 * Is the guest admitted to the place?
802 * #GNUNET_YES if admitted,
803 * #GNUNET_NO if refused entry
804 * #GNUNET_SYSERR if the request could not be answered.
806 * Method for the message sent along with the decision.
807 * NULL if no message was sent.
809 * Environment with variables for the message.
810 * NULL if there are no variables.
811 * It has to be freed using GNUNET_ENV_environment_destroy()
812 * when it is not needed anymore.
816 * Payload of the message.
819 (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
821 const struct GNUNET_PSYC_Message *entry_resp);
825 * Request entry to a place as a guest.
827 * @param cfg Configuration to contact the social service.
828 * @param ego Identity of the guest.
829 * @param crypto_address Public key of the place to enter.
830 * @param origin Peer identity of the origin of the underlying multicast group.
831 * @param relay_count Number of elements in the @a relays array.
832 * @param relays Relays for the underlying multicast group.
833 * @param method_name Method name for the message.
834 * @param env Environment containing variables for the message, or NULL.
835 * @param data Payload for the message to give to the enter callback.
836 * @param data_size Number of bytes in @a data.
837 * @param slicer Slicer to use for processing incoming requests from guests.
839 * @return NULL on errors, otherwise handle for the guest.
841 struct GNUNET_SOCIAL_Guest *
842 GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
843 const struct GNUNET_SOCIAL_Ego *ego,
844 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
845 const struct GNUNET_PeerIdentity *origin,
846 uint32_t relay_count,
847 const struct GNUNET_PeerIdentity *relays,
848 const struct GNUNET_PSYC_Message *entry_msg,
849 struct GNUNET_SOCIAL_Slicer *slicer,
850 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
851 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
856 * Request entry to a place by name as a guest.
859 * Configuration to contact the social service.
861 * Identity of the guest.
863 * GNS name of the place to enter. Either in the form of
864 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
865 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
866 * nym's public key 'NYMPUBKEY', and can be used to request entry to a
867 * pseudonym's place directly.
869 * Password to decrypt the record, or NULL for cleartext records.
871 * Entry request message.
873 * Slicer to use for processing incoming requests from guests.
874 * @param local_enter_cb
875 * Called upon connection established to the social service.
876 * @param entry_decision_cb
877 * Called upon receiving entry decision.
879 * @return NULL on errors, otherwise handle for the guest.
881 struct GNUNET_SOCIAL_Guest *
882 GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
883 const struct GNUNET_SOCIAL_Ego *ego,
884 const char *gns_name,
885 const char *password,
886 const struct GNUNET_PSYC_Message *join_msg,
887 struct GNUNET_SOCIAL_Slicer *slicer,
888 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
889 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
894 * Reconnect to an already entered place as guest.
897 * Guest connection handle.
898 * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
900 * Slicer to use for processing incoming requests from guests.
901 * @param local_enter_cb
902 * Called upon connection established to the social service.
903 * @param entry_decision_cb
904 * Called upon receiving entry decision.
906 * @return NULL on errors, otherwise handle for the guest.
908 struct GNUNET_SOCIAL_Guest *
909 GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
910 struct GNUNET_SOCIAL_Slicer *slicer,
911 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
916 * Flags for talking to the host of a place.
918 enum GNUNET_SOCIAL_TalkFlags
920 GNUNET_SOCIAL_TALK_NONE = 0
927 struct GNUNET_SOCIAL_TalkRequest;
931 * Talk to the host of the place.
934 * Place where we want to talk to the host.
936 * Method to invoke on the host.
938 * Environment containing variables for the message, or NULL.
940 * Function to use to get the payload for the method.
941 * @param notify_data_cls
942 * Closure for @a notify_data.
944 * Flags for the message being sent.
946 * @return NULL if we are already trying to talk to the host,
947 * otherwise handle to cancel the request.
949 struct GNUNET_SOCIAL_TalkRequest *
950 GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
951 const char *method_name,
952 const struct GNUNET_ENV_Environment *env,
953 GNUNET_PSYC_TransmitNotifyData notify_data,
954 void *notify_data_cls,
955 enum GNUNET_SOCIAL_TalkFlags flags);
959 * Resume talking to the host of the place.
962 * Talk request to resume.
965 GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
969 * Cancel talking to the host of the place.
972 * Talk request to cancel.
975 GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
979 * Disconnect from a place.
981 * Invalidates guest handle.
984 * The guest to disconnect.
985 * @param disconnect_cb
986 * Function called after disconnected from the service.
988 * Closure for @a disconnect_cb.
991 GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
992 GNUNET_ContinuationCallback disconnect_cb,
997 * Leave a place temporarily or permanently.
999 * Notifies the owner of the place about leaving, and destroys the place handle.
1004 * Optional environment for the leave message if @a keep_active
1005 * is #GNUNET_NO. NULL if not needed.
1006 * @param disconnect_cb
1007 * Called upon disconnecting from the social service.
1010 GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
1011 struct GNUNET_ENV_Environment *env,
1012 GNUNET_ContinuationCallback disconnect_cb,
1017 * Obtain handle for a place entered as guest.
1019 * The returned handle can be used to access the place API.
1021 * @param guest Handle for the guest.
1023 * @return Handle for the place, valid as long as @a guest is valid.
1025 struct GNUNET_SOCIAL_Place *
1026 GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
1030 * A history request.
1032 struct GNUNET_SOCIAL_HistoryRequest;
1036 * Learn about the history of a place.
1038 * Messages are returned through the @a slicer function
1039 * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1042 * Place we want to learn more about.
1043 * @param start_message_id
1044 * First historic message we are interested in.
1045 * @param end_message_id
1046 * Last historic message we are interested in (inclusive).
1047 * @param method_prefix
1048 * Only retrieve messages with this method prefix.
1050 * OR'ed GNUNET_PSYC_HistoryReplayFlags
1052 * Slicer to use for retrieved messages.
1053 * Can be the same as the slicer of the place.
1055 * Function called after all messages retrieved.
1056 * NULL if not needed.
1057 * @param cls Closure for @a result_cb.
1059 struct GNUNET_SOCIAL_HistoryRequest *
1060 GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1061 uint64_t start_message_id,
1062 uint64_t end_message_id,
1063 const char *method_prefix,
1065 struct GNUNET_SOCIAL_Slicer *slicer,
1066 GNUNET_ResultCallback result_cb,
1071 * Learn about the history of a place.
1073 * Sends messages through the slicer function of the place where
1074 * start_message_id <= message_id <= end_message_id.
1075 * The messages will have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
1077 * To get the latest message, use 0 for both the start and end message ID.
1080 * Place we want to learn more about.
1081 * @param message_limit
1082 * Maximum number of historic messages we are interested in.
1084 * Function called after all messages retrieved.
1085 * NULL if not needed.
1086 * @param cls Closure for @a result_cb.
1088 struct GNUNET_SOCIAL_HistoryRequest *
1089 GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
1090 uint64_t message_limit,
1091 const char *method_prefix,
1093 struct GNUNET_SOCIAL_Slicer *slicer,
1094 GNUNET_ResultCallback result_cb,
1098 * Cancel learning about the history of a place.
1101 * History lesson to cancel.
1104 GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
1107 struct GNUNET_SOCIAL_LookHandle;
1111 * Look at a particular object in the place.
1113 * The best matching object is returned (its name might be less specific than
1114 * what was requested).
1117 * The place to look the object at.
1119 * Full name of the object.
1121 * Set to the size of the returned value.
1123 * @return NULL if there is no such object at this place.
1125 struct GNUNET_SOCIAL_LookHandle *
1126 GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc,
1127 const char *full_name,
1128 GNUNET_PSYC_StateVarCallback var_cb,
1129 GNUNET_ResultCallback result_cb,
1133 * Look for objects in the place with a matching name prefix.
1136 * The place to look its objects at.
1137 * @param name_prefix
1138 * Look at objects with names beginning with this value.
1140 * Function to call for each object found.
1142 * Closure for callback function.
1144 * @return Handle that can be used to stop looking at objects.
1146 struct GNUNET_SOCIAL_LookHandle *
1147 GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc,
1148 const char *name_prefix,
1149 GNUNET_PSYC_StateVarCallback var_cb,
1150 GNUNET_ResultCallback result_cb,
1155 * Stop looking at objects.
1157 * @param lh Look handle to stop.
1160 GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
1164 * Advertise a @e place in the GNS zone of @a ego.
1167 * Application handle.
1170 * @param place_pub_key
1171 * Public key of place to add.
1173 * The name for the PLACE record to put in the zone.
1175 * Password used to encrypt the record or NULL to keep it cleartext.
1176 * @param relay_count
1177 * Number of elements in the @a relays array.
1179 * List of relays to put in the PLACE record to advertise
1180 * as entry points to the place in addition to the origin.
1181 * @param expiration_time
1182 * Expiration time of the record, use 0 to remove the record.
1184 * Function called with the result of the operation.
1186 * Closure for @a result_cb
1188 * @return #GNUNET_OK if the request was sent,
1189 * #GNUNET_SYSERR on error, e.g. the name/password is too long.
1192 GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
1193 const struct GNUNET_SOCIAL_Ego *ego,
1195 const char *password,
1196 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
1197 const struct GNUNET_PeerIdentity *origin,
1198 uint32_t relay_count,
1199 const struct GNUNET_PeerIdentity *relays,
1200 struct GNUNET_TIME_Absolute expiration_time,
1201 GNUNET_ResultCallback result_cb,
1206 * Add public key to the GNS zone of the @e ego.
1213 * The name for the PKEY record to put in the zone.
1214 * @param nym_pub_key
1215 * Public key of nym to add.
1216 * @param expiration_time
1217 * Expiration time of the record, use 0 to remove the record.
1219 * Function called with the result of the operation.
1221 * Closure for @a result_cb
1223 * @return #GNUNET_OK if the request was sent,
1224 * #GNUNET_SYSERR on error, e.g. the name is too long.
1227 GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
1228 const struct GNUNET_SOCIAL_Ego *ego,
1230 const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
1231 struct GNUNET_TIME_Absolute expiration_time,
1232 GNUNET_ResultCallback result_cb,
1236 #if 0 /* keep Emacsens' auto-indent happy */
1243 /* ifndef GNUNET_SOCIAL_SERVICE_H */
1245 /* end of gnunet_social_service.h */