gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis-gtk] branch master updated: fix #7226: keep polling for


From: gnunet
Subject: [taler-anastasis-gtk] branch master updated: fix #7226: keep polling for providers
Date: Tue, 28 Jun 2022 13:28:29 +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 9af1ca5  fix #7226: keep polling for providers
9af1ca5 is described below

commit 9af1ca5d04d7a997b71157494336a4b9763f0a2f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Jun 28 13:28:27 2022 +0200

    fix #7226: keep polling for providers
---
 src/anastasis/anastasis-gtk_action.c               | 212 ++++++++++++---------
 ...astasis-gtk_handle-auth-edit-provider-clicked.c |   6 +-
 2 files changed, 129 insertions(+), 89 deletions(-)

diff --git a/src/anastasis/anastasis-gtk_action.c 
b/src/anastasis/anastasis-gtk_action.c
index 05a4a86..0056e27 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -701,6 +701,107 @@ activate_by_method (json_t *methods)
 }
 
 
+/**
+ * Function called with the results of #ANASTASIS_redux_action on 
"poll_providers".
+ *
+ * @param cls NULL
+ * @param error_code Error code
+ * @param response new state as result or config information of a provider
+ */
+static void
+long_poll_providers_action_cb (void *cls,
+                               enum TALER_ErrorCode error_code,
+                               json_t *response);
+
+
+/**
+ * Schedules the specified action.
+ *
+ * @param cls NULL
+ */
+static void
+long_poll_providers_task (void *cls)
+{
+  struct ANASTASIS_LongAction *la = &AG_lacs[ANASTASIS_LP_POLL_PROVIDERS];
+  json_t *tspec;
+
+  (void) cls;
+  la->task = NULL;
+  if (GNUNET_TIME_absolute_is_future (la->next_time))
+  {
+    la->task = GNUNET_SCHEDULER_add_at (la->next_time,
+                                        &long_poll_providers_task,
+                                        NULL);
+    return;
+  }
+  la->next_time = 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");
+  la->ra = ANASTASIS_redux_action (AG_redux_state,
+                                   "poll_providers",
+                                   tspec,
+                                   &long_poll_providers_action_cb,
+                                   NULL);
+  json_decref (tspec);
+}
+
+
+/**
+ * Check if all providers we care about are ready,
+ * and if not try to long poll them.
+ *
+ * @return false if we have no providers at all
+ */
+static bool
+sync_providers (void)
+{
+  struct ANASTASIS_LongAction *la = &AG_lacs[ANASTASIS_LP_POLL_PROVIDERS];
+  json_t *ap;
+  const char *url;
+  json_t *obj;
+  bool ready = false;
+  bool poll = false;
+
+  ap = json_object_get (AG_redux_state,
+                        "authentication_providers");
+  json_object_foreach (ap, url, obj)
+  {
+    struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+    enum GNUNET_GenericReturnValue ret;
+
+    ret = ANASTASIS_reducer_lookup_salt (AG_redux_state,
+                                         url,
+                                         &provider_salt);
+    switch (ret)
+    {
+    case GNUNET_OK:
+      ready = true;
+      break;
+    case GNUNET_NO:
+      poll = true;
+      break;
+    case GNUNET_SYSERR:
+      GNUNET_break (0);
+      break;
+    }
+  }
+  if (poll)
+  {
+    la->next_time = GNUNET_TIME_UNIT_ZERO_ABS;
+    la->task = GNUNET_SCHEDULER_add_now (&long_poll_providers_task,
+                                         NULL);
+  }
+  return ready || poll;
+}
+
+
+/**
+ * Allow the user to configure authorization methods from
+ * the set of methods offered by known providers.
+ */
 static void
 action_authentications_editing (void)
 {
@@ -709,6 +810,7 @@ action_authentications_editing (void)
 
   AG_hide_all_frames ();
   AG_insensitive_children ("anastasis_gtk_auth_button_grid");
+  (void) sync_providers ();
   aps = json_object_get (AG_redux_state,
                          "authentication_providers");
   {
@@ -765,7 +867,7 @@ action_authentications_editing (void)
         activate_by_method (methods);
         break;
       default:
-        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Status of provider `%s' is %u/%u\n",
                     provider_url,
                     (unsigned int) ec,
@@ -2006,54 +2108,6 @@ long_poll_sync_action_cb (void *cls,
 }
 
 
-/**
- * Function called with the results of #ANASTASIS_redux_action on 
"poll_providers".
- *
- * @param cls NULL
- * @param error_code Error code
- * @param response new state as result or config information of a provider
- */
-static void
-long_poll_providers_action_cb (void *cls,
-                               enum TALER_ErrorCode error_code,
-                               json_t *response);
-
-
-/**
- * Schedules the specified action.
- *
- * @param cls NULL
- */
-static void
-long_poll_providers_task (void *cls)
-{
-  struct ANASTASIS_LongAction *la = &AG_lacs[ANASTASIS_LP_POLL_PROVIDERS];
-  json_t *tspec;
-
-  (void) cls;
-  la->task = NULL;
-  if (GNUNET_TIME_absolute_is_future (la->next_time))
-  {
-    la->task = GNUNET_SCHEDULER_add_at (la->next_time,
-                                        &long_poll_providers_task,
-                                        NULL);
-    return;
-  }
-  la->next_time = 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");
-  la->ra = ANASTASIS_redux_action (AG_redux_state,
-                                   "poll_providers",
-                                   tspec,
-                                   &long_poll_providers_action_cb,
-                                   NULL);
-  json_decref (tspec);
-}
-
-
 /**
  * Start policy discovery process. Triggers download(s)
  * of the various provider configurations and (once we
@@ -2088,11 +2142,27 @@ long_poll_providers_action_cb (void *cls,
                                          NULL);
     return;
   }
-  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);
+  if (NULL == AG_pd)
+  {
+    json_t *ns;
+
+    /* Simply merge the state */
+    ap = json_object_get (response,
+                          "authentication_providers");
+    ns = json_incref (AG_redux_state);
+    json_object_set (ns,
+                     "authentication_providers",
+                     ap);
+    AG_action_cb (NULL,
+                  TALER_EC_NONE,
+                  ns);
+    json_decref (ns);
+    return;
+  }
+  /* Find out which provider is new, merge that one! */
   json_object_foreach (ap, url, obj)
   {
     struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
@@ -2120,55 +2190,21 @@ long_poll_providers_action_cb (void *cls,
 static void
 begin_discovery (void)
 {
-  struct ANASTASIS_LongAction *la = &AG_lacs[ANASTASIS_LP_POLL_PROVIDERS];
   GtkListStore *ls;
-  json_t *ap;
-  const char *url;
-  json_t *obj;
-  bool ready = false;
-  bool poll = false;
+  bool have_providers;
 
   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 provider_salt;
-    enum GNUNET_GenericReturnValue ret;
-
-    ret = ANASTASIS_reducer_lookup_salt (AG_redux_state,
-                                         url,
-                                         &provider_salt);
-    switch (ret)
-    {
-    case GNUNET_OK:
-      ready = true;
-      break;
-    case GNUNET_NO:
-      poll = true;
-      break;
-    case GNUNET_SYSERR:
-      GNUNET_break (0);
-      break;
-    }
-  }
-  if (poll)
-  {
-    la->next_time = GNUNET_TIME_UNIT_ZERO_ABS;
-    la->task = GNUNET_SCHEDULER_add_now (&long_poll_providers_task,
-                                         NULL);
-  }
+  have_providers = sync_providers ();
   if (NULL == AG_pd)
     AG_pd = ANASTASIS_policy_discovery_start (AG_redux_state,
                                               NULL,
                                               &expand_policy_list,
                                               ls);
-  if ( (! ready) &&
-       (! poll) )
+  if (! have_providers)
   {
     AG_error (_ ("No available providers! Try to add one!"));
   }
diff --git a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c 
b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
index 091b1fb..3e55413 100644
--- a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c
@@ -326,7 +326,11 @@ url_add_button_clicked_cb (GtkButton *button,
 
 
 /**
- * FIXME.
+ * The user changed the URL of a provider to be possibly added.
+ * Validate the syntax and if it is a valid URL, enable the button.
+ *
+ * @param entry the edited widget
+ * @param user_data the dialog builder
  */
 void
 url_entry_changed_cb (GtkEntry *entry,

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