aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2013-07-12 08:47:10 +0000
committerGabor X Toth <*@tg-x.net>2013-07-12 08:47:10 +0000
commit15b4d21a45db18ce0384d1c42c83459ba2ed24f8 (patch)
treea70ebcbc24dca219f1a7df943dc52c0fd706c555
parent57be99113715a6023164633556ea1de50ceae6e1 (diff)
downloadgnunet-15b4d21a45db18ce0384d1c42c83459ba2ed24f8.tar.gz
gnunet-15b4d21a45db18ce0384d1c42c83459ba2ed24f8.zip
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
-rw-r--r--AUTHORS2
-rw-r--r--src/include/gnunet_crypto_lib.h2
-rw-r--r--src/include/gnunet_multicast_service.h156
-rw-r--r--src/include/gnunet_protocols.h41
-rw-r--r--src/include/gnunet_psyc_lib.h164
-rw-r--r--src/include/gnunet_psyc_service.h273
-rw-r--r--src/include/gnunet_psycstore_service.h23
-rw-r--r--src/include/gnunet_social_service.h145
8 files changed, 496 insertions, 310 deletions
diff --git a/AUTHORS b/AUTHORS
index a06da68df..3a67d57fa 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,6 +23,7 @@ Martin Schanzenbach <schanzen@in.tum.de>
23Maximilian Szengel <gnunet@maxsz.de> 23Maximilian Szengel <gnunet@maxsz.de>
24Florian Dold <florian.dold@gmail.com> 24Florian Dold <florian.dold@gmail.com>
25Christian Fuchs <christian.fuchs@cfuchs.net> 25Christian Fuchs <christian.fuchs@cfuchs.net>
26Gabor X Toth <tg-x.net>
26 27
27Code contributions also came from: 28Code contributions also came from:
28Adam Warrington [ UPnP ] 29Adam Warrington [ UPnP ]
@@ -36,7 +37,6 @@ Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
36Eric Haumant 37Eric Haumant
37Eric Noack <corvus-gnunet@cybertrench.com> 38Eric Noack <corvus-gnunet@cybertrench.com>
38Felix von Leitner [ diet libc snprintf for win32 ] 39Felix von Leitner [ diet libc snprintf for win32 ]
39Gabor Toth
40Gerd Knorr <kraxel@bytesex.org> 40Gerd Knorr <kraxel@bytesex.org>
41Glenn McGrath <bug1@iinet.net.au> 41Glenn McGrath <bug1@iinet.net.au>
42Hendrik Pagenhardt <Hendrik.Pagenhardt@gmx.net> 42Hendrik Pagenhardt <Hendrik.Pagenhardt@gmx.net>
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
153 153
154 154
155/** 155/**
156 * @brief 0-terminated ASCII encoding of a 'struct GNUNET_ShortHashCode'. 156 * @brief 0-terminated ASCII encoding of a struct GNUNET_CRYPTO_ShortHashCode.
157 */ 157 */
158struct GNUNET_CRYPTO_ShortHashAsciiEncoded 158struct GNUNET_CRYPTO_ShortHashAsciiEncoded
159{ 159{
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 @@
22 * @file include/gnunet_multicast_service.h 22 * @file include/gnunet_multicast_service.h
23 * @brief multicast service; establish tunnels to distant peers 23 * @brief multicast service; establish tunnels to distant peers
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author tg(x) 25 * @author Gabor X Toth
26 */ 26 */
27 27
28#ifndef GNUNET_MULTICAST_SERVICE_H 28#ifndef GNUNET_MULTICAST_SERVICE_H
@@ -138,12 +138,12 @@ struct GNUNET_MULTICAST_MessageHeader
138 uint64_t message_id GNUNET_PACKED; 138 uint64_t message_id GNUNET_PACKED;
139 139
140 /** 140 /**
141 * Counter that monotonically increases whenever a member leaves the group. 141 * Counter that monotonically increases whenever a member parts the group.
142 * 142 *
143 * It has significance in case of replay requests: when a member has missed 143 * It has significance in case of replay requests: when a member has missed
144 * messages and gets a replay request: in this case if the @a group_generation 144 * messages and gets a replay request: in this case if the @a group_generation
145 * is still the same before and after the missed messages, it means that no 145 * is still the same before and after the missed messages, it means that no
146 * @e join or @a leave operations happened during the missed messages. 146 * @e join or @e part operations happened during the missed messages.
147 */ 147 */
148 uint64_t group_generation GNUNET_PACKED; 148 uint64_t group_generation GNUNET_PACKED;
149 149
@@ -174,7 +174,7 @@ struct GNUNET_MULTICAST_MessageHeader
174 * Header for the message body. 174 * Header for the message body.
175 * 175 *
176 * Three message types are specifically understood by multicast, namely "peer 176 * Three message types are specifically understood by multicast, namely "peer
177 * join", "peer leave", and "group terminated". Multicast will use those 177 * join", "peer part", and "group terminated". Multicast will use those
178 * messages to update its list of candidates for content distribution. All 178 * messages to update its list of candidates for content distribution. All
179 * other message types are application-specific. 179 * other message types are application-specific.
180 */ 180 */
@@ -194,9 +194,17 @@ GNUNET_NETWORK_STRUCT_END
194 */ 194 */
195struct GNUNET_MULTICAST_JoinHandle; 195struct GNUNET_MULTICAST_JoinHandle;
196 196
197/**
198 * Handle that identifies a part request.
199 *
200 * Used to match calls to #GNUNET_MULTICAST_PartCallback to the
201 * corresponding calls to GNUNET_MULTICAST_part_ack().
202 */
203struct GNUNET_MULTICAST_PartHandle;
204
197 205
198/** 206/**
199 * Function to call with the decision made for a membership change request. 207 * Function to call with the decision made for a join request.
200 * 208 *
201 * Must be called once and only once in response to an invocation of the 209 * Must be called once and only once in response to an invocation of the
202 * #GNUNET_MULTICAST_JoinCallback. 210 * #GNUNET_MULTICAST_JoinCallback.
@@ -206,9 +214,8 @@ struct GNUNET_MULTICAST_JoinHandle;
206 * can also be used to redirect the peer to a different group at the 214 * can also be used to redirect the peer to a different group at the
207 * application layer; this response is to be transmitted to the 215 * application layer; this response is to be transmitted to the
208 * peer that issued the request even if admission is denied. 216 * peer that issued the request even if admission is denied.
209 * @param is_admitted #GNUNET_OK if joining is approved, 217 * @param is_admitted #GNUNET_YES if joining is approved,
210 * #GNUNET_SYSERR if it is disapproved; 218 * #GNUNET_NO if it is disapproved
211 * #GNUNET_NO for peers leaving.
212 * @param relay_count Number of relays given. 219 * @param relay_count Number of relays given.
213 * @param relays Array of suggested peers that might be useful relays to use 220 * @param relays Array of suggested peers that might be useful relays to use
214 * when joining the multicast group (essentially a list of peers that 221 * when joining the multicast group (essentially a list of peers that
@@ -220,10 +227,19 @@ struct GNUNET_MULTICAST_JoinHandle;
220 */ 227 */
221void 228void
222GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, 229GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh,
223 const struct GNUNET_MessageHeader *join_response, 230 const struct GNUNET_MessageHeader *join_response,
224 int is_admitted, 231 int is_admitted,
225 unsigned int relay_count, 232 unsigned int relay_count,
226 const struct GNUNET_PeerIdentity *relays); 233 const struct GNUNET_PeerIdentity *relays);
234
235
236/**
237 * Part acknowledgment.
238 *
239 * @param ph Part handle.
240 */
241void
242GNUNET_MULTICAST_part_ack (struct GNUNET_MULTICAST_PartHandle *ph);
227 243
228 244
229/** 245/**
@@ -249,17 +265,17 @@ typedef void (*GNUNET_MULTICAST_JoinCallback)(void *cls,
249/** 265/**
250 * Method called whenever another peer wants to part the multicast group. 266 * Method called whenever another peer wants to part the multicast group.
251 * 267 *
252 * A leave request must be always be honoured. 268 * A part request must always be honoured, and answered with GNUNET_MULTICAST_part_ack();
253 * 269 *
254 * @param cls Closure. 270 * @param cls Closure.
255 * @param peer Identity of the peer that wants to leave. 271 * @param peer Identity of the peer that wants to part.
256 * @param msg Application-dependent leave message from the leaving user. 272 * @param msg Application-dependent part message from the leaving user.
257 * @param jh Join handle to pass to GNUNET_MULTICAST_join_decison(). 273 * @param ph Part handle.
258 */ 274 */
259typedef void (*GNUNET_MULTICAST_PartCallback)(void *cls, 275typedef void (*GNUNET_MULTICAST_PartCallback)(void *cls,
260 const struct GNUNET_PeerIdentity *peer, 276 const struct GNUNET_PeerIdentity *peer,
261 const struct GNUNET_MessageHeader *msg, 277 const struct GNUNET_MessageHeader *msg,
262 struct GNUNET_MULTICAST_JoinHandle *jh); 278 struct GNUNET_MULTICAST_PartHandle *ph);
263 279
264 280
265/** 281/**
@@ -283,6 +299,9 @@ GNUNET_MULTICAST_membership_test_answer (struct GNUNET_MULTICAST_MembershipTestH
283/** 299/**
284 * Method called to test if a member was in the group at a particular time. 300 * Method called to test if a member was in the group at a particular time.
285 * 301 *
302 * It is called when a replay request is received to determine if the requested
303 * message can be replayed.
304 *
286 * @param cls Closure. 305 * @param cls Closure.
287 * @param peer Identity of the peer that we want to test. 306 * @param peer Identity of the peer that we want to test.
288 * @param message_id Message ID for which we want to do the test. 307 * @param message_id Message ID for which we want to do the test.
@@ -300,7 +319,7 @@ typedef void (*GNUNET_MULTICAST_MembershipTestCallback)(void *cls,
300 * 319 *
301 * @param cls Closure (set from GNUNET_MULTICAST_origin_start). 320 * @param cls Closure (set from GNUNET_MULTICAST_origin_start).
302 * @param sender Identity of the sender. 321 * @param sender Identity of the sender.
303 * @param request_id Unique counter for the request from this sender to this origin. 322 * @param request_id Unique counter for the request from this sender to this origin. FIXME: needed?
304 * @param msg Message to the origin. 323 * @param msg Message to the origin.
305 */ 324 */
306typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls, 325typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls,
@@ -322,11 +341,11 @@ typedef void (*GNUNET_MULTICAST_RequestCallback) (void *cls,
322 * normal message IDs in either direction start at 1. 341 * normal message IDs in either direction start at 1.
323 * @param msg Message from the origin, NULL if the origin shut down 342 * @param msg Message from the origin, NULL if the origin shut down
324 * (or we were kicked out, and we should thus call 343 * (or we were kicked out, and we should thus call
325 * GNUNET_MULTICAST_member_leave() next) 344 * GNUNET_MULTICAST_member_part() next)
326 */ 345 */
327typedef void (*GNUNET_MULTICAST_MulticastMessageCallback) (void *cls, 346typedef void (*GNUNET_MULTICAST_MessageCallback) (void *cls,
328 uint64_t message_id, 347 uint64_t message_id,
329 const struct GNUNET_MULTICAST_MessageHeader *msg); 348 const struct GNUNET_MULTICAST_MessageHeader *msg);
330 349
331 350
332/** 351/**
@@ -336,11 +355,12 @@ struct GNUNET_MULTICAST_ReplayHandle;
336 355
337 356
338/** 357/**
339 * Functions with this signature are called whenever the multicast 358 * Functions with this signature are called whenever the multicast service needs
340 * service needs a message to be replayed. Implementations of this 359 * a message to be replayed.
341 * function MUST call GNUNET_MULTICAST_replay() ONCE (with a message 360 *
342 * or an error); however, if the origin is destroyed or the group is 361 * Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE
343 * left, the replay handle must no longer be used. 362 * (with a message or an error); however, if the origin is destroyed or the
363 * group is left, the replay handle must no longer be used.
344 * 364 *
345 * @param cls Closure (set from GNUNET_MULTICAST_origin_start() 365 * @param cls Closure (set from GNUNET_MULTICAST_origin_start()
346 * or GNUNET_MULTICAST_member_join()). 366 * or GNUNET_MULTICAST_member_join()).
@@ -398,48 +418,6 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh,
398 418
399 419
400/** 420/**
401 * Handle to pass back for the answer of a ping.
402 */
403struct GNUNET_MULTICAST_PingHandle;
404
405
406/**
407 * A response to a @e ping.
408 *
409 * @param rh Handle that was given for the ping.
410 * @param message_id Latest message ID seen by this peer for this group.
411 *
412 * @deprecated needed???
413 */
414void
415GNUNET_MULTICAST_pong (struct GNUNET_MULTICAST_ReplayHandle *rh,
416 uint64_t message_id);
417
418
419/**
420 * Method called whenever a @e ping is received from another member.
421 *
422 * A @e ping is sent after a period of inactivity to check if the member has not
423 * missed any messages. A ping contains the latest message ID a member has
424 * seen, and must be answered with GNUNET_MULTICAST_pong() containing the latest
425 * message ID seen by this peer. If the latest message ID on this peer is higher, the
426 * missing messages must be replayed to the requesting member using
427 * GNUNET_MULTICAST_replay().
428 *
429 * @param cls Closure.
430 * @param peer Identity of the peer who sent the ping.
431 * @param latest_message_id Latest message ID seen by the requesting member.
432 * @param rh Handle to pass back to GNUNET_MULTICAST_pong() or GNUNET_MULTICAST_replay().
433 *
434 * @deprecated needed???
435 */
436typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls,
437 const struct GNUNET_PeerIdentity *peer,
438 uint64_t latest_messaged_id
439 struct GNUNET_MULTICAST_ReplayHandle *rh);
440
441
442/**
443 * Start a multicast group. 421 * Start a multicast group.
444 * 422 *
445 * Will advertise the origin in the P2P overlay network under the respective 423 * Will advertise the origin in the P2P overlay network under the respective
@@ -460,7 +438,6 @@ typedef void (*GNUNET_MULTICAST_PingCallback)(void *cls,
460 * @param join_policy What is the membership policy of the group? 438 * @param join_policy What is the membership policy of the group?
461 * @param replay_cb Function that can be called to replay a message. 439 * @param replay_cb Function that can be called to replay a message.
462 * @param test_cb Function multicast can use to test group membership. 440 * @param test_cb Function multicast can use to test group membership.
463 * @param ping_cb Function called to answer a ping. -- Gabor: remove this one!? deprecated?
464 * @param join_cb Function called to approve / disapprove joining of a peer. 441 * @param join_cb Function called to approve / disapprove joining of a peer.
465 * @param part_cb Function called when a member wants to part the group. 442 * @param part_cb Function called when a member wants to part the group.
466 * @param request_cb Function called with messages from group members. 443 * @param request_cb Function called with messages from group members.
@@ -473,7 +450,6 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
473 enum GNUNET_MULTICAST_JoinPolicy join_policy, 450 enum GNUNET_MULTICAST_JoinPolicy join_policy,
474 GNUNET_MULITCAST_ReplayCallback replay_cb, 451 GNUNET_MULITCAST_ReplayCallback replay_cb,
475 GNUNET_MULITCAST_MembershipTestCallback test_cb, 452 GNUNET_MULITCAST_MembershipTestCallback test_cb,
476 GNUNET_MULITCAST_PingCallback ping_cb,
477 GNUNET_MULTICAST_JoinCallback join_cb, 453 GNUNET_MULTICAST_JoinCallback join_cb,
478 GNUNET_MULTICAST_PartCallback part_cb, 454 GNUNET_MULTICAST_PartCallback part_cb,
479 GNUNET_MULTICAST_RequestCallback request_cb); 455 GNUNET_MULTICAST_RequestCallback request_cb);
@@ -483,7 +459,7 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
483 * Handle for a request to send a message to all multicast group members 459 * Handle for a request to send a message to all multicast group members
484 * (from the origin). 460 * (from the origin).
485 */ 461 */
486struct GNUNET_MULTICAST_MulticastRequest; 462struct GNUNET_MULTICAST_OriginMessageHandle;
487 463
488 464
489/** 465/**
@@ -495,7 +471,7 @@ struct GNUNET_MULTICAST_MulticastRequest;
495 * @param cb_cls Closure for @a cb. 471 * @param cb_cls Closure for @a cb.
496 * @return NULL on error (i.e. request already pending). 472 * @return NULL on error (i.e. request already pending).
497 */ 473 */
498struct GNUNET_MULTICAST_MulticastRequest * 474struct GNUNET_MULTICAST_OriginMessageHandle *
499GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin, 475GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
500 size_t size, 476 size_t size,
501 GNUNET_CONNECTION_TransmitReadyNotify cb, 477 GNUNET_CONNECTION_TransmitReadyNotify cb,
@@ -505,10 +481,10 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
505/** 481/**
506 * Cancel request for message transmission to multicast group. 482 * Cancel request for message transmission to multicast group.
507 * 483 *
508 * @param mr Request to cancel. 484 * @param mh Request to cancel.
509 */ 485 */
510void 486void
511GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_MulticastRequest *mr); 487GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginMessageHandle *mh);
512 488
513 489
514/** 490/**
@@ -527,7 +503,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin);
527 * candidate can be provided in the @a join_req message. If the join fails, the 503 * candidate can be provided in the @a join_req message. If the join fails, the
528 * @a message_cb is invoked with a (failure) response and then with NULL. If 504 * @a message_cb is invoked with a (failure) response and then with NULL. If
529 * the join succeeds, outstanding (state) messages and ongoing multicast 505 * the join succeeds, outstanding (state) messages and ongoing multicast
530 * messages will be given to the @a message_cb until the member decides to leave 506 * messages will be given to the @a message_cb until the member decides to part
531 * the group. The @a test_cb and @a replay_cb functions may be called at 507 * the group. The @a test_cb and @a replay_cb functions may be called at
532 * anytime by the multicast service to support relaying messages to other 508 * anytime by the multicast service to support relaying messages to other
533 * members of the group. 509 * members of the group.
@@ -535,6 +511,7 @@ GNUNET_MULTICAST_origin_end (struct GNUNET_MULTICAST_Origin *origin);
535 * @param cfg Configuration to use. 511 * @param cfg Configuration to use.
536 * @param cls Closure for callbacks. 512 * @param cls Closure for callbacks.
537 * @param pub_key ECC key that identifies the group. 513 * @param pub_key ECC key that identifies the group.
514 * @param origin Peer identity of the origin.
538 * @param max_known_message_id Largest known message ID to the replay service; 515 * @param max_known_message_id Largest known message ID to the replay service;
539 * all messages with IDs larger than this ID will be replayed if 516 * all messages with IDs larger than this ID will be replayed if
540 * possible (lower IDs will be considered known and thus only 517 * possible (lower IDs will be considered known and thus only
@@ -561,18 +538,19 @@ struct GNUNET_MULTICAST_Member *
561GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 538GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
562 void *cls, 539 void *cls,
563 const struct GNUNET_CRYPTO_EccPublicKey *pub_key, 540 const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
541 const struct GNUNET_PeerIdentity *origin,
564 uint64_t max_known_message_id, 542 uint64_t max_known_message_id,
565 uint64_t max_known_state_message_id, 543 uint64_t max_known_state_message_id,
566 GNUNET_MULTICAST_ReplayCallback replay_cb, 544 GNUNET_MULTICAST_ReplayCallback replay_cb,
567 GNUNET_MULITCAST_MembershipTestCallback test_cb, 545 GNUNET_MULITCAST_MembershipTestCallback test_cb,
568 GNUNET_MULTICAST_MulticastMessageCallback message_cb, 546 GNUNET_MULTICAST_MessageCallback message_cb,
569 const struct GNUNET_MessageHeader *join_req); 547 const struct GNUNET_MessageHeader *join_req);
570 548
571 549
572/** 550/**
573 * Handle for a replay request. 551 * Handle for a replay request.
574 */ 552 */
575struct GNUNET_MULTICAST_ReplayRequest; 553struct GNUNET_MULTICAST_MemberReplayHandle;
576 554
577 555
578/** 556/**
@@ -587,20 +565,20 @@ struct GNUNET_MULTICAST_ReplayRequest;
587 * @param message_cb_cls Closure for @a message_cb. 565 * @param message_cb_cls Closure for @a message_cb.
588 * @return Replay request handle, NULL on error. 566 * @return Replay request handle, NULL on error.
589 */ 567 */
590struct GNUNET_MULTICAST_ReplayRequest * 568struct GNUNET_MULTICAST_MemberReplayHandle *
591GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member, 569GNUNET_MULTICAST_member_request_replay (struct GNUNET_MULTICAST_Member *member,
592 uint64_t message_id, 570 uint64_t message_id,
593 GNUNET_MULTICAST_MulticastMessageCallback message_cb, 571 GNUNET_MULTICAST_MessageCallback message_cb,
594 void *message_cb_cls); 572 void *message_cb_cls);
595 573
596 574
597/** 575/**
598 * Cancel a replay request. 576 * Cancel a replay request.
599 * 577 *
600 * @param rr Request to cancel. 578 * @param rh Request to cancel.
601 */ 579 */
602void 580void
603GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_ReplayRequest *rr); 581GNUNET_MULTICAST_member_request_replay_cancel (struct GNUNET_MULTICAST_MemberReplayHandle *rh);
604 582
605 583
606/** 584/**
@@ -613,9 +591,9 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member);
613 591
614 592
615/** 593/**
616 * Handle for a message to be delivered to the origin. 594 * Handle for a message to be delivered from a member to the origin.
617 */ 595 */
618struct GNUNET_MULTICAST_ResponseRequest; 596struct GNUNET_MULTICAST_MemberRequestHandle;
619 597
620 598
621/** 599/**
@@ -627,7 +605,7 @@ struct GNUNET_MULTICAST_ResponseRequest;
627 * @param cb_cls Closure for @a cb. 605 * @param cb_cls Closure for @a cb.
628 * @return Handle to cancel request, NULL on error (i.e. request already pending). 606 * @return Handle to cancel request, NULL on error (i.e. request already pending).
629 */ 607 */
630struct GNUNET_MULTICAST_ResponseRequest * 608struct GNUNET_MULTICAST_MemberRequestHandle *
631GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, 609GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
632 size_t size, 610 size_t size,
633 GNUNET_CONNECTION_TransmitReadyNotify cb, 611 GNUNET_CONNECTION_TransmitReadyNotify cb,
@@ -637,10 +615,10 @@ GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
637/** 615/**
638 * Cancel request for message transmission to origin. 616 * Cancel request for message transmission to origin.
639 * 617 *
640 * @param rr Request to cancel. 618 * @param rh Request to cancel.
641 */ 619 */
642void 620void
643GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_ResponseRequest *rr); 621GNUNET_MULTICAST_member_to_origin_cancel (struct GNUNET_MULTICAST_MemberRequestHandle *rh);
644 622
645 623
646 624
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"
1878 */ 1878 */
1879#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST 1879#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST
1880 1880
1881
1882/** 1881/**
1883 * A peer wants to join the group. 1882 * A peer wants to join the group.
1884 * 1883 *
1885 * Unicast message to a group member. 1884 * Unicast message to the origin or another group member.
1886 */
1887#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST_JOIN
1888
1889/**
1890 * A join request was rejected.
1891 *
1892 * Unicast response to a join request.
1893 */ 1885 */
1894#define GNUNET_MESSAGE_TYPE_MULTICAST_REJECT_JOIN 1886#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST
1895 1887
1896/** 1888/**
1897 * A peer joined the group. 1889 * Response to a join request.
1898 * 1890 *
1899 * Sent to all members by the origin. 1891 * Unicast message from a group member to the peer wanting to join.
1900 */
1901#define GNUNET_MESSAGE_TYPE_MULTICAST_NOTICE_JOIN
1902
1903/**
1904 * A peer wants to leave the group.
1905 */
1906#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST_LEAVE
1907
1908/**
1909 * A peer left the group.
1910 */ 1892 */
1911#define GNUNET_MESSAGE_TYPE_MULTICAST_NOTICE_LEAVE 1893#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
1912 1894
1913/** 1895/**
1914 * Ping request from a peer. 1896 * A peer wants to part the group.
1915 *
1916 * A ping is sent after a period of inactivity and contains the last received
1917 * message ID.
1918 */ 1897 */
1919#define GNUNET_MESSAGE_TYPE_MULTICAST_PEER_PING 1898#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST
1920 1899
1921/** 1900/**
1922 * Response to a ping. 1901 * Acknowledgement sent in response to a part request.
1923 * 1902 *
1924 * Contains the last received message ID. 1903 * Unicast message from a group member to the peer wanting to part.
1925 */ 1904 */
1926#define GNUNET_MESSAGE_TYPE_MULTICAST_PEER_PONG 1905#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_ACK
1927 1906
1928/** 1907/**
1929 * Group terminated. 1908 * 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 @@
1/*
2 This file is part of GNUnet.
3 (C) 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_lib.h
23 * @brief Library for common PSYC functionality:
24 * types, variable (de)serialization.
25 * @author Gabor X Toth
26 */
27
28
29/**
30 * Possible operations on PSYC state (persistent) and transient variables (per message).
31 */
32enum GNUNET_PSYC_Operator
33{
34 /**
35 * Set value of a transient variable.
36 */
37 GNUNET_PSYC_OP_SET = ':',
38
39 /**
40 * Assign value for a persistent state variable.
41 *
42 * If an assigned value is NULL, the variable is deleted.
43 */
44 GNUNET_PSYC_OP_ASSIGN = '=',
45
46 /**
47 * Augment state variable.
48 *
49 * Used for appending strings, adding numbers, and adding new items to a list or dictionary.
50 */
51 GNUNET_PSYC_OP_AUGMENT = '+',
52
53 /**
54 * Diminish state variable.
55 *
56 * Used for subtracting numbers, and removing items from a list or dictionary.
57 */
58 GNUNET_PSYC_OP_DIMINISH = '-',
59
60 /**
61 * Update state variable.
62 *
63 * Used for modifying a single item of a list or dictionary.
64 */
65 GNUNET_PSYC_OP_UPDATE = '@',
66};
67
68
69/**
70 * PSYC variable types.
71 */
72enum GNUNET_PSYC_Type
73{
74 GNUNET_PSYC_TYPE_DATA = 0,
75 GNUNET_PSYC_TYPE_NUMBER,
76 GNUNET_PSYC_TYPE_LIST,
77 GNUNET_PSYC_TYPE_DICT
78};
79
80
81/**
82 * Get the type of variable.
83 *
84 * @param name Name of the variable.
85 *
86 * @return Variable type.
87 */
88enum GNUNET_PSYC_Type
89GNUNET_PSYC_var_get_type (char *name);
90
91
92/**
93 * Get the variable's value as an integer.
94 *
95 * @param size Size of value.
96 * @param value Raw value of variable.
97 * @param[out] number Value converted to a 64-bit integer.
98 *
99 * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid).
100 */
101int
102GNUNET_PSYC_value_to_number (size_t size, const void *value, int64_t *number);
103
104
105/**
106 * Get the variable's value as a list.
107 *
108 * @param size Size of value.
109 * @param value Raw value of variable.
110 * @param[out] list A newly created list holding the elements.
111 *
112 * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid).
113 */
114int
115GNUNET_PSYC_value_to_list (size_t size, const void *value, GNUNET_CONTAINER_SList **list);
116
117
118/**
119 * Get the variable's value as a dictionary.
120 *
121 * @param size Size of value.
122 * @param value Raw value of variable.
123 * @param[out] dict A newly created hashmap holding the elements of the dictionary.
124 *
125 * @return #GNUNET_OK on success, #GNUNET_SYSERR if an error occurred (e.g. the value is invalid).
126 */
127int
128GNUNET_PSYC_value_to_dict (size_t size, const void *value, GNUNET_CONTAINER_MultiHashMap **dict);
129
130
131/**
132 * Create a PSYC variable value from an integer.
133 *
134 * @param number The number to convert.
135 * @param[out] value_size Size of returned value.
136 *
137 * @return A newly allocated value or NULL on error.
138 */
139void *
140GNUNET_PSYC_value_from_number (int64_t number, size_t *value_size);
141
142
143/**
144 * Create a PSYC variable value from a list.
145 *
146 * @param list The list to convert.
147 * @param[out] value_size Size of returned value.
148 *
149 * @return A newly allocated value or NULL on error.
150 */
151void *
152GNUNET_PSYC_value_from_list (GNUNET_CONTAINER_SList *list, size_t *value_size);
153
154
155/**
156 * Create a PSYC variable value from a dictionary.
157 *
158 * @param dict The dict to convert.
159 * @param[out] value_size Size of returned value.
160 *
161 * @return A newly allocated value or NULL on error.
162 */
163void *
164GNUNET_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 @@
28 * and this API deliberately exposes as little as possible 28 * and this API deliberately exposes as little as possible
29 * of the actual data stream format to the application! 29 * of the actual data stream format to the application!
30 * @author Christian Grothoff 30 * @author Christian Grothoff
31 * @author Gabor X Toth
31 * 32 *
32 * NOTE: 33 * NOTE:
33 * - this API does not know about psyc's "root" and "places"; 34 * - this API does not know about psyc's "root" and "places";
@@ -52,7 +53,7 @@
52 * - PSYC defines standard variables, methods, etc. This 53 * - PSYC defines standard variables, methods, etc. This
53 * library deliberately abstracts over all of these; a 54 * library deliberately abstracts over all of these; a
54 * higher-level API should combine the naming system (GADS) 55 * higher-level API should combine the naming system (GADS)
55 * and standard methods (message, join, leave, warn, 56 * and standard methods (message, join, part, warn,
56 * fail, error) and variables (action, color, time, 57 * fail, error) and variables (action, color, time,
57 * tag, etc.). However, this API does take over the 58 * tag, etc.). However, this API does take over the
58 * routing variables, specifically 'context' (channel), 59 * routing variables, specifically 'context' (channel),
@@ -75,6 +76,7 @@
75 * Idee (lynx): 76 * Idee (lynx):
76 * - rename "channel" to "master" 77 * - rename "channel" to "master"
77 * - rename "member" to "slave" 78 * - rename "member" to "slave"
79 * - rename "group" to "channel"
78 */ 80 */
79 81
80#ifndef GNUNET_PSYC_SERVICE_H 82#ifndef GNUNET_PSYC_SERVICE_H
@@ -89,6 +91,7 @@ extern "C"
89#endif 91#endif
90 92
91#include "gnunet_util_lib.h" 93#include "gnunet_util_lib.h"
94#include "gnunet_psyc_lib.h"
92#include "gnunet_multicast_service.h" 95#include "gnunet_multicast_service.h"
93 96
94 97
@@ -121,12 +124,27 @@ enum GNUNET_PSYC_FragmentStatus
121 124
122 125
123/** 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 */
132struct 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 */
140struct GNUNET_PSYC_PartHandle;
141
142
143/**
124 * Method called from PSYC upon receiving a message indicating a call 144 * Method called from PSYC upon receiving a message indicating a call
125 * to a @e method. 145 * to a @e method.
126 * 146 *
127 * @param cls Closure. 147 * @param cls Closure.
128 * @param full_method_name Original method name from PSYC (may be more
129 * specific than the registered method name due to try-and-slice matching).
130 * @param sender Who transmitted the message (origin, except for messages 148 * @param sender Who transmitted the message (origin, except for messages
131 * from one of the members to the origin). 149 * from one of the members to the origin).
132 * @param message_id Unique message counter for this message; 150 * @param message_id Unique message counter for this message;
@@ -134,6 +152,9 @@ enum GNUNET_PSYC_FragmentStatus
134 * this channel). 152 * this channel).
135 * @param group_generation Group generation counter for this message 153 * @param group_generation Group generation counter for this message
136 * (always zero for messages from members to channel owner); FIXME: needed? 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.
137 * @param data_off Byte offset of @a data in the overall data of the method. 158 * @param data_off Byte offset of @a data in the overall data of the method.
138 * @param data_size Number of bytes in @a data. 159 * @param data_size Number of bytes in @a data.
139 * @param data Data stream given to the method (might not be zero-terminated 160 * @param data Data stream given to the method (might not be zero-terminated
@@ -141,10 +162,10 @@ enum GNUNET_PSYC_FragmentStatus
141 * @param frag Fragmentation status for the data. 162 * @param frag Fragmentation status for the data.
142 */ 163 */
143typedef int (*GNUNET_PSYC_Method)(void *cls, 164typedef int (*GNUNET_PSYC_Method)(void *cls,
144 const char *full_method_name,
145 const struct GNUNET_PeerIdentity *sender, 165 const struct GNUNET_PeerIdentity *sender,
146 uint64_t message_id, 166 uint64_t message_id,
147 uint64_t group_generation, 167 uint64_t group_generation,
168 const char *method_name,
148 uint64_t data_off, 169 uint64_t data_off,
149 size_t data_size, 170 size_t data_size,
150 const void *data, 171 const void *data,
@@ -152,6 +173,72 @@ typedef int (*GNUNET_PSYC_Method)(void *cls,
152 173
153 174
154/** 175/**
176 * Method called from PSYC upon receiving a join request.
177 *
178 * @param cls Closure.
179 * @param sender Who transmitted the message.
180 * @param method_name Method name in the join request.
181 * @param data_size Number of bytes in @a data.
182 * @param data Data stream given to the method (might not be zero-terminated
183 * if data is binary).
184 */
185typedef int (*GNUNET_PSYC_JoinCallback)(void *cls,
186 const struct GNUNET_PeerIdentity *sender,
187 const char *method_name,
188 size_t data_size,
189 const void *data,
190 struct GNUNET_PSYC_JoinHandle *jh);
191
192
193/**
194 * Method called from PSYC upon receiving a part request.
195 *
196 * @param cls Closure.
197 * @param sender Who transmitted the message.
198 * @param method_name Method name in the part request.
199 * @param data_size Number of bytes in @a data.
200 * @param data Data stream given to the method (might not be zero-terminated
201 * if data is binary).
202 */
203typedef int (*GNUNET_PSYC_PartCallback)(void *cls,
204 const struct GNUNET_PeerIdentity *sender,
205 const char *method_name,
206 size_t data_size,
207 const void *data,
208 struct GNUNET_PSYC_PartHandle *ph);
209
210
211/**
212 * Function to call with the decision made for a join request.
213 *
214 * Must be called once and only once in response to an invocation of the
215 * #GNUNET_PSYC_JoinCallback.
216 *
217 * @param jh Join request handle.
218 * @param is_admitted #GNUNET_YES if joining is approved,
219 * #GNUNET_NO if it is disapproved
220 * @param method_name Method name for the message transmitted with the response.
221 * @param data_size Size of @a data.
222 * @param data Data of the message.
223 */
224void
225GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
226 int is_admitted,
227 const char *method_name,
228 size_t data_size,
229 const void *data);
230
231
232/**
233 * Send a part acknowledgment.
234 *
235 * @param ph Part handle.
236 */
237void
238GNUNET_PSYC_part_ack (struct GNUNET_PSYC_PartHandle *ph);
239
240
241/**
155 * Handle for the channel of a PSYC group. 242 * Handle for the channel of a PSYC group.
156 */ 243 */
157struct GNUNET_PSYC_Channel; 244struct GNUNET_PSYC_Channel;
@@ -166,13 +253,10 @@ struct GNUNET_PSYC_Channel;
166 * invoked; the join handler must then generate a "join" message to approve the 253 * invoked; the join handler must then generate a "join" message to approve the
167 * joining of the new member. The channel can also change group membership 254 * joining of the new member. The channel can also change group membership
168 * without explicit requests. Note that PSYC doesn't itself "understand" join 255 * without explicit requests. Note that PSYC doesn't itself "understand" join
169 * or leave messages, the respective methods must call other PSYC functions to 256 * or part messages, the respective methods must call other PSYC functions to
170 * inform PSYC about the meaning of the respective events. 257 * inform PSYC about the meaning of the respective events.
171 * 258 *
172 * @param cfg Configuration to use (to connect to PSYC service). 259 * @param cfg Configuration to use (to connect to PSYC service).
173 * @param method Function to invoke on messages received from members,
174 * typcially at least contains functions for @e join and @e leave.
175 * @param method_cls Closure for @a method.
176 * @param priv_key ECC key that will be used to sign messages for this 260 * @param priv_key ECC key that will be used to sign messages for this
177 * PSYC session; public key is used to identify the 261 * PSYC session; public key is used to identify the
178 * PSYC group; FIXME: we'll likely want to use 262 * PSYC group; FIXME: we'll likely want to use
@@ -183,75 +267,46 @@ struct GNUNET_PSYC_Channel;
183 * key(s) when setting up their own channels 267 * key(s) when setting up their own channels
184 * @param join_policy What is the membership policy of the group? 268 * @param join_policy What is the membership policy of the group?
185 * Used to automate group management decisions. 269 * Used to automate group management decisions.
270 * @param method_cb Function to invoke on messages received from members.
271 * @param join_cb Function to invoke when a peer wants to join.
272 * @param part_cb Function to invoke when a peer wants to part.
273 * @param cls Closure for the callbacks.
186 * @return Handle for the channel, NULL on error. 274 * @return Handle for the channel, NULL on error.
187 */ 275 */
188struct GNUNET_PSYC_Channel * 276struct GNUNET_PSYC_Channel *
189GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg, 277GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
190 GNUNET_PSYC_Method method,
191 void *method_cls,
192 const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, 278 const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
193 enum GNUNET_MULTICAST_JoinPolicy join_policy); 279 enum GNUNET_MULTICAST_JoinPolicy join_policy,
194 280 GNUNET_PSYC_Method method_cb,
195 281 GNUNET_PSYC_JoinCallback join_cb,
196/** 282 GNUNET_PSYC_PartCallback part_cb,
197 * Possible operations on PSYC state (persistent) and variables (per message). 283 void *cls);
198 */
199enum GNUNET_PSYC_Operator
200{
201 /**
202 * Replace the full state with the new value ("=").
203 */
204 GNUNET_PSYC_SOT_SET_STATE = 0,
205
206 /**
207 * Delete the complete entry from the state (given data must be
208 * empty). Equivalent to @a SET with empty data, but more
209 * explicit ("=");
210 */
211 GNUNET_PSYC_SOT_DELETE = 0,
212
213 /**
214 * Set the value of a variable to a new value (":").
215 */
216 GNUNET_PSYC_SOT_SET_VARIABLE,
217
218 /**
219 * Add the given value to the set of values in the state ("+").
220 */
221 GNUNET_PSYC_SOT_ADD_STATE,
222
223 /**
224 * Remove the given value from the set of values in the state ("-").
225 */
226 GNUNET_PSYC_SOT_REMOVE_STATE
227
228};
229 284
230 285
231/** 286/**
232 * Update channel state (or set a variable). 287 * Modify channel state (or set a transient variable).
233 * 288 *
234 * The state of a channel must fit into the memory of each member (and the 289 * The state of a channel must fit into the memory of each member (and the
235 * channel); large values that require streaming must only be passed as the 290 * channel); large values that require streaming must only be passed as the
236 * stream arguments to methods. State updates might not be transmitted to group 291 * stream arguments to methods. State modifications might not be transmitted to
237 * members until the next call to GNUNET_PSYC_channel_notify_transmit_ready(). 292 * group members until the next call to GNUNET_PSYC_channel_transmit().
238 * Variable updates must be given just before the call to the respective method 293 * Variable updates must be given just before the call to the respective method
239 * that needs the variables. 294 * that needs the variables.
240 * 295 *
241 * @param channel Handle to the PSYC group / channel. 296 * @param channel Handle to the PSYC group / channel.
242 * @param full_state_name Name of the field in the channel state to change. 297 * @param oper Kind of update operation (add, remove, replace, delete).
243 * @param type Kind of update operation (add, remove, replace, delete). 298 * @param name Name of the state or transient variable to modify.
244 * @param data_size Number of bytes in data. 299 * @param value_size Number of bytes in @a value.
245 * @param data New state value. 300 * @param value Value of state variable.
246 * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error 301 * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error
247 * (i.e. state too large). 302 * (i.e. state too large).
248 */ 303 */
249int 304int
250GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, 305GNUNET_PSYC_channel_state_modify (struct GNUNET_PSYC_Channel *channel,
251 const char *full_state_name, 306 enum GNUNET_PSYC_Operator oper,
252 enum GNUNET_PSYC_Operator type, 307 const char *name,
253 size_t data_size, 308 size_t value_size,
254 const void *data); 309 const void *value);
255 310
256 311
257/** 312/**
@@ -264,10 +319,10 @@ GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel,
264 * @param message_id Set to the unique message ID that was generated for 319 * @param message_id Set to the unique message ID that was generated for
265 * this message. 320 * this message.
266 * @param group_generation Set to the group generation used for this 321 * @param group_generation Set to the group generation used for this
267 * message. 322 * message.
268 * @param data_size[in,out] Initially set to the number of bytes available in @a data, 323 * @param data_size[in,out] Initially set to the number of bytes available in @a data,
269 * should be set to the number of bytes written to data (IN/OUT). 324 * should be set to the number of bytes written to data (IN/OUT).
270 * @param data[out] Where to write the body of the message to give to the method; 325 * @param[out] data Where to write the body of the message to give to the method;
271 * function must copy at most @a *data_size bytes to @a data. 326 * function must copy at most @a *data_size bytes to @a data.
272 * @return #GNUNET_SYSERR on error (fatal, aborts transmission) 327 * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
273 * #GNUNET_NO on success, if more data is to be transmitted later 328 * #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,
275 * #GNUNET_YES if this completes the transmission (all data supplied) 330 * #GNUNET_YES if this completes the transmission (all data supplied)
276 */ 331 */
277typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, 332typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls,
278 uint64_t message_id, 333 uint64_t message_id,
279 uint64_t group_generation, 334 uint64_t group_generation,
280 size_t *data_size, 335 size_t *data_size,
281 void *data); 336 void *data);
282 337
283 338
284/** 339/**
285 * Handle for a pending PSYC transmission operation. 340 * Handle for a pending PSYC transmission operation.
286 */ 341 */
287struct GNUNET_PSYC_ChannelTransmitHandle; 342struct GNUNET_PSYC_ChannelTransmitHandle;
288 343
@@ -293,17 +348,17 @@ struct GNUNET_PSYC_ChannelTransmitHandle;
293 * @param channel Handle to the PSYC multicast group. 348 * @param channel Handle to the PSYC multicast group.
294 * @param increment_group_generation #GNUNET_YES if we need to increment 349 * @param increment_group_generation #GNUNET_YES if we need to increment
295 * the group generation counter after transmitting this message. 350 * the group generation counter after transmitting this message.
296 * @param full_method_name Which method should be invoked. 351 * @param method_name Which method should be invoked.
297 * @param notify Function to call to obtain the arguments. 352 * @param notify Function to call to obtain the arguments.
298 * @param notify_cls Closure for @a notify. 353 * @param notify_cls Closure for @a notify.
299 * @return Transmission handle, NULL on error (i.e. more than one request queued). 354 * @return Transmission handle, NULL on error (i.e. more than one request queued).
300 */ 355 */
301struct GNUNET_PSYC_ChannelTransmitHandle * 356struct GNUNET_PSYC_ChannelTransmitHandle *
302GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, 357GNUNET_PSYC_channel_transmit (struct GNUNET_PSYC_Channel *channel,
303 int increment_group_generation, 358 int increment_group_generation,
304 const char *full_method_name, 359 const char *method_name,
305 GNUNET_PSYC_ChannelReadyNotify notify, 360 GNUNET_PSYC_ChannelReadyNotify notify,
306 void *notify_cls); 361 void *notify_cls);
307 362
308 363
309/** 364/**
@@ -312,7 +367,7 @@ GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel,
312 * @param th Handle of the request that is being aborted. 367 * @param th Handle of the request that is being aborted.
313 */ 368 */
314void 369void
315GNUNET_PSYC_channel_notify_transmit_ready_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); 370GNUNET_PSYC_channel_transmit_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th);
316 371
317 372
318/** 373/**
@@ -358,13 +413,12 @@ GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member);
358 * channel still needs to explicitly transmit a @e join message to notify other 413 * channel still needs to explicitly transmit a @e join message to notify other
359 * group members and they then also must still call this function in their 414 * group members and they then also must still call this function in their
360 * respective methods handling the @e join message. This way, how @e join and 415 * respective methods handling the @e join message. This way, how @e join and
361 * @e leave operations are exactly implemented is still up to the application; 416 * @e part operations are exactly implemented is still up to the application;
362 * for example, there might be a @e leave_all method to kick out everyone. 417 * for example, there might be a @e part_all method to kick out everyone.
363 * 418 *
364 * Note that group members are explicitly trusted to execute such 419 * Note that group members are explicitly trusted to execute such methods
365 * methods correctly; not doing so correctly will result in either 420 * correctly; not doing so correctly will result in either denying members
366 * denying members access or offering access to group data to 421 * access or offering access to group data to non-members.
367 * non-members.
368 * 422 *
369 * @param group Group handle. 423 * @param group Group handle.
370 * @param member Which peer to add. 424 * @param member Which peer to add.
@@ -383,11 +437,11 @@ GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group,
383 * 437 *
384 * Note that this will NOT generate any PSYC traffic, it will merely update the 438 * Note that this will NOT generate any PSYC traffic, it will merely update the
385 * local data base to modify how we react to <em>membership test</em> queries. The 439 * local data base to modify how we react to <em>membership test</em> queries. The
386 * channel still needs to explicitly transmit a @e leave message to notify other 440 * channel still needs to explicitly transmit a @e part message to notify other
387 * group members and they then also must still call this function in their 441 * group members and they then also must still call this function in their
388 * respective methods handling the @e leave message. This way, how @e join and 442 * respective methods handling the @e part message. This way, how @e join and
389 * @e leave operations are exactly implemented is still up to the application; 443 * @e part operations are exactly implemented is still up to the application;
390 * for example, there might be a @e leave_all message to kick out everyone. 444 * for example, there might be a @e part_all message to kick out everyone.
391 * 445 *
392 * Note that group members are explicitly trusted to perform these 446 * Note that group members are explicitly trusted to perform these
393 * operations correctly; not doing so correctly will result in either 447 * operations correctly; not doing so correctly will result in either
@@ -447,22 +501,22 @@ struct GNUNET_PSYC_StateHandler
447 501
448}; 502};
449 503
450
451/** 504/**
452 * Join a PSYC group. 505 * Join a PSYC group.
453 * 506 *
454 * The entity joining is always the local peer. The user must immediately use 507 * The entity joining is always the local peer. The user must immediately use
455 * the GNUNET_PSYC_member_send_to_host() (and possibly 508 * the GNUNET_PSYC_member_to_origin() (and possibly
456 * GNUNET_PSYC_member_host_variable_set()) functions to transmit a @e join_msg to 509 * GNUNET_PSYC_member_origin_variable_set()) functions to transmit a @e join_msg to
457 * the channel; if the join request succeeds, the channel state (and @e recent 510 * the channel; if the join request succeeds, the channel state (and @e recent
458 * method calls) will be replayed to the joining member. There is no explicit 511 * method calls) will be replayed to the joining member. There is no explicit
459 * notification on failure (as the channel may simply take days to approve, and 512 * notification on failure (as the channel may simply take days to approve, a-v/snd
460 * disapproval is simply being ignored). 513 * disapproval is simply being ignored).
461 * 514 *
462 * @param cfg Configuration to use. 515 * @param cfg Configuration to use.
463 * @param pub_key ECC key that identifies the channel we wish to join 516 * @param pub_key ECC key that identifies the channel we wish to join
517 * @param origin Peer identity of the origin.
464 * @param method Function to invoke on messages received from the channel, 518 * @param method Function to invoke on messages received from the channel,
465 * typically at least contains functions for @e join and @e leave. 519 * typically at least contains functions for @e join and @e part.
466 * @param method_cls Closure for @a method. 520 * @param method_cls Closure for @a method.
467 * @param state_count Number of @a state_handlers. 521 * @param state_count Number of @a state_handlers.
468 * @param state_handlers Array of state event handlers. 522 * @param state_handlers Array of state event handlers.
@@ -471,6 +525,7 @@ struct GNUNET_PSYC_StateHandler
471struct GNUNET_PSYC_Member * 525struct GNUNET_PSYC_Member *
472GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 526GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
473 const struct GNUNET_CRYPTO_EccPublicKey *pub_key, 527 const struct GNUNET_CRYPTO_EccPublicKey *pub_key,
528 const struct GNUNET_PeerIdentity *origin,
474 GNUNET_PSYC_Method method, 529 GNUNET_PSYC_Method method,
475 void *method_cls, 530 void *method_cls,
476 unsigned int state_count, 531 unsigned int state_count,
@@ -478,16 +533,15 @@ GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
478 533
479 534
480/** 535/**
481 * Leave a multicast group. 536 * Part a PSYC group.
482 * 537 *
483 * Will terminate the connection to the PSYC service. Polite clients should 538 * Will terminate the connection to the PSYC service. Polite clients should
484 * first explicitly send a @e leave request (via 539 * first explicitly send a @e part request (via GNUNET_PSYC_member_to_origin()).
485 * GNUNET_PSYC_member_send_to_host()).
486 * 540 *
487 * @param member membership handle 541 * @param member membership handle
488 */ 542 */
489void 543void
490GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); 544GNUNET_PSYC_member_part (struct GNUNET_PSYC_Member *member);
491 545
492 546
493/** 547/**
@@ -500,13 +554,13 @@ GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member);
500 * @param cls Closure. 554 * @param cls Closure.
501 * @param data_size[in,out] Initially set to the number of bytes available in @a data, 555 * @param data_size[in,out] Initially set to the number of bytes available in @a data,
502 * should be set to the number of bytes written to data (IN/OUT). 556 * should be set to the number of bytes written to data (IN/OUT).
503 * @param data[out] Where to write the body of the message to give to the method; 557 * @param[out] data Where to write the body of the message to give to the method;
504 * function must copy at most @a *data_size bytes to @a data. 558 * function must copy at most @a *data_size bytes to @a data.
505 * @return #GNUNET_SYSERR on error (fatal, aborts transmission). 559 * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
506 * #GNUNET_NO on success, if more data is to be transmitted later. 560 * #GNUNET_NO on success, if more data is to be transmitted later.
507 * #GNUNET_YES if this completes the transmission (all data supplied). 561 * #GNUNET_YES if this completes the transmission (all data supplied).
508 */ 562 */
509typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, 563typedef int (*GNUNET_PSYC_MemberReadyNotify)(void *cls,
510 size_t *data_size, 564 size_t *data_size,
511 char *data); 565 char *data);
512 566
@@ -514,7 +568,7 @@ typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls,
514/** 568/**
515 * Handle for a pending PSYC transmission operation. 569 * Handle for a pending PSYC transmission operation.
516 */ 570 */
517struct GNUNET_PSYC_OriginTransmitHandle; 571struct GNUNET_PSYC_MemberTransmitHandle;
518 572
519 573
520/** 574/**
@@ -526,18 +580,18 @@ struct GNUNET_PSYC_OriginTransmitHandle;
526 * @param notify_cls Closure for @a notify. 580 * @param notify_cls Closure for @a notify.
527 * @return Transmission handle, NULL on error (i.e. more than one request queued). 581 * @return Transmission handle, NULL on error (i.e. more than one request queued).
528 */ 582 */
529struct GNUNET_PSYC_OriginTransmitHandle * 583struct GNUNET_PSYC_MemberTransmitHandle *
530GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, 584GNUNET_PSYC_member_to_origin (struct GNUNET_PSYC_Member *member,
531 const char *method_name, 585 const char *method_name,
532 GNUNET_PSYC_OriginReadyNotify notify, 586 GNUNET_PSYC_MemberReadyNotify notify,
533 void *notify_cls); 587 void *notify_cls);
534 588
535 589
536/** 590/**
537 * Set a (temporary, ":") variable for the next message being transmitted 591 * Set a (temporary, ":") variable for the next message being transmitted
538 * via GNUNET_PSYC_member_send_to_host(). 592 * via GNUNET_PSYC_member_to_origin().
539 * 593 *
540 * If GNUNET_PSYC_member_send_to_host() is called and then cancelled, all 594 * If GNUNET_PSYC_member_to_origin() is called and then cancelled, all
541 * variables that were set using this function will be unset (lost/forgotten). 595 * variables that were set using this function will be unset (lost/forgotten).
542 * To clear a variable state after setting it, you can also call this function 596 * To clear a variable state after setting it, you can also call this function
543 * again with NULL/0 for the @a value. 597 * again with NULL/0 for the @a value.
@@ -560,7 +614,7 @@ GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member,
560 * @param th Handle of the request that is being aborted. 614 * @param th Handle of the request that is being aborted.
561 */ 615 */
562void 616void
563GNUNET_PSYC_member_send_to_origin_cancel (struct GNUNET_PSYC_OriginTransmitHandle *th); 617GNUNET_PSYC_member_to_origin_cancel (struct GNUNET_PSYC_MemberTransmitHandle *th);
564 618
565 619
566/** 620/**
@@ -575,9 +629,11 @@ struct GNUNET_PSYC_Story;
575 * Historic messages (but NOT the state at the time) will be replayed (given to 629 * Historic messages (but NOT the state at the time) will be replayed (given to
576 * the normal method handlers) if available and if access is permitted. 630 * the normal method handlers) if available and if access is permitted.
577 * 631 *
632 * To get the latest message, use 0 for both the start and end message ID.
633 *
578 * @param member Which channel should be replayed? 634 * @param member Which channel should be replayed?
579 * @param start Earliest interesting point in history. 635 * @param start_message_id Earliest interesting point in history.
580 * @param end Last (exclusive) interesting point in history. 636 * @param end_message_id Last (exclusive) interesting point in history.
581 * @param method Function to invoke on messages received from the story. 637 * @param method Function to invoke on messages received from the story.
582 * @param method_cls Closure for @a method. 638 * @param method_cls Closure for @a method.
583 * @param finish_cb Function to call when the requested story has been fully 639 * @param finish_cb Function to call when the requested story has been fully
@@ -591,8 +647,8 @@ struct GNUNET_PSYC_Story;
591 */ 647 */
592struct GNUNET_PSYC_Story * 648struct GNUNET_PSYC_Story *
593GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, 649GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member,
594 uint64_t start, 650 uint64_t start_message_id,
595 uint64_t end, 651 uint64_t end_message_id,
596 GNUNET_PSYC_Method method, 652 GNUNET_PSYC_Method method,
597 void *method_cls, 653 void *method_cls,
598 void (*finish_cb)(void *), 654 void (*finish_cb)(void *),
@@ -651,7 +707,7 @@ GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member,
651 * 707 *
652 * @param member Membership handle. 708 * @param member Membership handle.
653 * @param variable_name Name of the variable to query. 709 * @param variable_name Name of the variable to query.
654 * @param return_value_size Set to number of bytes in variable, 710 * @param[out] return_value_size Set to number of bytes in variable,
655 * needed as variables might contain binary data and 711 * needed as variables might contain binary data and
656 * might also not be 0-terminated; set to 0 on errors. 712 * might also not be 0-terminated; set to 0 on errors.
657 * @return NULL on error (no matching state or variable), pointer 713 * @return NULL on error (no matching state or variable), pointer
@@ -663,7 +719,6 @@ GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member,
663 size_t *return_value_size); 719 size_t *return_value_size);
664 720
665 721
666
667#if 0 /* keep Emacsens' auto-indent happy */ 722#if 0 /* keep Emacsens' auto-indent happy */
668{ 723{
669#endif 724#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 @@
21/** 21/**
22 * @file include/gnunet_psycstore_service.h 22 * @file include/gnunet_psycstore_service.h
23 * @brief PSYCstore service; implements persistent storage for the PSYC service 23 * @brief PSYCstore service; implements persistent storage for the PSYC service
24 * @author tg(x) 24 * @author Gabor X Toth
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27#ifndef GNUNET_PSYCSTORE_SERVICE_H 27#ifndef GNUNET_PSYCSTORE_SERVICE_H
@@ -91,6 +91,7 @@ typedef void (*GNUNET_PSYCSTORE_ContinuationCallback)(void *cls,
91 * @param h Handle for the PSYCstore. 91 * @param h Handle for the PSYCstore.
92 * @param channel_id ID of the channel where the event happened. 92 * @param channel_id ID of the channel where the event happened.
93 * @param message_id ID of the message in which this event was announced. 93 * @param message_id ID of the message in which this event was announced.
94 * @param group_generation Generation of the group when this event was announced.
94 * @param peer Identity of joining/leaving peer. 95 * @param peer Identity of joining/leaving peer.
95 * @param did_join #GNUNET_YES on join, #GNUNET_NO on leave. 96 * @param did_join #GNUNET_YES on join, #GNUNET_NO on leave.
96 * @param ccb Callback to call with the result of the storage operation. 97 * @param ccb Callback to call with the result of the storage operation.
@@ -102,6 +103,7 @@ struct GNUNET_PSYCSTORE_OperationHandle *
102GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, 103GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
103 const struct GNUNET_HashCode *channel_id, 104 const struct GNUNET_HashCode *channel_id,
104 uint64_t message_id, 105 uint64_t message_id,
106 uint64_t group_generation,
105 const struct GNUNET_PeerIdentity *peer, 107 const struct GNUNET_PeerIdentity *peer,
106 int did_join, 108 int did_join,
107 GNUNET_PSYCSTORE_ContinuationCallback ccb, 109 GNUNET_PSYCSTORE_ContinuationCallback ccb,
@@ -169,7 +171,7 @@ typedef void (*GNUNET_PSYCSTORE_MessageResultCallback)(void *cls,
169 * 171 *
170 * @param h Handle for the PSYCstore. 172 * @param h Handle for the PSYCstore.
171 * @param channel_id The channel we are interested in. 173 * @param channel_id The channel we are interested in.
172 * @param message_id Message ID to check. 174 * @param message_id Message ID to check. Use 0 to get the latest message.
173 * @param rcb Callback to call with the result of the operation. 175 * @param rcb Callback to call with the result of the operation.
174 * @param rcb_cls Closure for the callback. 176 * @param rcb_cls Closure for the callback.
175 * 177 *
@@ -184,23 +186,6 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
184 186
185 187
186/** 188/**
187 * Get latest message sent to a channel.
188 *
189 * @param h Handle for the PSYCstore.
190 * @param channel_id The channel we are interested in.
191 * @param rcb Callback to call with the result of the operation.
192 * @param rcb_cls Closure for the callback.
193 *
194 * @return Handle that can be used to cancel the operation.
195 */
196struct GNUNET_PSYCSTORE_OperationHandle *
197GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
198 const struct GNUNET_HashCode *channel_id,
199 GNUNET_PSYCSTORE_MessageResultCallback rcb,
200 void *rcb_cls);
201
202
203/**
204 * Store a state variable. 189 * Store a state variable.
205 * 190 *
206 * @param h Handle for the PSYCstore. 191 * @param h Handle for the PSYCstore.
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 @@
21/** 21/**
22 * @file include/gnunet_social_service.h 22 * @file include/gnunet_social_service.h
23 * @brief Social service; implements social functionality using the PSYC service. 23 * @brief Social service; implements social functionality using the PSYC service.
24 * @author tg(x) 24 * @author Gabor X Toth
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27#ifndef GNUNET_SOCIAL_SERVICE_H 27#ifndef GNUNET_SOCIAL_SERVICE_H
@@ -36,6 +36,7 @@ extern "C"
36#endif 36#endif
37 37
38#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
39#include "gnunet_psyc_lib.h"
39#include "gnunet_psyc_service.h" 40#include "gnunet_psyc_service.h"
40#include "gnunet_multicast_service.h" 41#include "gnunet_multicast_service.h"
41 42
@@ -74,7 +75,7 @@ struct GNUNET_SOCIAL_Slicer;
74 75
75/** 76/**
76 * Method called from SOCIAL upon receiving a message indicating a call 77 * Method called from SOCIAL upon receiving a message indicating a call
77 * to a @a method. 78 * to a @e method.
78 * 79 *
79 * @param cls Closure. 80 * @param cls Closure.
80 * @param full_method_name Original method name from PSYC (may be more 81 * @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);
171 * 172 *
172 * @param cls Closure. 173 * @param cls Closure.
173 * @param nym Handle for the user who wants to join. 174 * @param nym Handle for the user who wants to join.
174 * @param join_msg_size Number of bytes in @a join_msg. 175 * @param msg_size Number of bytes in @a msg.
175 * @param join_msg Payload given on join (e.g. a password). 176 * @param msg Payload given on enter (e.g. a password).
176 */ 177 */
177typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls, 178typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls,
178 struct GNUNET_SOCIAL_Nym *nym, 179 struct GNUNET_SOCIAL_Nym *nym,
179 size_t join_msg_size, 180 size_t msg_size,
180 const void *join_msg); 181 const void *msg);
181 182
182 183
183/** 184/**
@@ -244,7 +245,7 @@ GNUNET_SOCIAL_home_admit (struct GNUNET_SOCIAL_Home *home,
244 * #GNUNET_SOCIAL_FarewellCallback is invoked, 245 * #GNUNET_SOCIAL_FarewellCallback is invoked,
245 * which should be very soon after this call. 246 * which should be very soon after this call.
246 * 247 *
247 * @param home Home to eject nym from. 248 * @param home Home to eject @a nym from.
248 * @param nym Handle for the entity to be ejected. 249 * @param nym Handle for the entity to be ejected.
249 */ 250 */
250void 251void
@@ -277,7 +278,7 @@ GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home,
277 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). 278 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name().
278 * 279 *
279 * @param nym Pseudonym to map to a cryptographic identifier. 280 * @param nym Pseudonym to map to a cryptographic identifier.
280 * @param identity Set to the identity of the nym (short hash of the public key). 281 * @param[out] identity Set to the identity of the nym (short hash of the public key).
281 */ 282 */
282void 283void
283GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym, 284GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym,
@@ -288,7 +289,7 @@ GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym,
288 * Obtain the (cryptographic, binary) address for the home. 289 * Obtain the (cryptographic, binary) address for the home.
289 * 290 *
290 * @param home Home to get the (public) address from. 291 * @param home Home to get the (public) address from.
291 * @param crypto_address Address suitable for storing in GADS, i.e. in 292 * @param[out] crypto_address Address suitable for storing in GADS, i.e. in
292 * 'HEX.place' or within the respective GADS record type ("PLACE") 293 * 'HEX.place' or within the respective GADS record type ("PLACE")
293 */ 294 */
294void 295void
@@ -296,10 +297,25 @@ GNUNET_SOCIAL_home_get_address (struct GNUNET_SOCIAL_Home *home,
296 struct GNUNET_HashCode *crypto_address); 297 struct GNUNET_HashCode *crypto_address);
297 298
298 299
300
301/**
302 * Advertise @a home under @a name in the GADS zone of the @e ego.
303 *
304 * @param home The home to advertise.
305 * @param name The name to put in the zone.
306 * @param expiration_time Expiration time of the record, use 0 to remove the record.
307 */
308void
309GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home,
310 const char *name,
311 GNUNET_TIME_Relative expiration_time);
312
313
314
299/** 315/**
300 * (Re)decorate the home by changing objects in it. 316 * (Re)decorate the home by changing objects in it.
301 * 317 *
302 * If the operation is #GNUNET_PSYC_SOT_SET_VARIABLE then the decoration only 318 * If the operation is #GNUNET_PSYC_OP_SET then the decoration only
303 * applies to the next announcement by the home owner. 319 * applies to the next announcement by the home owner.
304 * 320 *
305 * @param home The home to decorate. 321 * @param home The home to decorate.
@@ -325,17 +341,18 @@ struct GNUNET_SOCIAL_Announcement;
325/** 341/**
326 * Send a message to all nyms that are present in the home. 342 * Send a message to all nyms that are present in the home.
327 * 343 *
328 * This function is restricted to the home owner. Nyms can 344 * This function is restricted to the home owner. Nyms can only send requests
345 * to the home owner who can decide to relay it to other guests.
329 * 346 *
330 * @param home Home to address the announcement to. 347 * @param home Home to address the announcement to.
331 * @param full_method_name Method to use for the announcement. 348 * @param method_name Method to use for the announcement.
332 * @param notify Function to call to get the payload of the announcement. 349 * @param notify Function to call to get the payload of the announcement.
333 * @param notify_cls Closure for @a notify. 350 * @param notify_cls Closure for @a notify.
334 * @return NULL on error (announcement already in progress?). 351 * @return NULL on error (announcement already in progress?).
335 */ 352 */
336struct GNUNET_SOCIAL_Announcement * 353struct GNUNET_SOCIAL_Announcement *
337GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home, 354GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home,
338 const char *full_method_name, 355 const char *method_name,
339 GNUNET_PSYC_OriginReadyNotify notify, 356 GNUNET_PSYC_OriginReadyNotify notify,
340 void *notify_cls); 357 void *notify_cls);
341 358
@@ -361,15 +378,15 @@ GNUNET_SOCIAL_home_to_place (struct GNUNET_SOCIAL_Home *home);
361 378
362 379
363/** 380/**
364 * Leave a home, visitors can stay. 381 * Leave a home temporarily, visitors can stay.
365 * 382 *
366 * After leaving, handling of incoming messages are left to other clients of the 383 * After leaving, handling of incoming messages are left to other clients of the
367 * social service, and stops after the last client exits. 384 * social service, and stops after the last client exits.
368 * 385 *
369 * @param home Home to leave (handle becomes invalid). 386 * @param home Home to leave temporarily (handle becomes invalid).
370 */ 387 */
371void 388void
372GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home); 389GNUNET_SOCIAL_home_away (struct GNUNET_SOCIAL_Home *home);
373 390
374 391
375/** 392/**
@@ -380,30 +397,50 @@ GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home);
380void 397void
381GNUNET_SOCIAL_home_destroy (struct GNUNET_SOCIAL_Home *home); 398GNUNET_SOCIAL_home_destroy (struct GNUNET_SOCIAL_Home *home);
382 399
383
384/** 400/**
385 * Join a place (home hosted by someone else). 401 * Request entry to a place (home hosted by someone else).
386 * 402 *
387 * @param cfg Configuration to contact the social service. 403 * @param cfg Configuration to contact the social service.
388 * @param ego Owner of the home (host). 404 * @param ego Owner of the home (host).
389 * @param address Address of the place to join (GADS name, i.e. 'room.friend.gads'), 405 * @param address Address of the place to enter (GADS name, i.e. 'room.friend.gads'),
390 * if the name has the form 'HEX.place', GADS is not 406 * if the name has the form 'HEX.place', GADS is not
391 * used and HEX is assumed to be the hash of the public 407 * used and HEX is assumed to be the hash of the public
392 * key already; 'HEX.zkey' however would refer to 408 * key already; 'HEX.zkey' however would refer to
393 * the 'PLACE' record in the GADS zone with the public key 409 * the 'PLACE' record in the GADS zone with the public key
394 * 'HEX'. 410 * 'HEX'.
395 * @param slicer slicer to use to process messages from this place 411 * @param msg_size Number of bytes in @a msg.
396 * @param join_msg_size Number of bytes in @a join_msg. 412 * @param msg Message to give to the enter callback.
397 * @param join_msg Message to give to the join callback. 413 * @param slicer Slicer to use for processing incoming requests from guests.
398 * @return NULL on errors, otherwise handle to the place. 414 * @return NULL on errors, otherwise handle to the place.
399 */ 415 */
400struct GNUNET_SOCIAL_Place * 416struct GNUNET_SOCIAL_Place *
401GNUNET_SOCIAL_place_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 417GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
402 struct GNUNET_SOCIAL_Ego *ego, 418 struct GNUNET_SOCIAL_Ego *ego,
403 const char *address, 419 char *address,
404 struct GNUNET_SOCIAL_Slicer *slicer, 420 size_t msg_size,
405 size_t join_msg_size, 421 const void *msg,
406 const void *join_msg); 422 struct GNUNET_SOCIAL_Slicer *slicer);
423
424/**
425 * Request entry to a place (home hosted by someone else).
426 *
427 * @param cfg Configuration to contact the social service.
428 * @param ego Owner of the home (host).
429 * @param crypto_address Public key of the place to enter.
430 * @param peer Peer to send request to.
431 * @param slicer Slicer to use for processing incoming requests from guests.
432 * @param msg_size Number of bytes in @a msg.
433 * @param msg Message to give to the enter callback.
434 * @return NULL on errors, otherwise handle to the place.
435 */
436struct GNUNET_SOCIAL_Place *
437GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
438 struct GNUNET_SOCIAL_Ego *ego,
439 struct GNUNET_HashCode *crypto_address,
440 struct GNUNET_PeerIdentity *peer,
441 struct GNUNET_SOCIAL_Slicer *slicer,
442 size_t msg_size,
443 const void *msg);
407 444
408 445
409struct GNUNET_SOCIAL_WatchHandle; 446struct GNUNET_SOCIAL_WatchHandle;
@@ -515,7 +552,6 @@ GNUNET_SOCIAL_place_frame_talk (struct GNUNET_SOCIAL_Place *place,
515 */ 552 */
516struct GNUNET_SOCIAL_TalkRequest; 553struct GNUNET_SOCIAL_TalkRequest;
517 554
518
519/** 555/**
520 * Talk to the host of the place. 556 * Talk to the host of the place.
521 * 557 *
@@ -532,25 +568,6 @@ GNUNET_SOCIAL_place_talk (struct GNUNET_SOCIAL_Place *place,
532 GNUNET_PSYC_OriginReadyNotify cb, 568 GNUNET_PSYC_OriginReadyNotify cb,
533 void *cb_cls); 569 void *cb_cls);
534 570
535/**
536 * Talk to a nym.
537 *
538 * FIXME: look up nym in GADS and talk to its place.
539 * FIXME: do we want this in this API!? Not sure. -CG
540 *
541 * @param nym Nym we want to talk to.
542 * @param method_name Method to invoke on the @a nym.
543 * @param cb Function to use to get the payload for the method.
544 * @param cb_cls Closure for @a cb.
545 * @return NULL if we are already trying to talk to the host,
546 * otherwise handle to cancel the request.
547 */
548struct GNUNET_SOCIAL_TalkRequest *
549GNUNET_SOCIAL_nym_talk (struct GNUNET_SOCIAL_Nym *nym,
550 const char *method_name,
551 GNUNET_PSYC_OriginReadyNotify cb,
552 void *cb_cls);
553
554 571
555/** 572/**
556 * Cancel talking to the host of the place. 573 * Cancel talking to the host of the place.
@@ -559,19 +576,20 @@ GNUNET_SOCIAL_nym_talk (struct GNUNET_SOCIAL_Nym *nym,
559 */ 576 */
560void 577void
561GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); 578GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
562 579
563 580
564/** 581/**
565 * A history lesson. 582 * A history lesson.
566 */ 583 */
567struct GNUNET_SOCIAL_HistoryLesson; 584struct GNUNET_SOCIAL_HistoryLesson;
568 585
569
570/** 586/**
571 * Learn about the history of a place. 587 * Learn about the history of a place.
572 * 588 *
573 * Sends messages through the given slicer function where 589 * Sends messages through the given slicer function where
574 * start_message_id <= message_id <= end_message_id. 590 * start_message_id <= message_id <= end_message_id.
591 *
592 * To get the latest message, use 0 for both the start and end message ID.
575 * 593 *
576 * @param place Place we want to learn more about. 594 * @param place Place we want to learn more about.
577 * @param start_message_id First historic message we are interested in. 595 * @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
600 618
601 619
602/** 620/**
603 * Leave a place (destroys the place handle). 621 * Leave a place permanently.
604 *
605 * Can either move our user into an @e away state (in which we continue to record
606 * ongoing conversations and state changes if our peer is running), or leave the
607 * place entirely and stop following the conversation.
608 * 622 *
609 * @param place Place to leave. 623 * Notifies the owner of the place about leaving, and destroys the place handle.
610 * @param keep_following #GNUNET_YES to ask the social service to continue 624 *
611 * to follow the conversation, #GNUNET_NO to fully leave the place. 625 * @param place Place to leave permanently.
612 */ 626 */
613void 627void
614GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place, 628GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place);
615 int keep_following); 629
616 630
631/**
632 * Leave a place temporarily.
633 *
634 * Stop following the conversation for the @a place and destroy the @a place
635 * handle. Only affects the application calling this function, other clients of
636 * the service continue receiving the messages.
637 *
638 * @param place Place to leave temporarily.
639 */
640void
641GNUNET_SOCIAL_place_away (struct GNUNET_SOCIAL_Place *place);
617 642
618 643
619#if 0 /* keep Emacsens' auto-indent happy */ 644#if 0 /* keep Emacsens' auto-indent happy */