aboutsummaryrefslogtreecommitdiff
path: root/src/social
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-05-12 01:50:28 +0000
committerGabor X Toth <*@tg-x.net>2016-05-12 01:50:28 +0000
commit235521e7893c3f6be82103700f5056a4df285afa (patch)
treeb5a9137bee42539cfc2d2709f5179de7489a8701 /src/social
parent9ced7c72a9acfe9c99b4d2f07bb81e11a1a23707 (diff)
downloadgnunet-235521e7893c3f6be82103700f5056a4df285afa.tar.gz
gnunet-235521e7893c3f6be82103700f5056a4df285afa.zip
social cli docs
Diffstat (limited to 'src/social')
-rw-r--r--src/social/gnunet-social.c156
1 files changed, 146 insertions, 10 deletions
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c
index 9e69208b5..bb6f1e694 100644
--- a/src/social/gnunet-social.c
+++ b/src/social/gnunet-social.c
@@ -157,6 +157,9 @@ struct GNUNET_SOCIAL_Place *plc;
157/* DISCONNECT */ 157/* DISCONNECT */
158 158
159 159
160/**
161 * Callback called after the host or guest place disconnected.
162 */
160static void 163static void
161disconnected (void *cls) 164disconnected (void *cls)
162{ 165{
@@ -164,6 +167,9 @@ disconnected (void *cls)
164} 167}
165 168
166 169
170/**
171 * Callback called after the application disconnected.
172 */
167static void 173static void
168app_disconnected (void *cls) 174app_disconnected (void *cls)
169{ 175{
@@ -185,6 +191,9 @@ app_disconnected (void *cls)
185} 191}
186 192
187 193
194/**
195 * Disconnect from connected GNUnet services.
196 */
188static void 197static void
189disconnect () 198disconnect ()
190{ 199{
@@ -193,9 +202,7 @@ disconnect ()
193} 202}
194 203
195/** 204/**
196 * Terminate the test case (failure). 205 * Callback called when the program failed to finish the requested operation in time.
197 *
198 * @param cls NULL
199 */ 206 */
200static void 207static void
201timeout (void *cls) 208timeout (void *cls)
@@ -219,6 +226,9 @@ schedule_fail (void *cls)
219} 226}
220 227
221 228
229/**
230 * Schedule exit with succes result.
231 */
222static void 232static void
223exit_success () 233exit_success ()
224{ 234{
@@ -231,6 +241,9 @@ exit_success ()
231} 241}
232 242
233 243
244/**
245 * Schedule exit with failure result.
246 */
234static void 247static void
235exit_fail () 248exit_fail ()
236{ 249{
@@ -246,6 +259,11 @@ exit_fail ()
246/* LEAVE */ 259/* LEAVE */
247 260
248 261
262/**
263 * Callback notifying about the host has left and stopped hosting the place.
264 *
265 * This also indicates the end of the connection to the service.
266 */
249static void 267static void
250host_left () 268host_left ()
251{ 269{
@@ -255,6 +273,9 @@ host_left ()
255} 273}
256 274
257 275
276/**
277 * Leave a place permanently and stop hosting a place.
278 */
258static void 279static void
259host_leave () 280host_leave ()
260{ 281{
@@ -264,6 +285,11 @@ host_leave ()
264} 285}
265 286
266 287
288/**
289 * Callback notifying about the guest has left the place.
290 *
291 * This also indicates the end of the connection to the service.
292 */
267static void 293static void
268guest_left (void *cls) 294guest_left (void *cls)
269{ 295{
@@ -272,13 +298,15 @@ guest_left (void *cls)
272} 298}
273 299
274 300
301/**
302 * Leave a place permanently as guest.
303 */
275static void 304static void
276guest_leave () 305guest_leave ()
277{ 306{
278 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); 307 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
279 // method in the middle of vars? FIXME
280 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET, 308 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
281 "_notice_place_leave", DATA2ARG ("Leaving.")); 309 "_message", DATA2ARG ("Leaving."));
282 GNUNET_SOCIAL_guest_leave (gst, env, guest_left, NULL); 310 GNUNET_SOCIAL_guest_leave (gst, env, guest_left, NULL);
283 GNUNET_PSYC_env_destroy (env); 311 GNUNET_PSYC_env_destroy (env);
284 gst = NULL; 312 gst = NULL;
@@ -296,6 +324,10 @@ struct TransmitClosure
296} tmit; 324} tmit;
297 325
298 326
327/**
328 * Callback notifying about available buffer space to write message data
329 * when transmitting messages using host_announce() or guest_talk()
330 */
299static int 331static int
300notify_data (void *cls, uint16_t *data_size, void *data) 332notify_data (void *cls, uint16_t *data_size, void *data)
301{ 333{
@@ -326,6 +358,9 @@ notify_data (void *cls, uint16_t *data_size, void *data)
326} 358}
327 359
328 360
361/**
362 * Host announcement - send a message to the place.
363 */
329static void 364static void
330host_announce (const char *method, const char *data, size_t data_size) 365host_announce (const char *method, const char *data, size_t data_size)
331{ 366{
@@ -342,6 +377,10 @@ host_announce (const char *method, const char *data, size_t data_size)
342 GNUNET_SOCIAL_ANNOUNCE_NONE); 377 GNUNET_SOCIAL_ANNOUNCE_NONE);
343} 378}
344 379
380
381/**
382 * Assign a state var of @a name to the value of @a data.
383 */
345static void 384static void
346host_assign (const char *name, const char *data, size_t data_size) 385host_assign (const char *name, const char *data, size_t data_size)
347{ 386{
@@ -356,6 +395,9 @@ host_assign (const char *name, const char *data, size_t data_size)
356} 395}
357 396
358 397
398/**
399 * Guest talk request to host.
400 */
359static void 401static void
360guest_talk (const char *method, 402guest_talk (const char *method,
361 const char *data, size_t data_size) 403 const char *data, size_t data_size)
@@ -377,6 +419,9 @@ guest_talk (const char *method,
377/* HISTORY REPLAY */ 419/* HISTORY REPLAY */
378 420
379 421
422/**
423 * Callback notifying about the end of history replay results.
424 */
380static void 425static void
381recv_history_replay_result (void *cls, int64_t result, 426recv_history_replay_result (void *cls, int64_t result,
382 const void *data, uint16_t data_size) 427 const void *data, uint16_t data_size)
@@ -393,6 +438,10 @@ recv_history_replay_result (void *cls, int64_t result,
393} 438}
394 439
395 440
441/**
442 * Replay history between a given @a start and @a end message IDs,
443 * optionally filtered by a method @a prefix.
444 */
396static void 445static void
397history_replay (uint64_t start, uint64_t end, const char *prefix) 446history_replay (uint64_t start, uint64_t end, const char *prefix)
398{ 447{
@@ -404,6 +453,9 @@ history_replay (uint64_t start, uint64_t end, const char *prefix)
404} 453}
405 454
406 455
456/**
457 * Replay latest @a limit messages.
458 */
407static void 459static void
408history_replay_latest (uint64_t limit, const char *prefix) 460history_replay_latest (uint64_t limit, const char *prefix)
409{ 461{
@@ -418,6 +470,9 @@ history_replay_latest (uint64_t limit, const char *prefix)
418/* LOOK AT/FOR */ 470/* LOOK AT/FOR */
419 471
420 472
473/**
474 * Callback notifying about the end of state var results.
475 */
421static void 476static void
422look_result (void *cls, int64_t result_code, 477look_result (void *cls, int64_t result_code,
423 const void *data, uint16_t data_size) 478 const void *data, uint16_t data_size)
@@ -432,6 +487,9 @@ look_result (void *cls, int64_t result_code,
432} 487}
433 488
434 489
490/**
491 * Callback notifying about a state var result.
492 */
435static void 493static void
436look_var (void *cls, 494look_var (void *cls,
437 const struct GNUNET_MessageHeader *mod, 495 const struct GNUNET_MessageHeader *mod,
@@ -441,28 +499,37 @@ look_var (void *cls,
441 uint32_t full_value_size) 499 uint32_t full_value_size)
442{ 500{
443 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 501 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
444 "look_at_var: %s\n%.*s\n", 502 "Received var: %s\n%.*s\n",
445 name, value_size, (const char *) value); 503 name, value_size, (const char *) value);
446} 504}
447 505
448 506
507/**
508 * Look for a state var using exact match of the name.
509 */
449static void 510static void
450look_at (const char *name) 511look_at (const char *full_name)
451{ 512{
452 GNUNET_SOCIAL_place_look_at (plc, name, look_var, look_result, NULL); 513 GNUNET_SOCIAL_place_look_at (plc, full_name, look_var, look_result, NULL);
453} 514}
454 515
455 516
517/**
518 * Look for state vars by name prefix.
519 */
456static void 520static void
457look_for (const char *name) 521look_for (const char *name_prefix)
458{ 522{
459 GNUNET_SOCIAL_place_look_for (plc, name, look_var, look_result, NULL); 523 GNUNET_SOCIAL_place_look_for (plc, name_prefix, look_var, look_result, NULL);
460} 524}
461 525
462 526
463/* SLICER */ 527/* SLICER */
464 528
465 529
530/**
531 * Callback notifying about the start of a new incoming message.
532 */
466static void 533static void
467slicer_recv_method (void *cls, 534slicer_recv_method (void *cls,
468 const struct GNUNET_PSYC_MessageHeader *msg, 535 const struct GNUNET_PSYC_MessageHeader *msg,
@@ -477,6 +544,9 @@ slicer_recv_method (void *cls,
477} 544}
478 545
479 546
547/**
548 * Callback notifying about an incoming modifier.
549 */
480static void 550static void
481slicer_recv_modifier (void *cls, 551slicer_recv_modifier (void *cls,
482 const struct GNUNET_PSYC_MessageHeader *msg, 552 const struct GNUNET_PSYC_MessageHeader *msg,
@@ -495,6 +565,9 @@ slicer_recv_modifier (void *cls,
495} 565}
496 566
497 567
568/**
569 * Callback notifying about an incoming data fragment.
570 */
498static void 571static void
499slicer_recv_data (void *cls, 572slicer_recv_data (void *cls,
500 const struct GNUNET_PSYC_MessageHeader *msg, 573 const struct GNUNET_PSYC_MessageHeader *msg,
@@ -510,6 +583,9 @@ slicer_recv_data (void *cls,
510} 583}
511 584
512 585
586/**
587 * Callback notifying about the end of a message.
588 */
513static void 589static void
514slicer_recv_eom (void *cls, 590slicer_recv_eom (void *cls,
515 const struct GNUNET_PSYC_MessageHeader *msg, 591 const struct GNUNET_PSYC_MessageHeader *msg,
@@ -524,6 +600,9 @@ slicer_recv_eom (void *cls,
524} 600}
525 601
526 602
603/**
604 * Create a slicer for receiving message parts.
605 */
527static struct GNUNET_PSYC_Slicer * 606static struct GNUNET_PSYC_Slicer *
528slicer_create () 607slicer_create ()
529{ 608{
@@ -540,6 +619,12 @@ slicer_create ()
540/* GUEST ENTER */ 619/* GUEST ENTER */
541 620
542 621
622/**
623 * Callback called when the guest receives an entry decision from the host.
624 *
625 * It is called once after using guest_enter() or guest_enter_by_name(),
626 * in case of a reconnection only the local enter callback is called.
627 */
543static void 628static void
544guest_recv_entry_decision (void *cls, 629guest_recv_entry_decision (void *cls,
545 int is_admitted, 630 int is_admitted,
@@ -572,6 +657,9 @@ guest_recv_entry_decision (void *cls,
572} 657}
573 658
574 659
660/**
661 * Callback called after a guest connection is established to the local service.
662 */
575static void 663static void
576guest_recv_local_enter (void *cls, int result, 664guest_recv_local_enter (void *cls, int result,
577 const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key, 665 const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
@@ -590,6 +678,9 @@ guest_recv_local_enter (void *cls, int result,
590} 678}
591 679
592 680
681/**
682 * Create entry requset message.
683 */
593static struct GNUNET_PSYC_Message * 684static struct GNUNET_PSYC_Message *
594guest_enter_msg_create () 685guest_enter_msg_create ()
595{ 686{
@@ -604,6 +695,9 @@ guest_enter_msg_create ()
604} 695}
605 696
606 697
698/**
699 * Enter a place as guest, using its public key and peer ID.
700 */
607static void 701static void
608guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key, 702guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
609 const struct GNUNET_PeerIdentity *peer) 703 const struct GNUNET_PeerIdentity *peer)
@@ -628,6 +722,9 @@ guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
628} 722}
629 723
630 724
725/**
726 * Enter a place as guest using its GNS address.
727 */
631static void 728static void
632guest_enter_by_name (const char *gns_name) 729guest_enter_by_name (const char *gns_name)
633{ 730{
@@ -645,6 +742,11 @@ guest_enter_by_name (const char *gns_name)
645/* HOST ENTER */ 742/* HOST ENTER */
646 743
647 744
745/**
746 * Callback called when a @a nym wants to enter the place.
747 *
748 * The request needs to be replied with an entry decision.
749 */
648static void 750static void
649host_answer_door (void *cls, 751host_answer_door (void *cls,
650 struct GNUNET_SOCIAL_Nym *nym, 752 struct GNUNET_SOCIAL_Nym *nym,
@@ -683,6 +785,9 @@ host_answer_door (void *cls,
683} 785}
684 786
685 787
788/**
789 * Callback called when a @a nym has left the place.
790 */
686static void 791static void
687host_farewell (void *cls, 792host_farewell (void *cls,
688 const struct GNUNET_SOCIAL_Nym *nym, 793 const struct GNUNET_SOCIAL_Nym *nym,
@@ -699,6 +804,9 @@ host_farewell (void *cls,
699} 804}
700 805
701 806
807/**
808 * Callback called after the host entered the place.
809 */
702static void 810static void
703host_entered (void *cls, int result, 811host_entered (void *cls, int result,
704 const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key, 812 const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
@@ -717,6 +825,9 @@ host_entered (void *cls, int result,
717} 825}
718 826
719 827
828/**
829 * Enter and start hosting a place.
830 */
720static void 831static void
721host_enter () 832host_enter ()
722{ 833{
@@ -740,6 +851,9 @@ host_enter ()
740/* PLACE RECONNECT */ 851/* PLACE RECONNECT */
741 852
742 853
854/**
855 * Perform operations common to both host & guest places.
856 */
743static void 857static void
744place_reconnected () 858place_reconnected ()
745{ 859{
@@ -763,6 +877,9 @@ place_reconnected ()
763} 877}
764 878
765 879
880/**
881 * Callback called after reconnecting to a host place.
882 */
766static void 883static void
767host_reconnected (void *cls, int result, 884host_reconnected (void *cls, int result,
768 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, 885 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
@@ -786,6 +903,9 @@ host_reconnected (void *cls, int result,
786} 903}
787 904
788 905
906/**
907 * Callback called after reconnecting to a guest place.
908 */
789static void 909static void
790guest_reconnected (void *cls, int result, 910guest_reconnected (void *cls, int result,
791 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, 911 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
@@ -809,6 +929,9 @@ guest_reconnected (void *cls, int result,
809/* APP */ 929/* APP */
810 930
811 931
932/**
933 * Callback called after the ego and place callbacks.
934 */
812static void 935static void
813app_connected (void *cls) 936app_connected (void *cls)
814{ 937{
@@ -853,6 +976,9 @@ app_connected (void *cls)
853} 976}
854 977
855 978
979/**
980 * Callback notifying about a host place available for reconnection.
981 */
856static void 982static void
857app_recv_host (void *cls, 983app_recv_host (void *cls,
858 struct GNUNET_SOCIAL_HostConnection *hconn, 984 struct GNUNET_SOCIAL_HostConnection *hconn,
@@ -877,6 +1003,9 @@ app_recv_host (void *cls,
877} 1003}
878 1004
879 1005
1006/**
1007 * Callback notifying about a guest place available for reconnection.
1008 */
880static void 1009static void
881app_recv_guest (void *cls, 1010app_recv_guest (void *cls,
882 struct GNUNET_SOCIAL_GuestConnection *gconn, 1011 struct GNUNET_SOCIAL_GuestConnection *gconn,
@@ -901,6 +1030,9 @@ app_recv_guest (void *cls,
901} 1030}
902 1031
903 1032
1033/**
1034 * Callback notifying about an available ego.
1035 */
904static void 1036static void
905app_recv_ego (void *cls, 1037app_recv_ego (void *cls,
906 struct GNUNET_SOCIAL_Ego *e, 1038 struct GNUNET_SOCIAL_Ego *e,
@@ -920,6 +1052,10 @@ app_recv_ego (void *cls,
920} 1052}
921 1053
922 1054
1055
1056/**
1057 * Establish application connection to receive available egos and places.
1058 */
923static void 1059static void
924app_connect () 1060app_connect ()
925{ 1061{