summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO26
-rw-r--r--src/anastasis/Makefile.am2
-rw-r--r--src/anastasis/anastasis-gtk.c10
-rw-r--r--src/anastasis/anastasis-gtk.h5
-rw-r--r--src/anastasis/anastasis-gtk_action.c205
-rw-r--r--src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c5
-rw-r--r--src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c50
-rw-r--r--src/anastasis/anastasis-gtk_helper.h37
8 files changed, 206 insertions, 134 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..a24f650
--- /dev/null
+++ b/TODO
@@ -0,0 +1,26 @@
+- add 'more' button to download 'more' policies
+ when selecting secret for recovery (needs cursor implementation!)
+- implement 'add provider' button to add additional providers
+ when selecting secret for recovery (check with reducer if
+ the needed transition is supported!)
+ => implement 'anastasis_gtk_add_provider_button_clicked_cb'
+
+- check if transitions done with new secret selection logic
+ are actually OK!
+ => after adding personal information, we currently immediately
+ jump into downloading some/all/many policies
+ => change that logic in the reducer!
+ => new state with personal information attributes and
+ list of providers, transitions: 'next' with provider+version+mask
+ or 'add_provider' with provider_url!
+- implement 'mask' in reducer logic of anastasis.git!
+ (mask field is currently set, but then not used!)
+
+
+Bugs:
+
+2022-01-19T22:41:46.983703+0100 anastasis-gtk-44468 ERROR Widget `anastasis_gtk_secret_identification_vbox' not found, cannot hide it!
+ [=> renamed?]
+
+2022-01-19T22:41:46.983735+0100 anastasis-gtk-44468 ERROR Assertion failed at anastasis_api_discovery.c:279.
+ [=> diagnose!] \ No newline at end of file
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index cf0bbcf..6827f8e 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -48,7 +48,7 @@ anastasis_gtk_SOURCES = \
anastasis-gtk_handle-policy-activate.c \
anastasis-gtk_handle-policy-button.c \
anastasis-gtk_handle-policy-meta.c \
- anastasis-gtk_handle-policy-version-changed.c \
+ anastasis-gtk_handle-policy-selection-changed.c \
anastasis-gtk_handle-recovery-button-clicked.c \
anastasis-gtk_handle-secret-buttons.c \
anastasis-gtk_helper.c anastasis-gtk_helper.h \
diff --git a/src/anastasis/anastasis-gtk.c b/src/anastasis/anastasis-gtk.c
index 13e92a2..7d0a990 100644
--- a/src/anastasis/anastasis-gtk.c
+++ b/src/anastasis/anastasis-gtk.c
@@ -36,6 +36,11 @@
struct GNUNET_GTK_MainLoop *AG_ml;
/**
+ * Active policy discovery job, or NULL.
+ */
+struct ANASTASIS_PolicyDiscovery *AG_pd;
+
+/**
* Our configuration.
*/
const struct GNUNET_CONFIGURATION_Handle *AG_cfg;
@@ -104,6 +109,11 @@ shutdown_task (void *cls)
(void) cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Shutdown initiated\n");
+ if (NULL != AG_pd)
+ {
+ ANASTASIS_policy_discovery_stop (AG_pd);
+ AG_pd = NULL;
+ }
ANASTASIS_redux_done ();
if (NULL != AG_ra)
{
diff --git a/src/anastasis/anastasis-gtk.h b/src/anastasis/anastasis-gtk.h
index 5151383..7497223 100644
--- a/src/anastasis/anastasis-gtk.h
+++ b/src/anastasis/anastasis-gtk.h
@@ -37,6 +37,11 @@
extern struct GNUNET_GTK_MainLoop *AG_ml;
/**
+ * Active policy discovery job, or NULL.
+ */
+extern struct ANASTASIS_PolicyDiscovery *AG_pd;
+
+/**
* Our configuration.
*/
extern const struct GNUNET_CONFIGURATION_Handle *AG_cfg;
diff --git a/src/anastasis/anastasis-gtk_action.c b/src/anastasis/anastasis-gtk_action.c
index df6edb0..7ab6149 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1893,13 +1893,73 @@ show_challenge_feedback (const char *uuid,
/**
- * FIXME.
+ * Function called on each discovered recovery policy. Called
+ * with all arguments NULL if we have received all policies that
+ * we could possibly receive for the current operation.
+ *
+ * The client can then start a new policy discovery process, using the
+ * smallest (also most recent) @a version received per @a provider_url
+ * in the cursor to resume. Note that in this case, the application
+ * logic is responsible for de-duplication using @a hcpd, or it may show
+ * policies again if they are at different providers under versions not
+ * queried up to the cursor.
+ *
+ * @param cls closure with the `GtkListStore` to update.
+ * @param hcpd hash of the compressed policy document (unique per policy)
+ * @param provider_url which provider claims to have this policy
+ * @param version version of the policy at this provider
+ * @param attribute_mask combination of optional identity attributes
+ * present in the state that was used to locate this version
+ * @param server_time when did the provider receive the upload
+ * @param secret_name name the user assigned to the backup
+ */
+static void
+expand_policy_list (void *cls,
+ const struct GNUNET_HashCode *hcpd,
+ const char *provider_url,
+ uint32_t version,
+ json_int_t attribute_mask,
+ struct GNUNET_TIME_Timestamp server_time,
+ const char *secret_name)
+{
+ GtkListStore *ls = cls;
+ GtkTreeIter iter;
+ bool first;
+
+ first = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls),
+ &iter);
+ gtk_list_store_insert_with_values (
+ ls,
+ &iter,
+ -1, /* append */
+ AG_SSMC_PROVIDER_URL, provider_url,
+ AG_SSMC_POLICY_VERSION, (gint) version,
+ AG_SSMC_ATTRIBUTE_MASK, (gint) attribute_mask,
+ AG_SSMC_SECRET_NAME, secret_name,
+ AG_SSMC_POLICY_DATE_STRING, GNUNET_TIME_timestamp2s (server_time),
+ AG_SSMC_POLICY_DATE_NUMERIC, (guint64) server_time.abs_time.abs_value_us,
+ -1);
+ if (first)
+ {
+ GtkTreeSelection *selection;
+
+ selection = GTK_TREE_SELECTION (
+ GCG_get_main_window_object (
+ "anastasis_gtk_secret_selection_treeselection"));
+ gtk_tree_selection_select_iter (selection,
+ &iter);
+ }
+}
+
+
+/**
+ * Function called when it is time for the user to select a secret
+ * from the list of secrets. Builds the respective tree model.
*/
static void
action_secret_selecting (void)
{
- json_t *ri;
- json_t *re;
+ GtkListStore *ls;
AG_hide ("anastasis_gtk_start_frame");
if (AG_have_error)
@@ -1907,134 +1967,15 @@ action_secret_selecting (void)
AG_hide ("anastasis_gtk_challenge_frame");
AG_hide ("anastasis_gtk_identity_frame");
AG_hide ("anastasis_gtk_secret_identification_vbox");
- re = json_object_get (AG_redux_state,
- "recovery_error");
- if (NULL != re)
- {
- bool offline;
- const char *hint;
- struct GNUNET_JSON_Specification espec[] = {
- GNUNET_JSON_spec_bool ("offline",
- &offline),
- GNUNET_JSON_spec_string ("hint",
- &hint),
- GNUNET_JSON_spec_end ()
- };
-
- AG_insensitive ("anastasis_gtk_main_window_forward_button");
- if (GNUNET_OK !=
- GNUNET_JSON_parse (re,
- espec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- AG_error ("'recovery_error' did not parse correctly");
- return;
- }
- AG_error ("%s",
- dgettext ("taler-exchange",
- hint));
- AG_show ("anastasis_gtk_progress_vbox");
- AG_progress_update ();
- AG_show ("anastasis_gtk_recovery_progress_scrolled_window");
- AG_hide ("anastasis_gtk_backup_progress_scrolled_window");
- AG_show ("anastasis_gtk_main_control_vbox");
- AG_show ("anastasis_gtk_main_window_save_as_button");
- AG_show ("anastasis_gtk_select_secret_frame");
- AG_show ("anastasis_gtk_main_window_prev_button");
- AG_hide ("anastasis_gtk_main_window_quit_button");
- return;
- }
- else
- {
- json_t *aps;
- GtkComboBoxText *bt;
- const json_t *ap;
- const char *provider_url;
-
- bt = GTK_COMBO_BOX_TEXT (GCG_get_main_window_object (
- "anastasis_gtk_provider_url_combo_box_text"));
- gtk_combo_box_text_remove_all (bt);
- aps = json_object_get (AG_redux_state,
- "authentication_providers");
- json_object_foreach (aps,
- provider_url,
- ap)
- {
- gtk_combo_box_text_insert_text (bt,
- -1, /* append */
- provider_url);
- }
- }
- ri = json_object_get (AG_redux_state,
- "recovery_information");
- if (NULL != ri)
- {
- uint64_t version;
- const char *provider_url;
- struct GNUNET_JSON_Specification vspec[] = {
- GNUNET_JSON_spec_uint64 ("version",
- &version),
- GNUNET_JSON_spec_string ("provider_url",
- &provider_url),
- GNUNET_JSON_spec_end ()
- };
- GtkSpinButton *sb;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (ri,
- vspec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- AG_error ("'recovery_information' did not parse correctly");
- return;
- }
- sb = GTK_SPIN_BUTTON (GCG_get_main_window_object (
- "anastasis_gtk_policy_version_spin_button"));
- gtk_spin_button_set_value (sb,
- version);
- if (NULL == re)
- update_entry ("anastasis_gtk_provider_url_entry",
- provider_url);
- }
- else
- {
- GtkWidget *ge;
-
- ge = GTK_WIDGET (GCG_get_main_window_object (
- "anastasis_gtk_provider_url_entry"));
- if (! gtk_widget_has_focus (ge))
- gtk_widget_grab_focus (ge);
- }
- {
- json_t *rd;
- const char *sn;
-
- rd = json_object_get (AG_redux_state,
- "recovery_document");
- if (NULL == rd)
- {
- AG_insensitive ("anastasis_gtk_main_window_forward_button");
- }
- else
- {
- AG_enable_next ();
- sn = json_string_value (json_object_get (rd,
- "secret_name"));
- if (NULL != sn)
- {
- update_label ("anastasis_gtk_secret_name_label",
- sn);
- }
- else
- {
- update_label ("anastasis_gtk_secret_name_label",
- _ ("<not set>"));
- }
- AG_show ("anastasis_gtk_secret_identification_vbox");
- }
- }
+ ls = GTK_LIST_STORE (GCG_get_main_window_object (
+ "secret_selection_liststore"));
+ gtk_list_store_clear (ls);
+ GNUNET_assert (NULL != ls);
+ GNUNET_assert (NULL == AG_pd);
+ AG_pd = ANASTASIS_policy_discovery_start (AG_redux_state,
+ NULL,
+ &expand_policy_list,
+ ls);
AG_show ("anastasis_gtk_progress_vbox");
AG_progress_update ();
AG_show ("anastasis_gtk_recovery_progress_scrolled_window");
@@ -2044,7 +1985,7 @@ action_secret_selecting (void)
AG_show ("anastasis_gtk_select_secret_frame");
AG_show ("anastasis_gtk_main_window_prev_button");
AG_hide ("anastasis_gtk_main_window_quit_button");
- AG_enable_next ();
+ AG_insensitive ("anastasis_gtk_main_window_forward_button");
}
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
index ed3fb85..a0f76a5 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-back-clicked.c
@@ -69,6 +69,11 @@ anastasis_gtk_main_window_back_clicked (GObject *object,
ANASTASIS_redux_action_cancel (AG_ra);
AG_ra = NULL;
}
+ if (NULL != AG_pd)
+ {
+ ANASTASIS_policy_discovery_stop (AG_pd);
+ AG_pd = NULL;
+ }
state = json_string_value (json_object_get (AG_redux_state,
"recovery_state"));
if (NULL == state)
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
index 8ce8e3b..c3e78f3 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -435,15 +435,63 @@ forward_secret_editing (void)
}
+/**
+ * The user has pressed 'next' after selecting a secret to recover.
+ */
static void
forward_secret_selecting (void)
{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ json_t *args;
+ char *provider_url;
+ gint version;
+ gint mask;
+
AG_freeze ();
+ if (NULL != AG_pd)
+ {
+ ANASTASIS_policy_discovery_stop (AG_pd);
+ AG_pd = NULL;
+ }
+ selection = GTK_TREE_SELECTION (
+ GCG_get_main_window_object (
+ "anastasis_gtk_secret_selection_treeselection"));
+
+ if (! gtk_tree_selection_get_selected (selection,
+ &model,
+ &iter))
+ {
+ GNUNET_break (0);
+ AG_insensitive ("anastasis_gtk_main_window_forward_button");
+ return;
+ }
+ gtk_tree_model_get (model,
+ &iter,
+ AG_SSMC_PROVIDER_URL, &provider_url,
+ AG_SSMC_POLICY_VERSION, &version,
+ AG_SSMC_ATTRIBUTE_MASK, &mask,
+ -1);
+ args = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("provider_url",
+ provider_url),
+ GNUNET_JSON_pack_uint64 ("version",
+ version),
+ GNUNET_JSON_pack_uint64 ("mask",
+ mask)
+ );
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Proceeding with policy version %u at provider %s\n",
+ (unsigned int) version,
+ provider_url);
+ g_free (provider_url);
AG_ra = ANASTASIS_redux_action (AG_redux_state,
"next",
- NULL,
+ args,
&AG_action_cb,
NULL);
+ json_decref (args);
}
diff --git a/src/anastasis/anastasis-gtk_helper.h b/src/anastasis/anastasis-gtk_helper.h
index 2cd3d7a..b19e6dd 100644
--- a/src/anastasis/anastasis-gtk_helper.h
+++ b/src/anastasis/anastasis-gtk_helper.h
@@ -58,6 +58,43 @@ enum AG_ContinentsModelColumns
/**
+ * Columns of the secret_selection_liststore.
+ */
+enum AG_SecretSelectionModelColumns
+{
+ /**
+ * A gchararray.
+ */
+ AG_SSMC_PROVIDER_URL = 0,
+
+ /**
+ * A gint.
+ */
+ AG_SSMC_POLICY_VERSION = 1,
+
+ /**
+ * A gint.
+ */
+ AG_SSMC_ATTRIBUTE_MASK = 2,
+
+ /**
+ * A gchararray.
+ */
+ AG_SSMC_SECRET_NAME = 3,
+
+ /**
+ * A gchararray.
+ */
+ AG_SSMC_POLICY_DATE_STRING = 4,
+
+ /**
+ * A guint64.
+ */
+ AG_SSMC_POLICY_DATE_NUMERIC = 5
+};
+
+
+/**
* Columns of the currency_liststore.
*/
enum AG_CurrencyModelColumns