gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37131 - gnunet/src/social


From: gnunet
Subject: [GNUnet-SVN] r37131 - gnunet/src/social
Date: Thu, 5 May 2016 13:33:48 +0200

Author: tg
Date: 2016-05-05 13:33:48 +0200 (Thu, 05 May 2016)
New Revision: 37131

Modified:
   gnunet/src/social/gnunet-social.c
Log:
social cli

Modified: gnunet/src/social/gnunet-social.c
===================================================================
--- gnunet/src/social/gnunet-social.c   2016-05-05 11:33:40 UTC (rev 37130)
+++ gnunet/src/social/gnunet-social.c   2016-05-05 11:33:48 UTC (rev 37131)
@@ -30,8 +30,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_social_service.h"
 
-/** shell return code */
-static int ret = 0;
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
 /* operations corresponding to API calls */
 
@@ -59,102 +58,608 @@
 /** --history-replay-latest */
 static char *op_history_replay_latest;
 
-// FIXME: look-at and look-for
+/** --look-at */
+static int op_look_at;
 
+/** --look-for */
+static int op_look_for;
+
+
 /* options */
 
+/** --app */
+static char *opt_app = "cli";
+
 /** --place */
-static char *place;
+static char *opt_place;
 
-/** --listen */
-static int flag_listen;
+/** --ego */
+static char *opt_ego;
 
+/** --follow */
+static int opt_follow;
+
 /** --method */
-static char *method;
+static char *opt_method;
 
 /** --data */
-static char *data;     // should come from stdin instead, FIXME
+// FIXME: could also come from STDIN
+static char *opt_data;
 
-/** --prefix */
-static char *prefix;
+/** --name */
+static char *opt_name;
 
 /** --start */
-static uint64_t start;
+static uint64_t opt_start;
 
 /** --end */
-static uint64_t end;
+static uint64_t opt_end;
 
 /** --limit */
-static int limit;
+static int opt_limit;
 
 
+/* global vars */
+
+/** exit code */
+static int ret = 1;
+
+/** Task handle for timeout termination. */
+struct GNUNET_SCHEDULER_Task *timeout_task;
+
+const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+struct GNUNET_CORE_Handle *core;
+struct GNUNET_PeerIdentity peer;
+
+struct GNUNET_SOCIAL_App *app;
+
+/** public key of connected place */
+struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
+
+/** hash of @a place_pub_key */
+struct GNUNET_HashCode place_pub_hash;
+
+struct GNUNET_PSYC_Slicer *slicer;
+
+struct GNUNET_SOCIAL_Ego *ego;
+struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key;
+
+struct GNUNET_SOCIAL_Host *hst;
+struct GNUNET_SOCIAL_Guest *gst;
+struct GNUNET_SOCIAL_Place *plc;
+
+
+static void
+cleanup ()
+{
+
+}
+
+
 /**
- * Main function that will be run by the scheduler.
+ * Terminate the test case (failure).
  *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
- * @param cfg configuration
+ * @param cls NULL
  */
 static void
-run (void *cls, char *const *args, const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
+timeout (void *cls)
 {
-  if (op_host_enter) {
-     FPRINTF (stderr,
-               _("FIXME -C\n"));
-     if (flag_listen) {
-        FPRINTF (stderr,
-               _("Yes, yes!\n"));
-     }
-     return;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n");
+  cleanup ();
+}
+
+
+static void
+host_leave (struct GNUNET_SOCIAL_Host *host)
+{
+
+}
+
+
+static void
+host_announce (struct GNUNET_SOCIAL_Host *host,
+               const char *method,
+               const char *data)
+{
+
+}
+
+
+static void
+guest_leave (struct GNUNET_SOCIAL_Guest *guest)
+{
+
+}
+
+
+static void
+guest_talk (struct GNUNET_SOCIAL_Guest *guest,
+            const char *method,
+            const char *data)
+{
+
+}
+
+
+static void
+history_replay (struct GNUNET_SOCIAL_Place *place,
+                uint64_t start, uint64_t end, const char *prefix)
+{
+
+}
+
+
+static void
+history_replay_latest (struct GNUNET_SOCIAL_Place *place,
+                       uint64_t limit, const char *prefix)
+{
+
+}
+
+
+static void
+look_at (struct GNUNET_SOCIAL_Place *place,
+         const char *name)
+{
+
+}
+
+
+static void
+look_for (struct GNUNET_SOCIAL_Place *place,
+          const char *name)
+{
+
+}
+
+/* SLICER + CALLBACKS */
+
+
+static void
+slicer_recv_method (void *cls,
+                    const struct GNUNET_PSYC_MessageHeader *msg,
+                    const struct GNUNET_PSYC_MessageMethod *meth,
+                    uint64_t message_id,
+                    const char *method_name)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Received method for message ID %" PRIu64 ":\n"
+              "%s (flags: %x)\n",
+              message_id, method_name, ntohl (meth->flags));
+}
+
+
+static void
+slicer_recv_modifier (void *cls,
+                      const struct GNUNET_PSYC_MessageHeader *msg,
+                      const struct GNUNET_MessageHeader *pmsg,
+                      uint64_t message_id,
+                      enum GNUNET_PSYC_Operator oper,
+                      const char *name,
+                      const void *value,
+                      uint16_t value_size,
+                      uint16_t full_value_size)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Received modifier for message ID %" PRIu64 ":\n"
+              "%c%s: %.*s (size: %u)\n",
+              message_id, oper, name, value_size, value, value_size);
+}
+
+
+static void
+slicer_recv_data (void *cls,
+                  const struct GNUNET_PSYC_MessageHeader *msg,
+                  const struct GNUNET_MessageHeader *pmsg,
+                  uint64_t message_id,
+                  const void *data,
+                  uint16_t data_size)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Received data for message ID %" PRIu64 ":\n"
+              "%.*s\n",
+              message_id, data_size, data);
+}
+
+
+static void
+slicer_recv_eom (void *cls,
+                const struct GNUNET_PSYC_MessageHeader *msg,
+                const struct GNUNET_MessageHeader *pmsg,
+                uint64_t message_id,
+                uint8_t is_cancelled)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Received end of message ID %" PRIu64
+              ", cancelled: %u\n",
+              message_id, is_cancelled);
+}
+
+
+static struct GNUNET_PSYC_Slicer *
+slicer_create ()
+{
+  slicer = GNUNET_PSYC_slicer_create ();
+
+  /* register slicer to receive incoming messages with any method name */
+  GNUNET_PSYC_slicer_method_add (slicer, "", NULL,
+                                 slicer_recv_method, slicer_recv_modifier,
+                                 slicer_recv_data, slicer_recv_eom, NULL);
+  return slicer;
+}
+
+
+/* GUEST ENTER + CALLBACKS */
+
+
+static void
+guest_recv_entry_decision (void *cls,
+                           int is_admitted,
+                           const struct GNUNET_PSYC_Message *entry_msg)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Guest received entry decision %d\n",
+              is_admitted);
+
+  if (NULL != entry_msg)
+  {
+    struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
+    const char *method_name = NULL;
+    const void *data = NULL;
+    uint16_t data_size = 0;
+    struct GNUNET_PSYC_MessageHeader *
+      pmsg = GNUNET_PSYC_message_header_create_from_psyc (entry_msg);
+    GNUNET_PSYC_message_parse (pmsg, &method_name, env, &data, &data_size);
+    GNUNET_free (pmsg);
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "%s\n%.*s\n",
+                method_name, data_size, data);
   }
-  if (NULL == place) {
-     FPRINTF (stderr,
-               _("You did not provide me with a place to talk to.\n"));
-     ret = 1;
-     return;
+}
+
+
+static void
+guest_recv_local_enter (void *cls, int result,
+                        const struct GNUNET_CRYPTO_EddsaPublicKey 
*place_pub_key,
+                        uint64_t max_message_id)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Guest entered to local place: %d, max_message_id: %" PRIu64 
"\n",
+              result, max_message_id);
+  GNUNET_assert (0 <= result);
+}
+
+
+static struct GNUNET_PSYC_Message *
+guest_enter_msg_create ()
+{
+  const char *method_name = "_request_enter";
+  struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create ();
+  GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET,
+                       "_foo", "bar", sizeof ("bar"));
+  void *data = "let me in";
+  uint16_t data_size = strlen (data) + 1;
+
+  return GNUNET_PSYC_message_create (method_name, env, data, data_size);
+}
+
+
+static void
+guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
+             struct GNUNET_PeerIdentity *peer)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Entering to place as guest.\n");
+
+  gst = GNUNET_SOCIAL_guest_enter (app, ego, &place_pub_key,
+                                   GNUNET_PSYC_SLAVE_JOIN_NONE,
+                                   peer, 0, NULL, guest_enter_msg_create (),
+                                   slicer_create (),
+                                   guest_recv_local_enter,
+                                   guest_recv_entry_decision, NULL);
+  plc = GNUNET_SOCIAL_guest_get_place (gst);
+}
+
+
+static void
+guest_enter_by_name (const char *gns_name)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Entering to place by name as guest.\n");
+
+  gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL,
+                                           guest_enter_msg_create (), slicer,
+                                           guest_recv_local_enter,
+                                           guest_recv_entry_decision, NULL);
+  plc = GNUNET_SOCIAL_guest_get_place (gst);
+}
+
+
+
+/* HOST ENTER + CALLBACKS */
+
+
+static void
+host_answer_door (void *cls,
+                  struct GNUNET_SOCIAL_Nym *nym,
+                  const char *method_name,
+                  struct GNUNET_PSYC_Environment *env,
+                  const void *data,
+                  size_t data_size)
+{
+  const struct GNUNET_CRYPTO_EcdsaPublicKey *
+    nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
+  char *
+    nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Entry request: %s\n", nym_str);
+  GNUNET_free (nym_str);
+}
+
+
+static void
+host_farewell (void *cls,
+               const struct GNUNET_SOCIAL_Nym *nym,
+               struct GNUNET_PSYC_Environment *env)
+{
+  const struct GNUNET_CRYPTO_EcdsaPublicKey *
+    nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
+  char *
+    nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Farewell: %s\n", nym_str);
+  GNUNET_free (nym_str);
+}
+
+
+static void
+host_entered (void *cls, int result,
+              const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key,
+              uint64_t max_message_id)
+{
+  place_pub_key = *pub_key;
+  GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Entered: %s, max_message_id: %" PRIu64 "\n",
+              GNUNET_h2s_full (&place_pub_hash), max_message_id);
+}
+
+
+static void
+host_enter ()
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "host_enter()\n");
+
+  hst = GNUNET_SOCIAL_host_enter (app, ego,
+                                  GNUNET_PSYC_CHANNEL_PRIVATE,
+                                  slicer_create (), host_entered,
+                                  host_answer_door, host_farewell, NULL);
+  plc = GNUNET_SOCIAL_host_get_place (hst);
+}
+
+
+/* RECONNECT CALLBACKS */
+
+static void
+place_reconnected ()
+{
+  if (op_history_replay) {
+    history_replay (plc, opt_start, opt_end, opt_method);
   }
-  if (op_guest_enter) {
-     FPRINTF (stderr,
-               _("FIXME -E\n"));
-     if (flag_listen) {
-        FPRINTF (stderr,
-               _("Yes, yes!\n"));
-     }
-     return;
+  else if (op_history_replay_latest) {
+    history_replay_latest (plc, opt_limit, opt_method);
   }
-  if (flag_listen) {
-     FPRINTF (stderr,
-               _("The --listen flag is not defined for this operation.\n"));
-     ret = 1;
-     return;
+  else if (op_look_at) {
+    look_at (plc, opt_name);
   }
+  else if (op_look_for) {
+    look_for (plc, opt_name);
+  }
+}
+
+
+static void
+host_reconnected (void *cls, int result,
+                 const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
+                 uint64_t max_message_id)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Host reconnected\n");
+
   if (op_host_leave) {
-     FPRINTF (stderr,
-               _("FIXME HARDER -D\n"));
-     return;
+    host_leave (hst);
   }
+  else if (op_host_announce) {
+    host_announce (hst, opt_method, opt_data);
+  }
+  else {
+    place_reconnected ();
+  }
+}
+
+
+static void
+guest_reconnected (void *cls, int result,
+                   const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
+                   uint64_t max_message_id)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "Guest reconnected\n");
+
   if (op_guest_leave) {
-     FPRINTF (stderr,
-               _("FIXME HARDER -L\n"));
-     return;
+    guest_leave (gst);
   }
-  if (op_host_announce) {
-     FPRINTF (stderr,
-               _("FIXME -P\n"));
-     return;
+  else if (op_guest_talk) {
+    guest_talk (gst, opt_method, opt_data);
   }
-  if (op_guest_talk) {
-     FPRINTF (stderr,
-               _("FIXME -T\n"));
-     return;
+  else {
+    place_reconnected ();
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "TODO\n");
 }
 
 
+/* APP CALLBACKS */
+
+
+static void
+app_connected (void *cls)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "App connected: %p\n", cls);
+
+  if (op_host_enter) {
+    host_enter ();
+  }
+  else if (op_guest_enter) {
+    guest_enter (&place_pub_key);
+  }
+}
+
+
+static void
+app_recv_host (void *cls,
+               struct GNUNET_SOCIAL_HostConnection *hconn,
+               struct GNUNET_SOCIAL_Ego *ego,
+               const struct GNUNET_CRYPTO_EddsaPublicKey *host_pub_key,
+               enum GNUNET_SOCIAL_AppPlaceState place_state)
+{
+  struct GNUNET_HashCode host_pub_hash;
+  GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash);
+  char *
+    host_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (guest_pub_key);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Host: %s (%s)\n",
+              GNUNET_h2s_full (&host_pub_hash), host_pub_str);
+  GNUNET_free (host_pub_str);
+
+  if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key)))
+  {
+    hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, slicer_create (), 
host_reconnected,
+                                              host_answer_door, host_farewell, 
NULL);
+    plc = GNUNET_SOCIAL_host_get_place (hst);
+  }
+}
+
+
+static void
+app_recv_guest (void *cls,
+                struct GNUNET_SOCIAL_GuestConnection *gconn,
+                struct GNUNET_SOCIAL_Ego *ego,
+                const struct GNUNET_CRYPTO_EddsaPublicKey *guest_pub_key,
+                enum GNUNET_SOCIAL_AppPlaceState place_state)
+{
+  struct GNUNET_HashCode guest_pub_hash;
+  GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash);
+  char *
+    guest_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (guest_pub_key);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Guest: %s (%s)\n",
+              GNUNET_h2s_full (&guest_pub_hash), guest_pub_str);
+  GNUNET_free (guest_pub_str);
+
+  if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key)))
+  {
+    gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, 
GNUNET_PSYC_SLAVE_JOIN_NONE,
+                                               slicer_create (), 
guest_reconnected, NULL);
+    plc = GNUNET_SOCIAL_guest_get_place (gst);
+  }
+}
+
+
+static void
+app_recv_ego (void *cls,
+              struct GNUNET_SOCIAL_Ego *ego,
+              const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
+              const char *name)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Ego: %s\t%s\n",
+              name, GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key));
+}
+
+
+static void
+app_connect ()
+{
+  app = GNUNET_SOCIAL_app_connect (cfg, opt_app,
+                                   app_recv_ego,
+                                   app_recv_host,
+                                   app_recv_guest,
+                                   app_connected,
+                                   NULL);
+}
+
+/* CORE CALLBACKS */
+
+
+static void
+core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
+{
+  peer = *my_identity;
+  app_connect ();
+}
+
+
 /**
+ * Main function run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
+ * @param cfg configuration
+ */
+static void
+run (void *cls, char *const *args, const char *cfgfile,
+     const struct GNUNET_CONFIGURATION_Handle *c)
+{
+  cfg = c;
+
+  if (!opt_follow)
+  {
+    timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout, NULL);
+  }
+
+  if (op_host_enter && NULL != opt_place)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _ ("--place must not be specified when using --host-enter\n"));
+    return;
+  }
+
+  if (!opt_place
+      || GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (opt_place,
+                                                                  strlen 
(opt_place),
+                                                                  
&place_pub_key))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _ ("--place missing or invalid.\n"));
+    return;
+  }
+
+  if (opt_ego)
+  {
+    GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
+                                                strlen (opt_ego),
+                                                &ego_pub_key);
+  }
+
+  if (opt_peer)
+  {
+    // FIXME: peer ID from string
+  }
+
+  core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL,
+                              NULL, GNUNET_NO, NULL, GNUNET_NO, NULL);
+}
+
+
+/**
  * The main function to obtain peer information.
  *
  * @param argc number of arguments from the command line
@@ -166,70 +671,82 @@
 {
   int res;
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-     {'p', "place", "PUBKEY",
-      gettext_noop ("public key of place"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &place},
+    /* operations */
 
-     {'l', "listen", NULL,
-      gettext_noop ("listen for incoming messages"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &flag_listen},
+    { 'E', "host-enter", NULL,
+      _ ("create a place for nyms to join"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter },
 
-     {'m', "method", "METHOD_NAME",
-      gettext_noop ("method name to transmit"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &method},
+    { 'L', "host-leave", NULL,
+      _ ("destroy a place we were hosting"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave },
 
-     {'d', "data", "DATA",
-      gettext_noop ("message body to transmit"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &data},
+    { 'A', "host-announce", NULL,
+      _ ("publish something to a place we are hosting"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce },
 
-     {'p', "prefix", "METHOD_PREFIX",
-      gettext_noop ("method prefix filter for history replay"),
-      GNUNET_YES, &GNUNET_GETOPT_set_string, &prefix},
+    { 'e', "guest-enter", NULL,
+      _ ("join somebody else's place"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter },
 
-     {'s', "start", NULL,
-      gettext_noop ("start message ID for history replay"),
-      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &start},
+    { 'l', "guest-leave", NULL,
+      _ ("leave somebody else's place"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave },
 
-     {'e', "end", NULL,
-      gettext_noop ("end message ID for history replay"),
-      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &end},
+    { 't', "guest-talk", NULL,
+      _ ("submit something to somebody's place"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk },
 
-     {'n', "limit", NULL,
-      gettext_noop ("number of messages to replay from history"),
-      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &limit},
+    { 'R', "history-replay", NULL,
+      _ ("replay history of messages between message IDs --start and --end"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay },
 
-     {'C', "host-enter", NULL,
-      gettext_noop ("create a place for nyms to join"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter},
+    { 'r', "history-replay-latest", NULL,
+      _ ("replay history of latest messages up to the given --limit"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest },
 
-     {'D', "host-leave", NULL,
-      gettext_noop ("destroy a place we were hosting"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave},
+    /* options */
 
-     {'P', "host-announce", NULL,
-      gettext_noop ("publish something to a place we are hosting"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce},
+    { 'A', "app", "application ID",
+      _ ("application ID to use when connecting"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_app },
 
-     {'E', "guest-enter", NULL,
-      gettext_noop ("join somebody else's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter},
+    { 'p', "place", "PUBKEY",
+      _ ("public key of place"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place },
 
-     {'L', "guest-leave", NULL,
-      gettext_noop ("leave somebody else's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave},
+    { 'g', "ego", "PUBKEY",
+      _ ("public key of ego"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_place },
 
-     {'T', "guest-talk", NULL,
-      gettext_noop ("submit something to somebody's place"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk},
+    { 'f', "follow", NULL,
+      _ ("wait for incoming messages"),
+      GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow },
 
-     {'R', "history-replay", NULL,
-      gettext_noop ("FIXME"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay},
+    { 'm', "method", "METHOD_NAME",
+      _ ("method name"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_method },
 
-     {'H', "history-replay-latest", NULL,
-      gettext_noop ("FIXME"),
-      GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest},
+    { 'd', "data", "DATA",
+      _ ("message body to transmit"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_data },
 
+    { 'n', "name", "VAR_NAME",
+      _ ("state var name to query"),
+      GNUNET_NO, &GNUNET_GETOPT_set_string, &opt_name },
+
+    { 'a', "start", NULL,
+      _ ("start message ID for history replay"),
+      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_start },
+
+    { 'z', "end", NULL,
+      _ ("end message ID for history replay"),
+      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_end },
+
+    { 'n', "limit", NULL,
+      _ ("number of messages to replay from history"),
+      GNUNET_NO, &GNUNET_GETOPT_set_ulong, &opt_limit },
+
     GNUNET_GETOPT_OPTION_END
   };
 
@@ -237,25 +754,24 @@
     return 2;
 
   const char *help =
-    "enter/leave and send/receive messages in places of the social service";
+    _ ("interact with the social service: enter/leave, send/receive messages, 
access history and state")m;
   const char *usage =
-    "gnunet-social --host-enter [--listen]\n"
-    "gnunet-social --place <pubkey> --host-leave\n"
-    "gnunet-social --place <pubkey> --host-announce --method <method_name> 
--data <message_body>\n"
+    "gnunet-social --host-enter --ego <name or pubkey> [--listen]\n"
+    "gnunet-social --host-leave --place <pubkey>\n"
+    "gnunet-social --host-announce --place <pubkey> --method <method_name> 
--data <message body>\n"
     "\n"
-    "gnunet-social --place <pubkey> --guest-enter [--listen]\n"
-    "gnunet-social --place <pubkey> --guest-leave\n"
-    "gnunet-social --place <pubkey> --guest-talk --method <method_nmae> --data 
<data>\n"
+    "gnunet-social --guest-enter --place <pubkey> --ego <name or pubkey> 
[--listen]\n"
+    "gnunet-social --guest-leave --place <pubkey>\n"
+    "gnunet-social --guest-talk --place <pubkey> --method <method_nmae> --data 
<data>\n"
     "\n"
-    "gnunet-social --place <pubkey> --history-replay --start <msgid> --end 
<msgid>  [--prefix <method_prefix>]\n"
-    "gnunet-social --place <pubkey> --history-replay-latest --limit 
<msg_limit> [--prefix <method_prefix>]\n"
+    "gnunet-social --history-replay --place <pubkey> --start <msgid> --end 
<msgid>  [--method <method_prefix>]\n"
+    "gnunet-social --history-replay-latest --place <pubkey> --limit 
<msg_limit> [--method <method_prefix>]\n"
     "\n"
-    "gnunet-social --place <pubkey> --look-at <full_name>\n"
-    "gnunet-social --place <pubkey> --look-for <name_prefix>\n";
+    "gnunet-social --look-at --place <pubkey> --name <full_name>\n"
+    "gnunet-social --look-for --place <pubkey> --name <name_prefix>\n";
 
   res = GNUNET_PROGRAM_run (argc, argv, usage,
-                            gettext_noop (help),
-                            options, &run, NULL);
+                            help, options, &run, NULL);
 
   GNUNET_free ((void *) argv);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]