gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 04/08: fix


From: gnunet
Subject: [taler-anastasis] 04/08: fix
Date: Fri, 09 Oct 2020 12:03:45 +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 eb4d3059e12d9b65257c13f2d7c4506ea2882026
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Oct 7 20:30:00 2020 +0200

    fix
---
 src/include/anastasis_redux.h          | 10 +++++-----
 src/lib/Makefile.am                    |  1 +
 src/lib/anastasis_api_backup_redux.c   | 21 +++++++++++----------
 src/lib/anastasis_api_recovery_redux.c |  6 +++---
 src/lib/anastasis_api_redux.c          | 28 ++++++++++++++++------------
 5 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index ea811ad..c75ca2a 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -46,7 +46,7 @@ extern json_t *provider_list;
 /**
  * Currency of chosen country
  */
-extern char *currency;
+extern const char *currency;
 
 /**
  * Returns an initial ANASTASIS backup state.
@@ -107,7 +107,7 @@ typedef void
  * by a callback function.
  * This function can do network access to talk to anastasis service providers.
  *
- * @param state input state
+ * @param[in,out] state input/output state (to be modified)
  * @param action what action to perform
  * @param arguments data for the @a action
  * @param cb function to call with the result
@@ -115,7 +115,7 @@ typedef void
  * @return failure state or new state
  */
 void
-ANASTASIS_backup_action (const json_t *state,
+ANASTASIS_backup_action (json_t *state,
                          const char *action,
                          const json_t *arguments,
                          ANASTASIS_ActionCallback cb,
@@ -128,14 +128,14 @@ ANASTASIS_backup_action (const json_t *state,
  * by a callback function.
  * This function can do network access to talk to anastasis service providers.
  *
- * @param state input state
+ * @param[in,out] state input/output state (to be modified)
  * @param action what action to perform
  * @param arguments data for the @a action
  * @param cb function to call with the result
  * @param cb_cls closure for @a cb
  */
 void
-ANASTASIS_recovery_action (const json_t *state,
+ANASTASIS_recovery_action (json_t *state,
                            const char *action,
                            const json_t *arguments,
                            ANASTASIS_ActionCallback cb,
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 7e37ec4..04b092b 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -109,6 +109,7 @@ libanastasisredux_la_LIBADD = \
   -lgnunetcurl \
   -lgnunetutil \
   -ltalerutil \
+  -ltalerjson \
   -ljansson \
   $(XLIB)
 
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index e1e7167..bfcce2b 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -23,6 +23,7 @@
 
 #include <platform.h>
 #include <jansson.h>
+#include <taler/taler_json_lib.h>
 #include <taler/taler_util.h>
 #include "anastasis_redux.h"
 #include "anastasis_error_codes.h"
@@ -36,7 +37,7 @@
  *  @param cb_cls FIXME: Description
  */
 typedef void
-(*DispatchHandler)(const json_t *state,
+(*DispatchHandler)(json_t *state,
                    const json_t *arguments,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
@@ -103,7 +104,7 @@ ANASTASIS_backup_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
 
 /** FIXME: Implement just one "back" action
 static void
-edit_user_attributes (const json_t *state,
+edit_user_attributes (json_t *state,
                       const json_t *arguments,
                       ANASTASIS_ActionCallback cb,
                       void *cb_cls)
@@ -148,7 +149,7 @@ edit_user_attributes (const json_t *state,
 
 
 static void
-add_authentication (const json_t *state,
+add_authentication (json_t *state,
                     const json_t *arguments,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
@@ -256,7 +257,7 @@ go_with (struct PolicyBuilder *pb,
   pb->best_diversity = 0;
   pb->best_sel = best_sel;
   pb->m_idx = m_idx;
-  provider_candidate (&pb,
+  provider_candidate (pb,
                       prov_sel,
                       0);
 
@@ -268,8 +269,8 @@ go_with (struct PolicyBuilder *pb,
   {
     json_t *method_obj = json_array_get (pb->methods,
                                          m_idx[i]);
-    json_t *method_name = json_string_value (json_object_get (method_obj,
-                                                              "method"));
+    const char *method_name = json_string_value (json_object_get (method_obj,
+                                                                  "method"));
     json_t *method_providers = json_object_get (pb->providers,
                                                 method_name);
     json_t *provider_obj = json_array_get (method_providers,
@@ -332,7 +333,7 @@ method_candidate (struct PolicyBuilder *pb,
 
 
 static void
-done_authentication (const json_t *state,
+done_authentication (json_t *state,
                      const json_t *arguments,
                      ANASTASIS_ActionCallback cb,
                      void *cb_cls)
@@ -343,7 +344,7 @@ done_authentication (const json_t *state,
                                   "authentication_providers");
   pb.methods = json_object_get (state,
                                 "authentication_methods");
-  pb.policies = json_array_new ();
+  pb.policies = json_array ();
   pb.num_methods = json_array_size (pb.methods);
   switch (pb.num_methods)
   {
@@ -386,7 +387,7 @@ done_authentication (const json_t *state,
 
 
 static void
-del_authentication (const json_t *state,
+del_authentication (json_t *state,
                     const json_t *arguments,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
@@ -396,7 +397,7 @@ del_authentication (const json_t *state,
 
 
 static void
-add_policy (const json_t *state,
+add_policy (json_t *state,
             const json_t *arguments,
             ANASTASIS_ActionCallback cb,
             void *cb_cls)
diff --git a/src/lib/anastasis_api_recovery_redux.c 
b/src/lib/anastasis_api_recovery_redux.c
index ace589d..d76d78d 100644
--- a/src/lib/anastasis_api_recovery_redux.c
+++ b/src/lib/anastasis_api_recovery_redux.c
@@ -35,7 +35,7 @@
  *  @param cb_cls FIXME: Description
  */
 typedef void
-(*DispatchHandler)(const json_t *state,
+(*DispatchHandler)(json_t *state,
                    const json_t *arguments,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
@@ -106,7 +106,7 @@ ANASTASIS_recovery_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
  * by a callback function.
  * This function can do network access to talk to anastasis service providers.
  *
- * @param state input state
+ * @param[in,out] state input/output state (to be modified)
  * @param action what action to perform
  * @param arguments data for the @a action
  * @param cb function to call with the result
@@ -114,7 +114,7 @@ ANASTASIS_recovery_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
  * @return failure state or new state
  */
 void
-ANASTASIS_recovery_action (const json_t *state,
+ANASTASIS_recovery_action (json_t *state,
                            const char *action,
                            const json_t *arguments,
                            ANASTASIS_ActionCallback cb,
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 003f432..42ed682 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -44,7 +44,7 @@ json_t *provider_list;
 /**
  * Currency of chosen country
  */
-char *currency;
+const char *currency;
 
 
 /**
@@ -56,7 +56,7 @@ char *currency;
  *  @param cb_cls FIXME: Description
  */
 typedef void
-(*DispatchHandler)(const json_t *state,
+(*DispatchHandler)(json_t *state,
                    const json_t *arguments,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
@@ -218,7 +218,7 @@ select_continent (json_t *state,
 
 
 static void
-select_country (const json_t *state,
+select_country (json_t *state,
                 const json_t *arguments,
                 ANASTASIS_ActionCallback cb,
                 void *cb_cls)
@@ -231,7 +231,7 @@ select_country (const json_t *state,
   const char *s_mode = get_state_mode (state);
   GNUNET_assert (NULL != s_mode);
   currency = json_string_value (json_object_get (arguments,
-                                                 "country_currency"));
+                                                 "currency"));
   GNUNET_assert (NULL != currency);
   GNUNET_assert (GNUNET_SYSERR !=
                  redux_id_attr_init (json_string_value (country)));
@@ -245,6 +245,10 @@ select_country (const json_t *state,
                        "selected_country",
                        country);
 
+  json_object_set_new (state,
+                       "currency",
+                       json_string (currency));
+
   json_object_set_new (state,
                        "required_attributes",
                        root);
@@ -256,7 +260,7 @@ select_country (const json_t *state,
 
 
 static void
-unselect_country (const json_t *state,
+unselect_country (json_t *state,
                   const json_t *arguments,
                   ANASTASIS_ActionCallback cb,
                   void *cb_cls)
@@ -275,7 +279,7 @@ unselect_country (const json_t *state,
 
 
 static void
-unselect_continent (const json_t *state,
+unselect_continent (json_t *state,
                     const json_t *arguments,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
@@ -294,7 +298,7 @@ unselect_continent (const json_t *state,
 
 
 static void
-enter_user_attributes (const json_t *state,
+enter_user_attributes (json_t *state,
                        const json_t *arguments,
                        ANASTASIS_ActionCallback cb,
                        void *cb_cls)
@@ -389,7 +393,7 @@ ANASTASIS_redux_action (const json_t *state,
     },
     {
       "CountrySelectionState",
-      "select_continent",
+      "unselect_continent",
       &unselect_continent
     },
     {
@@ -410,14 +414,14 @@ ANASTASIS_redux_action (const json_t *state,
     { NULL, NULL, NULL }
   };
   json_t *new_state;
-  const char *s_mode = "backup-state";
+  const char *s_mode = "backup_state";
   const char *s = json_string_value (json_object_get (state,
-                                                      "backup-state"));
+                                                      "backup_state"));
   if (NULL == s)
   {
     s = json_string_value (json_object_get (state,
-                                            "recovery-state"));
-    s_mode = "recovery-state";
+                                            "recovery_state"));
+    s_mode = "recovery_state";
     if (NULL == s)
     {
       GNUNET_break (0);

-- 
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]