From 15b4d21a45db18ce0384d1c42c83459ba2ed24f8 Mon Sep 17 00:00:00 2001 From: Gabor X Toth <*@tg-x.net> Date: Fri, 12 Jul 2013 08:47:10 +0000 Subject: [PATCH] PSYC APIs: added missing args and functions, more consistent naming - multicast: origin arg for join; s/leave/part/g - psyc: origin arg for join; join/part callbacks - social: enter2, home_advertise, away - psycstore/social: get latest historic message using ID 0 - added PSYC lib --- AUTHORS | 2 +- src/include/gnunet_crypto_lib.h | 2 +- src/include/gnunet_multicast_service.h | 156 ++++++-------- src/include/gnunet_protocols.h | 41 +--- src/include/gnunet_psyc_lib.h | 164 +++++++++++++++ src/include/gnunet_psyc_service.h | 273 +++++++++++++++---------- src/include/gnunet_psycstore_service.h | 23 +-- src/include/gnunet_social_service.h | 145 +++++++------ 8 files changed, 496 insertions(+), 310 deletions(-) create mode 100644 src/include/gnunet_psyc_lib.h diff --git a/AUTHORS b/AUTHORS index a06da68df..3a67d57fa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ Martin Schanzenbach Maximilian Szengel Florian Dold Christian Fuchs +Gabor X Toth Code contributions also came from: Adam Warrington [ UPnP ] @@ -36,7 +37,6 @@ Enrico Scholz Eric Haumant Eric Noack Felix von Leitner [ diet libc snprintf for win32 ] -Gabor Toth Gerd Knorr Glenn McGrath Hendrik Pagenhardt diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 9da6488f2..4a9553346 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -153,7 +153,7 @@ struct GNUNET_CRYPTO_HashAsciiEncoded /** - * @brief 0-terminated ASCII encoding of a 'struct GNUNET_ShortHashCode'. + * @brief 0-terminated ASCII encoding of a struct GNUNET_CRYPTO_ShortHashCode. */ struct GNUNET_CRYPTO_ShortHashAsciiEncoded { diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index 76a6bcf32..df677784a 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h @@ -22,7 +22,7 @@ * @file include/gnunet_multicast_service.h * @brief multicast service; establish tunnels to distant peers * @author Christian Grothoff - * @author tg(x) + * @author Gabor X Toth */ #ifndef GNUNET_MULTICAST_SERVICE_H @@ -138,12 +138,12 @@ struct GNUNET_MULTICAST_MessageHeader uint64_t message_id GNUNET_PACKED; /** - * Counter that monotonically increases whenever a member leaves the group. + * Counter that monotonically increases whenever a member parts the group. * * It has significance in case of replay requests: when a member has missed * messages and gets a replay request: in this case if the @a group_generation * is still the same before and after the missed messages, it means that no - * @e join or @a leave operations happened during the missed messages. + * @e join or @e part operations happened during the missed messages. */ uint64_t group_generation GNUNET_PACKED; @@ -174,7 +174,7 @@ struct GNUNET_MULTICAST_MessageHeader * Header for the message body. * * Three message types are specifically understood by multicast, namely "peer - * join", "peer leave", and "group terminated". Multicast will use those + * join", "peer part", and "group terminated". Multicast will use those * messages to update its list of candidates for content distribution. All * other message types are application-specific. */ @@ -194,9 +194,17 @@ GNUNET_NETWORK_STRUCT_END */ struct GNUNET_MULTICAST_JoinHandle; +/** + * Handle that identifies a part request. + * + * Used to match calls to #GNUNET_MULTICAST_PartCallback to the + * corresponding calls to GNUNET_MULTICAST_part_ack(). + */ +struct GNUNET_MULTICAST_PartHandle; + /** - * Function to call with the decision made for a membership change request. + * Function to call with the decision made for a join request. * * Must be called once and only once in response to an invocation of the * #GNUNET_MULTICAST_JoinCallback. @@ -206,9 +214,8 @@ struct GNUNET_MULTICAST_JoinHandle; * can also be used to redirect the peer to a different group at the * application layer; this response is to be transmitted to the * peer that issued the request even if admission is denied. - * @param is_admitted #GNUNET_OK if joining is approved, - * #GNUNET_SYSERR if it is disapproved; - * #GNUNET_NO for peers leaving. + * @param is_admitted #GNUNET_YES if joining is approved, + * #GNUNET_NO if it is disapproved * @param relay_count Number of relays given. * @param relays Array of suggested peers that might be useful relays to use * when joining the multicast group (essentially a list of peers that @@ -220,10 +227,19 @@ struct GNUNET_MULTICAST_JoinHandle; */ void GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, - const struct GNUNET_MessageHeader *join_response, - int is_admitted, - unsigned int relay_count, - const struct GNUNET_PeerIdentity *relays); + const struct GNUNET_MessageHeader *join_response, + int is_admitted, + unsigned int relay_count, + const struct GNUNET_PeerIdentity *relays); + + +/** + * Part acknowledgment. + * + * @param ph Part handle. + */ +void +GNUNET_MULTICAST_part_ack (struct GNUNET_MULTICAST_PartHandle *ph); /** @@ -249,17 +265,17 @@ typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls, /** * Method called whenever another peer wants to part the multicast group. * - * A leave request must be always be honoured. + * A part request must always be honoured, and answered with GNUNET_MULTICAST_part_ack(); * * @param cls Closure. - * @param peer Identity of the peer that wants to leave. - * @param msg Application-dependent leave message from the leaving user. - * @param jh Join handle to pass to GNUNET_MULTICAST_join_decison(). + * @param peer Identity of the peer that wants to part. + * @param msg Application-dependent part message from the leaving user. + * @param ph Part handle. */ typedef void (*GNUNET_MULTICAST_PartCallback)(void *cls, - const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *msg, - struct GNUNET_MULTICAST_JoinHandle *jh); + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *msg, + struct GNUNET_MULTICAST_PartHandle *ph); /** @@ -283,6 +299,9 @@ GNUNET_MULTICAST_membership_test_answer (struct GNUNET_MULTICAST_MembershipTestH /** * Method called to test if a member was in the group at a particular time. * + * It is called when a replay request is received to determine if the requested + * message can be replayed. + * * @param cls Closure. * @param peer Identity of the peer that we want to test. * @param message_id Message ID for which we want to do the test. @@ -300,7 +319,7 @@ typedef void (*GNUNET_MULTICAST_MembershipTestCallback)(void *cls, * * @param cls Closure (set from GNUNET_MULTICAST_origin_start). * @param sender Identity of the sender. - * @param request_id Unique counter for the request from this sender to this origin. + * @param request_id Unique counter for the request from this sender to this origin. FIXME: needed? * @param msg Message to the origin. */ typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls, @@ -322,11 +341,11 @@ typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls, * normal message IDs in either direction start at 1. * @param msg Message from the origin, NULL if the origin shut down * (or we were kicked out, and we should thus call - * GNUNET_MULTICAST_member_leave() next) + * GNUNET_MULTICAST_member_part() next) */ -typedef void (*GNUNET_MULTICAST_MulticastMessageCallback) (void *cls, - uint64_t message_id, - const struct GNUNET_MULTICAST_MessageHeader *msg); +typedef void (*GNUNET_MULTICAST_MessageCallback) (void *cls, + uint64_t message_id, + const struct GNUNET_MULTICAST_MessageHeader *msg); /** @@ -336,11 +355,12 @@ struct GNUNET_MULTICAST_ReplayHandle; /** - * Functions with this signature are called whenever the multicast - * service needs a message to be replayed. Implementations of this - * function MUST call GNUNET_MULTICAST_replay() ONCE (with a message - * or an error); however, if the origin is destroyed or the group is - * left, the replay handle must no longer be used. + * Functions with this signature are called whenever the multicast service needs + * a message to be replayed. + * + * Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE + * (with a message or an error); however, if the origin is destroyed or the + * group is left, the replay handle must no longer be used. * * @param cls Closure (set from GNUNET_MULTICAST_origin_start() * or GNUNET_MULTICAST_member_join()). @@ -397,48 +417,6 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh, enum GNUNET_MULTICAST_ReplayErrorCode ec); -/** - * Handle to pass back for the answer of a ping. - */ -struct GNUNET_MULTICAST_PingHandle; - - -/** - * A response to a @e ping. - * - * @param rh Handle that was given for the ping. - * @param message_id Latest message ID seen by this peer for this group. - * - * @deprecated needed??? - */ -void -GNUNET_MULTICAST_pong (struct GNUNET_MULTICAST_ReplayHandle *rh, - uint64_t message_id); - - -/** - * Method called whenever a @e ping is received from another member. - * - * A @e ping is sent after a period of inactivity to check if the member has not - * missed any messages. A ping contains the latest message ID a member has - * seen, and must be answered with GNUNET_MULTICAST_pong() containing the latest - * message ID seen by this peer. If the latest message ID on this peer is higher, the - * missing messages must be replayed to the requesting member using - * GNUNET_MULTICAST_replay(). - * - * @param cls Closure. - * @param peer Identity of the peer who sent the ping. - * @param latest_message_id Latest message ID seen by the requesting member. - * @param rh Handle to pass back to GNUNET_MULTICAST_pong() or GNUNET_MULTICAST_replay(). - * - * @deprecated needed??? - */ -typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls, - const struct GNUNET_PeerIdentity *peer, - uint64_t latest_messaged_id - struct GNUNET_MULTICAST_ReplayHandle *rh); - - /** * Start a multicast group. * @@ -460,7 +438,6 @@ typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls, * @param join_policy What is the membership policy of the group? * @param replay_cb Function that can be called to replay a message. * @param test_cb Function multicast can use to test group membership. - * @param ping_cb Function called to answer a ping. -- Gabor: remove this one!? deprecated? * @param join_cb Function called to approve / disapprove joining of a peer. * @param part_cb Function called when a member wants to part the group. * @param request_cb Function called with messages from group members. @@ -473,7 +450,6 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_MULTICAST_JoinPolicy join_policy, GNUNET_MULITCAST_ReplayCallback replay_cb, GNUNET_MULITCAST_MembershipTestCallback test_cb, - GNUNET_MULITCAST_PingCallback ping_cb, GNUNET_MULTICAST_JoinCallback join_cb, GNUNET_MULTICAST_PartCallback part_cb, GNUNET_MULTICAST_RequestCallback request_cb); @@ -483,7 +459,7 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg, * Handle for a request to send a message to all multicast group members * (from the origin). */ -struct GNUNET_MULTICAST_MulticastRequest; +struct GNUNET_MULTICAST_OriginMessageHandle; /** @@ -495,7 +471,7 @@ struct GNUNET_MULTICAST_MulticastRequest; * @param cb_cls Closure for @a cb. * @return NULL on error (i.e. request already pending). */ -struct GNUNET_MULTICAST_MulticastRequest * +struct GNUNET_MULTICAST_OriginMessageHandle * GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, size_t size, GNUNET_CONNECTION_TransmitReadyNotify cb, @@ -505,10 +481,10 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, /** * Cancel request for message transmission to multicast group. * - * @param mr Request to cancel. + * @param mh Request to cancel. */ void -GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_MulticastRequest *mr); +GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginMessageHandle *mh); /** @@ -527,7 +503,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin); * candidate can be provided in the @a join_req message. If the join fails, the * @a message_cb is invoked with a (failure) response and then with NULL. If * the join succeeds, outstanding (state) messages and ongoing multicast - * messages will be given to the @a message_cb until the member decides to leave + * messages will be given to the @a message_cb until the member decides to part * the group. The @a test_cb and @a replay_cb functions may be called at * anytime by the multicast service to support relaying messages to other * members of the group. @@ -535,6 +511,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin); * @param cfg Configuration to use. * @param cls Closure for callbacks. * @param pub_key ECC key that identifies the group. + * @param origin Peer identity of the origin. * @param max_known_message_id Largest known message ID to the replay service; * all messages with IDs larger than this ID will be replayed if * possible (lower IDs will be considered known and thus only @@ -561,18 +538,19 @@ struct GNUNET_MULTICAST_Member * GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, const struct GNUNET_CRYPTO_EccPublicKey *pub_key, + const struct GNUNET_PeerIdentity *origin, uint64_t max_known_message_id, uint64_t max_known_state_message_id, GNUNET_MULTICAST_ReplayCallback replay_cb, GNUNET_MULITCAST_MembershipTestCallback test_cb, - GNUNET_MULTICAST_MulticastMessageCallback message_cb, + GNUNET_MULTICAST_MessageCallback message_cb, const struct GNUNET_MessageHeader *join_req); /** * Handle for a replay request. */ -struct GNUNET_MULTICAST_ReplayRequest; +struct GNUNET_MULTICAST_MemberReplayHandle; /** @@ -587,20 +565,20 @@ struct GNUNET_MULTICAST_ReplayRequest; * @param message_cb_cls Closure for @a message_cb. * @return Replay request handle, NULL on error. */ -struct GNUNET_MULTICAST_ReplayRequest * +struct GNUNET_MULTICAST_MemberReplayHandle * GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member, uint64_t message_id, - GNUNET_MULTICAST_MulticastMessageCallback message_cb, + GNUNET_MULTICAST_MessageCallback message_cb, void *message_cb_cls); /** * Cancel a replay request. * - * @param rr Request to cancel. + * @param rh Request to cancel. */ void -GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_ReplayRequest *rr); +GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_MemberReplayHandle *rh); /** @@ -613,9 +591,9 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member); /** - * Handle for a message to be delivered to the origin. + * Handle for a message to be delivered from a member to the origin. */ -struct GNUNET_MULTICAST_ResponseRequest; +struct GNUNET_MULTICAST_MemberRequestHandle; /** @@ -627,7 +605,7 @@ struct GNUNET_MULTICAST_ResponseRequest; * @param cb_cls Closure for @a cb. * @return Handle to cancel request, NULL on error (i.e. request already pending). */ -struct GNUNET_MULTICAST_ResponseRequest * +struct GNUNET_MULTICAST_MemberRequestHandle * GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, size_t size, GNUNET_CONNECTION_TransmitReadyNotify cb, @@ -637,10 +615,10 @@ GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, /** * Cancel request for message transmission to origin. * - * @param rr Request to cancel. + * @param rh Request to cancel. */ void -GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_ResponseRequest *rr); +GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_MemberRequestHandle *rh); diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 1fb153673..b60fe65d4 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -1878,52 +1878,31 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST - /** * A peer wants to join the group. * - * Unicast message to a group member. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST_JOIN - -/** - * A join request was rejected. - * - * Unicast response to a join request. + * Unicast message to the origin or another group member. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REJECT_JOIN +#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST /** - * A peer joined the group. + * Response to a join request. * - * Sent to all members by the origin. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_NOTICE_JOIN - -/** - * A peer wants to leave the group. - */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST_LEAVE - -/** - * A peer left the group. + * Unicast message from a group member to the peer wanting to join. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_NOTICE_LEAVE +#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION /** - * Ping request from a peer. - * - * A ping is sent after a period of inactivity and contains the last received - * message ID. + * A peer wants to part the group. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_PEER_PING +#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST /** - * Response to a ping. + * Acknowledgement sent in response to a part request. * - * Contains the last received message ID. + * Unicast message from a group member to the peer wanting to part. */ -#define GNUNET_MESSAGE_TYPE_MULTICAST_PEER_PONG +#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_ACK /** * Group terminated. diff --git a/src/include/gnunet_psyc_lib.h b/src/include/gnunet_psyc_lib.h new file mode 100644 index 000000000..bd8cbf025 --- /dev/null +++ b/src/include/gnunet_psyc_lib.h @@ -0,0 +1,164 @@ +/* + This file is part of GNUnet. + (C) 2013 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file include/gnunet_psyc_lib.h + * @brief Library for common PSYC functionality: + * types, variable (de)serialization. + * @author Gabor X Toth + */ + + +/** + * Possible operations on PSYC state (persistent) and transient variables (per message). + */ +enum GNUNET_PSYC_Operator +{ + /** + * Set value of a transient variable. + */ + GNUNET_PSYC_OP_SET = ':', + + /** + * Assign value for a persistent state variable. + * + * If an assigned value is NULL, the variable is deleted. + */ + GNUNET_PSYC_OP_ASSIGN = '=', + + /** + * Augment state variable. + * + * Used for appending strings, adding numbers, and adding new items to a list or dictionary. + */ + GNUNET_PSYC_OP_AUGMENT = '+', + + /** + * Diminish state variable. + * + * Used for subtracting numbers, and removing items from a list or dictionary. + */ + GNUNET_PSYC_OP_DIMINISH = '-', + + /** + * Update state variable. + * + * Used for modifying a single item of a list or dictionary. + */ + GNUNET_PSYC_OP_UPDATE = '@', +}; + + +/** + * PSYC variable types. + */ +enum GNUNET_PSYC_Type +{ + GNUNET_PSYC_TYPE_DATA = 0, + GNUNET_PSYC_TYPE_NUMBER, + GNUNET_PSYC_TYPE_LIST, + GNUNET_PSYC_TYPE_DICT +}; + + +/** + * Get the type of variable. + * + * @param name Name of the variable. + * + * @return Variable type. + */ +enum GNUNET_PSYC_Type +GNUNET_PSYC_var_get_type (char *name); + + +/** + * Get the variable's value as an integer. + * + * @param size Size of value. + * @param value Raw value of variable. + * @param[out] number Value converted to a 64-bit integer. + * + * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). + */ +int +GNUNET_PSYC_value_to_number (size_t size, const void *value, int64_t *number); + + +/** + * Get the variable's value as a list. + * + * @param size Size of value. + * @param value Raw value of variable. + * @param[out] list A newly created list holding the elements. + * + * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). + */ +int +GNUNET_PSYC_value_to_list (size_t size, const void *value, GNUNET_CONTAINER_SList **list); + + +/** + * Get the variable's value as a dictionary. + * + * @param size Size of value. + * @param value Raw value of variable. + * @param[out] dict A newly created hashmap holding the elements of the dictionary. + * + * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid). + */ +int +GNUNET_PSYC_value_to_dict (size_t size, const void *value, GNUNET_CONTAINER_MultiHashMap **dict); + + +/** + * Create a PSYC variable value from an integer. + * + * @param number The number to convert. + * @param[out] value_size Size of returned value. + * + * @return A newly allocated value or NULL on error. + */ +void * +GNUNET_PSYC_value_from_number (int64_t number, size_t *value_size); + + +/** + * Create a PSYC variable value from a list. + * + * @param list The list to convert. + * @param[out] value_size Size of returned value. + * + * @return A newly allocated value or NULL on error. + */ +void * +GNUNET_PSYC_value_from_list (GNUNET_CONTAINER_SList *list, size_t *value_size); + + +/** + * Create a PSYC variable value from a dictionary. + * + * @param dict The dict to convert. + * @param[out] value_size Size of returned value. + * + * @return A newly allocated value or NULL on error. + */ +void * +GNUNET_PSYC_value_from_dict (GNUNET_CONTAINER_MultiHashMap *dict, size_t *value_size); diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 1eebe0a4b..6987bab82 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h @@ -28,6 +28,7 @@ * and this API deliberately exposes as little as possible * of the actual data stream format to the application! * @author Christian Grothoff + * @author Gabor X Toth * * NOTE: * - this API does not know about psyc's "root" and "places"; @@ -52,7 +53,7 @@ * - PSYC defines standard variables, methods, etc. This * library deliberately abstracts over all of these; a * higher-level API should combine the naming system (GADS) - * and standard methods (message, join, leave, warn, + * and standard methods (message, join, part, warn, * fail, error) and variables (action, color, time, * tag, etc.). However, this API does take over the * routing variables, specifically 'context' (channel), @@ -75,6 +76,7 @@ * Idee (lynx): * - rename "channel" to "master" * - rename "member" to "slave" + * - rename "group" to "channel" */ #ifndef GNUNET_PSYC_SERVICE_H @@ -89,6 +91,7 @@ extern "C" #endif #include "gnunet_util_lib.h" +#include "gnunet_psyc_lib.h" #include "gnunet_multicast_service.h" @@ -120,13 +123,28 @@ enum GNUNET_PSYC_FragmentStatus }; +/** + * Handle that identifies a join request. + * + * Used to match calls to #GNUNET_PSYC_JoinCallback to the + * corresponding calls to GNUNET_PSYC_join_decision(). + */ +struct GNUNET_PSYC_JoinHandle; + +/** + * Handle that identifies a part request. + * + * Used to match calls to #GNUNET_PSYC_PartCallback to the + * corresponding calls to GNUNET_PSYC_part_ack(). + */ +struct GNUNET_PSYC_PartHandle; + + /** * Method called from PSYC upon receiving a message indicating a call * to a @e method. * * @param cls Closure. - * @param full_method_name Original method name from PSYC (may be more - * specific than the registered method name due to try-and-slice matching). * @param sender Who transmitted the message (origin, except for messages * from one of the members to the origin). * @param message_id Unique message counter for this message; @@ -134,6 +152,9 @@ enum GNUNET_PSYC_FragmentStatus * this channel). * @param group_generation Group generation counter for this message * (always zero for messages from members to channel owner); FIXME: needed? + * @param method_name Original method name from PSYC (may be more + * specific than the registered method name due to try-and-slice matching). + * FIXME: no try-and-slice for methods defined here. * @param data_off Byte offset of @a data in the overall data of the method. * @param data_size Number of bytes in @a data. * @param data Data stream given to the method (might not be zero-terminated @@ -141,16 +162,82 @@ enum GNUNET_PSYC_FragmentStatus * @param frag Fragmentation status for the data. */ typedef int (*GNUNET_PSYC_Method)(void *cls, - const char *full_method_name, const struct GNUNET_PeerIdentity *sender, uint64_t message_id, uint64_t group_generation, + const char *method_name, uint64_t data_off, size_t data_size, const void *data, enum GNUNET_PSYC_FragmentStatus frag); +/** + * Method called from PSYC upon receiving a join request. + * + * @param cls Closure. + * @param sender Who transmitted the message. + * @param method_name Method name in the join request. + * @param data_size Number of bytes in @a data. + * @param data Data stream given to the method (might not be zero-terminated + * if data is binary). + */ +typedef int (*GNUNET_PSYC_JoinCallback)(void *cls, + const struct GNUNET_PeerIdentity *sender, + const char *method_name, + size_t data_size, + const void *data, + struct GNUNET_PSYC_JoinHandle *jh); + + +/** + * Method called from PSYC upon receiving a part request. + * + * @param cls Closure. + * @param sender Who transmitted the message. + * @param method_name Method name in the part request. + * @param data_size Number of bytes in @a data. + * @param data Data stream given to the method (might not be zero-terminated + * if data is binary). + */ +typedef int (*GNUNET_PSYC_PartCallback)(void *cls, + const struct GNUNET_PeerIdentity *sender, + const char *method_name, + size_t data_size, + const void *data, + struct GNUNET_PSYC_PartHandle *ph); + + +/** + * Function to call with the decision made for a join request. + * + * Must be called once and only once in response to an invocation of the + * #GNUNET_PSYC_JoinCallback. + * + * @param jh Join request handle. + * @param is_admitted #GNUNET_YES if joining is approved, + * #GNUNET_NO if it is disapproved + * @param method_name Method name for the message transmitted with the response. + * @param data_size Size of @a data. + * @param data Data of the message. + */ +void +GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh, + int is_admitted, + const char *method_name, + size_t data_size, + const void *data); + + +/** + * Send a part acknowledgment. + * + * @param ph Part handle. + */ +void +GNUNET_PSYC_part_ack (struct GNUNET_PSYC_PartHandle *ph); + + /** * Handle for the channel of a PSYC group. */ @@ -166,13 +253,10 @@ struct GNUNET_PSYC_Channel; * invoked; the join handler must then generate a "join" message to approve the * joining of the new member. The channel can also change group membership * without explicit requests. Note that PSYC doesn't itself "understand" join - * or leave messages, the respective methods must call other PSYC functions to + * or part messages, the respective methods must call other PSYC functions to * inform PSYC about the meaning of the respective events. * * @param cfg Configuration to use (to connect to PSYC service). - * @param method Function to invoke on messages received from members, - * typcially at least contains functions for @e join and @e leave. - * @param method_cls Closure for @a method. * @param priv_key ECC key that will be used to sign messages for this * PSYC session; public key is used to identify the * PSYC group; FIXME: we'll likely want to use @@ -183,75 +267,46 @@ struct GNUNET_PSYC_Channel; * key(s) when setting up their own channels * @param join_policy What is the membership policy of the group? * Used to automate group management decisions. + * @param method_cb Function to invoke on messages received from members. + * @param join_cb Function to invoke when a peer wants to join. + * @param part_cb Function to invoke when a peer wants to part. + * @param cls Closure for the callbacks. * @return Handle for the channel, NULL on error. */ struct GNUNET_PSYC_Channel * -GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_PSYC_Method method, - void *method_cls, +GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, - enum GNUNET_MULTICAST_JoinPolicy join_policy); - - -/** - * Possible operations on PSYC state (persistent) and variables (per message). - */ -enum GNUNET_PSYC_Operator -{ - /** - * Replace the full state with the new value ("="). - */ - GNUNET_PSYC_SOT_SET_STATE = 0, - - /** - * Delete the complete entry from the state (given data must be - * empty). Equivalent to @a SET with empty data, but more - * explicit ("="); - */ - GNUNET_PSYC_SOT_DELETE = 0, - - /** - * Set the value of a variable to a new value (":"). - */ - GNUNET_PSYC_SOT_SET_VARIABLE, - - /** - * Add the given value to the set of values in the state ("+"). - */ - GNUNET_PSYC_SOT_ADD_STATE, - - /** - * Remove the given value from the set of values in the state ("-"). - */ - GNUNET_PSYC_SOT_REMOVE_STATE - -}; + enum GNUNET_MULTICAST_JoinPolicy join_policy, + GNUNET_PSYC_Method method_cb, + GNUNET_PSYC_JoinCallback join_cb, + GNUNET_PSYC_PartCallback part_cb, + void *cls); /** - * Update channel state (or set a variable). + * Modify channel state (or set a transient variable). * * The state of a channel must fit into the memory of each member (and the * channel); large values that require streaming must only be passed as the - * stream arguments to methods. State updates might not be transmitted to group - * members until the next call to GNUNET_PSYC_channel_notify_transmit_ready(). + * stream arguments to methods. State modifications might not be transmitted to + * group members until the next call to GNUNET_PSYC_channel_transmit(). * Variable updates must be given just before the call to the respective method * that needs the variables. * * @param channel Handle to the PSYC group / channel. - * @param full_state_name Name of the field in the channel state to change. - * @param type Kind of update operation (add, remove, replace, delete). - * @param data_size Number of bytes in data. - * @param data New state value. + * @param oper Kind of update operation (add, remove, replace, delete). + * @param name Name of the state or transient variable to modify. + * @param value_size Number of bytes in @a value. + * @param value Value of state variable. * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error * (i.e. state too large). */ int -GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, - const char *full_state_name, - enum GNUNET_PSYC_Operator type, - size_t data_size, - const void *data); +GNUNET_PSYC_channel_state_modify (struct GNUNET_PSYC_Channel *channel, + enum GNUNET_PSYC_Operator oper, + const char *name, + size_t value_size, + const void *value); /** @@ -264,10 +319,10 @@ GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, * @param message_id Set to the unique message ID that was generated for * this message. * @param group_generation Set to the group generation used for this - * message. + * message. * @param data_size[in,out] Initially set to the number of bytes available in @a data, * should be set to the number of bytes written to data (IN/OUT). - * @param data[out] Where to write the body of the message to give to the method; + * @param[out] data Where to write the body of the message to give to the method; * function must copy at most @a *data_size bytes to @a data. * @return #GNUNET_SYSERR on error (fatal, aborts transmission) * #GNUNET_NO on success, if more data is to be transmitted later @@ -275,14 +330,14 @@ GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, * #GNUNET_YES if this completes the transmission (all data supplied) */ typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, - uint64_t message_id, - uint64_t group_generation, - size_t *data_size, - void *data); + uint64_t message_id, + uint64_t group_generation, + size_t *data_size, + void *data); /** - * Handle for a pending PSYC transmission operation. + * Handle for a pending PSYC transmission operation. */ struct GNUNET_PSYC_ChannelTransmitHandle; @@ -293,17 +348,17 @@ struct GNUNET_PSYC_ChannelTransmitHandle; * @param channel Handle to the PSYC multicast group. * @param increment_group_generation #GNUNET_YES if we need to increment * the group generation counter after transmitting this message. - * @param full_method_name Which method should be invoked. + * @param method_name Which method should be invoked. * @param notify Function to call to obtain the arguments. * @param notify_cls Closure for @a notify. * @return Transmission handle, NULL on error (i.e. more than one request queued). */ struct GNUNET_PSYC_ChannelTransmitHandle * -GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, - int increment_group_generation, - const char *full_method_name, - GNUNET_PSYC_ChannelReadyNotify notify, - void *notify_cls); +GNUNET_PSYC_channel_transmit (struct GNUNET_PSYC_Channel *channel, + int increment_group_generation, + const char *method_name, + GNUNET_PSYC_ChannelReadyNotify notify, + void *notify_cls); /** @@ -312,7 +367,7 @@ GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, * @param th Handle of the request that is being aborted. */ void -GNUNET_PSYC_channel_notify_transmit_ready_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); +GNUNET_PSYC_channel_transmit_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); /** @@ -358,13 +413,12 @@ GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member); * channel still needs to explicitly transmit a @e join message to notify other * group members and they then also must still call this function in their * respective methods handling the @e join message. This way, how @e join and - * @e leave operations are exactly implemented is still up to the application; - * for example, there might be a @e leave_all method to kick out everyone. + * @e part operations are exactly implemented is still up to the application; + * for example, there might be a @e part_all method to kick out everyone. * - * Note that group members are explicitly trusted to execute such - * methods correctly; not doing so correctly will result in either - * denying members access or offering access to group data to - * non-members. + * Note that group members are explicitly trusted to execute such methods + * correctly; not doing so correctly will result in either denying members + * access or offering access to group data to non-members. * * @param group Group handle. * @param member Which peer to add. @@ -383,11 +437,11 @@ GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group, * * Note that this will NOT generate any PSYC traffic, it will merely update the * local data base to modify how we react to membership test queries. The - * channel still needs to explicitly transmit a @e leave message to notify other + * channel still needs to explicitly transmit a @e part message to notify other * group members and they then also must still call this function in their - * respective methods handling the @e leave message. This way, how @e join and - * @e leave operations are exactly implemented is still up to the application; - * for example, there might be a @e leave_all message to kick out everyone. + * respective methods handling the @e part message. This way, how @e join and + * @e part operations are exactly implemented is still up to the application; + * for example, there might be a @e part_all message to kick out everyone. * * Note that group members are explicitly trusted to perform these * operations correctly; not doing so correctly will result in either @@ -447,22 +501,22 @@ struct GNUNET_PSYC_StateHandler }; - /** * Join a PSYC group. * * The entity joining is always the local peer. The user must immediately use - * the GNUNET_PSYC_member_send_to_host() (and possibly - * GNUNET_PSYC_member_host_variable_set()) functions to transmit a @e join_msg to + * the GNUNET_PSYC_member_to_origin() (and possibly + * GNUNET_PSYC_member_origin_variable_set()) functions to transmit a @e join_msg to * the channel; if the join request succeeds, the channel state (and @e recent * method calls) will be replayed to the joining member. There is no explicit - * notification on failure (as the channel may simply take days to approve, and + * notification on failure (as the channel may simply take days to approve, a-v/snd * disapproval is simply being ignored). * * @param cfg Configuration to use. * @param pub_key ECC key that identifies the channel we wish to join + * @param origin Peer identity of the origin. * @param method Function to invoke on messages received from the channel, - * typically at least contains functions for @e join and @e leave. + * typically at least contains functions for @e join and @e part. * @param method_cls Closure for @a method. * @param state_count Number of @a state_handlers. * @param state_handlers Array of state event handlers. @@ -471,6 +525,7 @@ struct GNUNET_PSYC_StateHandler struct GNUNET_PSYC_Member * GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EccPublicKey *pub_key, + const struct GNUNET_PeerIdentity *origin, GNUNET_PSYC_Method method, void *method_cls, unsigned int state_count, @@ -478,16 +533,15 @@ GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, /** - * Leave a multicast group. + * Part a PSYC group. * * Will terminate the connection to the PSYC service. Polite clients should - * first explicitly send a @e leave request (via - * GNUNET_PSYC_member_send_to_host()). + * first explicitly send a @e part request (via GNUNET_PSYC_member_to_origin()). * * @param member membership handle */ void -GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); +GNUNET_PSYC_member_part (struct GNUNET_PSYC_Member *member); /** @@ -500,13 +554,13 @@ GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); * @param cls Closure. * @param data_size[in,out] Initially set to the number of bytes available in @a data, * should be set to the number of bytes written to data (IN/OUT). - * @param data[out] Where to write the body of the message to give to the method; + * @param[out] data Where to write the body of the message to give to the method; * function must copy at most @a *data_size bytes to @a data. * @return #GNUNET_SYSERR on error (fatal, aborts transmission). * #GNUNET_NO on success, if more data is to be transmitted later. * #GNUNET_YES if this completes the transmission (all data supplied). */ -typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, +typedef int (*GNUNET_PSYC_MemberReadyNotify)(void *cls, size_t *data_size, char *data); @@ -514,7 +568,7 @@ typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, /** * Handle for a pending PSYC transmission operation. */ -struct GNUNET_PSYC_OriginTransmitHandle; +struct GNUNET_PSYC_MemberTransmitHandle; /** @@ -526,18 +580,18 @@ struct GNUNET_PSYC_OriginTransmitHandle; * @param notify_cls Closure for @a notify. * @return Transmission handle, NULL on error (i.e. more than one request queued). */ -struct GNUNET_PSYC_OriginTransmitHandle * -GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, - const char *method_name, - GNUNET_PSYC_OriginReadyNotify notify, - void *notify_cls); +struct GNUNET_PSYC_MemberTransmitHandle * +GNUNET_PSYC_member_to_origin (struct GNUNET_PSYC_Member *member, + const char *method_name, + GNUNET_PSYC_MemberReadyNotify notify, + void *notify_cls); /** * Set a (temporary, ":") variable for the next message being transmitted - * via GNUNET_PSYC_member_send_to_host(). + * via GNUNET_PSYC_member_to_origin(). * - * If GNUNET_PSYC_member_send_to_host() is called and then cancelled, all + * If GNUNET_PSYC_member_to_origin() is called and then cancelled, all * variables that were set using this function will be unset (lost/forgotten). * To clear a variable state after setting it, you can also call this function * again with NULL/0 for the @a value. @@ -560,7 +614,7 @@ GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member, * @param th Handle of the request that is being aborted. */ void -GNUNET_PSYC_member_send_to_origin_cancel (struct GNUNET_PSYC_OriginTransmitHandle *th); +GNUNET_PSYC_member_to_origin_cancel (struct GNUNET_PSYC_MemberTransmitHandle *th); /** @@ -575,9 +629,11 @@ struct GNUNET_PSYC_Story; * Historic messages (but NOT the state at the time) will be replayed (given to * the normal method handlers) if available and if access is permitted. * + * To get the latest message, use 0 for both the start and end message ID. + * * @param member Which channel should be replayed? - * @param start Earliest interesting point in history. - * @param end Last (exclusive) interesting point in history. + * @param start_message_id Earliest interesting point in history. + * @param end_message_id Last (exclusive) interesting point in history. * @param method Function to invoke on messages received from the story. * @param method_cls Closure for @a method. * @param finish_cb Function to call when the requested story has been fully @@ -591,8 +647,8 @@ struct GNUNET_PSYC_Story; */ struct GNUNET_PSYC_Story * GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, - uint64_t start, - uint64_t end, + uint64_t start_message_id, + uint64_t end_message_id, GNUNET_PSYC_Method method, void *method_cls, void (*finish_cb)(void *), @@ -651,7 +707,7 @@ GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member, * * @param member Membership handle. * @param variable_name Name of the variable to query. - * @param return_value_size Set to number of bytes in variable, + * @param[out] return_value_size Set to number of bytes in variable, * needed as variables might contain binary data and * might also not be 0-terminated; set to 0 on errors. * @return NULL on error (no matching state or variable), pointer @@ -663,7 +719,6 @@ GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, size_t *return_value_size); - #if 0 /* keep Emacsens' auto-indent happy */ { #endif diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h index b7df5883a..46034dae6 100644 --- a/src/include/gnunet_psycstore_service.h +++ b/src/include/gnunet_psycstore_service.h @@ -21,7 +21,7 @@ /** * @file include/gnunet_psycstore_service.h * @brief PSYCstore service; implements persistent storage for the PSYC service - * @author tg(x) + * @author Gabor X Toth * @author Christian Grothoff */ #ifndef GNUNET_PSYCSTORE_SERVICE_H @@ -91,6 +91,7 @@ typedef void (*GNUNET_PSYCSTORE_ContinuationCallback)(void *cls, * @param h Handle for the PSYCstore. * @param channel_id ID of the channel where the event happened. * @param message_id ID of the message in which this event was announced. + * @param group_generation Generation of the group when this event was announced. * @param peer Identity of joining/leaving peer. * @param did_join #GNUNET_YES on join, #GNUNET_NO on leave. * @param ccb Callback to call with the result of the storage operation. @@ -102,6 +103,7 @@ struct GNUNET_PSYCSTORE_OperationHandle * GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, const struct GNUNET_HashCode *channel_id, uint64_t message_id, + uint64_t group_generation, const struct GNUNET_PeerIdentity *peer, int did_join, GNUNET_PSYCSTORE_ContinuationCallback ccb, @@ -169,7 +171,7 @@ typedef void (*GNUNET_PSYCSTORE_MessageResultCallback)(void *cls, * * @param h Handle for the PSYCstore. * @param channel_id The channel we are interested in. - * @param message_id Message ID to check. + * @param message_id Message ID to check. Use 0 to get the latest message. * @param rcb Callback to call with the result of the operation. * @param rcb_cls Closure for the callback. * @@ -183,23 +185,6 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, void *rcb_cls); -/** - * Get latest message sent to a channel. - * - * @param h Handle for the PSYCstore. - * @param channel_id The channel we are interested in. - * @param rcb Callback to call with the result of the operation. - * @param rcb_cls Closure for the callback. - * - * @return Handle that can be used to cancel the operation. - */ -struct GNUNET_PSYCSTORE_OperationHandle * -GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h, - const struct GNUNET_HashCode *channel_id, - GNUNET_PSYCSTORE_MessageResultCallback rcb, - void *rcb_cls); - - /** * Store a state variable. * diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index de4e66f0a..ea643de5a 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h @@ -21,7 +21,7 @@ /** * @file include/gnunet_social_service.h * @brief Social service; implements social functionality using the PSYC service. - * @author tg(x) + * @author Gabor X Toth * @author Christian Grothoff */ #ifndef GNUNET_SOCIAL_SERVICE_H @@ -36,6 +36,7 @@ extern "C" #endif #include "gnunet_util_lib.h" +#include "gnunet_psyc_lib.h" #include "gnunet_psyc_service.h" #include "gnunet_multicast_service.h" @@ -74,7 +75,7 @@ struct GNUNET_SOCIAL_Slicer; /** * Method called from SOCIAL upon receiving a message indicating a call - * to a @a method. + * to a @e method. * * @param cls Closure. * @param full_method_name Original method name from PSYC (may be more @@ -171,13 +172,13 @@ GNUNET_SOCIAL_ego_destroy (struct GNUNET_SOCIAL_Ego *ego); * * @param cls Closure. * @param nym Handle for the user who wants to join. - * @param join_msg_size Number of bytes in @a join_msg. - * @param join_msg Payload given on join (e.g. a password). + * @param msg_size Number of bytes in @a msg. + * @param msg Payload given on enter (e.g. a password). */ typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls, struct GNUNET_SOCIAL_Nym *nym, - size_t join_msg_size, - const void *join_msg); + size_t msg_size, + const void *msg); /** @@ -244,7 +245,7 @@ GNUNET_SOCIAL_home_admit (struct GNUNET_SOCIAL_Home *home, * #GNUNET_SOCIAL_FarewellCallback is invoked, * which should be very soon after this call. * - * @param home Home to eject nym from. + * @param home Home to eject @a nym from. * @param nym Handle for the entity to be ejected. */ void @@ -277,7 +278,7 @@ GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home, * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). * * @param nym Pseudonym to map to a cryptographic identifier. - * @param identity Set to the identity of the nym (short hash of the public key). + * @param[out] identity Set to the identity of the nym (short hash of the public key). */ void GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym, @@ -288,7 +289,7 @@ GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym, * Obtain the (cryptographic, binary) address for the home. * * @param home Home to get the (public) address from. - * @param crypto_address Address suitable for storing in GADS, i.e. in + * @param[out] crypto_address Address suitable for storing in GADS, i.e. in * 'HEX.place' or within the respective GADS record type ("PLACE") */ void @@ -296,10 +297,25 @@ GNUNET_SOCIAL_home_get_address (struct GNUNET_SOCIAL_Home *home, struct GNUNET_HashCode *crypto_address); + +/** + * Advertise @a home under @a name in the GADS zone of the @e ego. + * + * @param home The home to advertise. + * @param name The name to put in the zone. + * @param expiration_time Expiration time of the record, use 0 to remove the record. + */ +void +GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home, + const char *name, + GNUNET_TIME_Relative expiration_time); + + + /** * (Re)decorate the home by changing objects in it. * - * If the operation is #GNUNET_PSYC_SOT_SET_VARIABLE then the decoration only + * If the operation is #GNUNET_PSYC_OP_SET then the decoration only * applies to the next announcement by the home owner. * * @param home The home to decorate. @@ -325,17 +341,18 @@ struct GNUNET_SOCIAL_Announcement; /** * Send a message to all nyms that are present in the home. * - * This function is restricted to the home owner. Nyms can + * This function is restricted to the home owner. Nyms can only send requests + * to the home owner who can decide to relay it to other guests. * * @param home Home to address the announcement to. - * @param full_method_name Method to use for the announcement. + * @param method_name Method to use for the announcement. * @param notify Function to call to get the payload of the announcement. * @param notify_cls Closure for @a notify. * @return NULL on error (announcement already in progress?). */ struct GNUNET_SOCIAL_Announcement * GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home, - const char *full_method_name, + const char *method_name, GNUNET_PSYC_OriginReadyNotify notify, void *notify_cls); @@ -361,15 +378,15 @@ GNUNET_SOCIAL_home_to_place (struct GNUNET_SOCIAL_Home *home); /** - * Leave a home, visitors can stay. + * Leave a home temporarily, visitors can stay. * * After leaving, handling of incoming messages are left to other clients of the * social service, and stops after the last client exits. * - * @param home Home to leave (handle becomes invalid). + * @param home Home to leave temporarily (handle becomes invalid). */ void -GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home); +GNUNET_SOCIAL_home_away (struct GNUNET_SOCIAL_Home *home); /** @@ -380,30 +397,50 @@ GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home); void GNUNET_SOCIAL_home_destroy (struct GNUNET_SOCIAL_Home *home); - /** - * Join a place (home hosted by someone else). + * Request entry to a place (home hosted by someone else). * * @param cfg Configuration to contact the social service. * @param ego Owner of the home (host). - * @param address Address of the place to join (GADS name, i.e. 'room.friend.gads'), + * @param address Address of the place to enter (GADS name, i.e. 'room.friend.gads'), * if the name has the form 'HEX.place', GADS is not * used and HEX is assumed to be the hash of the public * key already; 'HEX.zkey' however would refer to * the 'PLACE' record in the GADS zone with the public key * 'HEX'. - * @param slicer slicer to use to process messages from this place - * @param join_msg_size Number of bytes in @a join_msg. - * @param join_msg Message to give to the join callback. + * @param msg_size Number of bytes in @a msg. + * @param msg Message to give to the enter callback. + * @param slicer Slicer to use for processing incoming requests from guests. * @return NULL on errors, otherwise handle to the place. */ struct GNUNET_SOCIAL_Place * -GNUNET_SOCIAL_place_join (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SOCIAL_Ego *ego, - const char *address, - struct GNUNET_SOCIAL_Slicer *slicer, - size_t join_msg_size, - const void *join_msg); +GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_SOCIAL_Ego *ego, + char *address, + size_t msg_size, + const void *msg, + struct GNUNET_SOCIAL_Slicer *slicer); + +/** + * Request entry to a place (home hosted by someone else). + * + * @param cfg Configuration to contact the social service. + * @param ego Owner of the home (host). + * @param crypto_address Public key of the place to enter. + * @param peer Peer to send request to. + * @param slicer Slicer to use for processing incoming requests from guests. + * @param msg_size Number of bytes in @a msg. + * @param msg Message to give to the enter callback. + * @return NULL on errors, otherwise handle to the place. + */ +struct GNUNET_SOCIAL_Place * +GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_SOCIAL_Ego *ego, + struct GNUNET_HashCode *crypto_address, + struct GNUNET_PeerIdentity *peer, + struct GNUNET_SOCIAL_Slicer *slicer, + size_t msg_size, + const void *msg); struct GNUNET_SOCIAL_WatchHandle; @@ -515,7 +552,6 @@ GNUNET_SOCIAL_place_frame_talk (struct GNUNET_SOCIAL_Place *place, */ struct GNUNET_SOCIAL_TalkRequest; - /** * Talk to the host of the place. * @@ -532,25 +568,6 @@ GNUNET_SOCIAL_place_talk (struct GNUNET_SOCIAL_Place *place, GNUNET_PSYC_OriginReadyNotify cb, void *cb_cls); -/** - * Talk to a nym. - * - * FIXME: look up nym in GADS and talk to its place. - * FIXME: do we want this in this API!? Not sure. -CG - * - * @param nym Nym we want to talk to. - * @param method_name Method to invoke on the @a nym. - * @param cb Function to use to get the payload for the method. - * @param cb_cls Closure for @a cb. - * @return NULL if we are already trying to talk to the host, - * otherwise handle to cancel the request. - */ -struct GNUNET_SOCIAL_TalkRequest * -GNUNET_SOCIAL_nym_talk (struct GNUNET_SOCIAL_Nym *nym, - const char *method_name, - GNUNET_PSYC_OriginReadyNotify cb, - void *cb_cls); - /** * Cancel talking to the host of the place. @@ -559,19 +576,20 @@ GNUNET_SOCIAL_nym_talk (struct GNUNET_SOCIAL_Nym *nym, */ void GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); - + /** * A history lesson. */ struct GNUNET_SOCIAL_HistoryLesson; - /** * Learn about the history of a place. * * Sends messages through the given slicer function where * start_message_id <= message_id <= end_message_id. + * + * To get the latest message, use 0 for both the start and end message ID. * * @param place Place we want to learn more about. * @param start_message_id First historic message we are interested in. @@ -600,20 +618,27 @@ GNUNET_SOCIAL_place_get_history_cancel (struct GNUNET_SOCIAL_HistoryLesson *hist /** - * Leave a place (destroys the place handle). - * - * Can either move our user into an @e away state (in which we continue to record - * ongoing conversations and state changes if our peer is running), or leave the - * place entirely and stop following the conversation. + * Leave a place permanently. * - * @param place Place to leave. - * @param keep_following #GNUNET_YES to ask the social service to continue - * to follow the conversation, #GNUNET_NO to fully leave the place. + * Notifies the owner of the place about leaving, and destroys the place handle. + * + * @param place Place to leave permanently. */ void -GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place, - int keep_following); +GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place); + +/** + * Leave a place temporarily. + * + * Stop following the conversation for the @a place and destroy the @a place + * handle. Only affects the application calling this function, other clients of + * the service continue receiving the messages. + * + * @param place Place to leave temporarily. + */ +void +GNUNET_SOCIAL_place_away (struct GNUNET_SOCIAL_Place *place); #if 0 /* keep Emacsens' auto-indent happy */ -- 2.25.1