[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: show recovery document
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: show recovery document |
Date: |
Sun, 14 Mar 2021 22:03:41 +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 17cd871 show recovery document
17cd871 is described below
commit 17cd871a497f208469a1c80d8d1273c5387fb095
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sun Mar 14 22:03:38 2021 +0100
show recovery document
---
contrib/anastasis_gtk_main_window.glade | 74 +++++++++-
src/anastasis/anastasis-gtk_action.c | 164 ++++++++++++++++++++-
.../anastasis-gtk_handle-recovery-button-clicked.c | 2 +-
3 files changed, 235 insertions(+), 5 deletions(-)
diff --git a/contrib/anastasis_gtk_main_window.glade
b/contrib/anastasis_gtk_main_window.glade
index 25d28a5..37a1077 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -1117,10 +1117,80 @@ Author: Christian Grothoff, Dennis Neufeld
</packing>
</child>
<child>
- <object class="GtkLabel"
id="anastasis_gtk_open_challenge_label">
+ <object class="GtkAlignment">
<property
name="visible">True</property>
<property
name="can-focus">False</property>
- <property name="label"
translatable="yes">DYNAMIC TEXT EXPLAINING CHALLENGES NEEDED TO RECOVER
SECRET.</property>
+ <property
name="top-padding">10</property>
+ <property
name="bottom-padding">10</property>
+ <property
name="left-padding">12</property>
+ <child>
+ <object
class="GtkScrolledWindow">
+ <property
name="visible">True</property>
+ <property
name="can-focus">True</property>
+ <property
name="shadow-type">in</property>
+ <child>
+ <object class="GtkTreeView"
id="anastasis_gtk_choose_policy_treeview">
+ <property
name="visible">True</property>
+ <property
name="can-focus">True</property>
+ <property
name="model">policy_review_treestore</property>
+ <property
name="enable-search">False</property>
+ <property
name="search-column">0</property>
+ <child
internal-child="selection">
+ <object
class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object
class="GtkTreeViewColumn" id="policy_name_column1">
+ <property
name="sizing">autosize</property>
+ <property name="title"
translatable="yes">Policy</property>
+ <child>
+ <object
class="GtkCellRendererText" id="policy_name_column2"/>
+ <attributes>
+ <attribute
name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object
class="GtkTreeViewColumn" id="challenge_type_column2">
+ <property
name="sizing">autosize</property>
+ <property name="title"
translatable="yes">Type</property>
+ <child>
+ <object
class="GtkCellRendererText" id="challenge_type_column3"/>
+ <attributes>
+ <attribute
name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object
class="GtkTreeViewColumn" id="policy_cost1">
+ <property
name="sizing">autosize</property>
+ <property name="title"
translatable="yes">Cost</property>
+ <child>
+ <object
class="GtkCellRendererText" id="cost_column1"/>
+ <attributes>
+ <attribute
name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object
class="GtkTreeViewColumn" id="provider_column1">
+ <property name="title"
translatable="yes">Provider</property>
+ <child>
+ <object
class="GtkCellRendererText" id="provider_url_column1">
+ <property
name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute
name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property
name="expand">False</property>
diff --git a/src/anastasis/anastasis-gtk_action.c
b/src/anastasis/anastasis-gtk_action.c
index 627941e..7c9dfbd 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -453,10 +453,10 @@ action_user_attributes_collecting (void)
// FIXME: add KNOWN attributes from state to widgets!
AG_sensitive ("anastasis_gtk_main_window_prev_button");
+ AG_identity_changed ();
AG_show ("anastasis_gtk_main_control_vbox");
AG_show ("anastasis_gtk_main_window_prev_button");
AG_show ("anastasis_gtk_main_window_forward_button");
- AG_identity_changed ();
AG_show ("anastasis_gtk_identity_frame");
AG_show ("anastasis_gtk_user_attributes_image");
}
@@ -1223,6 +1223,37 @@ remove_child (GtkWidget *child,
}
+static const json_t *
+find_challenge_by_uuid (const char *uuid)
+{
+ json_t *rd;
+ json_t *cs;
+ size_t index;
+ json_t *c;
+
+ rd = json_object_get (redux_state,
+ "recovery_document");
+ cs = json_object_get (rd,
+ "cs");
+ json_array_foreach (cs, index, c)
+ {
+ const char *u;
+
+ u = json_string_value (json_object_get (c,
+ "uuid"));
+ if (NULL == u)
+ {
+ GNUNET_break (0);
+ continue;
+ }
+ if (0 == strcmp (u,
+ uuid))
+ return c;
+ }
+ return NULL;
+}
+
+
static void
action_challenge_selecting (void)
{
@@ -1232,7 +1263,132 @@ action_challenge_selecting (void)
GtkBox *box;
AG_hide_all_frames ();
- AG_show ("anastasis_gtk_challenge_frame");
+
+ {
+ GtkTreeStore *ts;
+ json_t *policies;
+ size_t pindex;
+ json_t *policy;
+ char *summary = NULL;
+ struct TALER_Amount total;
+ json_t *rd;
+
+ ts = GTK_TREE_STORE (GCG_get_main_window_object (
+ "policy_review_treestore"));
+ gtk_tree_store_clear (ts);
+ rd = json_object_get (redux_state,
+ "recovery_document");
+ policies = json_object_get (rd,
+ "dps");
+ GNUNET_assert (NULL != policies);
+ json_array_foreach (policies, pindex, policy)
+ {
+ json_t *challenges;
+ size_t index;
+ json_t *challenge;
+ GtkTreeIter piter;
+
+ gtk_tree_store_insert_with_values (ts,
+ &piter,
+ NULL, /* no parent */
+ -1, /* append */
+ -1);
+ challenges = json_object_get (policy,
+ "challenges");
+ if (NULL == challenges)
+ {
+ GNUNET_break_op (0);
+ AG_error ("Policy did not parse correctly");
+ return;
+ }
+ json_array_foreach (challenges, index, challenge)
+ {
+ const char *uuid = json_string_value (json_object_get (challenge,
+ "uuid"));
+ const json_t *cs;
+ const char *type;
+ const char *provider;
+ const char *instructions;
+ struct GNUNET_JSON_Specification pspec[] = {
+ GNUNET_JSON_spec_string ("type",
+ &type),
+ GNUNET_JSON_spec_string ("url",
+ &provider),
+ GNUNET_JSON_spec_string ("instructions",
+ &instructions),
+ GNUNET_JSON_spec_end ()
+ };
+ struct TALER_Amount recovery_cost;
+
+ GNUNET_assert (NULL != uuid);
+ cs = find_challenge_by_uuid (uuid);
+ if (NULL == cs)
+ {
+ GNUNET_break_op (0);
+ AG_error ("Policy did not parse correctly");
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (cs,
+ pspec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ AG_error ("Policy did not parse correctly");
+ return;
+ }
+
+ lookup_recovery_cost (provider,
+ type,
+ &recovery_cost);
+ gtk_tree_store_insert_with_values (ts,
+ NULL,
+ &piter, /* parent */
+ -1, /* append */
+ AG_PRMC_POLICY_NAME,
+ instructions,
+ AG_PRMC_METHOD_TYPE,
+ type,
+ AG_PRMC_COST,
+ TALER_amount2s (&recovery_cost),
+ AG_PRMC_PROVIDER_URL,
+ provider,
+ -1);
+ if (NULL == summary)
+ {
+ summary = GNUNET_strdup (type);
+ total = recovery_cost;
+ }
+ else
+ {
+ char *tmp;
+
+ if (TALER_amount_add (&total,
+ &total,
+ &recovery_cost))
+ {
+ GNUNET_break_op (0);
+ AG_error ("Could not add up costs");
+ }
+ GNUNET_asprintf (&tmp,
+ "%s + %s",
+ summary,
+ type);
+ GNUNET_free (summary);
+ summary = tmp;
+ }
+ } /* for each challenge */
+ if (NULL != summary)
+ {
+ gtk_tree_store_set (ts,
+ &piter,
+ AG_PRMC_POLICY_NAME, summary,
+ AG_PRMC_COST, TALER_amount2s (&total),
+ -1);
+ GNUNET_free (summary);
+ }
+ } /* for each policy */
+ }
challenges = json_object_get (redux_state,
"challenges");
box = GTK_BOX (GCG_get_main_window_object (
@@ -1261,6 +1417,9 @@ action_challenge_selecting (void)
GNUNET_break (0);
continue;
}
+ fprintf (stderr,
+ "Making button for %s\n",
+ instructions);
{
char *ins_str;
@@ -1292,6 +1451,7 @@ action_challenge_selecting (void)
}
AG_show ("anastasis_gtk_main_control_vbox");
AG_show ("anastasis_gtk_main_window_save_as_button");
+ AG_show ("anastasis_gtk_challenge_frame");
AG_hide ("anastasis_gtk_main_window_quit_button");
AG_hide ("anastasis_gtk_main_window_prev_button");
AG_hide ("anastasis_gtk_main_window_forward_button");
diff --git a/src/anastasis/anastasis-gtk_handle-recovery-button-clicked.c
b/src/anastasis/anastasis-gtk_handle-recovery-button-clicked.c
index 297472b..e74c4da 100644
--- a/src/anastasis/anastasis-gtk_handle-recovery-button-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-recovery-button-clicked.c
@@ -39,7 +39,7 @@
*/
void
anastasis_gtk_recovery_button_clicked (GObject *object,
- gpointer user_data)
+ gpointer user_data)
{
json_t *j;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis-gtk] branch master updated: show recovery document,
gnunet <=