aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_social_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
committerGabor X Toth <*@tg-x.net>2016-01-12 23:26:47 +0000
commit50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea (patch)
treea8023bdb9c9446a45792d7100303265c78713a50 /src/include/gnunet_social_service.h
parent3cbdbe18dbd56def00c0014381ff90b4ee664904 (diff)
downloadgnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.tar.gz
gnunet-50eaf8d7de763d25b7dae7ffdee8d7c6b5fe71ea.zip
psycutil reorg: message, env, slicer
Diffstat (limited to 'src/include/gnunet_social_service.h')
-rw-r--r--src/include/gnunet_social_service.h293
1 files changed, 21 insertions, 272 deletions
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index 344521c7a..4ad6036a9 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -216,7 +216,7 @@ extern "C"
216 216
217#include <stdint.h> 217#include <stdint.h>
218#include "gnunet_util_lib.h" 218#include "gnunet_util_lib.h"
219#include "gnunet_env_lib.h" 219#include "gnunet_psyc_util_lib.h"
220#include "gnunet_identity_service.h" 220#include "gnunet_identity_service.h"
221#include "gnunet_namestore_service.h" 221#include "gnunet_namestore_service.h"
222#include "gnunet_psyc_service.h" 222#include "gnunet_psyc_service.h"
@@ -263,14 +263,6 @@ struct GNUNET_SOCIAL_Host;
263struct GNUNET_SOCIAL_Guest; 263struct GNUNET_SOCIAL_Guest;
264 264
265/** 265/**
266 * Handle to an implementation of try-and-slice.
267 */
268struct GNUNET_SOCIAL_Slicer;
269
270
271
272
273/**
274 * Handle that can be used to reconnect to a place as host. 266 * Handle that can be used to reconnect to a place as host.
275 */ 267 */
276struct GNUNET_SOCIAL_HostConnection; 268struct GNUNET_SOCIAL_HostConnection;
@@ -450,239 +442,6 @@ GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
450 442
451 443
452/** 444/**
453 * Function called upon receiving a message indicating a call to a @e method.
454 *
455 * This function is called one or more times for each message until all data
456 * fragments arrive from the network.
457 *
458 * @param cls
459 * Closure.
460 * @param msg
461 * Message part, as it arrived from the network.
462 * @param message_id
463 * Message counter, monotonically increasing from 1.
464 * @param nym
465 * The sender of the message.
466 * Can be NULL if the message is not connected to a pseudonym.
467 * @param flags
468 * OR'ed GNUNET_PSYC_MessageFlags
469 * @param method_name
470 * Original method name from PSYC.
471 * May be more specific than the registered method name due to
472 * try-and-slice matching.
473 */
474typedef void
475(*GNUNET_SOCIAL_MethodCallback) (void *cls,
476 const struct GNUNET_PSYC_MessageMethod *msg,
477 uint64_t message_id,
478 uint32_t flags,
479 const struct GNUNET_SOCIAL_Nym *nym,
480 const char *method_name);
481
482
483/**
484 * Function called upon receiving a modifier of a message.
485 *
486 * @param cls
487 * Closure.
488 * @param message_id
489 * Message ID this data fragment belongs to.
490 * @param msg
491 * Message part, as it arrived from the network.
492 * @param oper
493 * Operation to perform.
494 * 0 in case of a modifier continuation.
495 * @param name
496 * Name of the modifier.
497 * NULL in case of a modifier continuation.
498 * @param value
499 * Value of the modifier.
500 * @param value_size
501 * Size of @value.
502 */
503typedef void
504(*GNUNET_SOCIAL_ModifierCallback) (void *cls,
505 const struct GNUNET_MessageHeader *msg,
506 uint64_t message_id,
507 enum GNUNET_ENV_Operator oper,
508 const char *name,
509 const void *value,
510 uint16_t value_size,
511 uint16_t full_value_size);
512
513
514/**
515 * Function called upon receiving a data fragment of a message.
516 *
517 * @param cls
518 * Closure.
519 * @param message_id
520 * Message ID this data fragment belongs to.
521 * @param msg
522 * Message part, as it arrived from the network.
523 * @param data_offset
524 * Byte offset of @a data in the overall data of the method.
525 * @param data_size
526 * Number of bytes in @a data.
527 * @param data
528 * Data stream given to the method.
529 * @param end
530 * End of message?
531 * #GNUNET_NO if there are further fragments,
532 * #GNUNET_YES if this is the last fragment,
533 * #GNUNET_SYSERR indicates the message was cancelled by the sender.
534 */
535typedef void
536(*GNUNET_SOCIAL_DataCallback) (void *cls,
537 const struct GNUNET_MessageHeader *msg,
538 uint64_t message_id,
539 uint64_t data_offset,
540 const void *data,
541 uint16_t data_size);
542
543
544/**
545 * End of message.
546 *
547 * @param cls
548 * Closure.
549 * @param msg
550 * Message part, as it arrived from the network.
551 * @param message_id
552 * Message ID this data fragment belongs to.
553 * @param cancelled
554 * #GNUNET_YES if the message was cancelled,
555 * #GNUNET_NO if the message is complete.
556 */
557typedef void
558(*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls,
559 const struct GNUNET_MessageHeader *msg,
560 uint64_t message_id,
561 uint8_t cancelled);
562
563
564/**
565 * Create a try-and-slice instance.
566 *
567 * A slicer processes incoming messages and notifies callbacks about matching
568 * methods or modifiers encountered.
569 *
570 * @return A new try-and-slice construct.
571 */
572struct GNUNET_SOCIAL_Slicer *
573GNUNET_SOCIAL_slicer_create (void);
574
575
576/**
577 * Add a method to the try-and-slice instance.
578 *
579 * The callbacks are called for messages with a matching @a method_name prefix.
580 *
581 * @param slicer
582 * The try-and-slice instance to extend.
583 * @param method_name
584 * Name of the given method, use empty string to match all.
585 * @param method_cb
586 * Method handler invoked upon a matching message.
587 * @param modifier_cb
588 * Modifier handler, invoked after @a method_cb
589 * for each modifier in the message.
590 * @param data_cb
591 * Data handler, invoked after @a modifier_cb for each data fragment.
592 * @param eom_cb
593 * Invoked upon reaching the end of a matching message.
594 * @param cls
595 * Closure for the callbacks.
596 */
597void
598GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
599 const char *method_name,
600 GNUNET_SOCIAL_MethodCallback method_cb,
601 GNUNET_SOCIAL_ModifierCallback modifier_cb,
602 GNUNET_SOCIAL_DataCallback data_cb,
603 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
604 void *cls);
605
606/**
607 * Remove a registered method from the try-and-slice instance.
608 *
609 * Removes one matching handler registered with the given
610 * @a method_name and callbacks.
611 *
612 * @param slicer
613 * The try-and-slice instance.
614 * @param method_name
615 * Name of the method to remove.
616 * @param method_cb
617 * Method handler.
618 * @param modifier_cb
619 * Modifier handler.
620 * @param data_cb
621 * Data handler.
622 * @param eom_cb
623 * End of message handler.
624 *
625 * @return #GNUNET_OK if a method handler was removed,
626 * #GNUNET_NO if no handler matched the given method name and callbacks.
627 */
628int
629GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
630 const char *method_name,
631 GNUNET_SOCIAL_MethodCallback method_cb,
632 GNUNET_SOCIAL_ModifierCallback modifier_cb,
633 GNUNET_SOCIAL_DataCallback data_cb,
634 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
635
636
637/**
638 * Watch a place for changed objects.
639 *
640 * @param slicer
641 * The try-and-slice instance.
642 * @param object_filter
643 * Object prefix to match.
644 * @param modifier_cb
645 * Function to call when encountering a state modifier.
646 * @param cls
647 * Closure for callback.
648 */
649void
650GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
651 const char *object_filter,
652 GNUNET_SOCIAL_ModifierCallback modifier_cb,
653 void *cls);
654
655
656/**
657 * Remove a registered modifier from the try-and-slice instance.
658 *
659 * Removes one matching handler registered with the given
660 * @a object_filter and callback.
661 *
662 * @param slicer
663 * The try-and-slice instance.
664 * @param object_filter
665 * Object prefix to match.
666 * @param modifier_cb
667 * Function to call when encountering a state modifier changes.
668 */
669int
670GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
671 const char *object_filter,
672 GNUNET_SOCIAL_ModifierCallback modifier_cb);
673
674
675/**
676 * Destroy a given try-and-slice instance.
677 *
678 * @param slicer
679 * Slicer to destroy
680 */
681void
682GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
683
684
685/**
686 * Function called asking for nym to be admitted to the place. 445 * Function called asking for nym to be admitted to the place.
687 * 446 *
688 * Should call either GNUNET_SOCIAL_host_admit() or 447 * Should call either GNUNET_SOCIAL_host_admit() or
@@ -704,7 +463,7 @@ typedef void
704(*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls, 463(*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
705 struct GNUNET_SOCIAL_Nym *nym, 464 struct GNUNET_SOCIAL_Nym *nym,
706 const char *method_name, 465 const char *method_name,
707 struct GNUNET_ENV_Environment *env, 466 struct GNUNET_PSYC_Environment *env,
708 size_t data_size, 467 size_t data_size,
709 const void *data); 468 const void *data);
710 469
@@ -723,7 +482,7 @@ typedef void
723typedef void 482typedef void
724(*GNUNET_SOCIAL_FarewellCallback) (void *cls, 483(*GNUNET_SOCIAL_FarewellCallback) (void *cls,
725 const struct GNUNET_SOCIAL_Nym *nym, 484 const struct GNUNET_SOCIAL_Nym *nym,
726 struct GNUNET_ENV_Environment *env); 485 struct GNUNET_PSYC_Environment *env);
727 486
728 487
729/** 488/**
@@ -778,7 +537,7 @@ struct GNUNET_SOCIAL_Host *
778GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app, 537GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
779 const struct GNUNET_SOCIAL_Ego *ego, 538 const struct GNUNET_SOCIAL_Ego *ego,
780 enum GNUNET_PSYC_Policy policy, 539 enum GNUNET_PSYC_Policy policy,
781 struct GNUNET_SOCIAL_Slicer *slicer, 540 struct GNUNET_PSYC_Slicer *slicer,
782 GNUNET_SOCIAL_HostEnterCallback enter_cb, 541 GNUNET_SOCIAL_HostEnterCallback enter_cb,
783 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, 542 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
784 GNUNET_SOCIAL_FarewellCallback farewell_cb, 543 GNUNET_SOCIAL_FarewellCallback farewell_cb,
@@ -806,7 +565,7 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
806 */ 565 */
807struct GNUNET_SOCIAL_Host * 566struct GNUNET_SOCIAL_Host *
808GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn, 567GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
809 struct GNUNET_SOCIAL_Slicer *slicer, 568 struct GNUNET_PSYC_Slicer *slicer,
810 GNUNET_SOCIAL_HostEnterCallback enter_cb, 569 GNUNET_SOCIAL_HostEnterCallback enter_cb,
811 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, 570 GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
812 GNUNET_SOCIAL_FarewellCallback farewell_cb, 571 GNUNET_SOCIAL_FarewellCallback farewell_cb,
@@ -862,7 +621,7 @@ GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
862void 621void
863GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host, 622GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
864 const struct GNUNET_SOCIAL_Nym *nym, 623 const struct GNUNET_SOCIAL_Nym *nym,
865 struct GNUNET_ENV_Environment *env); 624 struct GNUNET_PSYC_Environment *env);
866 625
867 626
868/** 627/**
@@ -915,7 +674,7 @@ struct GNUNET_SOCIAL_Announcement;
915struct GNUNET_SOCIAL_Announcement * 674struct GNUNET_SOCIAL_Announcement *
916GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, 675GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
917 const char *method_name, 676 const char *method_name,
918 const struct GNUNET_ENV_Environment *env, 677 const struct GNUNET_PSYC_Environment *env,
919 GNUNET_PSYC_TransmitNotifyData notify_data, 678 GNUNET_PSYC_TransmitNotifyData notify_data,
920 void *notify_data_cls, 679 void *notify_data_cls,
921 enum GNUNET_SOCIAL_AnnounceFlags flags); 680 enum GNUNET_SOCIAL_AnnounceFlags flags);
@@ -1032,7 +791,7 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
1032 */ 791 */
1033void 792void
1034GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, 793GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
1035 const struct GNUNET_ENV_Environment *env, 794 const struct GNUNET_PSYC_Environment *env,
1036 GNUNET_ContinuationCallback disconnect_cb, 795 GNUNET_ContinuationCallback disconnect_cb,
1037 void *cls); 796 void *cls);
1038 797
@@ -1062,22 +821,12 @@ typedef void
1062 * Function called upon a guest receives a decision about entry to the place. 821 * Function called upon a guest receives a decision about entry to the place.
1063 * 822 *
1064 * @param is_admitted 823 * @param is_admitted
1065 * Is the guest admitted to the place? 824 * Is the guest admitted to the place?
1066 * #GNUNET_YES if admitted, 825 * #GNUNET_YES if admitted,
1067 * #GNUNET_NO if refused entry 826 * #GNUNET_NO if refused entry,
1068 * #GNUNET_SYSERR if the request could not be answered. 827 * #GNUNET_SYSERR if the request could not be answered.
1069 * @param method_name
1070 * Method for the message sent along with the decision.
1071 * NULL if no message was sent.
1072 * @param env
1073 * Environment with variables for the message.
1074 * NULL if there are no variables.
1075 * It has to be freed using GNUNET_ENV_environment_destroy()
1076 * when it is not needed anymore.
1077 * @param data_size
1078 * Size of @data.
1079 * @param data 828 * @param data
1080 * Payload of the message. 829 * Entry response message.
1081 */ 830 */
1082typedef void 831typedef void
1083(*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, 832(*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
@@ -1124,7 +873,7 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
1124 uint32_t relay_count, 873 uint32_t relay_count,
1125 const struct GNUNET_PeerIdentity *relays, 874 const struct GNUNET_PeerIdentity *relays,
1126 const struct GNUNET_PSYC_Message *entry_msg, 875 const struct GNUNET_PSYC_Message *entry_msg,
1127 struct GNUNET_SOCIAL_Slicer *slicer, 876 struct GNUNET_PSYC_Slicer *slicer,
1128 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 877 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
1129 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb, 878 GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
1130 void *cls); 879 void *cls);
@@ -1162,7 +911,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
1162 const char *gns_name, 911 const char *gns_name,
1163 const char *password, 912 const char *password,
1164 const struct GNUNET_PSYC_Message *join_msg, 913 const struct GNUNET_PSYC_Message *join_msg,
1165 struct GNUNET_SOCIAL_Slicer *slicer, 914 struct GNUNET_PSYC_Slicer *slicer,
1166 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 915 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
1167 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, 916 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
1168 void *cls); 917 void *cls);
@@ -1188,7 +937,7 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
1188struct GNUNET_SOCIAL_Guest * 937struct GNUNET_SOCIAL_Guest *
1189GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, 938GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
1190 enum GNUNET_PSYC_SlaveJoinFlags flags, 939 enum GNUNET_PSYC_SlaveJoinFlags flags,
1191 struct GNUNET_SOCIAL_Slicer *slicer, 940 struct GNUNET_PSYC_Slicer *slicer,
1192 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 941 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
1193 void *cls); 942 void *cls);
1194 943
@@ -1230,7 +979,7 @@ struct GNUNET_SOCIAL_TalkRequest;
1230struct GNUNET_SOCIAL_TalkRequest * 979struct GNUNET_SOCIAL_TalkRequest *
1231GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, 980GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
1232 const char *method_name, 981 const char *method_name,
1233 const struct GNUNET_ENV_Environment *env, 982 const struct GNUNET_PSYC_Environment *env,
1234 GNUNET_PSYC_TransmitNotifyData notify_data, 983 GNUNET_PSYC_TransmitNotifyData notify_data,
1235 void *notify_data_cls, 984 void *notify_data_cls,
1236 enum GNUNET_SOCIAL_TalkFlags flags); 985 enum GNUNET_SOCIAL_TalkFlags flags);
@@ -1289,7 +1038,7 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
1289 */ 1038 */
1290void 1039void
1291GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, 1040GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
1292 struct GNUNET_ENV_Environment *env, 1041 struct GNUNET_PSYC_Environment *env,
1293 GNUNET_ContinuationCallback disconnect_cb, 1042 GNUNET_ContinuationCallback disconnect_cb,
1294 void *leave_cls); 1043 void *leave_cls);
1295 1044
@@ -1343,7 +1092,7 @@ GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
1343 uint64_t end_message_id, 1092 uint64_t end_message_id,
1344 const char *method_prefix, 1093 const char *method_prefix,
1345 uint32_t flags, 1094 uint32_t flags,
1346 struct GNUNET_SOCIAL_Slicer *slicer, 1095 struct GNUNET_PSYC_Slicer *slicer,
1347 GNUNET_ResultCallback result_cb, 1096 GNUNET_ResultCallback result_cb,
1348 void *cls); 1097 void *cls);
1349 1098
@@ -1371,7 +1120,7 @@ GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
1371 uint64_t message_limit, 1120 uint64_t message_limit,
1372 const char *method_prefix, 1121 const char *method_prefix,
1373 uint32_t flags, 1122 uint32_t flags,
1374 struct GNUNET_SOCIAL_Slicer *slicer, 1123 struct GNUNET_PSYC_Slicer *slicer,
1375 GNUNET_ResultCallback result_cb, 1124 GNUNET_ResultCallback result_cb,
1376 void *cls); 1125 void *cls);
1377 1126
@@ -1524,4 +1273,4 @@ GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
1524/* ifndef GNUNET_SOCIAL_SERVICE_H */ 1273/* ifndef GNUNET_SOCIAL_SERVICE_H */
1525#endif 1274#endif
1526 1275
1527/** @} */ /* end of group social */ 1276/** @} */ /* end of group */