aboutsummaryrefslogtreecommitdiff
path: root/src/social/gnunet-social.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-05-05 11:33:48 +0000
committerGabor X Toth <*@tg-x.net>2016-05-05 11:33:48 +0000
commitc30990ca48dcb9fe8ddc523b0dc3e610483f2bb5 (patch)
tree1497921389864d048f8961ea2e4c997fc6d1bd46 /src/social/gnunet-social.c
parent78edac9543fa364868e9570080b46a153ec5fad4 (diff)
downloadgnunet-c30990ca48dcb9fe8ddc523b0dc3e610483f2bb5.tar.gz
gnunet-c30990ca48dcb9fe8ddc523b0dc3e610483f2bb5.zip
social cli
Diffstat (limited to 'src/social/gnunet-social.c')
-rw-r--r--src/social/gnunet-social.c760
1 files changed, 638 insertions, 122 deletions
diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c
index 51896af12..e0b5273ac 100644
--- a/src/social/gnunet-social.c
+++ b/src/social/gnunet-social.c
@@ -30,8 +30,7 @@
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_social_service.h" 31#include "gnunet_social_service.h"
32 32
33/** shell return code */ 33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
34static int ret = 0;
35 34
36/* operations corresponding to API calls */ 35/* operations corresponding to API calls */
37 36
@@ -59,98 +58,604 @@ static char *op_history_replay;
59/** --history-replay-latest */ 58/** --history-replay-latest */
60static char *op_history_replay_latest; 59static char *op_history_replay_latest;
61 60
62// FIXME: look-at and look-for 61/** --look-at */
62static int op_look_at;
63
64/** --look-for */
65static int op_look_for;
66
63 67
64/* options */ 68/* options */
65 69
70/** --app */
71static char *opt_app = "cli";
72
66/** --place */ 73/** --place */
67static char *place; 74static char *opt_place;
75
76/** --ego */
77static char *opt_ego;
68 78
69/** --listen */ 79/** --follow */
70static int flag_listen; 80static int opt_follow;
71 81
72/** --method */ 82/** --method */
73static char *method; 83static char *opt_method;
74 84
75/** --data */ 85/** --data */
76static char *data; // should come from stdin instead, FIXME 86// FIXME: could also come from STDIN
87static char *opt_data;
77 88
78/** --prefix */ 89/** --name */
79static char *prefix; 90static char *opt_name;
80 91
81/** --start */ 92/** --start */
82static uint64_t start; 93static uint64_t opt_start;
83 94
84/** --end */ 95/** --end */
85static uint64_t end; 96static uint64_t opt_end;
86 97
87/** --limit */ 98/** --limit */
88static int limit; 99static int opt_limit;
100
101
102/* global vars */
103
104/** exit code */
105static int ret = 1;
106
107/** Task handle for timeout termination. */
108struct GNUNET_SCHEDULER_Task *timeout_task;
109
110const struct GNUNET_CONFIGURATION_Handle *cfg;
111
112struct GNUNET_CORE_Handle *core;
113struct GNUNET_PeerIdentity peer;
114
115struct GNUNET_SOCIAL_App *app;
116
117/** public key of connected place */
118struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
119
120/** hash of @a place_pub_key */
121struct GNUNET_HashCode place_pub_hash;
122
123struct GNUNET_PSYC_Slicer *slicer;
124
125struct GNUNET_SOCIAL_Ego *ego;
126struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
127
128struct GNUNET_SOCIAL_Host *hst;
129struct GNUNET_SOCIAL_Guest *gst;
130struct GNUNET_SOCIAL_Place *plc;
131
132
133static void
134cleanup ()
135{
136
137}
89 138
90 139
91/** 140/**
92 * Main function that will be run by the scheduler. 141 * Terminate the test case (failure).
93 * 142 *
94 * @param cls closure 143 * @param cls NULL
95 * @param args remaining command-line arguments
96 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
97 * @param cfg configuration
98 */ 144 */
99static void 145static void
100run (void *cls, char *const *args, const char *cfgfile, 146timeout (void *cls)
101 const struct GNUNET_CONFIGURATION_Handle *cfg)
102{ 147{
103 if (op_host_enter) { 148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n");
104 FPRINTF (stderr, 149 cleanup ();
105 _("FIXME -C\n")); 150}
106 if (flag_listen) { 151
107 FPRINTF (stderr, 152
108 _("Yes, yes!\n")); 153static void
109 } 154host_leave (struct GNUNET_SOCIAL_Host *host)
110 return; 155{
156
157}
158
159
160static void
161host_announce (struct GNUNET_SOCIAL_Host *host,
162 const char *method,
163 const char *data)
164{
165
166}
167
168
169static void
170guest_leave (struct GNUNET_SOCIAL_Guest *guest)
171{
172
173}
174
175
176static void
177guest_talk (struct GNUNET_SOCIAL_Guest *guest,
178 const char *method,
179 const char *data)
180{
181
182}
183
184
185static void
186history_replay (struct GNUNET_SOCIAL_Place *place,
187 uint64_t start, uint64_t end, const char *prefix)
188{
189
190}
191
192
193static void
194history_replay_latest (struct GNUNET_SOCIAL_Place *place,
195 uint64_t limit, const char *prefix)
196{
197
198}
199
200
201static void
202look_at (struct GNUNET_SOCIAL_Place *place,
203 const char *name)
204{
205
206}
207
208
209static void
210look_for (struct GNUNET_SOCIAL_Place *place,
211 const char *name)
212{
213
214}
215
216/* SLICER + CALLBACKS */
217
218
219static void
220slicer_recv_method (void *cls,
221 const struct GNUNET_PSYC_MessageHeader *msg,
222 const struct GNUNET_PSYC_MessageMethod *meth,
223 uint64_t message_id,
224 const char *method_name)
225{
226 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
227 "Received method for message ID %" PRIu64 ":\n"
228 "%s (flags: %x)\n",
229 message_id, method_name, ntohl (meth->flags));
230}
231
232
233static void
234slicer_recv_modifier (void *cls,
235 const struct GNUNET_PSYC_MessageHeader *msg,
236 const struct GNUNET_MessageHeader *pmsg,
237 uint64_t message_id,
238 enum GNUNET_PSYC_Operator oper,
239 const char *name,
240 const void *value,
241 uint16_t value_size,
242 uint16_t full_value_size)
243{
244 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
245 "Received modifier for message ID %" PRIu64 ":\n"
246 "%c%s: %.*s (size: %u)\n",
247 message_id, oper, name, value_size, value, value_size);
248}
249
250
251static void
252slicer_recv_data (void *cls,
253 const struct GNUNET_PSYC_MessageHeader *msg,
254 const struct GNUNET_MessageHeader *pmsg,
255 uint64_t message_id,
256 const void *data,
257 uint16_t data_size)
258{
259 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
260 "Received data for message ID %" PRIu64 ":\n"
261 "%.*s\n",
262 message_id, data_size, data);
263}
264
265
266static void
267slicer_recv_eom (void *cls,
268 const struct GNUNET_PSYC_MessageHeader *msg,
269 const struct GNUNET_MessageHeader *pmsg,
270 uint64_t message_id,
271 uint8_t is_cancelled)
272{
273 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
274 "Received end of message ID %" PRIu64
275 ", cancelled: %u\n",
276 message_id, is_cancelled);
277}
278
279
280static struct GNUNET_PSYC_Slicer *
281slicer_create ()
282{
283 slicer = GNUNET_PSYC_slicer_create ();
284
285 /* register slicer to receive incoming messages with any method name */
286 GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
287 slicer_recv_method, slicer_recv_modifier,
288 slicer_recv_data, slicer_recv_eom, NULL);
289 return slicer;
290}
291
292
293/* GUEST ENTER + CALLBACKS */
294
295
296static void
297guest_recv_entry_decision (void *cls,
298 int is_admitted,
299 const struct GNUNET_PSYC_Message *entry_msg)
300{
301 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
302 "Guest received entry decision %d\n",
303 is_admitted);
304
305 if (NULL != entry_msg)
306 {
307 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
308 const char *method_name = NULL;
309 const void *data = NULL;
310 uint16_t data_size = 0;
311 struct GNUNET_PSYC_MessageHeader *
312 pmsg = GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
313 GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
314 GNUNET_free (pmsg);
315
316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
317 "%s\n%.*s\n",
318 method_name, data_size, data);
319 }
320}
321
322
323static void
324guest_recv_local_enter (void *cls, int result,
325 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
326 uint64_t max_message_id)
327{
328 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
329 "Guest entered to local place: %d, max_message_id: %" PRIu64 "\n",
330 result, max_message_id);
331 GNUNET_assert (0 <= result);
332}
333
334
335static struct GNUNET_PSYC_Message *
336guest_enter_msg_create ()
337{
338 const char *method_name = "_request_enter";
339 struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
340 GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
341 "_foo", "bar", sizeof ("bar"));
342 void *data = "let me in";
343 uint16_t data_size = strlen (data) + 1;
344
345 return GNUNET_PSYC_message_create (method_name, env, data, data_size);
346}
347
348
349static void
350guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
351 struct GNUNET_PeerIdentity *peer)
352{
353 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
354 "Entering to place as guest.\n");
355
356 gst = GNUNET_SOCIAL_guest_enter (app, ego, &place_pub_key,
357 GNUNET_PSYC_SLAVE_JOIN_NONE,
358 peer, 0, NULL, guest_enter_msg_create (),
359 slicer_create (),
360 guest_recv_local_enter,
361 guest_recv_entry_decision, NULL);
362 plc = GNUNET_SOCIAL_guest_get_place (gst);
363}
364
365
366static void
367guest_enter_by_name (const char *gns_name)
368{
369 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
370 "Entering to place by name as guest.\n");
371
372 gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL,
373 guest_enter_msg_create (), slicer,
374 guest_recv_local_enter,
375 guest_recv_entry_decision, NULL);
376 plc = GNUNET_SOCIAL_guest_get_place (gst);
377}
378
379
380
381/* HOST ENTER + CALLBACKS */
382
383
384static void
385host_answer_door (void *cls,
386 struct GNUNET_SOCIAL_Nym *nym,
387 const char *method_name,
388 struct GNUNET_PSYC_Environment *env,
389 const void *data,
390 size_t data_size)
391{
392 const struct GNUNET_CRYPTO_EcdsaPublicKey *
393 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
394 char *
395 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
396
397 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
398 "Entry request: %s\n", nym_str);
399 GNUNET_free (nym_str);
400}
401
402
403static void
404host_farewell (void *cls,
405 const struct GNUNET_SOCIAL_Nym *nym,
406 struct GNUNET_PSYC_Environment *env)
407{
408 const struct GNUNET_CRYPTO_EcdsaPublicKey *
409 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
410 char *
411 nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
412
413 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
414 "Farewell: %s\n", nym_str);
415 GNUNET_free (nym_str);
416}
417
418
419static void
420host_entered (void *cls, int result,
421 const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
422 uint64_t max_message_id)
423{
424 place_pub_key = *pub_key;
425 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
426 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
427 "Entered: %s, max_message_id: %" PRIu64 "\n",
428 GNUNET_h2s_full (&place_pub_hash), max_message_id);
429}
430
431
432static void
433host_enter ()
434{
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "host_enter()\n");
436
437 hst = GNUNET_SOCIAL_host_enter (app, ego,
438 GNUNET_PSYC_CHANNEL_PRIVATE,
439 slicer_create (), host_entered,
440 host_answer_door, host_farewell, NULL);
441 plc = GNUNET_SOCIAL_host_get_place (hst);
442}
443
444
445/* RECONNECT CALLBACKS */
446
447static void
448place_reconnected ()
449{
450 if (op_history_replay) {
451 history_replay (plc, opt_start, opt_end, opt_method);
111 } 452 }
112 if (NULL == place) { 453 else if (op_history_replay_latest) {
113 FPRINTF (stderr, 454 history_replay_latest (plc, opt_limit, opt_method);
114 _("You did not provide me with a place to talk to.\n"));
115 ret = 1;
116 return;
117 } 455 }
118 if (op_guest_enter) { 456 else if (op_look_at) {
119 FPRINTF (stderr, 457 look_at (plc, opt_name);
120 _("FIXME -E\n"));
121 if (flag_listen) {
122 FPRINTF (stderr,
123 _("Yes, yes!\n"));
124 }
125 return;
126 } 458 }
127 if (flag_listen) { 459 else if (op_look_for) {
128 FPRINTF (stderr, 460 look_for (plc, opt_name);
129 _("The --listen flag is not defined for this operation.\n"));
130 ret = 1;
131 return;
132 } 461 }
462}
463
464
465static void
466host_reconnected (void *cls, int result,
467 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
468 uint64_t max_message_id)
469{
470 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
471 "Host reconnected\n");
472
133 if (op_host_leave) { 473 if (op_host_leave) {
134 FPRINTF (stderr, 474 host_leave (hst);
135 _("FIXME HARDER -D\n"));
136 return;
137 } 475 }
476 else if (op_host_announce) {
477 host_announce (hst, opt_method, opt_data);
478 }
479 else {
480 place_reconnected ();
481 }
482}
483
484
485static void
486guest_reconnected (void *cls, int result,
487 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
488 uint64_t max_message_id)
489{
490 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
491 "Guest reconnected\n");
492
138 if (op_guest_leave) { 493 if (op_guest_leave) {
139 FPRINTF (stderr, 494 guest_leave (gst);
140 _("FIXME HARDER -L\n")); 495 }
141 return; 496 else if (op_guest_talk) {
497 guest_talk (gst, opt_method, opt_data);
498 }
499 else {
500 place_reconnected ();
501 }
502}
503
504
505/* APP CALLBACKS */
506
507
508static void
509app_connected (void *cls)
510{
511 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
512 "App connected: %p\n", cls);
513
514 if (op_host_enter) {
515 host_enter ();
516 }
517 else if (op_guest_enter) {
518 guest_enter (&place_pub_key);
519 }
520}
521
522
523static void
524app_recv_host (void *cls,
525 struct GNUNET_SOCIAL_HostConnection *hconn,
526 struct GNUNET_SOCIAL_Ego *ego,
527 const struct GNUNET_CRYPTO_EddsaPublicKey *host_pub_key,
528 enum GNUNET_SOCIAL_AppPlaceState place_state)
529{
530 struct GNUNET_HashCode host_pub_hash;
531 GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash);
532 char *
533 host_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (guest_pub_key);
534
535 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
536 "Host: %s (%s)\n",
537 GNUNET_h2s_full (&host_pub_hash), host_pub_str);
538 GNUNET_free (host_pub_str);
539
540 if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key)))
541 {
542 hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, slicer_create (), host_reconnected,
543 host_answer_door, host_farewell, NULL);
544 plc = GNUNET_SOCIAL_host_get_place (hst);
545 }
546}
547
548
549static void
550app_recv_guest (void *cls,
551 struct GNUNET_SOCIAL_GuestConnection *gconn,
552 struct GNUNET_SOCIAL_Ego *ego,
553 const struct GNUNET_CRYPTO_EddsaPublicKey *guest_pub_key,
554 enum GNUNET_SOCIAL_AppPlaceState place_state)
555{
556 struct GNUNET_HashCode guest_pub_hash;
557 GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash);
558 char *
559 guest_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (guest_pub_key);
560
561 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
562 "Guest: %s (%s)\n",
563 GNUNET_h2s_full (&guest_pub_hash), guest_pub_str);
564 GNUNET_free (guest_pub_str);
565
566 if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key)))
567 {
568 gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, GNUNET_PSYC_SLAVE_JOIN_NONE,
569 slicer_create (), guest_reconnected, NULL);
570 plc = GNUNET_SOCIAL_guest_get_place (gst);
571 }
572}
573
574
575static void
576app_recv_ego (void *cls,
577 struct GNUNET_SOCIAL_Ego *ego,
578 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
579 const char *name)
580{
581 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
582 "Ego: %s\t%s\n",
583 name, GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key));
584}
585
586
587static void
588app_connect ()
589{
590 app = GNUNET_SOCIAL_app_connect (cfg, opt_app,
591 app_recv_ego,
592 app_recv_host,
593 app_recv_guest,
594 app_connected,
595 NULL);
596}
597
598/* CORE CALLBACKS */
599
600
601static void
602core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
603{
604 peer = *my_identity;
605 app_connect ();
606}
607
608
609/**
610 * Main function run by the scheduler.
611 *
612 * @param cls closure
613 * @param args remaining command-line arguments
614 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
615 * @param cfg configuration
616 */
617static void
618run (void *cls, char *const *args, const char *cfgfile,
619 const struct GNUNET_CONFIGURATION_Handle *c)
620{
621 cfg = c;
622
623 if (!opt_follow)
624 {
625 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout, NULL);
142 } 626 }
143 if (op_host_announce) { 627
144 FPRINTF (stderr, 628 if (op_host_enter && NULL != opt_place)
145 _("FIXME -P\n")); 629 {
146 return; 630 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
631 _ ("--place must not be specified when using --host-enter\n"));
632 return;
633 }
634
635 if (!opt_place
636 || GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (opt_place,
637 strlen (opt_place),
638 &place_pub_key))
639 {
640 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
641 _ ("--place missing or invalid.\n"));
642 return;
147 } 643 }
148 if (op_guest_talk) { 644
149 FPRINTF (stderr, 645 if (opt_ego)
150 _("FIXME -T\n")); 646 {
151 return; 647 GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
648 strlen (opt_ego),
649 &ego_pub_key);
152 } 650 }
153 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TODO\n"); 651
652 if (opt_peer)
653 {
654 // FIXME: peer ID from string
655 }
656
657 core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL,
658 NULL, GNUNET_NO, NULL, GNUNET_NO, NULL);
154} 659}
155 660
156 661
@@ -166,69 +671,81 @@ main (int argc, char *const *argv)
166{ 671{
167 int res; 672 int res;
168 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 673 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
169 {'p', "place", "PUBKEY", 674 /* operations */
170 gettext_noop ("public key of place"), 675
171 GNUNET_YES, &GNUNET_GETOPT_set_string, &place}, 676 { 'E', "host-enter", NULL,
677 _ ("create a place for nyms to join"),
678 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter },
679
680 { 'L', "host-leave", NULL,
681 _ ("destroy a place we were hosting"),
682 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave },
683
684 { 'A', "host-announce", NULL,
685 _ ("publish something to a place we are hosting"),
686 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce },
687
688 { 'e', "guest-enter", NULL,
689 _ ("join somebody else's place"),
690 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter },
172 691
173 {'l', "listen", NULL, 692 { 'l', "guest-leave", NULL,
174 gettext_noop ("listen for incoming messages"), 693 _ ("leave somebody else's place"),
175 GNUNET_NO, &GNUNET_GETOPT_set_one, &flag_listen}, 694 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave },
176 695
177 {'m', "method", "METHOD_NAME", 696 { 't', "guest-talk", NULL,
178 gettext_noop ("method name to transmit"), 697 _ ("submit something to somebody's place"),
179 GNUNET_YES, &GNUNET_GETOPT_set_string, &method}, 698 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk },
180 699
181 {'d', "data", "DATA", 700 { 'R', "history-replay", NULL,
182 gettext_noop ("message body to transmit"), 701 _ ("replay history of messages between message IDs --start and --end"),
183 GNUNET_YES, &GNUNET_GETOPT_set_string, &data}, 702 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay },
184 703
185 {'p', "prefix", "METHOD_PREFIX", 704 { 'r', "history-replay-latest", NULL,
186 gettext_noop ("method prefix filter for history replay"), 705 _ ("replay history of latest messages up to the given --limit"),
187 GNUNET_YES, &GNUNET_GETOPT_set_string, &prefix}, 706 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest },
188 707
189 {'s', "start", NULL, 708 /* options */
190 gettext_noop ("start message ID for history replay"),
191 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &start},
192 709
193 {'e', "end", NULL, 710 { 'A', "app", "application ID",
194 gettext_noop ("end message ID for history replay"), 711 _ ("application ID to use when connecting"),
195 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &end}, 712 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_app },
196 713
197 {'n', "limit", NULL, 714 { 'p', "place", "PUBKEY",
198 gettext_noop ("number of messages to replay from history"), 715 _ ("public key of place"),
199 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &limit}, 716 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place },
200 717
201 {'C', "host-enter", NULL, 718 { 'g', "ego", "PUBKEY",
202 gettext_noop ("create a place for nyms to join"), 719 _ ("public key of ego"),
203 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter}, 720 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place },
204 721
205 {'D', "host-leave", NULL, 722 { 'f', "follow", NULL,
206 gettext_noop ("destroy a place we were hosting"), 723 _ ("wait for incoming messages"),
207 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave}, 724 GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow },
208 725
209 {'P', "host-announce", NULL, 726 { 'm', "method", "METHOD_NAME",
210 gettext_noop ("publish something to a place we are hosting"), 727 _ ("method name"),
211 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce}, 728 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_method },
212 729
213 {'E', "guest-enter", NULL, 730 { 'd', "data", "DATA",
214 gettext_noop ("join somebody else's place"), 731 _ ("message body to transmit"),
215 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter}, 732 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_data },
216 733
217 {'L', "guest-leave", NULL, 734 { 'n', "name", "VAR_NAME",
218 gettext_noop ("leave somebody else's place"), 735 _ ("state var name to query"),
219 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave}, 736 GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_name },
220 737
221 {'T', "guest-talk", NULL, 738 { 'a', "start", NULL,
222 gettext_noop ("submit something to somebody's place"), 739 _ ("start message ID for history replay"),
223 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk}, 740 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_start },
224 741
225 {'R', "history-replay", NULL, 742 { 'z', "end", NULL,
226 gettext_noop ("FIXME"), 743 _ ("end message ID for history replay"),
227 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay}, 744 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_end },
228 745
229 {'H', "history-replay-latest", NULL, 746 { 'n', "limit", NULL,
230 gettext_noop ("FIXME"), 747 _ ("number of messages to replay from history"),
231 GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest}, 748 GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_limit },
232 749
233 GNUNET_GETOPT_OPTION_END 750 GNUNET_GETOPT_OPTION_END
234 }; 751 };
@@ -237,25 +754,24 @@ main (int argc, char *const *argv)
237 return 2; 754 return 2;
238 755
239 const char *help = 756 const char *help =
240 "enter/leave and send/receive messages in places of the social service"; 757 _ ("interact with the social service: enter/leave, send/receive messages, access history and state")m;
241 const char *usage = 758 const char *usage =
242 "gnunet-social --host-enter [--listen]\n" 759 "gnunet-social --host-enter --ego <name or pubkey> [--listen]\n"
243 "gnunet-social --place <pubkey> --host-leave\n" 760 "gnunet-social --host-leave --place <pubkey>\n"
244 "gnunet-social --place <pubkey> --host-announce --method <method_name> --data <message_body>\n" 761 "gnunet-social --host-announce --place <pubkey> --method <method_name> --data <message body>\n"
245 "\n" 762 "\n"
246 "gnunet-social --place <pubkey> --guest-enter [--listen]\n" 763 "gnunet-social --guest-enter --place <pubkey> --ego <name or pubkey> [--listen]\n"
247 "gnunet-social --place <pubkey> --guest-leave\n" 764 "gnunet-social --guest-leave --place <pubkey>\n"
248 "gnunet-social --place <pubkey> --guest-talk --method <method_nmae> --data <data>\n" 765 "gnunet-social --guest-talk --place <pubkey> --method <method_nmae> --data <data>\n"
249 "\n" 766 "\n"
250 "gnunet-social --place <pubkey> --history-replay --start <msgid> --end <msgid> [--prefix <method_prefix>]\n" 767 "gnunet-social --history-replay --place <pubkey> --start <msgid> --end <msgid> [--method <method_prefix>]\n"
251 "gnunet-social --place <pubkey> --history-replay-latest --limit <msg_limit> [--prefix <method_prefix>]\n" 768 "gnunet-social --history-replay-latest --place <pubkey> --limit <msg_limit> [--method <method_prefix>]\n"
252 "\n" 769 "\n"
253 "gnunet-social --place <pubkey> --look-at <full_name>\n" 770 "gnunet-social --look-at --place <pubkey> --name <full_name>\n"
254 "gnunet-social --place <pubkey> --look-for <name_prefix>\n"; 771 "gnunet-social --look-for --place <pubkey> --name <name_prefix>\n";
255 772
256 res = GNUNET_PROGRAM_run (argc, argv, usage, 773 res = GNUNET_PROGRAM_run (argc, argv, usage,
257 gettext_noop (help), 774 help, options, &run, NULL);
258 options, &run, NULL);
259 775
260 GNUNET_free ((void *) argv); 776 GNUNET_free ((void *) argv);
261 777