aboutsummaryrefslogtreecommitdiff
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.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c
index 8ad386f..df6edb0 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1671,10 +1671,12 @@ find_challenge_by_uuid (const char *uuid)
1671 * Translate the @a state into a localized, human-readable 1671 * Translate the @a state into a localized, human-readable
1672 * string. 1672 * string.
1673 * 1673 *
1674 * @param f full json state about the state
1674 * @param state a challenge state, as a string 1675 * @param state a challenge state, as a string
1675 */ 1676 */
1676static const char * 1677static char *
1677translate_state (const char *state) 1678translate_state (const json_t *f,
1679 const char *state)
1678{ 1680{
1679 struct 1681 struct
1680 { 1682 {
@@ -1698,8 +1700,6 @@ translate_state (const char *state)
1698 { .in = "truth-unknown", 1700 { .in = "truth-unknown",
1699 .out = _ ("fatal: challenge unknown to provider; " 1701 .out = _ ("fatal: challenge unknown to provider; "
1700 "maybe you can solve another policy?") }, 1702 "maybe you can solve another policy?") },
1701 { .in = "rate-limit-exceeded",
1702 .out = _ ("wait, tries exceeded at this time") },
1703 { .in = "authentication-timeout", 1703 { .in = "authentication-timeout",
1704 .out = _ ("awaiting completion of authentication process") }, 1704 .out = _ ("awaiting completion of authentication process") },
1705 { .in = "external-instructions", 1705 { .in = "external-instructions",
@@ -1708,17 +1708,52 @@ translate_state (const char *state)
1708 .out = NULL } 1708 .out = NULL }
1709 }; 1709 };
1710 1710
1711 if (0 == strcmp (state,
1712 "rate-limit-exceeded"))
1713 {
1714 uint32_t request_limit;
1715 struct GNUNET_TIME_Relative rf;
1716 struct GNUNET_JSON_Specification spec[] = {
1717 GNUNET_JSON_spec_uint32 ("request_limit",
1718 &request_limit),
1719 GNUNET_JSON_spec_relative_time ("request_frequency",
1720 &rf),
1721 GNUNET_JSON_spec_end ()
1722 };
1723 char *reply;
1724
1725 if (GNUNET_OK !=
1726 GNUNET_JSON_parse (f,
1727 spec,
1728 NULL, NULL))
1729 {
1730 GNUNET_break (0);
1731 json_dumpf (f,
1732 stderr,
1733 JSON_INDENT (2));
1734 return GNUNET_strdup (
1735 _ ("wait, tries exceeded at this time"));
1736
1737 }
1738 GNUNET_asprintf (&reply,
1739 _ ("exceeded limit of %u attempts in %s"),
1740 (unsigned int) request_limit,
1741 GNUNET_TIME_relative2s (rf,
1742 true));
1743 return reply;
1744 }
1745
1711 for (unsigned int i = 0; NULL != state_map[i].in; i++) 1746 for (unsigned int i = 0; NULL != state_map[i].in; i++)
1712 { 1747 {
1713 if (0 != strcmp (state_map[i].in, 1748 if (0 != strcmp (state_map[i].in,
1714 state)) 1749 state))
1715 continue; 1750 continue;
1716 return state_map[i].out; 1751 return GNUNET_strdup (state_map[i].out);
1717 } 1752 }
1718 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1753 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1719 "Could not localize unexpected state `%s'\n", 1754 "Could not localize unexpected state `%s'\n",
1720 state); 1755 state);
1721 return state; 1756 return GNUNET_strdup (state);
1722} 1757}
1723 1758
1724 1759
@@ -1826,15 +1861,17 @@ show_challenge_feedback (const char *uuid,
1826 } 1861 }
1827 else 1862 else
1828 { 1863 {
1829 const char *hint; 1864 char *hint;
1830 GtkLabel *l; 1865 GtkLabel *l;
1831 1866
1832 hint = translate_state (state); 1867 hint = translate_state (f,
1868 state);
1833 l = GTK_LABEL (gtk_builder_get_object (builder, 1869 l = GTK_LABEL (gtk_builder_get_object (builder,
1834 "hint_label")); 1870 "hint_label"));
1835 gtk_label_set_text (l, 1871 gtk_label_set_text (l,
1836 hint); 1872 hint);
1837 gtk_widget_show (GTK_WIDGET (l)); 1873 gtk_widget_show (GTK_WIDGET (l));
1874 GNUNET_free (hint);
1838 } 1875 }
1839 if (0 == strcmp (state, 1876 if (0 == strcmp (state,
1840 "details")) 1877 "details"))