summaryrefslogtreecommitdiff
path: root/src/anastasis/anastasis-gtk_action.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/anastasis/anastasis-gtk_action.c')
-rw-r--r--src/anastasis/anastasis-gtk_action.c150
1 files changed, 9 insertions, 141 deletions
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c
index a597eb2..7beabbf 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1682,96 +1682,6 @@ find_challenge_by_uuid (const char *uuid)
/**
- * Translate the @a state into a localized, human-readable
- * string.
- *
- * @param f full json state about the state
- * @param state a challenge state, as a string
- */
-static char *
-translate_state (const json_t *f,
- const char *state)
-{
- struct
- {
- const char *in;
- const char *out;
- } state_map [] = {
- { .in = "solved",
- .out = _ ("challenge solved") },
- { .in = "payment",
- .out = _ ("make payment") },
- { .in = "body",
- .out = _ ("fatal: unexpected reply from provider") },
- { .in = "hint",
- .out = _ ("read hint") },
- { .in = "details",
- .out = _ ("read feedback") },
- { .in = "redirect",
- .out = _ ("open link") },
- { .in = "server-failure",
- .out = _ ("wait, Anastasis provider failed (hopefully temporary)") },
- { .in = "truth-unknown",
- .out = _ ("fatal: challenge unknown to provider; "
- "maybe you can solve another policy?") },
- { .in = "authentication-timeout",
- .out = _ ("awaiting completion of authentication process") },
- { .in = "external-instructions",
- .out = _ ("challenge-specific action required") },
- { .in = NULL,
- .out = NULL }
- };
-
- if (0 == strcmp (state,
- "rate-limit-exceeded"))
- {
- uint32_t request_limit;
- struct GNUNET_TIME_Relative rf;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_uint32 ("request_limit",
- &request_limit),
- GNUNET_JSON_spec_relative_time ("request_frequency",
- &rf),
- GNUNET_JSON_spec_end ()
- };
- char *reply;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (f,
- spec,
- NULL, NULL))
- {
- GNUNET_break (0);
- json_dumpf (f,
- stderr,
- JSON_INDENT (2));
- return GNUNET_strdup (
- _ ("wait, tries exceeded at this time"));
-
- }
- GNUNET_asprintf (&reply,
- _ ("exceeded limit of %u attempts in %s"),
- (unsigned int) request_limit,
- GNUNET_TIME_relative2s (rf,
- true));
- return reply;
- }
-
- for (unsigned int i = 0; NULL != state_map[i].in; i++)
- {
- if (0 != strcmp (state_map[i].in,
- state))
- continue;
- return GNUNET_strdup (state_map[i].out);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Could not localize unexpected state `%s'\n",
- state);
- return GNUNET_strdup (state);
-}
-
-
-/**
* Update the list store with the challenge feedback.
*
* @param uuid the UUID to render feedback for
@@ -1784,12 +1694,9 @@ show_challenge_feedback (const char *uuid,
json_t *cf;
const json_t *f;
const char *state;
- const char *redirect_url = NULL;
const char *hint = NULL;
- json_t *details = NULL;
const char *taler_pay_uri = NULL;
uint32_t ec = 0;
- uint32_t http_status = 0;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("state",
&state),
@@ -1797,18 +1704,9 @@ show_challenge_feedback (const char *uuid,
GNUNET_JSON_spec_string ("taler_pay_uri",
&taler_pay_uri)),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("details",
- &details)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("redirect_url",
- &redirect_url)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("hint",
+ GNUNET_JSON_spec_string ("display_hint",
&hint)),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
- GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("error_code",
&ec)),
GNUNET_JSON_spec_end ()
@@ -1844,58 +1742,28 @@ show_challenge_feedback (const char *uuid,
g_object_unref (qr);
}
}
- /* Note: Eventually, we want to think about where we show the
- redirect_url, if 'state' == 'redirect';
- But: redirect_url is currently not used by any provider.*/
if (TALER_EC_NONE != ec)
{
const char *emsg;
GtkLabel *l;
+ char *msg;
emsg = TALER_ErrorCode_get_hint (ec);
+ GNUNET_asprintf (&msg,
+ "#%u: %s",
+ (unsigned int) ec,
+ emsg);
l = GTK_LABEL (gtk_builder_get_object (builder,
"error_label"));
gtk_label_set_text (l,
- emsg);
- gtk_widget_show (GTK_WIDGET (l));
- }
- if (0 == strcmp (state,
- "hint"))
- {
- const char *thint;
- GtkLabel *l;
-
- thint = dgettext ("taler-exchange",
- hint);
- l = GTK_LABEL (gtk_builder_get_object (builder,
- "hint_label"));
- gtk_label_set_text (l,
- thint);
- gtk_widget_show (GTK_WIDGET (l));
- }
- else
- {
- char *hint;
- GtkLabel *l;
-
- hint = translate_state (f,
- state);
- l = GTK_LABEL (gtk_builder_get_object (builder,
- "hint_label"));
- gtk_label_set_text (l,
- hint);
+ msg);
+ GNUNET_free (msg);
gtk_widget_show (GTK_WIDGET (l));
- GNUNET_free (hint);
}
- if (0 == strcmp (state,
- "details"))
+ if (NULL != hint)
{
- const char *hint;
GtkLabel *l;
- hint = dgettext ("taler-exchange",
- json_string_value (json_object_get (details,
- "hint")));
l = GTK_LABEL (gtk_builder_get_object (builder,
"hint_label"));
gtk_label_set_text (l,