gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: worked on redux


From: gnunet
Subject: [taler-anastasis] branch master updated: worked on redux
Date: Thu, 10 Sep 2020 16:24:24 +0200

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

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

The following commit(s) were added to refs/heads/master by this push:
     new e97f6d4  worked on redux
e97f6d4 is described below

commit e97f6d479fb935e30858d9fe1e49c28052ae2b4d
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Thu Sep 10 16:24:13 2020 +0200

    worked on redux
---
 contrib/Makefile.am                               | 16 +++++
 contrib/redux.ch.json                             |  9 ++-
 contrib/redux.countries.json                      | 34 ++++++----
 contrib/redux.de.json                             | 30 +++++++++
 src/include/anastasis_redux.h                     | 11 +++-
 src/lib/{redux.c => anastasis_api_backup_redux.c} | 80 +++++++++++++++++++++--
 6 files changed, 160 insertions(+), 20 deletions(-)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
new file mode 100644
index 0000000..84424af
--- /dev/null
+++ b/contrib/Makefile.am
@@ -0,0 +1,16 @@
+# This Makefile.am is in the public domain
+# Process this file with automake to produce Makefile.in
+
+SUBDIRS = .
+
+pkgdatadir= $(prefix)/share/anastasis/
+
+EXTRA_DIST = \
+  $(pkgdata_DATA) \
+  get_version.sh \
+  pogen.sh
+
+pkgdata_DATA = \
+  redux.ch.json \
+  redux.de.json \
+  redux.countries.json
diff --git a/contrib/redux.ch.json b/contrib/redux.ch.json
index 63b900b..923b847 100644
--- a/contrib/redux.ch.json
+++ b/contrib/redux.ch.json
@@ -4,17 +4,20 @@
            "type": "string",
            "name": "full_name",
            "label": "Full name",
-           "label_i18n":{"de":"Vollstaendiger Name"},
+               "label_i18n":{
+                                               "de_DE":"Vollstaendiger Name",
+                                               "de_CH":"Vollstaendiger Name"
+                                        },
            "widget": "ANASTASIS_IA_full_name"
        },
        {
            "type": "date",
            "name": "birthdate",
            "label": "Birthdate",
-           "label_i18n":{"de":"Geburtsdatum"},
+           "label_i18n":{"de_CH":"Geburtsdatum"},
            "widget": "ANASTASIS_IA_birthdate"
        }
-       ],
+       ]
 }
 
 
diff --git a/contrib/redux.countries.json b/contrib/redux.countries.json
index 1756a2c..1d684e2 100644
--- a/contrib/redux.countries.json
+++ b/contrib/redux.countries.json
@@ -1,17 +1,27 @@
 {
     "countries": [
-       { "code" : "ch",
-         "continent" : "Europe",
-         "name" : "Switzerland",
-         "name_i18n" : { "de":"Schweiz" },
-         "currency": "CHR"
-       },
-       { "code" : "de",
-         "name" : "Germany",
-         "continent" : "Europe",
-         "continent_i18n" : { "de" : "Europa" },
-         "name_i18n" : { "de_CH":"Grosses Kanton" },
-         "currency": "EUR"
+       { 
+               "code" : "ch",
+               "name" : "Switzerland",
+               "continent" : "Europe",
+               "name_i18n" : { 
+                                                       "de_DE":"Schweiz",
+                                                       "de_CH":"Schwiiz",
+                                                       "fr":"Suisse",
+                                                       "en": "Swiss" 
+                                               },
+               "currency": "CHF"
        },
+       { 
+               "code" : "de",
+               "name" : "Germany",
+               "continent" : "Europe",
+               "continent_i18n" : { "de" : "Europa" },
+               "name_i18n" : { "de_DE":"Deutschland",
+                                               "de_CH":"Deutschland",
+                                               "fr": "Allemagne",
+                                               "en": "Germany" },
+               "currency": "EUR"
+       }
     ]
 }
diff --git a/contrib/redux.de.json b/contrib/redux.de.json
new file mode 100644
index 0000000..a0225e1
--- /dev/null
+++ b/contrib/redux.de.json
@@ -0,0 +1,30 @@
+{
+    "required_attributes": [
+       {
+           "type": "string",
+           "name": "full_name",
+           "label": "Full name",
+           "label_i18n":{
+                                               "de_DE": "Vollstaendiger Name",
+                                               "de_CH": "Vollstaendiger Name",
+                                               "fr": "Nom complet",
+                                               "en": "Full name"
+                                        },
+           "widget": "ANASTASIS_IA_full_name"
+       },
+       {
+           "type": "date",
+           "name": "birthdate",
+           "label": "Birthdate",
+           "label_i18n":{
+                                               "de_DE":"Geburtsdatum",
+                                               "de_CH":"Geburtsdatum",
+                                               "fr":"Date de naissance",
+                                               "en":"Birthdate"
+                                       },
+           "widget": "ANASTASIS_IA_birthdate"
+       }
+       ]
+}
+
+
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index 7d978a9..72ab34e 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -27,6 +27,15 @@
 #include <gnunet/gnunet_util_lib.h>
 #include "anastasis_error_codes.h"
 
+/**
+ * JSON containing all supported countries and additional data.
+ */
+extern json_t *redux_countries;
+
+/**
+ * JSON containing country specific identity attributes to ask the user for.
+ */
+extern json_t *redux_id_attr;
 
 /**
  * Returns an initial ANASTASIS backup state.
@@ -103,4 +112,4 @@ ANASTASIS_recovery_action (const json_t *state,
                            void *cb_cls);
 
 
-#endif  /* _ANASTASIS_JSON_H */
+#endif  /* _ANASTASIS_REDUX_H */
diff --git a/src/lib/redux.c b/src/lib/anastasis_api_backup_redux.c
similarity index 56%
rename from src/lib/redux.c
rename to src/lib/anastasis_api_backup_redux.c
index f8db250..533b199 100644
--- a/src/lib/redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -1,6 +1,52 @@
+/*
+  This file is part of Anastasis
+  Copyright (C) 2020 Taler Systems SA
+
+  Anastasis is free software; you can redistribute it and/or modify it under 
the
+  terms of the GNU Lesser General Public License as published by the Free 
Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  Anastasis; see the file COPYING.GPL.  If not, see 
<http://www.gnu.org/licenses/>
+*/
+/**
+ * @file lib/anastasis_api_backup_redux.c
+ * @brief anastasis reducer api
+ * @author Christian Grothoff
+ * @author Dominik Meister
+ * @author Dennis Neufeld
+ */
+
+#include <platform.h>
+#include <jansson.h>
+#include "anastasis_redux.h"
+#include "anastasis_error_codes.h"
+
+/**
+ * JSON containing all supported countries and additional data.
+ */
+json_t *redux_countries;
+
+/**
+ * JSON containing country specific identity attributes to ask the user for.
+ */
+json_t *redux_id_attr;
+
+/**
+ * Callback function FIXME: Description.
+ *
+ *  @param state FIXME: Description
+ *  @param arguments FIXME: Description
+ *  @param cb FIXME: Description
+ *  @param cb_cls FIXME: Description
+ */
 typedef void
 (*DispatchHandler)(const json_t *state,
-                   const jons_t *arguments,
+                   const json_t *arguments,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
 
@@ -13,11 +59,36 @@ json_t *
 ANASTASIS_backup_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   json_t *initial_state;
+  const char *temp_key;
+  json_t *temp_value;
+  json_t *root = json_object_get (redux_countries, "countries");
+  json_t *continents = json_array ();
 
+  json_object_foreach (root, temp_key, temp_value)
+  {
+    size_t index;
+    json_t *inner_temp_value;
+    bool contains = false;
+
+    if (temp_key == "continent")
+      json_array_foreach (continents,
+                          index,
+                          inner_temp_value)
+      {
+        if (inner_temp_value == temp_value)
+        {
+          contains = true;
+          break;
+        }
+      }
+
+      if (contains)
+        json_array_append_new (continents, temp_value);
+  }
 
   initial_state = json_object_pack ("{s:s, s:o}",
                                     "backup-state", "ReduxInitialBackupState",
-                                    "continents", FIXME);
+                                    "continents", continents);
   return initial_state;
 }
 
@@ -41,7 +112,8 @@ select_continent (const json_t *state,
   {
     GNUNET_break (0);
     cb (cb_cls,
-        error);
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
   }
   new_state = json_deep_copy (state);
   // FIXME: get list of countries for 'continent'
@@ -53,7 +125,7 @@ select_continent (const json_t *state,
                        "continent",
                        json_string (continent));
   cb (cb_cls,
-      TALER_EC_NONE,
+      ANASTASIS_EC_NONE,
       new_state);
   json_decref (new_state);
 }

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