gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: added truthstorestate


From: gnunet
Subject: [taler-anastasis] 01/02: added truthstorestate
Date: Sun, 17 May 2020 19:51:54 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit df8ad9d0b25f25103f95d857b4975bc46bdd733e
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sun May 17 16:27:58 2020 +0000

    added truthstorestate
---
 src/cli/anastasis-cli-splitter.c | 240 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 225 insertions(+), 15 deletions(-)

diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
index d7413a7..93036ad 100644
--- a/src/cli/anastasis-cli-splitter.c
+++ b/src/cli/anastasis-cli-splitter.c
@@ -22,12 +22,125 @@
  */
 #include "platform.h"
 #include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_util.h>
 #include "anastasis_service.h"
 #include "anastasis.h"
 
 /* Constant, max size of keyboard input buffer */
 #define MAX_SIZE_INPUT_BUFFER 256
 
+/**
+ * State for a "truth upload" CMD.
+ */
+struct TruthUploadState
+{
+  /**
+   * URL of the anastasis backend.
+   */
+  const char *backend_url;
+
+  /**
+   * label of the anastasis backend.
+   */
+  const char *backend_label;
+
+  /**
+   * supported methods of the anastasis backend.
+   */
+  const char *backend_methods;
+
+  /**
+   * insurance of the anastasis backend.
+   */
+  const struct TALER_Amount *backend_insurance;
+
+  /**
+   * cost of using the anastasis backend.
+   */
+  const struct TALER_Amount *backend_cost;
+
+  /**
+   * Label of this command.
+   */
+  const char *label;
+
+  /**
+   * The ID data to generate user identifier
+   */
+  const json_t *id_data;
+
+  /**
+   * The escrow method
+   */
+  const char *method;
+
+  /**
+   * A secret question
+   */
+  const char *secret_question;
+
+  /**
+   * Answer to secret question
+   */
+  const char *secret_answer;
+
+  /**
+   * Phonenumber for method SMS
+   */
+  const char *phone;
+
+  /**
+   * E-Mail address
+   */
+  const char *mail;
+
+  /**
+   * Instructions to be returned to client/user
+   * (e.g. "Look at your smartphone. SMS was sent to you")
+   */
+  const char *instructions;
+
+  /**
+   * Mime type of truth_data (eg. jpeg, string etc.)
+   */
+  const char *mime_type;
+
+  /**
+   * The truth_data (e.g. hash of answer to a secure question)
+   */
+  const void *truth_data;
+
+  /**
+   * Size of truth_data
+   */
+  size_t truth_data_size;
+
+  /**
+   * Expected status code.
+   */
+  unsigned int http_status;
+
+  /**
+   * The /truth POST operation handle.
+   */
+  struct ANASTASIS_TruthUpload *tuo;
+
+  /**
+   * closure for the payment callback
+   */
+  void *tpc_cls;
+
+  /**
+   * Reference to upload command of previous truth upload.
+   */
+  const char *upload_reference;
+
+  /**
+   * Truth object
+   */
+  const struct ANASTASIS_Truth *truth;
+};
+
 /**
  * Global option '--me' to import json containing details of user.
  */
@@ -53,6 +166,18 @@ static struct GNUNET_CURL_Context *ctx;
  */
 static struct GNUNET_CURL_RescheduleContext *rc;
 
+/**
+ * State for a "truth upload" CMD.
+ */
+static struct TruthUploadState *tu_states;
+
+/**
+ * Amount of truth upload states
+ */
+static unsigned int tu_states_length;
+
+
+
 
 static void
 start_read_keyboard (void);
@@ -122,11 +247,28 @@ read_keyboard_command (void *cls)
     return;
   }
 
-  if (0 == strncmp ("server",
-                    buffer,
-                    strlen ("server")))
+  if ((0 == strncmp ("server",
+                     buffer,
+                     strlen ("server")))
+      && (characters == strlen ("server") + sizeof (char)))
   {
     // FIXME "server" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        if (NULL != tu_states[i].backend_url)
+          printf ("server#%u: %s, %s, insured up to: %s, cost: %s\n",
+                  i,
+                  tu_states[i].backend_url,
+                  tu_states[i].backend_methods,
+                  TALER_amount_to_string (tu_states[i].backend_insurance),
+                  TALER_amount_to_string (tu_states[i].backend_cost));
+      }
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -143,11 +285,37 @@ read_keyboard_command (void *cls)
     return;
   }
 
-  if (0 == strncmp ("truth",
-                    buffer,
-                    strlen ("truth")))
+  if ((0 == strncmp ("truth",
+                     buffer,
+                     strlen ("truth")))
+      && (characters == strlen ("truth") + sizeof (char)))
   {
     // FIXME "truth" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        char *secret;
+        if (0 == strcmp ("SMS", tu_states[i].method))
+          secret = tu_states[i].phone;
+        if (0 == strcmp ("Secure-Question", tu_states[i].method))
+        {
+          secret = "\"";
+          strcat (secret, tu_states[i].secret_question);
+          strcat (secret, "\" ");
+          strcat (secret, "<OMITTED>");
+        }
+        if (NULL != secret)
+          printf ("truth#%u: %s %s %s\n",
+                  i,
+                  tu_states[i].backend_label,
+                  tu_states[i].method,
+                  secret);
+      }
+    }
+    else
+      printf ("Please add a truth before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -158,16 +326,31 @@ read_keyboard_command (void *cls)
                     strlen ("truth add")))
   {
     // FIXME "truth add" logic here
+    if (NULL != tu_states)
+    {
+      // FIXME
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
     return;
   }
-  if (0 == strncmp ("truth add question",
-                    buffer,
-                    strlen ("truth add question")))
+  if ((0 == strncmp ("truth add question",
+                     buffer,
+                     strlen ("truth add question")))
+      && (characters == strlen ("truth add question") + sizeof (char)))
   {
     // FIXME "truth add question" logic here
+    if (NULL != tu_states)
+    {
+      // FIXME
+    }
+    else
+      printf ("Please add a server before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -178,15 +361,41 @@ read_keyboard_command (void *cls)
                     strlen ("truth --secrets")))
   {
     // FIXME "truth --secrets" logic here
+    if (NULL != tu_states)
+    {
+      for (unsigned int i = 0; i < tu_states_length; i++)
+      {
+        char *secret;
+        if (0 == strcmp ("SMS", tu_states[i].method))
+          secret = tu_states[i].phone;
+        if (0 == strcmp ("Secure-Question", tu_states[i].method))
+        {
+          secret = "\"";
+          strcat (secret, tu_states[i].secret_question);
+          strcat (secret, "\" \"");
+          strcat (secret, tu_states[i].secret_answer);
+          strcat (secret, "\"");
+        }
+        if (NULL != secret)
+          printf ("truth#%u: %s %s\n",
+                  i,
+                  tu_states[i].method,
+                  secret);
+      }
+    }
+    else
+      printf ("Please add a truth before!\n");
+
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
     return;
   }
 
-  if (0 == strncmp ("policy",
-                    buffer,
-                    strlen ("policy")))
+  if ((0 == strncmp ("policy",
+                     buffer,
+                     strlen ("policy")))
+      && (characters == strlen ("policy") + sizeof (char)))
   {
     // FIXME "policy" logic here
     start_read_keyboard ();
@@ -205,9 +414,10 @@ read_keyboard_command (void *cls)
     return;
   }
 
-  if (0 == strncmp ("publish",
-                    buffer,
-                    strlen ("publish")))
+  if ((0 == strncmp ("publish",
+                     buffer,
+                     strlen ("publish")))
+      && (characters == strlen ("publish") + sizeof (char)))
   {
     // FIXME "publish" logic here
     start_read_keyboard ();

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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