gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: work on #6827


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: work on #6827
Date: Fri, 02 Apr 2021 22:55:31 +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 4e5190a  work on #6827
4e5190a is described below

commit 4e5190a3484b19cbfdccf5e8585349218c8f2a31
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Apr 2 22:55:29 2021 +0200

    work on #6827
---
 contrib/anastasis_gtk_main_window.glade |   7 +-
 src/anastasis/anastasis-gtk_action.c    | 223 ++++++++++++++++++++++++++++----
 src/anastasis/anastasis-gtk_helper.h    |   4 +
 3 files changed, 207 insertions(+), 27 deletions(-)

diff --git a/contrib/anastasis_gtk_main_window.glade 
b/contrib/anastasis_gtk_main_window.glade
index 9e55f78..0b95296 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
 
@@ -1589,7 +1589,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                             </child>
                                           </object>
                                           <packing>
-                                            <property 
name="expand">False</property>
+                                            <property 
name="expand">True</property>
                                             <property 
name="fill">True</property>
                                             <property 
name="position">1</property>
                                           </packing>
@@ -1613,6 +1613,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                                     <child>
                                                       <object 
class="GtkTreeView" id="anastasis_gtk_choose_policy_treeview">
                                                         <property 
name="visible">True</property>
+                                                        <property 
name="model">policy_review_treestore</property>
                                                         <property 
name="can-focus">True</property>
                                                         <property 
name="tooltip-text" translatable="yes">This table shows possible ways to 
recover the secret. For each policy, the challenges that must still be 
satisfied are listed.</property>
                                                         <property 
name="enable-search">False</property>
@@ -1689,7 +1690,7 @@ Author: Christian Grothoff, Dennis Neufeld
                                             </child>
                                           </object>
                                           <packing>
-                                            <property 
name="expand">False</property>
+                                            <property 
name="expand">True</property>
                                             <property 
name="fill">True</property>
                                             <property 
name="position">2</property>
                                           </packing>
diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index e47b590..9edc968 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -843,6 +843,13 @@ action_policies_reviewing (void)
     }
     GNUNET_JSON_parse_free (pspec);
   }
+  {
+    GtkTreeView *tv;
+
+    tv = GTK_TREE_VIEW (GCG_get_main_window_object (
+                          "anastasis_gtk_review_policy_treeview"));
+    gtk_tree_view_expand_all (tv);
+  }
   AG_sensitive ("anastasis_gtk_main_window_prev_button");
   AG_sensitive ("anastasis_gtk_main_window_forward_button");
   AG_show ("anastasis_gtk_b_policy_frame");
@@ -1216,6 +1223,8 @@ action_backup_finished (void)
                                        -1, /* append */
                                        AG_BPC_PROVIDER_URL, url,
                                        AG_BPC_BACKUP_VERSION, (guint64) 
version,
+                                       AG_BPC_FAILURE_FLAG, false,
+                                       AG_BPC_SUCCESS_FLAG, true,
                                        -1);
   }
   AG_show ("anastasis_gtk_completed_frame");
@@ -1309,6 +1318,167 @@ find_challenge_by_uuid (const char *uuid)
 }
 
 
+/**
+ * Find out offset of challenge with the given @a uuid in the
+ * "cs" array.
+ *
+ * @param[out] roff set to the offset
+ * @param[out] cost set to the cost of the challenge
+ */
+static int
+get_challenge_offset (const char *uuid,
+                      guint *roff,
+                      struct TALER_Amount *cost)
+{
+  const json_t *recdoc;
+  const json_t *cs;
+  const json_t *c;
+  size_t off;
+
+  recdoc = json_object_get (AG_redux_state,
+                            "recovery_document");
+  GNUNET_assert (NULL != recdoc);
+  cs = json_object_get (recdoc,
+                        "cs");
+  GNUNET_assert (NULL != cs);
+  json_array_foreach (cs, off, c)
+  {
+    const char *provider;
+    const char *type;
+    const char *u;
+    struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_string ("type",
+                               &type),
+      GNUNET_JSON_spec_string ("url",
+                               &provider),
+      GNUNET_JSON_spec_string ("uuid",
+                               &u),
+      GNUNET_JSON_spec_end ()
+    };
+
+    if (GNUNET_OK !=
+        GNUNET_JSON_parse (c,
+                           spec,
+                           NULL, NULL))
+    {
+      GNUNET_break (0);
+      continue;
+    }
+    if (0 == strcmp (uuid,
+                     u))
+    {
+      *roff = off;
+      lookup_recovery_cost (provider,
+                            type,
+                            cost);
+      return GNUNET_OK;
+    }
+  }
+  GNUNET_break (0);
+  return GNUNET_SYSERR;
+}
+
+
+/**
+ * Update the list store with the challenge feedback.
+ */
+static void
+show_challenge_feedback (void)
+{
+  GtkListStore *ls;
+  json_t *cf;
+  const json_t *f;
+  const char *uuid;
+
+  ls = GTK_LIST_STORE (GCG_get_main_window_object (
+                         "challenge_status_liststore"));
+  gtk_list_store_clear (ls);
+  cf = json_object_get (AG_redux_state,
+                        "challenge_feedback");
+  json_object_foreach (cf, uuid, f)
+  {
+    const char *state;
+    const char *redirect_url = NULL;
+    const char *instructions = NULL;
+    const char *taler_pay_uri = NULL;
+    uint32_t ec = 0;
+    uint32_t http_status = 0;
+    struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_string ("state",
+                               &state),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_string ("taler_pay_uri",
+                                 &taler_pay_uri)),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_string ("redirect_url",
+                                 &redirect_url)),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_string ("instructions",
+                                 &instructions)),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_uint32 ("http_status",
+                                 &http_status)),
+      GNUNET_JSON_spec_mark_optional (
+        GNUNET_JSON_spec_uint32 ("error_code",
+                                 &ec)),
+      GNUNET_JSON_spec_end ()
+    };
+    struct TALER_Amount cost;
+    guint off;
+    GdkPixbuf *qr = NULL;
+    const char *emsg = NULL;
+
+    if (GNUNET_OK !=
+        GNUNET_JSON_parse (f,
+                           spec,
+                           NULL, NULL))
+    {
+      GNUNET_break (0);
+      json_dumpf (f,
+                  stderr,
+                  JSON_INDENT (2));
+      continue;
+    }
+    if (GNUNET_OK !=
+        get_challenge_offset (uuid,
+                              &off,
+                              &cost))
+    {
+      GNUNET_break (0);
+      continue;
+    }
+    if (NULL != taler_pay_uri)
+    {
+      qr = setup_qrcode ("anastasis_gtk_challenge_status_treeview",
+                         taler_pay_uri,
+                         strlen (taler_pay_uri));
+    }
+    if (TALER_EC_NONE != ec)
+      emsg = TALER_ErrorCode_get_hint (ec);
+    if (0 == strcmp (state,
+                     "instructions"))
+      emsg = instructions; // FIXME: deal with JSON instructions nicely!
+    gtk_list_store_insert_with_values (
+      ls,
+      NULL,
+      -1,                                  /* append */
+      AG_CSM_CHALLENGE_OFFSET, off,
+      AG_CSM_CHALLENGE_UUID, uuid,
+      AG_CSM_SOLVED, 0 == strcmp (state, "solved"),
+      AG_CSM_STATUS, state,
+      AG_CSM_PAYMENT_QR_CODE, qr,
+      AG_CSM_ERROR_MESSAGE, emsg,
+      AG_CSM_PAYTO_URI, taler_pay_uri,
+      AG_CSM_PAYING, 0 == strcmp (state, "payment"),
+      AG_CSM_HAS_ERROR, NULL != emsg,
+      AG_CSM_COST, TALER_amount2s (&cost),
+      AG_CSM_REDIRECT_URL, redirect_url,
+      AG_CSM_HAVE_REDIRECT, 0 == strcmp (state, "redirect"),
+      -1);
+  }
+}
+
+
 static void
 action_challenge_selecting (void)
 {
@@ -1321,6 +1491,7 @@ action_challenge_selecting (void)
   json_t *re;
 
   AG_hide_all_frames ();
+  show_challenge_feedback ();
   {
     GtkComboBoxText *bt;
     json_t *aps;
@@ -1434,7 +1605,6 @@ action_challenge_selecting (void)
     size_t pindex;
     json_t *policy;
     char *summary = NULL;
-    struct TALER_Amount total;
 
     ts = GTK_TREE_STORE (GCG_get_main_window_object (
                            "policy_review_treestore"));
@@ -1449,11 +1619,10 @@ action_challenge_selecting (void)
       json_t *challenge;
       GtkTreeIter piter;
 
-      gtk_tree_store_insert_with_values (ts,
-                                         &piter,
-                                         NULL, /* no parent */
-                                         -1, /* append */
-                                         -1);
+      gtk_tree_store_insert (ts,
+                             &piter,
+                             NULL, /* no parent */
+                             -1 /* append */);
       challenges = json_object_get (policy,
                                     "challenges");
       if (NULL == challenges)
@@ -1527,19 +1696,11 @@ action_challenge_selecting (void)
         if (NULL == summary)
         {
           summary = GNUNET_strdup (type);
-          total = recovery_cost;
         }
         else
         {
           char *tmp;
 
-          if (0 > TALER_amount_add (&total,
-                                    &total,
-                                    &recovery_cost))
-          {
-            GNUNET_break_op (0);
-            AG_error ("ERROR: Could not add up costs");
-          }
           GNUNET_asprintf (&tmp,
                            "%s + %s",
                            summary,
@@ -1553,12 +1714,18 @@ action_challenge_selecting (void)
         gtk_tree_store_set (ts,
                             &piter,
                             AG_PRMC_POLICY_NAME, summary,
-                            AG_PRMC_COST, TALER_amount2s (&total),
                             -1);
         GNUNET_free (summary);
       }
     } /* for each policy */
   }
+  {
+    GtkTreeView *tv;
+
+    tv = GTK_TREE_VIEW (GCG_get_main_window_object (
+                          "anastasis_gtk_choose_policy_treeview"));
+    gtk_tree_view_expand_all (tv);
+  }
   challenges = json_object_get (rd,
                                 "cs");
   box = GTK_BOX (GCG_get_main_window_object (
@@ -1792,7 +1959,12 @@ render_feedback (GtkBuilder *builder,
     return;
 
   elabel = GTK_LABEL (gtk_builder_get_object (builder,
-                                              
"anastasis_gtk_c_code_error_label"));
+                                              target_widget));
+  if (NULL == elabel)
+  {
+    GNUNET_break (0);
+    return;
+  }
   if (GNUNET_OK !=
       GNUNET_JSON_parse (cs,
                          spec,
@@ -1913,8 +2085,6 @@ diag_question (const json_t *details)
 {
   GtkBuilder *builder;
   GtkDialog *ad;
-  GtkLabel *label;
-  const char *instructions;
 
   builder = GNUNET_GTK_get_new_builder (
     "anastasis_gtk_challenge_question.glade",
@@ -1926,12 +2096,17 @@ diag_question (const json_t *details)
   }
   ad = GTK_DIALOG (gtk_builder_get_object (builder,
                                            "anastasis_gtk_c_question_dialog"));
-  label = GTK_LABEL (gtk_builder_get_object (builder,
-                                             "security_question_label"));
-  instructions = json_string_value (json_object_get (details,
-                                                     "instructions"));
-  gtk_label_set_text (label,
-                      instructions);
+  {
+    GtkLabel *label;
+    const char *instructions;
+
+    label = GTK_LABEL (gtk_builder_get_object (builder,
+                                               "security_question_label"));
+    instructions = json_string_value (json_object_get (details,
+                                                       "instructions"));
+    gtk_label_set_text (label,
+                        instructions);
+  }
   {
     const char *uuid_str;
 
diff --git a/src/anastasis/anastasis-gtk_helper.h 
b/src/anastasis/anastasis-gtk_helper.h
index fc2a9ae..02e8681 100644
--- a/src/anastasis/anastasis-gtk_helper.h
+++ b/src/anastasis/anastasis-gtk_helper.h
@@ -204,10 +204,12 @@ enum AG_AuthenticationMethodsModelColumns
    * A gchararray.
    */
   AG_AMMC_TYPE = 0,
+
   /**
    * A gchararray.
    */
   AG_AMMC_VISUALIZATION = 1,
+
   /**
    * A guint.
    */
@@ -224,10 +226,12 @@ enum AG_UnpaidQrcodesModelColumns
    * A GdkPixbuf.
    */
   AG_UQRMC_QR_IMAGE = 0,
+
   /**
    * A gchararray.
    */
   AG_UQRMC_URL = 1,
+
   /**
    * A gchararray.
    */

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