gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: add logic to render expirat


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: add logic to render expiration times and fees
Date: Sun, 11 Jul 2021 22:14:12 +0200

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 392eea2  add logic to render expiration times and fees
392eea2 is described below

commit 392eea22eeceadabf92f1610ae60d917befdef51
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jul 11 22:14:10 2021 +0200

    add logic to render expiration times and fees
---
 src/anastasis/anastasis-gtk_action.c | 92 +++++++++++++++++++++++++++---------
 1 file changed, 69 insertions(+), 23 deletions(-)

diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 67736f6..528f81f 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1035,22 +1035,50 @@ action_policies_reviewing (void)
 }
 
 
+/**
+ * Function called when we begin editing the secret.
+ */
 static void
 action_secret_editing (void)
 {
+  struct GNUNET_TIME_Absolute exp_time;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_absolute_time ("expiration",
+                                    &exp_time),
+    GNUNET_JSON_spec_end ()
+  };
+  struct tm tv;
 
   AG_hide_all_frames ();
+
+  if (GNUNET_OK !=
+      GNUNET_JSON_parse (AG_redux_state,
+                         spec,
+                         NULL, NULL))
+  {
+    GNUNET_break (0);
+    AG_error ("State did not parse correctly: lacks expiration");
+    return;
+  }
+
+  {
+    time_t t;
+
+    t = exp_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
+    GNUNET_assert (NULL !=
+                   localtime_r (&t,
+                                &tv));
+  }
+
   {
     GtkLabel *fee_label;
-    struct TALER_Amount fee = {
-      .value = 0
-    };
+    json_t *fees;
 
     fee_label = GTK_LABEL (GCG_get_main_window_object (
                              "backup_fee_value_label"));
-    GNUNET_break (0); // FIXME: get backup fee from model!
-    if ( (0 == fee.value) &&
-         (0 == fee.fraction) )
+    fees = json_object_get (AG_redux_state,
+                            "upload_fees");
+    if (0 == json_array_size (fees))
     {
       gtk_label_set_text (fee_label,
                           _ (/* in the sense of gratis */
@@ -1058,13 +1086,39 @@ action_secret_editing (void)
     }
     else
     {
-      char *val;
+      char *val = GNUNET_strdup ("");
+      size_t pos;
+      json_t *fee;
+      struct TALER_Amount a;
+
+      json_array_foreach (fees, pos, fee)
+      {
+        struct GNUNET_JSON_Specification spec[] = {
+          TALER_JSON_spec_amount ("fee",
+                                  &a),
+          GNUNET_JSON_spec_end ()
+        };
+        char *tmp;
+
+        if (GNUNET_OK !=
+            GNUNET_JSON_parse (fee,
+                               spec,
+                               NULL, NULL))
+        {
+          GNUNET_break (0);
+          continue;
+        }
 
-      GNUNET_asprintf (&val,
-                       "%llu.%u %s",
-                       (unsigned long long) fee.value,
-                       (unsigned int) fee.fraction,
-                       fee.currency);
+        GNUNET_asprintf (&tmp,
+                         "%s%s%llu.%u %s",
+                         val,
+                         strlen (val) > 0 ? ", " : "",
+                         (unsigned long long) a.value,
+                         (unsigned int) a.fraction,
+                         a.currency);
+        GNUNET_free (val);
+        val = tmp;
+      }
       gtk_label_set_text (fee_label,
                           val);
       GNUNET_free (val);
@@ -1072,19 +1126,10 @@ action_secret_editing (void)
   }
   {
     GtkLabel *expiration_label;
-    struct GNUNET_TIME_Absolute exp_time;
     char estr[128];
-    struct tm tv;
-    time_t t;
 
     expiration_label = GTK_LABEL (GCG_get_main_window_object (
                                     "expiration_date_without_year_label"));
-    // FIXME: get expiration from model!
-    exp_time = GNUNET_TIME_absolute_get ();
-    t = exp_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
-    GNUNET_assert (NULL !=
-                   localtime_r (&t,
-                                &tv));
     GNUNET_assert (sizeof (estr) >
                    strftime (estr,
                              sizeof (estr),
@@ -1093,6 +1138,7 @@ action_secret_editing (void)
     gtk_label_set_text (expiration_label,
                         estr);
   }
+
   {
     GtkSpinButton *sb;
     unsigned int this_year;
@@ -1105,11 +1151,11 @@ action_secret_editing (void)
     gtk_spin_button_set_range (sb,
                                this_year + 1,
                                this_year + 6);
-    GNUNET_break (0); // FIXME: obtain current expiration from model!
-    exp_year = this_year + 1;
+    exp_year = tv.tm_year + 1900;
     gtk_spin_button_set_value (sb,
                                (double) exp_year);
   }
+
   {
     GtkEntry *entry;
     const char *name = "";

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