[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: -working on new policy disc
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: -working on new policy discovery |
Date: |
Sun, 30 Jan 2022 13:56:33 +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 160075f -working on new policy discovery
160075f is described below
commit 160075f3b5a8728643ae0b05948744f0be39b9e2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jan 30 13:56:31 2022 +0100
-working on new policy discovery
---
contrib/anastasis_gtk_main_window.glade | 94 +++----
src/anastasis/anastasis-gtk_action.c | 303 +++++++++++++++++----
...anastasis-gtk_handle-main-window-back-clicked.c | 1 +
...stasis-gtk_handle-main-window-forward-clicked.c | 1 +
4 files changed, 293 insertions(+), 106 deletions(-)
diff --git a/contrib/anastasis_gtk_main_window.glade
b/contrib/anastasis_gtk_main_window.glade
index c7edb2b..94f1455 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -3492,6 +3492,50 @@ date of your secret's recovery data.</property>
<property
name="visible">True</property>
<property
name="can-focus">False</property>
<property
name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property
name="visible">True</property>
+ <property
name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel"
id="select_secret_hint_label">
+ <property
name="visible">True</property>
+ <property
name="can-focus">False</property>
+ <property
name="halign">start</property>
+ <property name="label"
translatable="yes">Select a secret to recover from the list below. If no
secrets are listed,
+you need to either go back and correct your personal information or
+explicitly add the provider which you used before for the backup.</property>
+ </object>
+ <packing>
+ <property
name="expand">True</property>
+ <property
name="fill">True</property>
+ <property
name="padding">10</property>
+ <property
name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="anastasis_gtk_add_provider_button">
+ <property name="label"
translatable="yes">Add provider</property>
+ <property
name="visible">True</property>
+ <property
name="can-focus">True</property>
+ <property
name="receives-default">True</property>
+ <property
name="image">add_image</property>
+ <signal name="clicked"
handler="anastasis_gtk_add_provider_button_clicked_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">True</property>
+ <property
name="padding">5</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">True</property>
+ <property
name="padding">5</property>
+ <property
name="position">0</property>
+ </packing>
+ </child>
<child>
<object
class="GtkScrolledWindow" id="anastasis_secret_selection_scrolled_window">
<property
name="visible">True</property>
@@ -3590,56 +3634,12 @@ date of your secret's recovery data.</property>
<packing>
<property
name="expand">True</property>
<property
name="fill">True</property>
- <property
name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property
name="visible">True</property>
- <property
name="can-focus">False</property>
- <child>
- <object class="GtkLabel"
id="select_secret_hint_label">
- <property
name="visible">True</property>
- <property
name="can-focus">False</property>
- <property
name="halign">start</property>
- <property name="label"
translatable="yes">Select a secret to recover from the list below. If no
secrets are listed,
-you need to either go back and correct your personal information or
-explicitly add the provider which you used before for the backup.</property>
- </object>
- <packing>
- <property
name="expand">True</property>
- <property
name="fill">True</property>
- <property
name="padding">10</property>
- <property
name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton"
id="anastasis_gtk_add_provider_button">
- <property name="label"
translatable="yes">Add provider</property>
- <property
name="visible">True</property>
- <property
name="can-focus">True</property>
- <property
name="receives-default">True</property>
- <property
name="image">add_image</property>
- <signal name="clicked"
handler="anastasis_gtk_add_provider_button_clicked_cb" swapped="no"/>
- </object>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">True</property>
- <property
name="padding">5</property>
- <property
name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">True</property>
- <property
name="padding">5</property>
- <property
name="position">5</property>
+ <property
name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property
name="expand">False</property>
+ <property
name="expand">True</property>
<property
name="fill">True</property>
<property
name="position">0</property>
</packing>
@@ -3660,7 +3660,7 @@ explicitly add the provider which you used before for the
backup.</property>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
diff --git a/src/anastasis/anastasis-gtk_action.c
b/src/anastasis/anastasis-gtk_action.c
index 8da6719..6aabd19 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -493,7 +493,11 @@ update_label (const char *name,
/**
- * FIXME.
+ * We are entering the tab where the user has to enter their personal
+ * attributes. Show widgets applicable to the selected country, and
+ * dynamically generate widgets if necessary. Furthermore, restore
+ * widget contents from our state (if stored attribute values are
+ * present in our state).
*/
static void
action_user_attributes_collecting (void)
@@ -646,6 +650,7 @@ action_user_attributes_collecting (void)
AG_show ("anastasis_gtk_recovery_progress_scrolled_window");
AG_hide ("anastasis_gtk_backup_progress_scrolled_window");
}
+ AG_show ("anastasis_gtk_main_window_save_as_button");
AG_show ("anastasis_gtk_main_control_vbox");
AG_show ("anastasis_gtk_main_window_prev_button");
AG_enable_next ();
@@ -677,6 +682,9 @@ activate_by_method (json_t *methods)
NULL, NULL))
{
GNUNET_break (0);
+ json_dumpf (method,
+ stderr,
+ JSON_INDENT (2));
continue;
}
@@ -855,6 +863,9 @@ lookup_recovery_cost (const char *provider,
if (NULL == ap)
{
GNUNET_break (0);
+ json_dumpf (aps,
+ stderr,
+ JSON_INDENT (2));
return GNUNET_SYSERR;
}
methods = json_object_get (ap,
@@ -877,6 +888,9 @@ lookup_recovery_cost (const char *provider,
NULL, NULL))
{
GNUNET_break (0);
+ json_dumpf (method,
+ stderr,
+ JSON_INDENT (2));
continue;
}
if (0 == strcmp (mtype,
@@ -887,6 +901,9 @@ lookup_recovery_cost (const char *provider,
}
}
GNUNET_break (0);
+ json_dumpf (methods,
+ stderr,
+ JSON_INDENT (2));
return GNUNET_SYSERR;
}
@@ -1953,61 +1970,105 @@ expand_policy_list (void *cls,
/**
- * Function called when it is time for the user to select a secret
- * from the list of secrets. Builds the respective tree model.
+ * Function called with the results of #ANASTASIS_redux_action on "poll".
+ *
+ * @param cls NULL
+ * @param error_code Error code
+ * @param response new state as result or config information of a provider
*/
static void
-action_secret_selecting (void)
+long_poll_action_cb (void *cls,
+ enum TALER_ErrorCode error_code,
+ json_t *response);
+
+
+/**
+ * Schedules the "poll" action.
+ *
+ * @param cls NULL
+ * FIXME: dead code!??
+ */
+static void
+long_poll_task (void *cls)
{
- GtkListStore *ls;
+ json_t *tspec;
- AG_hide ("anastasis_gtk_start_frame");
- if (AG_have_error)
- AG_show ("anastasis_gtk_error_label");
- AG_hide ("anastasis_gtk_challenge_frame");
- AG_hide ("anastasis_gtk_identity_frame");
- ls = GTK_LIST_STORE (GCG_get_main_window_object (
- "secret_selection_liststore"));
- gtk_list_store_clear (ls);
- GNUNET_assert (NULL != ls);
- GNUNET_assert (NULL == AG_pd);
- AG_pd = ANASTASIS_policy_discovery_start (AG_redux_state,
- NULL,
- &expand_policy_list,
- ls);
- AG_show ("anastasis_gtk_progress_vbox");
- AG_progress_update ();
- AG_show ("anastasis_gtk_recovery_progress_scrolled_window");
- AG_hide ("anastasis_gtk_backup_progress_scrolled_window");
- AG_show ("anastasis_gtk_main_control_vbox");
- AG_show ("anastasis_gtk_main_window_save_as_button");
- AG_show ("anastasis_gtk_select_secret_frame");
- AG_show ("anastasis_gtk_main_window_prev_button");
- AG_hide ("anastasis_gtk_main_window_quit_button");
- AG_insensitive ("anastasis_gtk_main_window_forward_button");
+ (void) cls;
+ AG_long_task = NULL;
+ if (GNUNET_TIME_absolute_is_future (long_next))
+ {
+ AG_long_task = GNUNET_SCHEDULER_add_at (long_next,
+ &long_poll_task,
+ cls);
+ return;
+ }
+ long_next = GNUNET_TIME_relative_to_absolute (LP_TIMEOUT);
+ tspec = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_time_rel ("timeout",
+ LP_TIMEOUT));
+ AG_long_action
+ = ANASTASIS_redux_action (AG_redux_state,
+ "poll",
+ tspec,
+ &long_poll_action_cb,
+ NULL);
+ json_decref (tspec);
+}
+
+
+// FIXME: dead code!??
+static void
+long_poll_action_cb (void *cls,
+ enum TALER_ErrorCode error_code,
+ json_t *response)
+{
+ (void) cls;
+ AG_long_action = NULL;
+ switch (error_code)
+ {
+ case TALER_EC_NONE:
+ /* continued below */
+ break;
+ default:
+ AG_error (_ ("poll failed: %s (#%u)"),
+ TALER_ErrorCode_get_hint (error_code),
+ (unsigned int) error_code);
+ /* simply try again */
+ AG_long_task = GNUNET_SCHEDULER_add_now (&long_poll_task,
+ NULL);
+ return;
+ }
+ if (NULL != AG_ra)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_action_cancel (AG_ra);
+ }
+ AG_action_cb (NULL,
+ TALER_EC_NONE,
+ response);
}
/**
- * Function called with the results of #ANASTASIS_redux_action on "poll".
+ * Function called with the results of #ANASTASIS_redux_action on
"poll_providers".
*
- * @param cls closure, NULL
+ * @param cls NULL
* @param error_code Error code
* @param response new state as result or config information of a provider
*/
static void
-long_action_cb (void *cls,
- enum TALER_ErrorCode error_code,
- json_t *response);
+long_poll_providers_action_cb (void *cls,
+ enum TALER_ErrorCode error_code,
+ json_t *response);
/**
- * Schedules the 'poll' action.
+ * Schedules the specified action.
*
* @param cls NULL
*/
static void
-long_task (void *cls)
+long_poll_providers_task (void *cls)
{
json_t *tspec;
@@ -2016,36 +2077,44 @@ long_task (void *cls)
if (GNUNET_TIME_absolute_is_future (long_next))
{
AG_long_task = GNUNET_SCHEDULER_add_at (long_next,
- &long_task,
- NULL);
+ &long_poll_providers_task,
+ cls);
return;
}
long_next = GNUNET_TIME_relative_to_absolute (LP_TIMEOUT);
tspec = GNUNET_JSON_PACK (
GNUNET_JSON_pack_time_rel ("timeout",
LP_TIMEOUT));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Starting long polling task for provider configurations\n");
AG_long_action
= ANASTASIS_redux_action (AG_redux_state,
- "poll",
+ "poll_providers",
tspec,
- &long_action_cb,
- NULL);
+ &long_poll_providers_action_cb,
+ cls);
json_decref (tspec);
}
/**
- * Function called with the results of #ANASTASIS_redux_action on "poll".
- *
- * @param cls closure, NULL
- * @param error_code Error code
- * @param response new state as result or config information of a provider
+ * Start policy discovery process. Triggers download(s)
+ * of the various provider configurations and (once we
+ * have any) starts the policy discovery process.
*/
static void
-long_action_cb (void *cls,
- enum TALER_ErrorCode error_code,
- json_t *response)
+begin_discovery (void);
+
+
+static void
+long_poll_providers_action_cb (void *cls,
+ enum TALER_ErrorCode error_code,
+ json_t *response)
{
+ json_t *ap;
+ const char *url;
+ json_t *obj;
+
AG_long_action = NULL;
switch (error_code)
{
@@ -2053,22 +2122,125 @@ long_action_cb (void *cls,
/* continued below */
break;
default:
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "'poll' action failed: %s\n",
- TALER_ErrorCode_get_hint (error_code));
+ AG_error (_ ("Polling for providers failed: %s (#%u)"),
+ TALER_ErrorCode_get_hint (error_code),
+ (unsigned int) error_code);
/* simply try again */
- AG_long_task = GNUNET_SCHEDULER_add_now (&long_task,
+ AG_long_task = GNUNET_SCHEDULER_add_now (&long_poll_providers_task,
NULL);
return;
}
- if (NULL != AG_ra)
+ GNUNET_assert (NULL != AG_pd);
+ /* Find out which provider is new, merge that one! */
+ ap = json_object_get (response,
+ "authentication_providers");
+ GNUNET_assert (NULL != ap);
+ json_object_foreach (ap, url, obj)
{
- GNUNET_break (0);
- ANASTASIS_redux_action_cancel (AG_ra);
+ struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+
+ if (GNUNET_OK ==
+ ANASTASIS_reducer_lookup_salt (AG_redux_state,
+ url,
+ &salt))
+ continue;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Expanding policy discovery to recently discovered live
provider `%s'\n",
+ url);
+ ANASTASIS_policy_discovery_more (AG_pd,
+ url,
+ obj);
+ }
+ /* update our state to the new state, but without
+ going through the usual action loop */
+ json_decref (AG_redux_state);
+ AG_redux_state = json_incref (response);
+ GNUNET_assert (NULL != AG_redux_state);
+}
+
+
+static void
+begin_discovery (void)
+{
+ GtkListStore *ls;
+ json_t *ap;
+ const char *url;
+ json_t *obj;
+ bool ready = false;
+ bool poll = false;
+
+ ls = GTK_LIST_STORE (GCG_get_main_window_object (
+ "secret_selection_liststore"));
+ GNUNET_assert (NULL != ls);
+ if (NULL == AG_pd)
+ gtk_list_store_clear (ls);
+ ap = json_object_get (AG_redux_state,
+ "authentication_providers");
+ json_object_foreach (ap, url, obj)
+ {
+ struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+ enum GNUNET_GenericReturnValue ret;
+
+ ret = ANASTASIS_reducer_lookup_salt (AG_redux_state,
+ url,
+ &salt);
+ switch (ret)
+ {
+ case GNUNET_OK:
+ ready = true;
+ break;
+ case GNUNET_NO:
+ poll = true;
+ break;
+ case GNUNET_SYSERR:
+ GNUNET_break (0);
+ break;
+ }
}
- AG_action_cb (NULL,
- TALER_EC_NONE,
- response);
+ if (poll)
+ {
+ long_next = GNUNET_TIME_UNIT_ZERO_ABS;
+ AG_long_task = GNUNET_SCHEDULER_add_now (&long_poll_providers_task,
+ NULL);
+ }
+ if (NULL == AG_pd)
+ AG_pd = ANASTASIS_policy_discovery_start (AG_redux_state,
+ NULL,
+ &expand_policy_list,
+ ls);
+ if ( (! ready) &&
+ (! poll) )
+ {
+ AG_error (_ ("No available providers! Try to add one!"));
+ }
+}
+
+
+/**
+ * Function called when it is time for the user to select a secret
+ * from the list of secrets. Builds the respective tree model.
+ */
+static void
+action_secret_selecting (void)
+{
+ AG_hide ("anastasis_gtk_start_frame");
+ AG_stop_long_action ();
+ if (AG_have_error)
+ AG_show ("anastasis_gtk_error_label");
+ AG_hide ("anastasis_gtk_challenge_frame");
+ AG_hide ("anastasis_gtk_identity_frame");
+ if (NULL == AG_pd)
+ begin_discovery ();
+ AG_show ("anastasis_gtk_progress_vbox");
+ AG_progress_update ();
+ AG_show ("anastasis_gtk_recovery_progress_scrolled_window");
+ AG_hide ("anastasis_gtk_backup_progress_scrolled_window");
+ AG_show ("anastasis_gtk_main_control_vbox");
+ AG_show ("anastasis_gtk_main_window_save_as_button");
+ AG_show ("anastasis_gtk_select_secret_frame");
+ AG_show ("anastasis_gtk_main_window_prev_button");
+ AG_hide ("anastasis_gtk_main_window_quit_button");
+ AG_insensitive ("anastasis_gtk_main_window_forward_button");
}
@@ -2361,6 +2533,19 @@ action_challenge_selecting (void)
policy);
}
}
+#if FIXME
+ /* FIXME: Did we loose some logic like this here for the
+ long-polling challenges? At least the
+ 'long_poll_task' appears to have turned into dead code
+ and something like this would seem to be needed
+ here for the polling challenges (SEPA transfer) */
+ if (poll)
+ {
+ long_next = GNUNET_TIME_UNIT_ZERO_ABS;
+ AG_long_task = GNUNET_SCHEDULER_add_now (&long_poll_task,
+ NULL);
+ }
+#endif
AG_sensitive ("anastasis_gtk_review_policy_treeview");
AG_show ("anastasis_gtk_progress_vbox");
AG_progress_update ();
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
index a0f76a5..a7bb1c0 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
@@ -74,6 +74,7 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
ANASTASIS_policy_discovery_stop (AG_pd);
AG_pd = NULL;
}
+ AG_stop_long_action ();
state = json_string_value (json_object_get (AG_redux_state,
"recovery_state"));
if (NULL == state)
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
index c3e78f3..f6ffe37 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -455,6 +455,7 @@ forward_secret_selecting (void)
ANASTASIS_policy_discovery_stop (AG_pd);
AG_pd = NULL;
}
+ AG_stop_long_action ();
selection = GTK_TREE_SELECTION (
GCG_get_main_window_object (
"anastasis_gtk_secret_selection_treeselection"));
--
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: -working on new policy discovery,
gnunet <=