PSYC/social: header for method callbacks
[oweals/gnunet.git] / src / include / gnunet_psyc_service.h
1 /*
2      This file is part of GNUnet.
3      (C) 2012, 2013 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /** 
22  * @file include/gnunet_psyc_service.h
23  * @brief PSYC service; high-level access to the PSYC protocol
24  *        note that clients of this API are NOT expected to
25  *        understand the PSYC message format, only the semantics!
26  *        Parsing (and serializing) the PSYC stream format is done
27  *        within the implementation of the libgnunetpsyc library,
28  *        and this API deliberately exposes as little as possible
29  *        of the actual data stream format to the application!
30  * @author Christian Grothoff
31  * @author Gabor X Toth
32  *
33  * NOTE:
34  * - this API does not know about psyc's "root" and "places";
35  *   there is no 'root' in GNUnet-Psyc as we're decentralized;
36  *   'places' and 'persons' are combined within the same 
37  *   abstraction, that of a "channel".  Channels are identified
38  *   and accessed in this API using a public/private key.  
39  *   Higher-level applications should use NAMES within GADS
40  *   to obtain public keys, and the distinction between 
41  *   'places' and 'persons' can then be made with the help
42  *   of the naming system (and/or conventions).
43  *   Channels are (as in PSYC) organized into a hierarchy; each
44  *   channel owner (the one with the private key) is then
45  *   the operator of the multicast group (its Origin in 
46  *   the terminology of the multicast API).
47  * - The API supports passing large amounts of data using
48  *   'streaming' for the argument passed to a method.  State
49  *   and variables must fit into memory and cannot be streamed
50  *   (thus, no passing of 4 GB of data in a variable; 
51  *   once we implement this, we might want to create a
52  *   @c \#define for the maximum size of a variable).
53  * - PSYC defines standard variables, methods, etc.  This
54  *   library deliberately abstracts over all of these; a
55  *   higher-level API should combine the naming system (GADS)
56  *   and standard methods (message, join, part, warn,
57  *   fail, error) and variables (action, color, time,
58  *   tag, etc.).  However, this API does take over the
59  *   routing variables, specifically 'context' (channel),
60  *   and 'source'.  We only kind-of support 'target', as
61  *   the target is either everyone in the group or the
62  *   origin, and never just a single member of the group;
63  *   for such individual messages, an application needs to
64  *   construct an 'inbox' channel where the owner (only)
65  *   receives messages (but never forwards; private responses
66  *   would be transmitted by joining the senders 'inbox'
67  *   channel -- or a inbox#bob subchannel).  The
68  *   goal for all of this is to keep the abstractions in this 
69  *   API minimal: interaction with multicast, try \& slice,
70  *   state/variable/channel management.  Higher-level
71  *   operations belong elsewhere (so maybe this API should
72  *   be called 'PSYC-low', whereas a higher-level API
73  *   implementing defaults for standard methods and
74  *   variables might be called 'PSYC-std' or 'PSYC-high'.
75  *
76  * Idee (lynx): 
77  * - rename "channel" to "master"
78  * - rename "member" to "slave"
79  * - rename "group" to "channel"
80  */
81
82 #ifndef GNUNET_PSYC_SERVICE_H
83 #define GNUNET_PSYC_SERVICE_H
84
85 #ifdef __cplusplus
86 extern "C"
87 {
88 #if 0                           /* keep Emacsens' auto-indent happy */
89 }
90 #endif
91 #endif
92
93 #include "gnunet_util_lib.h"
94 #include "gnunet_psyc_lib.h"
95 #include "gnunet_multicast_service.h"
96
97
98 /** 
99  * Version number of GNUnet-PSYC API.
100  */
101 #define GNUNET_PSYC_VERSION 0x00000000
102
103
104 /** 
105  * Information flags for data fragments set via PSYC.
106  */
107 enum GNUNET_PSYC_FragmentStatus
108 {
109   /** 
110    * This is the first part of data for the given method call.
111    */
112   GNUNET_PSYC_FS_FIRST = 1,
113   
114   /** 
115    * This is the last part of data for the given method call.
116    */
117   GNUNET_PSYC_FS_LAST = 2,
118
119   /** 
120    * OR'ed flags if payload is not fragmented.
121    */
122   GNUNET_PSYC_FS_NOT_FRAGMENTED = (GNUNET_PSYC_FS_FIRST | GNUNET_PSYC_FS_LAST)
123 };
124
125
126 /** 
127  * Handle that identifies a join request.
128  *
129  * Used to match calls to #GNUNET_PSYC_JoinCallback to the
130  * corresponding calls to GNUNET_PSYC_join_decision().
131  */
132 struct GNUNET_PSYC_JoinHandle;
133
134 /** 
135  * Handle that identifies a part request.
136  *
137  * Used to match calls to #GNUNET_PSYC_PartCallback to the
138  * corresponding calls to GNUNET_PSYC_part_ack().
139  */
140 struct GNUNET_PSYC_PartHandle;
141
142
143 /** 
144  * Method called from PSYC upon receiving a message indicating a call
145  * to a @e method.  
146  *
147  * @param cls Closure.
148  * @param sender Who transmitted the message (origin, except for messages
149  *        from one of the members to the origin).
150  * @param message_id Unique message counter for this message;
151  *                   (unique only in combination with the given sender for
152  *                    this channel).
153  * @param group_generation Group generation counter for this message
154  *                   (always zero for messages from members to channel owner); FIXME: needed?
155  * @param method_name Original method name from PSYC (may be more
156  *        specific than the registered method name due to try-and-slice matching).
157  *        FIXME: no try-and-slice for methods defined here.
158  * @param header_length Number of modifiers in header.
159  * @param header Modifiers present in the message.
160  * @param data_off Byte offset of @a data in the overall data of the method.
161  * @param data_size Number of bytes in @a data.
162  * @param data Data stream given to the method (might not be zero-terminated 
163  *             if data is binary).
164  * @param frag Fragmentation status for the data.
165  */
166 typedef int (*GNUNET_PSYC_Method)(void *cls,
167                                   const struct GNUNET_PeerIdentity *sender,
168                                   uint64_t message_id,
169                                   uint64_t group_generation,
170                                   const char *method_name,
171                                   uint64_t data_off,
172                                   size_t data_size,
173                                   const void *data,
174                                   enum GNUNET_PSYC_FragmentStatus frag);
175
176
177 /** 
178  * Method called from PSYC upon receiving a join request.
179  *
180  * @param cls Closure.
181  * @param sender Who transmitted the message.
182  * @param method_name Method name in the join request.
183  * @param header_length Number of modifiers in header.
184  * @param header Modifiers present in the message.
185  * @param data_size Number of bytes in @a data.
186  * @param data Data stream given to the method (might not be zero-terminated 
187  *             if data is binary).
188  */
189 typedef int (*GNUNET_PSYC_JoinCallback)(void *cls,
190                                         const struct GNUNET_PeerIdentity *sender,
191                                         const char *method_name,
192                                         size_t header_length,
193                                         GNUNET_PSYC_Modifier *header,
194                                         size_t data_size,
195                                         const void *data,
196                                         struct GNUNET_PSYC_JoinHandle *jh);
197
198
199 /** 
200  * Method called from PSYC upon receiving a part request.
201  *
202  * @param cls Closure.
203  * @param sender Who transmitted the message.
204  * @param method_name Method name in the part request.
205  * @param header_length Number of modifiers in header.
206  * @param header Modifiers present in the message.
207  * @param data_size Number of bytes in @a data.
208  * @param data Data stream given to the method (might not be zero-terminated 
209  *             if data is binary).
210  */
211 typedef int (*GNUNET_PSYC_PartCallback)(void *cls,
212                                         const struct GNUNET_PeerIdentity *sender,
213                                         const char *method_name,
214                                         size_t header_length,
215                                         GNUNET_PSYC_Modifier *header,
216                                         size_t data_size,
217                                         const void *data,
218                                         struct GNUNET_PSYC_PartHandle *ph);
219
220
221 /** 
222  * Function to call with the decision made for a join request.
223  *
224  * Must be called once and only once in response to an invocation of the
225  * #GNUNET_PSYC_JoinCallback.
226  *
227  * @param jh Join request handle.
228  * @param is_admitted #GNUNET_YES if joining is approved,
229  *        #GNUNET_NO if it is disapproved
230  * @param method_name Method name for the message transmitted with the response.
231  * @param data_size Size of @a data.
232  * @param data Data of the message.
233  */
234 void
235 GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
236                            int is_admitted,
237                            const char *method_name,
238                            size_t data_size,
239                            const void *data);
240
241
242 /** 
243  * Send a part acknowledgment.
244  *
245  * @param ph Part handle.
246  */
247 void
248 GNUNET_PSYC_part_ack (struct GNUNET_PSYC_PartHandle *ph);
249
250
251 /** 
252  * Handle for the channel of a PSYC group.
253  */
254 struct GNUNET_PSYC_Channel;
255
256
257 /** 
258  * Create a PSYC channel.
259  *
260  * Will create a multicast group identified by the given ECC key.  Messages
261  * received from group members will be given to the respective handler methods.
262  * If a new member wants to join a group, the "join" method handler will be
263  * invoked; the join handler must then generate a "join" message to approve the
264  * joining of the new member.  The channel can also change group membership
265  * without explicit requests.  Note that PSYC doesn't itself "understand" join
266  * or part messages, the respective methods must call other PSYC functions to
267  * inform PSYC about the meaning of the respective events.
268  *
269  * @param cfg Configuration to use (to connect to PSYC service).
270  * @param priv_key ECC key that will be used to sign messages for this
271  *                 PSYC session; public key is used to identify the
272  *                 PSYC group; FIXME: we'll likely want to use
273  *                 NOT the p521 curve here, but a cheaper one in the future
274  *                 Note that end-users will usually not use the private key
275  *                 directly, but rather look it up in GADS for groups 
276  *                 managed by other users, or select a file with the private
277  *                 key(s) when setting up their own channels
278  * @param join_policy What is the membership policy of the group?
279  *                 Used to automate group management decisions.
280  * @param method_cb Function to invoke on messages received from members.
281  * @param join_cb Function to invoke when a peer wants to join.
282  * @param part_cb Function to invoke when a peer wants to part.
283  * @param cls Closure for the callbacks.
284  * @return Handle for the channel, NULL on error.
285  */
286 struct GNUNET_PSYC_Channel *
287 GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
288                             const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
289                             enum GNUNET_MULTICAST_JoinPolicy join_policy,
290                             GNUNET_PSYC_Method method_cb,
291                             GNUNET_PSYC_JoinCallback join_cb,
292                             GNUNET_PSYC_PartCallback part_cb,
293                             void *cls);
294
295
296 /** 
297  * Modify channel state (or set a transient variable).
298  *
299  * The state of a channel must fit into the memory of each member (and the
300  * channel); large values that require streaming must only be passed as the
301  * stream arguments to methods.  State modifications might not be transmitted to
302  * group members until the next call to GNUNET_PSYC_channel_transmit().
303  * Variable updates must be given just before the call to the respective method
304  * that needs the variables.
305  *
306  * @param channel Handle to the PSYC group / channel.
307  * @param oper Kind of update operation (add, remove, replace, delete).
308  * @param name Name of the state or transient variable to modify.
309  * @param value_size Number of bytes in @a value.
310  * @param value Value of state variable.
311  * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error
312  *        (i.e. state too large).
313  */
314 int
315 GNUNET_PSYC_channel_state_modify (struct GNUNET_PSYC_Channel *channel,
316                                   enum GNUNET_PSYC_Operator oper,
317                                   const char *name,
318                                   size_t value_size,
319                                   const void *value);
320
321
322 /** 
323  * Function called to provide data for a transmission via PSYC.
324  *
325  * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
326  * invalidates the respective transmission handle.
327  *
328  * @param cls Closure.
329  * @param message_id Set to the unique message ID that was generated for
330  *        this message.
331  * @param group_generation Set to the group generation used for this
332   *        message.
333  * @param data_size[in,out] Initially set to the number of bytes available in @a data,
334  *        should be set to the number of bytes written to data (IN/OUT).
335  * @param[out] data Where to write the body of the message to give to the method;
336  *        function must copy at most @a *data_size bytes to @a data.
337  * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
338  *         #GNUNET_NO on success, if more data is to be transmitted later 
339  *         (should be used if @a *data_size was not big enough to take all the data)
340  *         #GNUNET_YES if this completes the transmission (all data supplied)
341  */
342 typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls,
343                                               uint64_t message_id,
344                                               uint64_t group_generation,
345                                               size_t *data_size,
346                                               void *data);
347
348
349 /** 
350  * Handle for a pending PSYC transmission operation. 
351  */
352 struct GNUNET_PSYC_ChannelTransmitHandle;
353
354
355 /** 
356  * Send a message to call a method to all members in the PSYC channel.
357  *
358  * @param channel Handle to the PSYC multicast group.
359  * @param increment_group_generation #GNUNET_YES if we need to increment
360  *        the group generation counter after transmitting this message.
361  * @param method_name Which method should be invoked.
362  * @param notify Function to call to obtain the arguments.
363  * @param notify_cls Closure for @a notify.
364  * @return Transmission handle, NULL on error (i.e. more than one request queued).
365  */
366 struct GNUNET_PSYC_ChannelTransmitHandle *
367 GNUNET_PSYC_channel_transmit (struct GNUNET_PSYC_Channel *channel,
368                               int increment_group_generation,
369                               const char *method_name,
370                               GNUNET_PSYC_ChannelReadyNotify notify,
371                               void *notify_cls);
372
373
374 /** 
375  * Abort transmission request to channel.
376  *
377  * @param th Handle of the request that is being aborted.
378  */
379 void
380 GNUNET_PSYC_channel_transmit_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th);
381
382
383 /** 
384  * Destroy a PSYC channel.
385  *
386  * @param channel PSYC channel to terminate.
387  */
388 tvoid
389 GNUNET_PSYC_channel_destroy (struct GNUNET_PSYC_Channel *channel);
390
391
392 /** 
393  * Handle to access PSYC group operations for all members.
394  */
395 struct GNUNET_PSYC_Group;
396
397
398 /** 
399  * Convert @a channel to a @e group handle to access the @e group APIs.
400  * 
401  * @param channel Channel handle.
402  * @return Group handle, valid for as long as @a channel is valid.
403  */ 
404 struct GNUNET_PSYC_Group *
405 GNUNET_PSYC_channel_get_group (struct GNUNET_PSYC_Channel *channel);
406
407
408 /** 
409  * Convert @a member to a @e group handle to access the @e group APIs.
410  * 
411  * @param member Membership handle.
412  * @return Group handle, valid for as long as @a member is valid.
413  */ 
414 struct GNUNET_PSYC_Group *
415 GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member);
416
417
418 /** 
419  * Add a member to the group.
420  *
421  * Note that this will NOT generate any PSYC traffic, it will merely update the
422  * local data base to modify how we react to <em>membership test</em> queries.  The
423  * channel still needs to explicitly transmit a @e join message to notify other
424  * group members and they then also must still call this function in their
425  * respective methods handling the @e join message.  This way, how @e join and
426  * @e part operations are exactly implemented is still up to the application;
427  * for example, there might be a @e part_all method to kick out everyone.
428  *
429  * Note that group members are explicitly trusted to execute such methods
430  * correctly; not doing so correctly will result in either denying members
431  * access or offering access to group data to non-members.
432  *
433  * @param group Group handle.
434  * @param member Which peer to add.
435  * @param message_id Message ID for the message that changed the membership.
436  * @param group_generation The generation ID where the change went into effect.
437  */
438 void
439 GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group,
440                               const struct GNUNET_PeerIdentity *member,
441                               uint64_t message_id,
442                               uint64_t group_generation);
443
444
445 /** 
446  * Remove a member from the group.
447  *
448  * Note that this will NOT generate any PSYC traffic, it will merely update the
449  * local data base to modify how we react to <em>membership test</em> queries.  The
450  * channel still needs to explicitly transmit a @e part message to notify other
451  * group members and they then also must still call this function in their
452  * respective methods handling the @e part message.  This way, how @e join and
453  * @e part operations are exactly implemented is still up to the application;
454  * for example, there might be a @e part_all message to kick out everyone.
455  *
456  * Note that group members are explicitly trusted to perform these
457  * operations correctly; not doing so correctly will result in either
458  * denying members access or offering access to group data to
459  * non-members.
460  *
461  * @param group Group handle.
462  * @param member Which peer to remove.
463  * @param message_id Message ID for the message that changed the membership.
464  * @param group_generation The generation ID where the change went into effect.
465  */
466 void
467 GNUNET_PSYC_group_member_remove (struct GNUNET_PSYC_Group *group,
468                                  const struct GNUNET_PeerIdentity *member,
469                                  uint64_t message_id,
470                                  uint64_t group_generation);
471
472
473 /** 
474  * Function called to inform a member about state changes for a channel.
475  *
476  * Note that (for sets) only the delta is communicated, not the full state.
477  *
478  * @param cls Closure.
479  * @param full_state_name Full name of the state.
480  * @param type How to interpret the change.
481  * @param state_value Information about the new state.
482  * @param state_value_size Number of bytes in @a state_value.
483  */
484 typedef void (*GNUNET_PSYC_StateCallback)(void *cls,
485                                           const char *full_state_name,
486                                           enum GNUNET_PSYC_Operator type,
487                                           const void *state_value,
488                                           size_t state_value_size);
489
490
491 /** 
492  * Descriptor for an event handler handling PSYC state updates.
493  */
494 struct GNUNET_PSYC_StateHandler
495 {
496
497   /** 
498    * Name of the state variable this handler calls about, used in try-and-slice matching.
499    */
500   const char *state_name;
501
502   /** 
503    * Function to call whenever the respective state changes.
504    */
505   GNUNET_PSYC_StateCallback event_handler;
506
507   /** 
508    * Closure for the @a event_handler function.
509    */
510   void *event_handler_cls;
511
512 };
513
514 /** 
515  * Join a PSYC group.
516  *
517  * The entity joining is always the local peer.  The user must immediately use
518  * the GNUNET_PSYC_member_to_origin() (and possibly
519  * GNUNET_PSYC_member_origin_variable_set()) functions to transmit a @e join_msg to
520  * the channel; if the join request succeeds, the channel state (and @e recent
521  * method calls) will be replayed to the joining member.  There is no explicit
522  * notification on failure (as the channel may simply take days to approve, a-v/snd
523  * disapproval is simply being ignored).
524  *
525  * @param cfg Configuration to use.
526  * @param pub_key ECC key that identifies the channel we wish to join
527  * @param origin Peer identity of the origin.
528  * @param method Function to invoke on messages received from the channel,
529  *                typically at least contains functions for @e join and @e part.
530  * @param method_cls Closure for @a method.
531  * @param state_count Number of @a state_handlers.
532  * @param state_handlers Array of state event handlers.
533  * @return Handle for the member, NULL on error.
534  */
535 struct GNUNET_PSYC_Member *
536 GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 
537                          const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
538                          const struct GNUNET_PeerIdentity *origin,
539                          GNUNET_PSYC_Method method,
540                          void *method_cls,
541                          unsigned int state_count,
542                          struct GNUNET_PSYC_StateHandler *state_handlers);
543
544
545 /** 
546  * Part a PSYC group.
547  *
548  * Will terminate the connection to the PSYC service.  Polite clients should
549  * first explicitly send a @e part request (via GNUNET_PSYC_member_to_origin()).
550  *
551  * @param member membership handle
552  */
553 void
554 GNUNET_PSYC_member_part (struct GNUNET_PSYC_Member *member);
555
556
557 /** 
558  * Function called to provide data for a transmission to the channel
559  * owner (aka the @e host of the channel).
560  *
561  * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
562  * invalidates the respective transmission handle.
563  *
564  * @param cls Closure.
565  * @param data_size[in,out] Initially set to the number of bytes available in @a data,
566  *        should be set to the number of bytes written to data (IN/OUT).
567  * @param[out] data Where to write the body of the message to give to the method;
568  *        function must copy at most @a *data_size bytes to @a data.
569  * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
570  *         #GNUNET_NO on success, if more data is to be transmitted later.
571  *         #GNUNET_YES if this completes the transmission (all data supplied).
572  */
573 typedef int (*GNUNET_PSYC_MemberReadyNotify)(void *cls,
574                                              size_t *data_size,
575                                              char *data);
576
577
578 /** 
579  * Handle for a pending PSYC transmission operation.
580  */
581 struct GNUNET_PSYC_MemberTransmitHandle;
582
583
584 /** 
585  * Request a message to be sent to the channel origin.
586  *
587  * @param member Membership handle.
588  * @param method_name Which (PSYC) method should be invoked (on host).
589  * @param notify Function to call when we are allowed to transmit (to get data).
590  * @param notify_cls Closure for @a notify.
591  * @return Transmission handle, NULL on error (i.e. more than one request queued).
592  */
593 struct GNUNET_PSYC_MemberTransmitHandle *
594 GNUNET_PSYC_member_to_origin (struct GNUNET_PSYC_Member *member,
595                               const char *method_name,
596                               GNUNET_PSYC_MemberReadyNotify notify,
597                               void *notify_cls);
598
599
600 /** 
601  * Set a (temporary, ":") variable for the next message being transmitted
602  * via GNUNET_PSYC_member_to_origin().
603  *
604  * If GNUNET_PSYC_member_to_origin() is called and then cancelled, all
605  * variables that were set using this function will be unset (lost/forgotten).
606  * To clear a variable state after setting it, you can also call this function
607  * again with NULL/0 for the @a value.
608  *
609  * @param member Membership handle.
610  * @param variable_name Name of the variable to set.
611  * @param value Value to set for the given variable.
612  * @param value_size Number of bytes in @a value.
613  */
614 uint64_t
615 GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member,
616                                         const char *variable_name,
617                                         const void *value,
618                                         size_t value_size);
619
620
621 /** 
622  * Abort transmission request to origin.
623  *
624  * @param th Handle of the request that is being aborted.
625  */
626 void
627 GNUNET_PSYC_member_to_origin_cancel (struct GNUNET_PSYC_MemberTransmitHandle *th);
628
629
630 /** 
631  * Handle to a story telling operation.
632  */
633 struct GNUNET_PSYC_Story;
634
635
636 /** 
637  * Request to be told the message history of the channel.
638  *
639  * Historic messages (but NOT the state at the time) will be replayed (given to
640  * the normal method handlers) if available and if access is permitted.
641  *
642  * To get the latest message, use 0 for both the start and end message ID.
643  *
644  * @param member Which channel should be replayed?
645  * @param start_message_id Earliest interesting point in history.
646  * @param end_message_id Last (exclusive) interesting point in history.
647  * @param method Function to invoke on messages received from the story.
648  * @param method_cls Closure for @a method.
649  * @param finish_cb Function to call when the requested story has been fully 
650  *        told (counting message IDs might not suffice, as some messages
651  *        might be secret and thus the listener would not know the story is 
652  *        finished without being told explicitly); once this function
653  *        has been called, the client must not call
654  *        GNUNET_PSYC_member_story_tell_cancel() anymore.
655  * @param finish_cb_cls Closure to finish_cb.
656  * @return Handle to cancel story telling operation.
657  */
658 struct GNUNET_PSYC_Story *
659 GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member,
660                                uint64_t start_message_id,
661                                uint64_t end_message_id,
662                                GNUNET_PSYC_Method method,
663                                void *method_cls,
664                                void (*finish_cb)(void *),
665                                void *finish_cb_cls);
666
667
668 /** 
669  * Abort story telling.
670  *
671  * This function must not be called from within method handlers (as given to
672  * GNUNET_PSYC_member_join()) of the member.
673  *
674  * @param story Story telling operation to stop.
675  */
676 void
677 GNUNET_PSYC_member_story_tell_cancel (struct GNUNET_PSYC_Story *story);
678
679
680 /** 
681  * Call the given callback on all matching values (including variables) in the
682  * channel state.
683  *
684  * The callback is invoked synchronously on all matching states (as the state is
685  * fully replicated in the library in this process; channel states should be
686  * small, large data is to be passed as streaming data to methods).
687  *
688  * A name matches if it includes the @a state_name prefix, thus requesting the
689  * empty state ("") will match all values; requesting "_a_b" will also return
690  * values stored under "_a_b_c".
691  *
692  * @param member Membership handle.
693  * @param state_name Name of the state to query (full name 
694  *        might be longer, this is only the prefix that must match).
695  * @param cb Function to call on the matching state values.
696  * @param cb_cls Closure for @a cb.
697  * @return Message ID for which the state was returned (last seen
698  *         message ID).
699  */
700 uint64_t
701 GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member,
702                                   const char *state_name,
703                                   GNUNET_PSYC_StateCallback cb,
704                                   void *cb_cls);
705
706
707 /** 
708  * Obtain the current value of the best-matching value in the state
709  * (including variables).
710  *
711  * Note that variables are only valid during a #GNUNET_PSYC_Method invocation, as
712  * variables are only valid for the duration of a method invocation.
713  *
714  * If the requested variable name does not have an exact state in
715  * the state, the nearest less-specific name is matched; for example,
716  * requesting "_a_b" will match "_a" if "_a_b" does not exist.
717  *
718  * @param member Membership handle.
719  * @param variable_name Name of the variable to query.
720  * @param[out] return_value_size Set to number of bytes in variable, 
721  *        needed as variables might contain binary data and
722  *        might also not be 0-terminated; set to 0 on errors.
723  * @return NULL on error (no matching state or variable), pointer
724           to the respective value otherwise.
725  */
726 const void *
727 GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member,
728                               const char *variable_name,
729                               size_t *return_value_size);
730
731
732 #if 0                           /* keep Emacsens' auto-indent happy */
733 {
734 #endif
735 #ifdef __cplusplus
736 }
737 #endif
738
739 /* ifndef GNUNET_PSYC_SERVICE_H */
740 #endif
741 /* end of gnunet_psyc_service.h */