[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated (db23bb7 -> 46a7a69)
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated (db23bb7 -> 46a7a69) |
Date: |
Sun, 18 Oct 2020 20:49:43 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a change to branch master
in repository anastasis-gtk.
from db23bb7 fix
new 7b99b5f fix enums
new 46a7a69 fix get_config
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/anastasis/anastasis-gtk.c | 125 ++++++++++--------
src/anastasis/anastasis-gtk_backup.c | 75 +++++------
src/anastasis/anastasis-gtk_helper.c | 238 +++++++++++------------------------
src/include/anastasis-gtk_helper.h | 9 +-
4 files changed, 192 insertions(+), 255 deletions(-)
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index c141def..b57b902 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -49,6 +49,11 @@ struct GNUNET_CURL_RescheduleContext *rc;
*/
struct GNUNET_CURL_Context *ctx;
+/**
+ * Handle to an ongoing action.
+ */
+struct ANASTASIS_ReduxAction *ra;
+
/**
* Actual state.
*/
@@ -239,12 +244,12 @@ anastasis_gtk_continent_activated (GtkTreeView *tree_view,
gtk_tree_model_get (model, &iter, 0, &continent_name, -1);
json_object_set (arguments, "continent", json_string (continent_name));
- ANASTASIS_redux_action (redux_state,
- "select_continent",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "select_continent",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
g_free(continent_name);
}
}
@@ -288,16 +293,18 @@ anastasis_gtk_country_activated (GtkTreeView *tree_view,
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",
- arguments,
- &action_cb,
- ctx,
- NULL);
-
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION)))
+ ra = ANASTASIS_redux_action (redux_state,
+ "select_country",
+ arguments,
+ ctx,
+ &action_cb,
+ NULL);
+
g_free(country_name);
g_free(country_code);
+ g_free(country_currency);
}
}
@@ -314,13 +321,14 @@ anastasis_gtk_continent_unselected (GtkTreeSelection
*selection,
{
GtkTreeModel *model;
if (! gtk_tree_selection_get_selected (selection, &model, NULL)
- && ! check_state (redux_state, ContinentSelectionState))
- ANASTASIS_redux_action (redux_state,
- "unselect_continent",
- NULL,
- &action_cb,
- NULL,
- NULL);
+ && ! check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION)))
+ ra = ANASTASIS_redux_action (redux_state,
+ "unselect_continent",
+ NULL,
+ NULL,
+ &action_cb,
+ NULL);
}
@@ -337,13 +345,14 @@ anastasis_gtk_country_unselected (GtkTreeSelection
*selection,
GtkTreeModel *model;
if (! gtk_tree_selection_get_selected (selection, &model, NULL)
- && check_state (redux_state, UserAttributesCollectionState))
- ANASTASIS_redux_action (redux_state,
- "unselect_country",
- NULL,
- &action_cb,
- NULL,
- NULL);
+ && check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)))
+ ra = ANASTASIS_redux_action (redux_state,
+ "unselect_country",
+ NULL,
+ NULL,
+ &action_cb,
+ NULL);
}
@@ -357,14 +366,15 @@ void
anastasis_gtk_main_window_back_clicked (GObject *object,
gpointer user_data)
{
- ANASTASIS_redux_action (redux_state,
- "back",
- NULL,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "back",
+ NULL,
+ NULL,
+ &action_cb,
+ NULL);
//show identity frame, hide authentication frame
- if (check_state (redux_state, UserAttributesCollectionState) &&
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)) &&
gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_b_authentication_frame"))))
{
@@ -388,7 +398,8 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
gpointer user_data)
{
//show identity frame, hide continent frame
- if (check_state (redux_state, UserAttributesCollectionState) &&
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)) &&
gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_continent_frame"))))
{
@@ -456,19 +467,20 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
}
json_object_set_new (arguments, "identity_attributes", id_attr);
- if (check_state (redux_state, UserAttributesCollectionState))
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)))
{
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);
+ ra = ANASTASIS_redux_action (redux_state,
+ "enter_user_attributes",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
gtk_widget_set_sensitive (GTK_WIDGET (GCG_get_main_window_object (
@@ -480,17 +492,18 @@ anastasis_gtk_main_window_forward_clicked (GObject
*object,
if (gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
"anastasis_gtk_b_authentication_frame"))))
{
- if (check_state (redux_state, AuthenticationsEditingState))
+ if (check_state (redux_state,
+ ANASTASIS_backup_state_to_string
(ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING)))
{
json_t *auth_methods = json_object_get (redux_state,
"authentication_methods");
if (json_array_size (auth_methods) > 0)
- ANASTASIS_redux_action (redux_state,
- "next",
- NULL,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "next",
+ NULL,
+ NULL,
+ &action_cb,
+ NULL);
}
}
}
@@ -504,8 +517,20 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
static void
shutdown_task (void *cls)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown initiated\n");
+
GNUNET_GTK_main_loop_quit (ml);
ml = NULL;
+
+ if (NULL != ra)
+ {
+ GNUNET_free (ra);
+ ra = NULL;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown complete\n");
}
diff --git a/src/anastasis/anastasis-gtk_backup.c
b/src/anastasis/anastasis-gtk_backup.c
index 14eca7b..3c96a41 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -95,12 +95,12 @@ delete_auth_method (gpointer user_data)
GNUNET_assert (0 == json_object_set_new
(arguments,
"authentication_method",
method));
- ANASTASIS_redux_action (redux_state,
- "delete_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+
"delete_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
index++;
}
@@ -136,7 +136,8 @@ anastasis_gtk_backup_button_clicked (GObject *object,
redux_state = ANASTASIS_backup_start (cfg);
GNUNET_assert (0 == persist_state (redux_state));
- if (check_state (redux_state, ContinentSelectionState))
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION)))
{
init_continent_list (redux_state);
@@ -231,12 +232,12 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb
(GObject *object,
GNUNET_assert (0 == json_object_set_new (auth_method, "data",
method_data));
GNUNET_assert (0 == json_object_set_new (arguments,
"authentication_method", auth_method));
- ANASTASIS_redux_action (redux_state,
- "add_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
// set buttons
@@ -379,12 +380,12 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject
*object,
json_object_set_new (auth_method, "data", method_data);
json_object_set_new (arguments, "authentication_method",
method_data);
- ANASTASIS_redux_action (redux_state,
- "add_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
// set buttons
@@ -529,12 +530,12 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject
*object,
json_object_set_new (auth_method, "data", method_data);
json_object_set_new (arguments, "authentication_method",
method_data);
- ANASTASIS_redux_action (redux_state,
- "add_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
// set buttons
@@ -655,12 +656,12 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject
*object,
json_object_set_new (auth_method, "data", method_data);
json_object_set_new (arguments, "authentication_method",
method_data);
- ANASTASIS_redux_action (redux_state,
- "add_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
// set buttons
@@ -781,12 +782,12 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject
*object,
json_object_set_new (auth_method, "data", method_data);
json_object_set_new (arguments, "authentication_method",
method_data);
- ANASTASIS_redux_action (redux_state,
- "add_authentication",
- arguments,
- &action_cb,
- NULL,
- NULL);
+ ra = ANASTASIS_redux_action (redux_state,
+ "add_authentication",
+ arguments,
+ NULL,
+ &action_cb,
+ NULL);
}
// set buttons
diff --git a/src/anastasis/anastasis-gtk_helper.c
b/src/anastasis/anastasis-gtk_helper.c
index fdd19a8..8ef9e6a 100644
--- a/src/anastasis/anastasis-gtk_helper.c
+++ b/src/anastasis/anastasis-gtk_helper.c
@@ -282,169 +282,82 @@ action_cb (void *cls,
json_t *response)
{
if (NULL != response)
+ redux_state = json_deep_copy (response);
+ else
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION)))
+ {
+ 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,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION)))
+ {
+ 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,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)))
+ {
+ 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,
+ ANASTASIS_backup_state_to_string
(ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING)))
{
- // check kind of response
- if (NULL != json_object_get (response, "provider"))
+ if (json_object_get (redux_state, "backup_state"))
{
- 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
- {
- // update authentication_providers
- json_t *method_data;
- const char *method_name;
- json_t *methods = json_object_get (providers,
"authentication_providers");
- json_t *config = json_object_get (response, "config");
- GNUNET_assert (NULL != config);
- json_t *provider_id = json_object_get (response, "provider");
- GNUNET_assert (NULL != provider_id);
- bool contains_method = false;
-
- if (NULL != methods)
- {
- json_object_foreach (methods, method_name, method_data)
- {
- json_t *value;
- const char* key;
- json_object_foreach (config, key, value)
- {
- if (0 == strcmp (key, method_name))
- {
- json_t *provider;
- size_t index;
- json_t *provider_arr = json_object_get
(methods, method_name);
- GNUNET_assert (NULL != provider_arr);
- bool contains_provider = false;
-
- json_array_foreach (provider_arr, index,
provider)
- {
- if (1 == json_equal (provider,
provider_id))
- {
- contains_provider = true;
- break;
- }
- }
- if (! contains_provider)
- json_array_append_new (provider_arr,
json_array_get (value, 0));
- contains_method = true;
- break;
- }
- }
- }
- if (! contains_method)
- GNUNET_assert (0 ==
- json_object_update_recursive (methods,
-
json_object_get (response,
-
"config")));
- }
-
- // delete this provider from missing_providers
- size_t missing_index;
- json_t *missing_value;
-
- json_array_foreach (missing_providers, missing_index,
missing_value)
- {
- json_t *temp_provider_id = json_object_get (missing_value,
- "provider_id");
- if (1 == json_equal (provider_id, temp_provider_id))
- {
- json_array_remove (missing_providers, missing_index);
- break;
- }
- }
- }
+ anastasis_gtk_hide_all_frames ();
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_b_authentication_frame")));
+ gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
+
"anastasis_gtk_b_authentication_methods_image")));
+ init_b_auth_methods (redux_state);
}
- else
+ }
+ if (check_state (redux_state,
+ ANASTASIS_backup_state_to_string
(ANASTASIS_BACKUP_STATE_POLICIES_REVIEWING))
+ && gtk_widget_is_visible (GTK_WIDGET (GCG_get_main_window_object (
+ "anastasis_gtk_b_authentication_frame"))))
+ {
+ 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_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 (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")));
- gtk_widget_show (GTK_WIDGET (GCG_get_main_window_object (
-
"anastasis_gtk_b_authentication_methods_image")));
- init_b_auth_methods (redux_state);
- }
- }
- 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");
+ 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: see above
@@ -452,20 +365,13 @@ action_cb (void *cls,
}
-/**
- * Checks the actual state. True, if state is correct, else false.
- *
- * @param state the state to check
- * @param expected_state the expected state enum
- * @return bool
- */
bool
-check_state (json_t *state, REDUX_STATE expected_state)
+check_state (json_t *state, const char *expected_state)
{
const char *state_name = json_string_value (json_object_get (state,
"backup_state"));
if (NULL == state_name)
state_name = json_string_value (json_object_get (state,
"recovery_state"));
- if (0 == strcmp (state_name, STATE_STRING[expected_state]))
+ if (0 == strcmp (state_name, expected_state))
return true;
else
return false;
diff --git a/src/include/anastasis-gtk_helper.h
b/src/include/anastasis-gtk_helper.h
index 9aa781b..e37e3b7 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -55,6 +55,11 @@ extern struct GNUNET_CURL_Context *ctx;
*/
extern struct GNUNET_CURL_RescheduleContext *rc;
+/**
+ * Handle to an ongoing action.
+ */
+extern struct ANASTASIS_ReduxAction *ra;
+
/**
* Function called with the results of #ANASTASIS_redux_action.
@@ -116,11 +121,11 @@ check_attributes_fullfilled ();
* Checks the actual state. True, if state is correct, else false.
*
* @param state the state to check
- * @param expected_state the expected state enum
+ * @param expected_state the expected state as string
* @return bool
*/
bool
-check_state (json_t *state, REDUX_STATE expected_state);
+check_state (json_t *state, const char *expected_state);
/**
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis-gtk] branch master updated (db23bb7 -> 46a7a69),
gnunet <=