diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-27 22:26:07 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-27 22:26:07 +0100 |
commit | e39415981af2848da9155b1407730c5118e760e8 (patch) | |
tree | 59770332cf1c4af7cc2e9464c68a7fb13244947c /src/anastasis/anastasis-gtk_action.c | |
parent | 26af54aa831f2e84774951a5d9e0754820a26d35 (diff) | |
download | anastasis-gtk-e39415981af2848da9155b1407730c5118e760e8.tar.gz anastasis-gtk-e39415981af2848da9155b1407730c5118e760e8.tar.bz2 anastasis-gtk-e39415981af2848da9155b1407730c5118e760e8.zip |
fix #7078
Diffstat (limited to 'src/anastasis/anastasis-gtk_action.c')
-rw-r--r-- | src/anastasis/anastasis-gtk_action.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c index aefb379..d98d25c 100644 --- a/src/anastasis/anastasis-gtk_action.c +++ b/src/anastasis/anastasis-gtk_action.c @@ -65,6 +65,47 @@ bool AG_in_secret_name_editing; #define DEBUG 0 + +/** + * Lookup provider name by provider URL in our state. + * + * @param provider_url URL to lookup name for + * @return provider name, or if unknown, the @a provider_url + */ +static const char * +lookup_provider_name (const char *provider_url) +{ + json_t *providers; + json_t *provider; + const char *name; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("business_name", + &name)), + GNUNET_JSON_spec_end () + }; + + providers = json_object_get (AG_redux_state, + "authentication_providers"); + provider = json_object_get (providers, + provider_url); + if (NULL == provider) + return provider_url; + if (GNUNET_OK != + GNUNET_JSON_parse (provider, + spec, + NULL, NULL)) + { + GNUNET_break (0); + json_dumpf (provider, + stderr, + JSON_INDENT (2)); + return provider_url; + } + return name; +} + + /** * Prepare window for selection of the continent. */ @@ -931,10 +972,10 @@ action_policies_reviewing (void) json_array_foreach (methods, mindex, method) { uint32_t imethod; - const char *provider; + const char *provider_url; struct GNUNET_JSON_Specification mspec[] = { GNUNET_JSON_spec_string ("provider", - &provider), + &provider_url), GNUNET_JSON_spec_uint32 ("authentication_method", &imethod), GNUNET_JSON_spec_end () @@ -969,6 +1010,7 @@ action_policies_reviewing (void) GNUNET_JSON_spec_end () }; struct TALER_Amount method_cost; + const char *provider_name; if (GNUNET_OK != GNUNET_JSON_parse (jmethod, @@ -979,13 +1021,14 @@ action_policies_reviewing (void) continue; } if (GNUNET_OK != - lookup_recovery_cost (provider, + lookup_recovery_cost (provider_url, type, &method_cost)) { GNUNET_break (0); continue; } + provider_name = lookup_provider_name (provider_url); gtk_tree_store_insert_with_values ( ts, &miter, @@ -998,7 +1041,7 @@ action_policies_reviewing (void) AG_PRMC_COST, TALER_amount2s (&method_cost), AG_PRMC_PROVIDER_URL, - provider, + provider_url, AG_PRMC_EXPIRATION_TIME_STR, "N/A", AG_PRMC_POLICY_INDEX, @@ -1007,6 +1050,8 @@ action_policies_reviewing (void) TRUE, AG_PRMC_METHOD_INDEX, (guint) mindex, + AG_PRMC_PROVIDER_NAME, + provider_name, -1); if (NULL == summary) { @@ -1586,6 +1631,8 @@ action_backup_finished (void) GNUNET_STRINGS_absolute_time_to_string (pexp), AG_BPC_SUCCESS_FLAG, true, + AG_BPC_PROVIDER_NAME, + lookup_provider_name (url), -1); } { |