gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: towards having a policy rev


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: towards having a policy reviewing dialog
Date: Fri, 12 Mar 2021 11:35:53 +0100

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

grothoff pushed a commit to branch master
in repository anastasis-gtk.

The following commit(s) were added to refs/heads/master by this push:
     new 31892ba  towards having a policy reviewing dialog
31892ba is described below

commit 31892babcde305fcc7dfbe22af0ea1365da6204c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Mar 12 11:35:51 2021 +0100

    towards having a policy reviewing dialog
---
 contrib/anastasis_gtk_main_window.glade   |  10 +-
 src/anastasis/Makefile.am                 |   1 +
 src/anastasis/anastasis-gtk_action.c      | 153 +++++++++++++++++++++++++++++-
 src/testing/test_anastasis_reducer_4.conf |   2 +-
 4 files changed, 154 insertions(+), 12 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 6c3c363..0df7746 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 
+<!-- Generated with glade 3.38.2
 
 Copyright (C) Anastasis SARL
 
@@ -87,9 +87,7 @@ Author: Christian Grothoff, Dennis Neufeld
       <column type="gchararray"/>
       <!-- column-name method_type -->
       <column type="gchararray"/>
-      <!-- column-name method_cost -->
-      <column type="gchararray"/>
-      <!-- column-name total_cost -->
+      <!-- column-name cost -->
       <column type="gchararray"/>
       <!-- column-name provider_url -->
       <column type="gchararray"/>
@@ -1030,7 +1028,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                                 <child>
                                                   <object 
class="GtkCellRendererText" id="cost_column"/>
                                                   <attributes>
-                                                    <attribute 
name="text">3</attribute>
+                                                    <attribute 
name="text">2</attribute>
                                                   </attributes>
                                                 </child>
                                               </object>
@@ -1043,7 +1041,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                                     <property 
name="ellipsize">end</property>
                                                   </object>
                                                   <attributes>
-                                                    <attribute 
name="text">4</attribute>
+                                                    <attribute 
name="text">3</attribute>
                                                   </attributes>
                                                 </child>
                                               </object>
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 7f54aa0..27d081c 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -47,6 +47,7 @@ anastasis_gtk_LDADD = \
   -lgnunetjson \
   -ljansson \
   -ltalerjson \
+  -ltalerutil \
   -lanastasisrest \
   -lanastasisredux \
   $(INTLLIBS)
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 41f1993..8321ac0 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -618,19 +618,162 @@ action_authentications_editing (void)
   AG_show ("anastasis_gtk_main_window_forward_button");
   AG_show ("anastasis_gtk_b_authentication_frame");
   AG_show ("anastasis_gtk_b_authentication_methods_image");
+}
+
 
+/**
+ * Lookup @a method_cost of authentication method @a type at @a provider in our
+ * #redux_state.
+ *
+ * @param provider URL of provider
+ * @param type authentication method to look for
+ * @param[out] method_cost cost to return
+ */
+static void
+lookup_recovery_cost (const char *provider,
+                      const char *type,
+                      struct TALER_Amount *method_cost)
+{
+  memset (method_cost,
+          0,
+          sizeof (struct TALER_Amount));
+  GNUNET_break (0);
+  // redux_state.authentication_providers[url].methods[*].type = type => 
usage_fee
 }
 
 
 static void
 action_policies_reviewing (void)
 {
+  json_t *policies;
+  size_t pindex;
+  json_t *policy;
+  GtkTreeStore *ts;
+
   AG_hide_all_frames ();
-  GNUNET_break (0);
-  json_dumpf (redux_state,
-              stderr,
-              JSON_INDENT (2));
-  // FIXME: import policies into tree model!
+  ts = GTK_TREE_STORE (GCG_get_main_window_object ("policy_review_treestore"));
+  policies = json_object_get (redux_state,
+                              "policies");
+  GNUNET_assert (NULL != policies);
+  json_array_foreach (policies, pindex, policy)
+  {
+    GtkTreeIter piter;
+    struct TALER_Amount recovery_cost;
+    json_t *methods;
+    struct GNUNET_JSON_Specification pspec[] = {
+      TALER_JSON_spec_amount ("recovery_cost",
+                              &recovery_cost),
+      GNUNET_JSON_spec_json ("methods",
+                             &methods),
+      GNUNET_JSON_spec_end ()
+    };
+    size_t mindex;
+    json_t *method;
+    char *summary;
+
+    if (GNUNET_OK !=
+        GNUNET_JSON_parse (policy,
+                           pspec,
+                           NULL, NULL))
+    {
+      GNUNET_break (0);
+      continue;
+    }
+    gtk_tree_store_insert_with_values (ts,
+                                       &piter,
+                                       NULL, /* no parent */
+                                       -1, /* append */
+                                       2,
+                                       TALER_amount2s (&recovery_cost),
+                                       -1);
+
+    summary = NULL;
+    json_array_foreach (methods, mindex, method)
+    {
+      json_t *truth;
+      const char *provider;
+      struct GNUNET_JSON_Specification mspec[] = {
+        GNUNET_JSON_spec_string ("provider",
+                                 &provider),
+        GNUNET_JSON_spec_json ("truth",
+                               &truth),
+        GNUNET_JSON_spec_end ()
+      };
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (method,
+                             mspec,
+                             NULL, NULL))
+      {
+        GNUNET_break (0);
+        continue;
+      }
+      {
+        GtkTreeIter miter;
+        const char *instructions;
+        const char *type;
+        struct GNUNET_JSON_Specification tspec[] = {
+          GNUNET_JSON_spec_string ("instructions",
+                                   &instructions),
+          GNUNET_JSON_spec_string ("type",
+                                   &type),
+          GNUNET_JSON_spec_end ()
+        };
+        struct TALER_Amount method_cost;
+
+        if (GNUNET_OK !=
+            GNUNET_JSON_parse (truth,
+                               tspec,
+                               NULL, NULL))
+        {
+          GNUNET_break (0);
+          continue;
+        }
+        lookup_recovery_cost (provider,
+                              type,
+                              &method_cost);
+        gtk_tree_store_insert_with_values (ts,
+                                           &miter,
+                                           &piter, /* parent */
+                                           -1, /* append */
+                                           0,
+                                           instructions,
+                                           1,
+                                           type,
+                                           2,
+                                           TALER_amount2s (&recovery_cost),
+                                           3,
+                                           provider,
+                                           -1);
+        if (NULL == summary)
+        {
+          summary = GNUNET_strdup (type);
+        }
+        else
+        {
+          char *tmp;
+
+          GNUNET_asprintf (&tmp,
+                           "%s + %s",
+                           summary,
+                           type);
+          GNUNET_free (summary);
+          summary = tmp;
+        }
+      }
+
+
+      GNUNET_JSON_parse_free (mspec);
+    }
+    if (NULL != summary)
+    {
+      gtk_tree_store_set (ts,
+                          &piter,
+                          0, summary,
+                          -1);
+      GNUNET_free (summary);
+    }
+    GNUNET_JSON_parse_free (pspec);
+  }
   AG_sensitive ("anastasis_gtk_main_window_prev_button");
   AG_sensitive ("anastasis_gtk_main_window_forward_button");
   AG_show ("anastasis_gtk_b_policy_frame");
diff --git a/src/testing/test_anastasis_reducer_4.conf 
b/src/testing/test_anastasis_reducer_4.conf
index f3dbda8..fec7a14 100644
--- a/src/testing/test_anastasis_reducer_4.conf
+++ b/src/testing/test_anastasis_reducer_4.conf
@@ -19,6 +19,6 @@ ENABLED = yes
 COMMAND = /bin/false
 
 [authorization-email]
-COST = TESTKUDOS:0.0
+COST = TESTKUDOS:0.01
 ENABLED = yes
 COMMAND = /bin/false

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