summaryrefslogtreecommitdiff
path: root/src/anastasis/anastasis-gtk_action.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-19 22:45:53 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-19 22:45:53 +0100
commit6dfafa176e35f24268f1224f5cb499c27b3ad578 (patch)
tree63d9d5570b9d094ae40e37f271383dcf5602bdc9 /src/anastasis/anastasis-gtk_action.c
parentf60427ebc5369faa43b9ad721d15dbbd6e92baf8 (diff)
downloadanastasis-gtk-6dfafa176e35f24268f1224f5cb499c27b3ad578.tar.gz
anastasis-gtk-6dfafa176e35f24268f1224f5cb499c27b3ad578.tar.bz2
anastasis-gtk-6dfafa176e35f24268f1224f5cb499c27b3ad578.zip
-wip
Diffstat (limited to 'src/anastasis/anastasis-gtk_action.c')
-rw-r--r--src/anastasis/anastasis-gtk_action.c205
1 files changed, 73 insertions, 132 deletions
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");
}