[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: fix config api request
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: fix config api request |
Date: |
Sat, 10 Oct 2020 12:39:06 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis-gtk.
The following commit(s) were added to refs/heads/master by this push:
new 2af3228 fix config api request
2af3228 is described below
commit 2af3228931e79df5e987f9ab55446e3993af5553
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Sat Oct 10 12:39:01 2020 +0200
fix config api request
---
src/anastasis/anastasis-gtk.c | 8 ++
src/anastasis/anastasis-gtk_helper.c | 221 ++++++++++++++++++++++++++---------
src/include/anastasis-gtk_helper.h | 24 +++-
3 files changed, 190 insertions(+), 63 deletions(-)
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 17a5fe7..c141def 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -287,6 +287,7 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
json_object_set (arguments, "country_code", json_string
(country_code));
json_object_set (arguments, "currency", json_string
(country_currency));
+ reset_authentication_providers ();
if (check_state (redux_state, CountrySelectionState))
ANASTASIS_redux_action (redux_state,
"select_country",
@@ -456,12 +457,19 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
json_object_set_new (arguments, "identity_attributes", id_attr);
if (check_state (redux_state, UserAttributesCollectionState))
+ {
+ json_t *auth_providers = get_authentication_providers ();
+ if (NULL != auth_providers)
+ json_object_set_new (arguments,
+ "authentication_providers",
+ auth_providers);
ANASTASIS_redux_action (redux_state,
"enter_user_attributes",
arguments,
&action_cb,
NULL,
NULL);
+ }
gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_main_window_forward_button")), false);
diff --git a/src/anastasis/anastasis-gtk_helper.c
b/src/anastasis/anastasis-gtk_helper.c
index 7621f51..7060165 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -29,6 +29,53 @@
#include "anastasis-gtk_helper.h"
#include <jansson.h>
+/**
+ * List of authentication methods and their supporting providers.
+ */
+static json_t* providers;
+
+/**
+ * List of providers we do not have a config response yet.
+ */
+static json_t* missing_providers;
+
+
+/**
+ * Returs the authentication providers.
+ *
+ * @return json_t
+ */
+json_t *
+get_authentication_providers ()
+{
+ json_t *auth_providers = json_object_get (providers,
+ "authentication_providers");
+ return auth_providers;
+}
+
+
+/**
+ * Reset the list of authentication providers.
+ */
+void
+reset_authentication_providers ()
+{
+ if (NULL != providers)
+ GNUNET_assert (0 == json_object_clear (providers));
+}
+
+
+/**
+ * Returs the providers which did not respond yet.
+ *
+ * @return json_t
+ */
+json_t *
+get_missing_providers ()
+{
+ return missing_providers;
+}
+
/**
* Get num of cols a widget takes in a grid.
@@ -223,87 +270,145 @@ anastasis_gtk_hide_all_frames ()
/**
- * Function called with the results of #ANASTASIS_redux_action
- * or #ANASTASIS_recovery_action.
+ * Function called with the results of #ANASTASIS_redux_action.
*
* @param cls closure
* @param error_code Error code
- * @param new_state new state as result
+ * @param response new state as result or config information of a provider
*/
void
action_cb (void *cls,
enum ANASTASIS_ErrorCode error_code,
- json_t *result_state)
+ json_t *response)
{
- if (NULL != result_state)
+ if (NULL != response)
{
- redux_state = json_deep_copy (result_state);
- if (check_state (redux_state, ContinentSelectionState))
+ // check kind of response
+ if (NULL != json_object_get (response, "provider"))
{
- GtkListStore *country_liststore = GTK_LIST_STORE
(GCG_get_main_window_object ("country_liststore"));
-
- anastasis_gtk_hide_all_frames ();
- gtk_list_store_clear (country_liststore);
- gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_main_window_forward_button")), false);
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_continent_selection_image")));
- }
- if (check_state (redux_state, CountrySelectionState))
- {
- anastasis_gtk_hide_all_frames ();
- init_country_list (redux_state, json_string_value (json_object_get
(redux_state, "selected_continent")));
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_country_selection_image")));
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
- "anastasis_gtk_continent_frame")));
- gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_main_window_forward_button")), false);
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_continent_selection_image")));
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_country_selection_image")));
- }
- if (check_state (redux_state, UserAttributesCollectionState))
- {
- gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_main_window_forward_button")), true);
- init_id_attr (redux_state, json_string_value (json_object_get
(redux_state, "selected_country")));
+ if (NULL == providers)
+ {
+ size_t index;
+ json_t *value;
+ json_t *array = json_object_get (response, "provider_list");
+ json_t *provider_id = json_object_get (response, "provider");
+
+ GNUNET_assert (NULL != array);
+ providers = json_object ();
+ GNUNET_assert (0 == json_object_set_new (providers,
+
"authentication_providers",
+ json_object_get
(response,
+
"config")));
+ json_array_foreach (array, index, value)
+ {
+ json_t *new_provider_id = json_object_get (value,
+ "provider_id");
+ if (1 == json_equal (provider_id, new_provider_id))
+ break;
+ GNUNET_assert (0 == json_array_append_new
(missing_providers,
+ value));
+ }
+ }
+ else
+ {
+ size_t index;
+ json_t *value;
+
+ // update authentication_providers
+ /** FIXME: authentication methods is update wrongly here!!! */
+ GNUNET_assert (0 ==
+ json_object_update_recursive (providers,
+ json_object_get
(response,
+
"config")));
+ // delete this provider from missing_providers
+ json_t *provider_id = json_object_get (response, "provider");
+ json_array_foreach (missing_providers, index, value)
+ {
+ json_t *temp_provider_id = json_object_get (value,
+ "provider_id");
+ if (1 == json_equal (provider_id, temp_provider_id))
+ {
+ json_array_remove (missing_providers, index);
+ break;
+ }
+ }
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "PROVIDERS: %s\n\n",
+ json_dumps (providers, JSON_COMPACT));
}
- if (check_state (redux_state, AuthenticationsEditingState))
+ else
{
- if (json_object_get (redux_state, "backup_state"))
+ redux_state = json_deep_copy (response);
+ if (check_state (redux_state, ContinentSelectionState))
{
+ GtkListStore *country_liststore = GTK_LIST_STORE
(GCG_get_main_window_object ("country_liststore"));
+
anastasis_gtk_hide_all_frames ();
+ gtk_list_store_clear (country_liststore);
+ gtk_widget_set_sensitive (GTK_WIDGET
(GCG_get_main_window_object (
+
"anastasis_gtk_main_window_forward_button")), false);
gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_frame")));
- init_b_auth_methods (redux_state);
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_methods_image")));
+
"anastasis_gtk_continent_selection_image")));
}
- }
- if (check_state (redux_state, PoliciesReviewingState)
- && gtk_widget_is_visible (GTK_WIDGET
(GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_frame"))))
- {
- if (json_object_get (redux_state, "backup_state"))
+ if (check_state (redux_state, CountrySelectionState))
{
anastasis_gtk_hide_all_frames ();
- init_b_policy (redux_state);
+ init_country_list (redux_state, json_string_value
(json_object_get (redux_state, "selected_continent")));
gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
- "anastasis_gtk_b_policy_frame")));
+
"anastasis_gtk_country_selection_image")));
gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_policies_image")));
- set_policy_check_buttons (redux_state);
+ "anastasis_gtk_continent_frame")));
+ gtk_widget_set_sensitive (GTK_WIDGET
(GCG_get_main_window_object (
+
"anastasis_gtk_main_window_forward_button")), false);
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_continent_selection_image")));
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_country_selection_image")));
+ }
+ if (check_state (redux_state, UserAttributesCollectionState))
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET
(GCG_get_main_window_object (
+
"anastasis_gtk_main_window_forward_button")), true);
+ init_id_attr (redux_state, json_string_value (json_object_get
(redux_state, "selected_country")));
}
+ if (check_state (redux_state, AuthenticationsEditingState))
+ {
+ if (json_object_get (redux_state, "backup_state"))
+ {
+ anastasis_gtk_hide_all_frames ();
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_b_authentication_frame")));
+ init_b_auth_methods (redux_state);
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_b_authentication_methods_image")));
+ }
+ }
+ if (check_state (redux_state, PoliciesReviewingState)
+ && gtk_widget_is_visible (GTK_WIDGET
(GCG_get_main_window_object (
+
"anastasis_gtk_b_authentication_frame"))))
+ {
+ if (json_object_get (redux_state, "backup_state"))
+ {
+ anastasis_gtk_hide_all_frames ();
+ init_b_policy (redux_state);
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_b_policy_frame")));
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_b_policies_image")));
+ set_policy_check_buttons (redux_state);
+ }
+ }
+ /** FIXME: Don't use this like this; now used to check if json
state is build correctly */
+ if (0 == persist_state (redux_state))
+ return;
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to persist new state! \n");
}
- /** FIXME: Don't use this like this; now used to check if json state
is build correctly */
- if (0 == persist_state (redux_state))
- return;
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to persist new state! \n");
}
+
+
/** FIXME: see above
* GNUNET_SCHEDULER_shutdown (); */
}
diff --git a/src/include/anastasis-gtk_helper.h
b/src/include/anastasis-gtk_helper.h
index 2ff471b..9aa781b 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -57,19 +57,33 @@ extern struct GNUNET_CURL_RescheduleContext *rc;
/**
- * Function called with the results of #ANASTASIS_redux_action
- * or #ANASTASIS_recovery_action.
+ * Function called with the results of #ANASTASIS_redux_action.
*
* @param cls closure
* @param error_code Error code
- * @param new_state new state as result
+ * @param response new state as result or config information of provider
*/
void
action_cb (void *cls,
- enum ANASTASIS_ErrorCode error,
- json_t *new_state);
+ enum ANASTASIS_ErrorCode error_code,
+ json_t *response);
+/**
+ * Returs the authentication providers.
+ *
+ * @return json_t
+ */
+json_t *
+get_authentication_providers ();
+
+
+/**
+ * Reset the list of authentication providers.
+ */
+void
+reset_authentication_providers ();
+
/**
* Function to persist a state.
*
--
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: fix config api request,
gnunet <=