gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: enable add_provider also later


From: gnunet
Subject: [taler-anastasis] branch master updated: enable add_provider also later
Date: Tue, 09 Mar 2021 21:25:21 +0100

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new bedac41  enable add_provider also later
bedac41 is described below

commit bedac41c67d81e92628543580e74468cf158c090
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Mar 9 21:25:18 2021 +0100

    enable add_provider also later
---
 src/reducer/anastasis_api_backup_redux.c | 85 ++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/src/reducer/anastasis_api_backup_redux.c 
b/src/reducer/anastasis_api_backup_redux.c
index abf4efa..55ee482 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -760,6 +760,86 @@ done_authentication (json_t *state,
 }
 
 
+/* ******************** add_provider ******************* */
+
+
+/**
+ * DispatchHandler/Callback function which is called for a
+ * "add_provider" action.  Adds another Anastasis provider
+ * to the list of available providers for storing information.
+ *
+ * @param state state to operate on
+ * @param arguments arguments with a provider URL to add
+ * @param cb callback to call during/after operation
+ * @param cb_cls callback closure
+ */
+static struct ANASTASIS_ReduxAction *
+add_provider (json_t *state,
+              const json_t *arguments,
+              ANASTASIS_ActionCallback cb,
+              void *cb_cls)
+{
+  json_t *urls;
+  json_t *tlist;
+
+  tlist = json_object_get (state,
+                           "authentication_providers");
+  if (NULL == tlist)
+  {
+    tlist = json_object ();
+    GNUNET_assert (NULL != tlist);
+    GNUNET_assert (0 ==
+                   json_object_set_new (state,
+                                        "authentication_providers",
+                                        tlist));
+  }
+  if (NULL == arguments)
+  {
+    ANASTASIS_redux_fail_ (cb,
+                           cb_cls,
+                           TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+                           "arguments missing");
+    return NULL;
+  }
+  urls = json_object_get (arguments,
+                          "urls");
+  if (NULL == urls)
+  {
+    ANASTASIS_redux_fail_ (cb,
+                           cb_cls,
+                           TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+                           "'urls' missing");
+    return NULL;
+  }
+  {
+    size_t index;
+    json_t *url;
+
+    json_array_foreach (urls, index, url)
+    {
+      const char *url_str = json_string_value (url);
+
+      if (NULL == url_str)
+      {
+        ANASTASIS_redux_fail_ (cb,
+                               cb_cls,
+                               TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+                               "'urls' must be strings");
+        return NULL;
+      }
+      GNUNET_assert (0 ==
+                     json_object_set_new (tlist,
+                                          url_str,
+                                          json_object ()));
+    }
+  }
+  return ANASTASIS_REDUX_backup_begin_ (state,
+                                        NULL,
+                                        cb,
+                                        cb_cls);
+}
+
+
 /* ******************** add_policy ******************* */
 
 
@@ -2411,6 +2491,11 @@ ANASTASIS_backup_action_ (json_t *state,
       "next",
       &done_authentication
     },
+    {
+      ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING,
+      "add_provider",
+      &add_provider
+    },
     {
       ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING,
       "back",

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