gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (ad92efe -> 6f7d7c3)


From: gnunet
Subject: [taler-anastasis] branch master updated (ad92efe -> 6f7d7c3)
Date: Thu, 29 Oct 2020 20:52:11 +0100

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

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

    from ad92efe  added section
     new 69bc407  fix reducer state enums
     new d83454e  fix reducer cli
     new 6f7d7c3  merge

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/backend/anastasis-httpd_policy_upload.c |  24 +----
 src/backend/anastasis-httpd_truth.c         |   6 +-
 src/cli/anastasis-cli-redux.c               |  18 +---
 src/include/anastasis_redux.h               |  20 ++--
 src/lib/anastasis.c                         |   2 -
 src/lib/anastasis_api_backup_redux.c        | 143 +++++++++++++++++++++++++---
 src/lib/anastasis_api_config.c              |   2 -
 src/lib/anastasis_api_recovery_redux.c      |  92 +++++++++++++++++-
 src/lib/anastasis_api_redux.c               | 131 +++++++++++--------------
 9 files changed, 296 insertions(+), 142 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 701376a..bddc811 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -404,10 +404,6 @@ ongoing_payment_cb (void *cls,
 static void
 check_payment_cb (void *cls,
                   const struct TALER_MERCHANT_HttpResponse *hr,
-                  // int paid, FIXME: DELETE
-                  // int refunded, FIXME: DELETE
-                  // struct TALER_Amount *refund_amount, FIXME: DELETE
-                  // const char *taler_pay_uri) FIXME: DELETE
                   const struct TALER_MERCHANT_OrderStatusResponse *osr)
 
 {
@@ -424,11 +420,7 @@ check_payment_cb (void *cls,
   MHD_resume_connection (puc->con);
   AH_trigger_daemon ();
 
-  /**
-   * FIXME: DELETE
-  GNUNET_break ( (GNUNET_NO == refunded) &&
-                 (NULL == refund_amount) );
-  */if (osr->status)
+  if (osr->status)
   {
     enum ANASTASIS_DB_QueryStatus qs;
 
@@ -984,19 +976,7 @@ AH_handler_policy_post (struct MHD_Connection *connection,
         MHD_destroy_response (resp);
         return ret;
       }
-      /**
-       * FIXME: useful?
-      if (0 != GNUNET_memcmp (&hc,
-                              &puc->old_policy_upload_hash))
-      {
-        // Refuse upload: if-none-match failed!
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "Conflict detected, returning existing recovery 
document\n");
-        return AH_return_policy (connection,
-                                 &accountPubP,
-                                 MHD_HTTP_CONFLICT);
-      }
-      */}
+    }
     /* check if the client insists on paying */
     {
       const char *order_req;
diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 9bb1c77..9baddb3 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -369,11 +369,7 @@ check_payment_cb (void *cls,
   MHD_resume_connection (gc->connection);
   AH_trigger_daemon ();
 
-  /**
-   * FIXME: DELETE
-  GNUNET_break ( (GNUNET_NO == refunded) &&
-                 (NULL == refund_amount) );
-  */if (osr->status)
+  if (osr->status)
   {
     enum ANASTASIS_DB_QueryStatus qs;
 
diff --git a/src/cli/anastasis-cli-redux.c b/src/cli/anastasis-cli-redux.c
index e7ab8b2..c5d749b 100644
--- a/src/cli/anastasis-cli-redux.c
+++ b/src/cli/anastasis-cli-redux.c
@@ -104,16 +104,18 @@ persist_new_state (json_t *state,
     }
     return;
   }
-  if (-1 !=
+  char *state_str = json_dumps (state, JSON_COMPACT);
+  if (-1 >=
       fprintf (stdout,
                "%s",
-               json_dumps (state,
-                           JSON_COMPACT)))
+               state_str))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Could not dump state to stdout\n");
+    GNUNET_free (state_str);
     return;
   }
+  GNUNET_free (state_str);
 }
 
 
@@ -169,16 +171,6 @@ shutdown_task (void *cls)
     GNUNET_CURL_gnunet_rc_destroy (rc);
     rc = NULL;
   }
-  if (NULL != arguments)
-  {
-    json_decref (arguments);
-    arguments = NULL;
-  }
-  if (NULL != prev_state)
-  {
-    json_decref (prev_state);
-    prev_state = NULL;
-  }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Shutdown complete\n");
 }
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index c2557d9..27de17d 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -30,9 +30,9 @@
 
 #define ANASTASIS_GENERIC_STATES(REDUX_STATE) \
   REDUX_STATE (ERROR) \
-  REDUX_STATE (CONTINENT_SELECTION)   \
-  REDUX_STATE (COUNTRY_SELECTION)  \
-  REDUX_STATE (USER_ATTRIBUTES_COLLECTION)
+  REDUX_STATE (CONTINENT_SELECTING)   \
+  REDUX_STATE (COUNTRY_SELECTING)  \
+  REDUX_STATE (USER_ATTRIBUTES_COLLECTING)
 
 #define GENERATE_GENERIC_ENUM(ENUM) ANASTASIS_GENERIC_STATE_ ## ENUM,
 
@@ -47,7 +47,9 @@ enum ANASTASIS_GenericState
   ANASTASIS_GENERIC_STATES (REDUX_STATE) \
   REDUX_STATE (AUTHENTICATIONS_EDITING)  \
   REDUX_STATE (POLICIES_REVIEWING)   \
-  REDUX_STATE (PAYING)
+  REDUX_STATE (SECRET_EDITING) \
+  REDUX_STATE (POLICIES_PAYING) \
+  REDUX_STATE (FINISHED)
 
 #define GENERATE_BACKUP_ENUM(ENUM) ANASTASIS_BACKUP_STATE_ ## ENUM,
 
@@ -60,10 +62,10 @@ enum ANASTASIS_BackupState
 
 #define ANASTASIS_RECOVERY_STATES(REDUX_STATE) \
   ANASTASIS_GENERIC_STATES (REDUX_STATE) \
-  REDUX_STATE (AuthenticationsEditingState)  \
-  REDUX_STATE (PoliciesReviewingState)   \
-  REDUX_STATE (BackupPayingState)  \
-  REDUX_STATE (NoState) \
+  REDUX_STATE (CHALLENGE_SELECTING)  \
+  REDUX_STATE (CHALLENGE_PAYING)   \
+  REDUX_STATE (CHALLENGE_SOLVING)  \
+  REDUX_STATE (FINISHED)
 
 #define GENERATE_RECOVERY_ENUM(ENUM) ANASTASIS_RECOVERY_STATE_ ## ENUM,
 
@@ -90,7 +92,7 @@ extern const char *currency;
  * Returns the enum value to a string value of a state.
  *
  * @param state_string
- * @return XXX on error
+ * @return #ANASTASIS_GENERIC_STATE_ERROR on error
  */
 enum ANASTASIS_GenericState
 ANASTASIS_generic_state_from_string (const char *state_string);
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 6285818..8528d60 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -1953,8 +1953,6 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                                               ss->pss[l]);
     GNUNET_assert (NULL != ss->pss[l]->pso);
   }
-  // FIXME: clean up PSS, TRUTHS etc. !!!
-  // SETUP SHARE RESULT CALLBACK
   return ss;
 }
 
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 5d0e55d..a1d1c1e 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -140,11 +140,10 @@ ANASTASIS_backup_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
       json_array_append_new (continents,
                              continent);
   }
-
   initial_state = json_pack ("{s:s, s:o}",
                              "backup_state",
                              ANASTASIS_generic_state_to_string (
-                               ANASTASIS_BACKUP_STATE_CONTINENT_SELECTION),
+                               ANASTASIS_BACKUP_STATE_CONTINENT_SELECTING),
                              "continents",
                              continents);
   GNUNET_assert (NULL != initial_state);
@@ -162,15 +161,16 @@ add_authentication (json_t *state,
   json_t *method = json_object_get (arguments, "authentication_method");
   GNUNET_assert (NULL != method); // FIXME: cb with error code (text: 
authentication_method required)
   // FIXME: validate 'method' is well-formed!
-  json_t *auth_method_arr = json_deep_copy (json_object_get (state,
-                                                             
"authentication_methods"));
+  json_t *auth_method_arr = json_object_get (state,
+                                             "authentication_methods");
   if (NULL == auth_method_arr)
     auth_method_arr = json_array ();
   GNUNET_assert (NULL != auth_method_arr);
   GNUNET_assert (0 == json_array_append_new (auth_method_arr, method));
-  GNUNET_assert (0 == json_object_set_new (state,
-                                           "authentication_methods",
-                                           auth_method_arr));
+  GNUNET_assert (0 == json_object_set (state,
+                                       "authentication_methods",
+                                       auth_method_arr));
+
   cb (cb_cls,
       ANASTASIS_EC_NONE,
       state);
@@ -223,10 +223,6 @@ eval_provider_selection (struct PolicyBuilder *pb,
                                            prov_sel[i]);
     void *provider_obj_iter = json_object_iter (provider_obj);
     const char *provider_name = json_object_iter_key (provider_obj_iter);
-    json_t *policy_method = json_pack ("{s:i, s:s}",
-                                       "authentication_method", pb->m_idx[i],
-                                       "provider", provider_name);
-
     struct TALER_Amount method_cost;
     json_t *provider_data = json_object_get (provider_obj, provider_name);
 
@@ -264,7 +260,9 @@ eval_provider_selection (struct PolicyBuilder *pb,
 
   if (curr_diversity < pb->best_diversity)
     better = false;
-  else if (0 < TALER_amount_cmp (&curr_cost, &pb->best_cost))
+  else if ((GNUNET_YES == TALER_amount_cmp_currency (&curr_cost,
+                                                     &pb->best_cost))
+           && (0 < TALER_amount_cmp (&curr_cost, &pb->best_cost)))
     better = false;
 
   if (better)
@@ -511,6 +509,85 @@ add_policy (json_t *state,
             ANASTASIS_ActionCallback cb,
             void *cb_cls)
 {
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+del_policy (json_t *state,
+            const json_t *arguments,
+            struct GNUNET_CURL_Context *ctx,
+            ANASTASIS_ActionCallback cb,
+            void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+done_policy_review (json_t *state,
+                    const json_t *arguments,
+                    struct GNUNET_CURL_Context *ctx,
+                    ANASTASIS_ActionCallback cb,
+                    void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+enter_secret (json_t *state,
+              const json_t *arguments,
+              struct GNUNET_CURL_Context *ctx,
+              ANASTASIS_ActionCallback cb,
+              void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+pay_policy (json_t *state,
+            const json_t *arguments,
+            struct GNUNET_CURL_Context *ctx,
+            ANASTASIS_ActionCallback cb,
+            void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+back_finished (json_t *state,
+               const json_t *arguments,
+               struct GNUNET_CURL_Context *ctx,
+               ANASTASIS_ActionCallback cb,
+               void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
   return NULL;
 }
 
@@ -560,7 +637,47 @@ ANASTASIS_backup_action_ (struct GNUNET_CURL_Context *ctx,
     {
       ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING,
       "back",
-      &ANASTASIS_back_generic_decrement_,
+      &ANASTASIS_back_generic_decrement_
+    },
+    {
+      ANASTASIS_BACKUP_STATE_POLICIES_REVIEWING,
+      "add_policy",
+      &add_policy
+    },
+    {
+      ANASTASIS_BACKUP_STATE_POLICIES_REVIEWING,
+      "delete_policy",
+      &del_policy
+    },
+    {
+      ANASTASIS_BACKUP_STATE_POLICIES_REVIEWING,
+      "next",
+      &done_policy_review
+    },
+    {
+      ANASTASIS_BACKUP_STATE_POLICIES_REVIEWING,
+      "back",
+      &ANASTASIS_back_generic_decrement_
+    },
+    {
+      ANASTASIS_BACKUP_STATE_SECRET_EDITING,
+      "enter_secret",
+      &enter_secret
+    },
+    {
+      ANASTASIS_BACKUP_STATE_SECRET_EDITING,
+      "back",
+      &ANASTASIS_back_generic_decrement_
+    },
+    {
+      ANASTASIS_BACKUP_STATE_POLICIES_PAYING,
+      "pay",
+      &pay_policy
+    },
+    {
+      ANASTASIS_BACKUP_STATE_FINISHED,
+      "back",
+      &back_finished
     },
     { ANASTASIS_BACKUP_STATE_ERROR, NULL, NULL }
   };
diff --git a/src/lib/anastasis_api_config.c b/src/lib/anastasis_api_config.c
index dcc4fb9..a1b5e6a 100644
--- a/src/lib/anastasis_api_config.c
+++ b/src/lib/anastasis_api_config.c
@@ -73,8 +73,6 @@ struct ANASTASIS_ConfigOperation
    * Currency of the cost;
    */
   const char *currency;
-
-  // FIXME add configs
 };
 
 
diff --git a/src/lib/anastasis_api_recovery_redux.c 
b/src/lib/anastasis_api_recovery_redux.c
index 143ef2b..c76aa57 100644
--- a/src/lib/anastasis_api_recovery_redux.c
+++ b/src/lib/anastasis_api_recovery_redux.c
@@ -131,13 +131,73 @@ ANASTASIS_recovery_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
   initial_state = json_pack ("{s:s, s:o}",
                              "recovery_state",
                              ANASTASIS_recovery_state_to_string (
-                               ANASTASIS_RECOVERY_STATE_CONTINENT_SELECTION),
+                               ANASTASIS_RECOVERY_STATE_CONTINENT_SELECTING),
                              "continents",
                              continents);
   return initial_state;
 }
 
 
+static struct ANASTASIS_ReduxAction *
+select_challenge (json_t *state,
+                  const json_t *arguments,
+                  struct GNUNET_CURL_Context *ctx,
+                  ANASTASIS_ActionCallback cb,
+                  void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+pay_challenge (json_t *state,
+               const json_t *arguments,
+               struct GNUNET_CURL_Context *ctx,
+               ANASTASIS_ActionCallback cb,
+               void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+solve_challenge (json_t *state,
+                 const json_t *arguments,
+                 struct GNUNET_CURL_Context *ctx,
+                 ANASTASIS_ActionCallback cb,
+                 void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
+static struct ANASTASIS_ReduxAction *
+back_challenge_solving (json_t *state,
+                        const json_t *arguments,
+                        struct GNUNET_CURL_Context *ctx,
+                        ANASTASIS_ActionCallback cb,
+                        void *cb_cls)
+{
+  // FIXME: implement
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      state);
+  return NULL;
+}
+
+
 /**
  * Operates on a recovery state depending on given #ANASTASIS_RecoveryState
  * and #ANASTASIS_RecoveryAction. The new #ANASTASIS_RecoveryState is returned
@@ -165,6 +225,36 @@ ANASTASIS_recovery_action_ (struct GNUNET_CURL_Context 
*ctx,
     const char *recovery_action;
     DispatchHandler fun;
   } dispatchers[] = {
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+      "select_challenge",
+      &select_challenge
+    },
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+      "back",
+      &ANASTASIS_back_generic_decrement_
+    },
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
+      "pay",
+      &pay_challenge
+    },
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
+      "back",
+      &ANASTASIS_back_generic_decrement_
+    },
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
+      "solve_challenge",
+      &solve_challenge
+    },
+    {
+      ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
+      "back",
+      &back_challenge_solving
+    },
     { ANASTASIS_RECOVERY_STATE_ERROR, NULL, NULL }
   };
   const char *s = json_string_value (json_object_get (state,
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 09f2329..b362a3c 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -245,15 +245,11 @@ add_config_to_state (struct ConfigRequest *cr,
                                           method_type,
                                           ma_arr = json_array ()));
     }
-    prov = json_pack ("{s:o}",
+    prov = json_pack ("{s:o, s:o, s:s, s:s}",
+                      // FIXME: add insurance here...
                       "method_cost",
                       json_object_get (method,
-                                       "cost"));
-    GNUNET_assert (0 == json_object_set_new (ma,
-                                             cr->backend_id,
-                                             prov));
-    prov = json_pack ("{s:o, s:s, s:s}",
-                      // FIXME: add insurance here...
+                                       "cost"),
                       "annual_cost",
                       TALER_JSON_from_amount (&cr->backend_cost),
                       "provider_url",
@@ -298,7 +294,7 @@ conclude_select_country (struct SelectCountryHandle *sch)
   sch->cb (NULL,
            ANASTASIS_EC_NONE,
            sch->state);
-  free_select_country (sch);
+  // free_select_country (sch);
 }
 
 
@@ -497,7 +493,7 @@ select_continent (json_t *state,
                    s_mode,
                    json_string (
                      ANASTASIS_backup_state_to_string (
-                       ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION))));
+                       ANASTASIS_GENERIC_STATE_COUNTRY_SELECTING))));
 
   GNUNET_assert (0 ==
                  json_object_set_new (state,
@@ -524,7 +520,7 @@ select_country (json_t *state,
                 void *cb_cls)
 {
   json_t *root;
-  const json_t *provider_list;
+  json_t *provider_list;
   char *dn;
   json_error_t error;
   json_t *country;
@@ -549,7 +545,7 @@ select_country (json_t *state,
                    s_mode,
                    json_string (
                      ANASTASIS_generic_state_to_string (
-                       ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION))));
+                       ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTING))));
   GNUNET_assert (0 ==
                  json_object_set_new (state,
                                       "selected_country",
@@ -599,7 +595,6 @@ select_country (json_t *state,
     json_t *provider;
     json_t *provider_arr = json_object_get (provider_list,
                                             "anastasis_provider");
-
     sch = GNUNET_new (struct SelectCountryHandle);
     sch->cb = cb;
     sch->cb_cls = cb_cls;
@@ -666,7 +661,7 @@ unselect_country (json_t *state,
                    s_mode,
                    json_string (
                      ANASTASIS_generic_state_to_string (
-                       ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION))));
+                       ANASTASIS_GENERIC_STATE_COUNTRY_SELECTING))));
   cb (cb_cls,
       ANASTASIS_EC_NONE,
       state);
@@ -690,7 +685,7 @@ unselect_continent (json_t *state,
                    s_mode,
                    json_string (
                      ANASTASIS_generic_state_to_string (
-                       ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION))));
+                       ANASTASIS_GENERIC_STATE_CONTINENT_SELECTING))));
   cb (cb_cls,
       ANASTASIS_EC_NONE,
       state);
@@ -743,21 +738,36 @@ ANASTASIS_back_generic_decrement_ (json_t *state,
                                    ANASTASIS_ActionCallback cb,
                                    void *cb_cls)
 {
+  enum ANASTASIS_BackupState state_index;
   const char *s_mode = get_state_mode (state);
   GNUNET_assert (NULL != s_mode); // FIXME: call cb with error!
-  const char*state_string = json_string_value (json_object_get (state,
-                                                                s_mode));
+  const char *state_string = json_string_value (json_object_get (state,
+                                                                 s_mode));
   GNUNET_assert (NULL != state_string); // FIXME: call cb with error!
-  enum ANASTASIS_BackupState state_index = ANASTASIS_generic_state_from_string 
(
-    state_string);
-  GNUNET_assert (state_index > 0);
-  state_index = state_index - 1;
-  GNUNET_assert (0 ==
-                 json_object_set_new (
-                   state,
-                   s_mode,
-                   json_string (
-                     ANASTASIS_generic_state_to_string (state_index))));
+  if (0 == strcmp ("backup_state", s_mode))
+  {
+    state_index = ANASTASIS_backup_state_from_string (state_string);
+    GNUNET_assert (state_index > 0);
+    state_index = state_index - 1;
+    GNUNET_assert (0 ==
+                   json_object_set_new (
+                     state,
+                     s_mode,
+                     json_string (
+                       ANASTASIS_generic_state_to_string (state_index))));
+  }
+  else
+  {
+    state_index = ANASTASIS_recovery_state_from_string (state_string);
+    GNUNET_assert (state_index > 0);
+    state_index = state_index - 1;
+    GNUNET_assert (0 ==
+                   json_object_set_new (
+                     state,
+                     s_mode,
+                     json_string (
+                       ANASTASIS_generic_state_to_string (state_index))));
+  }
   cb (cb_cls,
       ANASTASIS_EC_NONE,
       state);
@@ -796,57 +806,32 @@ ANASTASIS_redux_action (const json_t *state,
     DispatchHandler fun;
   } dispatchers[] = {
     {
-      ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION,
+      ANASTASIS_GENERIC_STATE_CONTINENT_SELECTING,
       "select_continent",
       &select_continent
     },
     {
-      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION,
+      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTING,
       "unselect_continent",
       &unselect_continent
     },
     {
-      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION,
+      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTING,
       "select_continent",
       &select_continent
     },
     {
-      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION,
-      "select_country",
-      &select_country
-    },
-    {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
-      "unselect_country",
-      &unselect_country
-    },
-    {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
+      ANASTASIS_GENERIC_STATE_COUNTRY_SELECTING,
       "select_country",
       &select_country
     },
     {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
-      "back",
-      &unselect_country
-    },
-    {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
-      "select_continent",
-      &select_continent
-    },
-    {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
-      "unselect_continent",
-      &unselect_continent
-    },
-    {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
+      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTING,
       "enter_user_attributes",
       &enter_user_attributes
     },
     {
-      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION,
+      ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTING,
       "back",
       &ANASTASIS_back_generic_decrement_
     },
@@ -872,32 +857,28 @@ ANASTASIS_redux_action (const json_t *state,
     }
   }
   gs = ANASTASIS_generic_state_from_string (s);
-  if (ANASTASIS_GENERIC_STATE_ERROR == gs)
-  {
-    cb (cb_cls,
-        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
-        NULL);
-    return NULL;
-  }
   {
     json_t *new_state;
     struct ANASTASIS_ReduxAction *ret;
 
     new_state = json_deep_copy (state);
     GNUNET_assert (NULL != new_state);
-    for (unsigned int i = 0; NULL != dispatchers[i].fun; i++)
+    if (gs != ANASTASIS_GENERIC_STATE_ERROR)
     {
-      if ( (gs == dispatchers[i].redux_state) &&
-           (0 == strcmp (action,
-                         dispatchers[i].redux_action)) )
+      for (unsigned int i = 0; NULL != dispatchers[i].fun; i++)
       {
-        ret = dispatchers[i].fun (new_state,
-                                  arguments,
-                                  ctx,
-                                  cb,
-                                  cb_cls);
-        json_decref (new_state);
-        return ret;
+        if ( (gs == dispatchers[i].redux_state) &&
+             (0 == strcmp (action,
+                           dispatchers[i].redux_action)) )
+        {
+          ret = dispatchers[i].fun (new_state,
+                                    arguments,
+                                    ctx,
+                                    cb,
+                                    cb_cls);
+          json_decref (new_state);
+          return ret;
+        }
       }
     }
     if (recovery_mode)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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