diff options
Diffstat (limited to 'src/include/gnunet_social_service.h')
-rw-r--r-- | src/include/gnunet_social_service.h | 145 |
1 files changed, 85 insertions, 60 deletions
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 | */ |
177 | typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls, | 178 | typedef 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 | */ |
250 | void | 251 | void |
@@ -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 | */ |
282 | void | 283 | void |
283 | GNUNET_SOCIAL_nym_get_identity (struct GNUNET_SOCIAL_Nym *nym, | 284 | GNUNET_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 | */ |
294 | void | 295 | void |
@@ -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 | */ | ||
308 | void | ||
309 | GNUNET_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 | */ |
336 | struct GNUNET_SOCIAL_Announcement * | 353 | struct GNUNET_SOCIAL_Announcement * |
337 | GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home, | 354 | GNUNET_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 | */ |
371 | void | 388 | void |
372 | GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home); | 389 | GNUNET_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); | |||
380 | void | 397 | void |
381 | GNUNET_SOCIAL_home_destroy (struct GNUNET_SOCIAL_Home *home); | 398 | GNUNET_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 | */ |
400 | struct GNUNET_SOCIAL_Place * | 416 | struct GNUNET_SOCIAL_Place * |
401 | GNUNET_SOCIAL_place_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 417 | GNUNET_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 | */ | ||
436 | struct GNUNET_SOCIAL_Place * | ||
437 | GNUNET_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 | ||
409 | struct GNUNET_SOCIAL_WatchHandle; | 446 | struct GNUNET_SOCIAL_WatchHandle; |
@@ -515,7 +552,6 @@ GNUNET_SOCIAL_place_frame_talk (struct GNUNET_SOCIAL_Place *place, | |||
515 | */ | 552 | */ |
516 | struct GNUNET_SOCIAL_TalkRequest; | 553 | struct 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 | */ | ||
548 | struct GNUNET_SOCIAL_TalkRequest * | ||
549 | GNUNET_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 | */ |
560 | void | 577 | void |
561 | GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); | 578 | GNUNET_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 | */ |
567 | struct GNUNET_SOCIAL_HistoryLesson; | 584 | struct 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 | */ |
613 | void | 627 | void |
614 | GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place, | 628 | GNUNET_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 | */ | ||
640 | void | ||
641 | GNUNET_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 */ |