[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] 01/02: fix enums
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] 01/02: fix enums |
Date: |
Sun, 18 Oct 2020 20:49:44 +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.
commit 7b99b5f09988f617891efdd5e0a99df5e8be8b39
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Sat Oct 17 20:24:23 2020 +0200
fix enums
---
src/anastasis/anastasis-gtk.c | 35 +++---
src/anastasis/anastasis-gtk_backup.c | 15 +--
src/anastasis/anastasis-gtk_helper.c | 238 +++++++++++------------------------
src/include/anastasis-gtk_helper.h | 4 +-
4 files changed, 103 insertions(+), 189 deletions(-)
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index c141def..58ce839 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -242,8 +242,8 @@ anastasis_gtk_continent_activated (GtkTreeView *tree_view,
ANASTASIS_redux_action (redux_state,
"select_continent",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
g_free(continent_name);
}
@@ -288,12 +288,13 @@ 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))
+ if (check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_COUNTRY_SELECTION)))
ANASTASIS_redux_action (redux_state,
"select_country",
arguments,
- &action_cb,
ctx,
+ &action_cb,
NULL);
g_free(country_name);
@@ -314,12 +315,13 @@ anastasis_gtk_continent_unselected (GtkTreeSelection
*selection,
{
GtkTreeModel *model;
if (! gtk_tree_selection_get_selected (selection, &model, NULL)
- && ! check_state (redux_state, ContinentSelectionState))
+ && ! check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_CONTINENT_SELECTION)))
ANASTASIS_redux_action (redux_state,
"unselect_continent",
NULL,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -337,12 +339,13 @@ anastasis_gtk_country_unselected (GtkTreeSelection
*selection,
GtkTreeModel *model;
if (! gtk_tree_selection_get_selected (selection, &model, NULL)
- && check_state (redux_state, UserAttributesCollectionState))
+ && check_state (redux_state,
+ ANASTASIS_generic_state_to_string
(ANASTASIS_GENERIC_STATE_USER_ATTRIBUTES_COLLECTION)))
ANASTASIS_redux_action (redux_state,
"unselect_country",
NULL,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -360,11 +363,12 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
ANASTASIS_redux_action (redux_state,
"back",
NULL,
- &action_cb,
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 +392,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,7 +461,8 @@ 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)
@@ -466,8 +472,8 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
ANASTASIS_redux_action (redux_state,
"enter_user_attributes",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -480,7 +486,8 @@ 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");
@@ -488,8 +495,8 @@ anastasis_gtk_main_window_forward_clicked (GObject *object,
ANASTASIS_redux_action (redux_state,
"next",
NULL,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
}
diff --git a/src/anastasis/anastasis-gtk_backup.c
b/src/anastasis/anastasis-gtk_backup.c
index 14eca7b..d964b64 100644
--- a/src/anastasis/anastasis-gtk_backup.c
+++ b/src/anastasis/anastasis-gtk_backup.c
@@ -98,8 +98,8 @@ delete_auth_method (gpointer user_data)
ANASTASIS_redux_action (redux_state,
"delete_authentication",
arguments,
- &action_cb,
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);
@@ -234,8 +235,8 @@ anastasis_gtk_b_question_dialog_btn_ok_clicked_cb (GObject
*object,
ANASTASIS_redux_action (redux_state,
"add_authentication",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -382,8 +383,8 @@ anastasis_gtk_b_post_dialog_btn_ok_clicked_cb (GObject
*object,
ANASTASIS_redux_action (redux_state,
"add_authentication",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -532,8 +533,8 @@ anastasis_gtk_b_video_dialog_btn_ok_clicked_cb (GObject
*object,
ANASTASIS_redux_action (redux_state,
"add_authentication",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -658,8 +659,8 @@ anastasis_gtk_b_sms_dialog_btn_ok_clicked_cb (GObject
*object,
ANASTASIS_redux_action (redux_state,
"add_authentication",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
@@ -784,8 +785,8 @@ anastasis_gtk_b_email_dialog_btn_ok_clicked_cb (GObject
*object,
ANASTASIS_redux_action (redux_state,
"add_authentication",
arguments,
- &action_cb,
NULL,
+ &action_cb,
NULL);
}
diff --git a/src/anastasis/anastasis-gtk_helper.c
b/src/anastasis/anastasis-gtk_helper.c
index fdd19a8..489aa8b 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..3646a1a 100644
--- a/src/include/anastasis-gtk_helper.h
+++ b/src/include/anastasis-gtk_helper.h
@@ -116,11 +116,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.