anastasis-gtk

Demonstrator GUI for Anastasis
Log | Files | Refs | README | LICENSE

commit fa99c50d3346c47793aa463656ff1d8ad86354ca
parent ba92d27e5901f5063439914fbce99543cce74238
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 30 Sep 2021 14:43:12 +0200

allow providers to be enabled/disabled (fixes #6918)

Diffstat:
Mm4/libtool.m4 | 4++--
Mpo/POTFILES.in | 4++--
Msrc/anastasis/anastasis-gtk_action.c | 16++++++++++++----
Msrc/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c | 65+++++++++++++++++++++++++++++++++--------------------------------
4 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/m4/libtool.m4 b/m4/libtool.m4 @@ -1071,11 +1071,11 @@ _LT_EOF # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) + 10.*|11.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; diff --git a/po/POTFILES.in b/po/POTFILES.in @@ -10,6 +10,7 @@ src/anastasis/anastasis-gtk_handle-challenge-code.c src/anastasis/anastasis-gtk_handle-challenge-iban.c src/anastasis/anastasis-gtk_handle-challenge-question.c src/anastasis/anastasis-gtk_handle-challenge-row-activated.c +src/anastasis/anastasis-gtk_handle-challenge-totp.c src/anastasis/anastasis-gtk_handle-clear-secret-clicked.c src/anastasis/anastasis-gtk_handle-continent-selected.c src/anastasis/anastasis-gtk_handle-core-secret-changed.c @@ -30,9 +31,7 @@ src/anastasis/anastasis-gtk_handle-method-totp.c src/anastasis/anastasis-gtk_handle-method-video.c src/anastasis/anastasis-gtk_handle-payqr-selection-changed.c src/anastasis/anastasis-gtk_handle-policy-activate.c -src/anastasis/.#anastasis-gtk_handle-policy-button.c src/anastasis/anastasis-gtk_handle-policy-button.c -src/anastasis/.#anastasis-gtk_handle-policy-meta.c src/anastasis/anastasis-gtk_handle-policy-meta.c src/anastasis/anastasis-gtk_handle-policy-version-changed.c src/anastasis/anastasis-gtk_handle-recovery-button-clicked.c @@ -45,6 +44,7 @@ src/anastasis/anastasis-gtk_pe-delete-policy.c src/anastasis/anastasis-gtk_pe-edit-policy.c src/anastasis/anastasis-gtk_progress.c src/anastasis/os_installation.c +contrib/anastasis_gtk_about_window.glade contrib/anastasis_gtk_auth_add_email.glade contrib/anastasis_gtk_auth_add_iban.glade contrib/anastasis_gtk_auth_add_post.glade diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c @@ -708,7 +708,8 @@ action_authentications_editing (void) { uint32_t ec = 0; uint32_t hc = 0; - json_t *methods; + bool disabled = false; + json_t *methods = NULL; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_uint32 ("error_code", @@ -716,8 +717,13 @@ action_authentications_editing (void) GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("methods", &methods)), - GNUNET_JSON_spec_uint32 ("http_status", - &hc), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint32 ("http_status", + &hc)), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ("disabled", + &disabled)), + GNUNET_JSON_spec_end () }; @@ -729,6 +735,8 @@ action_authentications_editing (void) GNUNET_break (0); continue; } + if (disabled) + continue; switch (hc) { case MHD_HTTP_OK: @@ -820,7 +828,7 @@ action_authentications_editing (void) * @param[out] method_cost cost to return * @return #GNUNET_OK on success */ -static int +static enum GNUNET_GenericReturnValue lookup_recovery_cost (const char *provider, const char *type, struct TALER_Amount *method_cost) diff --git a/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c b/src/anastasis/anastasis-gtk_handle-auth-edit-provider-clicked.c @@ -314,7 +314,7 @@ url_add_button_clicked_cb (GtkButton *button, -1, AG_PMC_PROVIDER_URL, url, AG_PMC_PROVIDER_STATUS, _ ("new"), - AG_PMC_PROVIDER_STATUS_COLOR, "yellow", + AG_PMC_PROVIDER_STATUS_COLOR, "blue", AG_PMC_PROVIDER_ENABLED, true, AG_PMC_PROVIDER_SENSITIVE, false, AG_PMC_PROVIDER_NOT_SENSITIVE, true, @@ -363,8 +363,7 @@ edit_provider_dialog_response_cb (GtkDialog *dialog, GtkBuilder *builder = GTK_BUILDER (user_data); GtkTreeModel *tm; GtkTreeIter iter; - const json_t *providers; - json_t *urls; + json_t *args; if (GTK_RESPONSE_APPLY != response_id) { @@ -379,9 +378,7 @@ edit_provider_dialog_response_cb (GtkDialog *dialog, GNUNET_break (0); return; } - providers = json_object_get (AG_redux_state, - "authentication_providers"); - urls = json_array (); + args = json_object (); if (gtk_tree_model_get_iter_first (tm, &iter)) do { @@ -393,34 +390,26 @@ edit_provider_dialog_response_cb (GtkDialog *dialog, AG_PMC_PROVIDER_URL, &url, AG_PMC_PROVIDER_ENABLED, &enabled, -1); - if (NULL == json_object_get (providers, - url)) - { - // FIXME: store enabled status in JSON state! - GNUNET_assert (0 == - json_array_append_new (urls, - json_string (url))); - } + GNUNET_assert (0 == + json_object_set_new ( + args, + url, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_bool ("disabled", + ! enabled)))); g_free (url); } while (gtk_tree_model_iter_next (tm, &iter)); gtk_widget_destroy (GTK_WIDGET (dialog)); g_object_unref (G_OBJECT (builder)); - { - json_t *args; - - args = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_array_steal ("urls", - urls)); - AG_freeze (); - AG_ra = ANASTASIS_redux_action (AG_redux_state, - "add_provider", - args, - &AG_action_cb, - NULL); - json_decref (args); - } + AG_freeze (); + AG_ra = ANASTASIS_redux_action (AG_redux_state, + "add_provider", + args, + &AG_action_cb, + NULL); + json_decref (args); } @@ -458,11 +447,14 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton *object, uint32_t http_code; uint32_t ec; struct TALER_Amount ll; + bool disabled = false; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_uint32 ("http_status", &http_code)), - // FIXME: check: right fieldname? + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ("disabled", + &disabled)), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_amount_any ("liability_limit", &ll)), @@ -490,7 +482,8 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton *object, JSON_INDENT (2)); continue; } - if (MHD_HTTP_OK == http_code) + if ( (MHD_HTTP_OK == http_code) && + (! disabled) ) { status = GNUNET_strdup (_ ("available")); color = "green"; @@ -501,7 +494,8 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton *object, else GNUNET_break (0); } - else if (0 == http_code) + else if ( (0 == http_code) && + (! disabled) ) { GNUNET_asprintf (&status, _ ("Network failure: %s (#%u)"), @@ -509,6 +503,13 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton *object, (unsigned int) ec); color = "red"; } + else if (disabled) + { + GNUNET_asprintf (&status, + _ ("disabled")); + color = "blue"; + sensitive = true; + } else { GNUNET_asprintf (&status, @@ -527,7 +528,7 @@ anastasis_gtk_edit_provider_list_clicked_cb (GtkButton *object, AG_PMC_PROVIDER_STATUS, status, AG_PMC_PROVIDER_STATUS_COLOR, color, AG_PMC_PROVIDER_LIABILITY_LIMIT, ll_s, - AG_PMC_PROVIDER_ENABLED, sensitive, // FIXME: store active/inactive status in JSON state! + AG_PMC_PROVIDER_ENABLED, ! disabled, AG_PMC_PROVIDER_SENSITIVE, sensitive, AG_PMC_PROVIDER_NOT_SENSITIVE, ! sensitive, -1);