[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: implement secret display lo
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: implement secret display logic |
Date: |
Mon, 15 Mar 2021 21:35:39 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis-gtk.
The following commit(s) were added to refs/heads/master by this push:
new d36b464 implement secret display logic
d36b464 is described below
commit d36b464a9f102936b54e53ba63a538e4e7430554
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Mon Mar 15 21:35:36 2021 +0100
implement secret display logic
---
contrib/Makefile.am | 3 +-
contrib/anastasis_gtk_save_secret_dialog.glade | 93 +++++++++++++++++
src/anastasis/anastasis-gtk_action.c | 36 +++----
.../anastasis-gtk_handle-challenge-code.c | 24 ++---
.../anastasis-gtk_handle-challenge-question.c | 8 +-
.../anastasis-gtk_handle-secret-buttons.c | 114 +++++++++++++++++++--
src/anastasis/anastasis-gtk_io.c | 27 ++---
7 files changed, 252 insertions(+), 53 deletions(-)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index e9c46de..f64e115 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -31,4 +31,5 @@ pkgdata_DATA = \
anastasis_gtk_edit_providers.glade \
anastasis_gtk_open_file_dialog.glade \
anastasis_gtk_main_window.glade \
- anastasis_gtk_save_file_dialog.glade
+ anastasis_gtk_save_file_dialog.glade \
+ anastasis_gtk_save_secret_dialog.glade
diff --git a/contrib/anastasis_gtk_save_secret_dialog.glade
b/contrib/anastasis_gtk_save_secret_dialog.glade
new file mode 100644
index 0000000..d80efea
--- /dev/null
+++ b/contrib/anastasis_gtk_save_secret_dialog.glade
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Copyright (C)
+
+This file is part of .
+
+ is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+ is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with . If not, see <http://www.gnu.org/licenses/>.
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <!-- interface-license-type gplv3 -->
+ <object class="GtkFileFilter" id="anastasis_file_filter">
+ <patterns>
+ <pattern>*.secret</pattern>
+ </patterns>
+ </object>
+ <object class="GtkFileChooserDialog" id="save_file_dialog">
+ <property name="can-focus">False</property>
+ <property name="window-position">center</property>
+ <property name="type-hint">dialog</property>
+ <property name="action">save</property>
+ <property name="filter">anastasis_file_filter</property>
+ <signal name="response" handler="save_secret_dialog_response_cb"
swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="has-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button1</action-widget>
+ <action-widget response="-3">button2</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/anastasis/anastasis-gtk_action.c
b/src/anastasis/anastasis-gtk_action.c
index 5ea33db..6225026 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1265,7 +1265,7 @@ action_challenge_selecting (void)
AG_hide_all_frames ();
rd = json_object_get (redux_state,
- "recovery_document");
+ "recovery_document");
{
GtkTreeStore *ts;
json_t *policies;
@@ -1327,15 +1327,15 @@ action_challenge_selecting (void)
AG_error ("Policy did not parse correctly");
return;
}
- {
- const json_t *ks;
-
- ks = json_object_get (cs,
- "key_share");
- if ( (NULL != ks) &&
- (! json_is_null (ks)) )
- continue; /* already solved */
- }
+ {
+ const json_t *ks;
+
+ ks = json_object_get (cs,
+ "key_share");
+ if ( (NULL != ks) &&
+ (! json_is_null (ks)) )
+ continue; /* already solved */
+ }
if (GNUNET_OK !=
GNUNET_JSON_parse (cs,
cspec,
@@ -1426,10 +1426,10 @@ action_challenge_selecting (void)
const json_t *ks;
ks = json_object_get (challenge,
- "key_share");
+ "key_share");
if ( (NULL != ks) &&
- (! json_is_null (ks)) )
- continue; /* already solved */
+ (! json_is_null (ks)) )
+ continue; /* already solved */
}
if (GNUNET_OK !=
GNUNET_JSON_parse (challenge,
@@ -1440,8 +1440,8 @@ action_challenge_selecting (void)
continue;
}
lookup_recovery_cost (provider,
- type,
- &cost);
+ type,
+ &cost);
{
char *ins_str;
@@ -1637,16 +1637,16 @@ action_challenge_solving (void)
const char *type;
GtkDialog *diag;
const char *uuid;
- const json_t *challenge;
+ const json_t *challenge;
uuid = json_string_value (json_object_get (redux_state,
- "selected_challenge_uuid"));
+ "selected_challenge_uuid"));
if (NULL == uuid)
{
GNUNET_break (0);
return;
}
- challenge = find_challenge_by_uuid (uuid);
+ challenge = find_challenge_by_uuid (uuid);
if (NULL == challenge)
{
GNUNET_break (0);
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-code.c
b/src/anastasis/anastasis-gtk_handle-challenge-code.c
index 0db6e61..00b7fee 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-code.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-code.c
@@ -55,23 +55,23 @@ anastasis_gtk_c_code_dialog_response_cb (GtkDialog *dialog,
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
ra = ANASTASIS_redux_action (redux_state,
- "back",
- NULL,
- &AG_action_cb,
- NULL);
+ "back",
+ NULL,
+ &AG_action_cb,
+ NULL);
return;
}
q = GTK_ENTRY (gtk_builder_get_object (builder,
"anastasis_gtk_c_code_entry"));
qs = gtk_entry_get_text (q);
if (1 != sscanf (qs,
- "%u%c",
- &pin,
- &dummy))
+ "%u%c",
+ &pin,
+ &dummy))
{
GNUNET_break (0);
return;
- }
+ }
args = json_pack ("{s:I}",
"pin",
qs);
@@ -102,10 +102,10 @@ anastasis_gtk_c_code_dialog_answer_entry_changed_cb
(GtkEntry *entry,
"anastasis_gtk_c_code_entry"));
as = gtk_entry_get_text (a);
ok = ( (NULL != as) &&
- (1 == sscanf (as,
- "%u%c",
- &pin,
- &dummy)) );
+ (1 == sscanf (as,
+ "%u%c",
+ &pin,
+ &dummy)) );
gtk_widget_set_sensitive (
GTK_WIDGET (gtk_builder_get_object (builder,
"anastasis_gtk_c_code_dialog_btn_ok")),
diff --git a/src/anastasis/anastasis-gtk_handle-challenge-question.c
b/src/anastasis/anastasis-gtk_handle-challenge-question.c
index 9663cc3..e50cb4c 100644
--- a/src/anastasis/anastasis-gtk_handle-challenge-question.c
+++ b/src/anastasis/anastasis-gtk_handle-challenge-question.c
@@ -53,10 +53,10 @@ anastasis_gtk_c_question_dialog_response_cb (GtkDialog
*dialog,
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
ra = ANASTASIS_redux_action (redux_state,
- "back",
- NULL,
- &AG_action_cb,
- NULL);
+ "back",
+ NULL,
+ &AG_action_cb,
+ NULL);
return;
}
q = GTK_ENTRY (gtk_builder_get_object (builder,
diff --git a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
index c327365..f99b9d4 100644
--- a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
+++ b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
@@ -45,6 +45,71 @@ anastasis_gtk_enter_secret_open_button_clicked_cb (GtkButton
*button,
}
+/**
+ * Function called from the open-directory dialog upon completion.
+ *
+ * @param dialog the pseudonym selection dialog
+ * @param response_id response code from the dialog
+ * @param user_data the builder of the dialog
+ */
+void
+save_secret_dialog_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+ char *filename;
+ size_t data_len;
+ void *data;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_varsize ("core_secret",
+ &data,
+ &data_len),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GTK_RESPONSE_ACCEPT != response_id)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (G_OBJECT (builder));
+ return;
+ }
+ filename =
+ GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (G_OBJECT (builder));
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_JSON_parse (redux_state,
+ spec,
+ NULL, NULL));
+ {
+ enum GNUNET_GenericReturnValue ret;
+
+ ret = GNUNET_DISK_fn_write (filename,
+ data,
+ data_len,
+ GNUNET_DISK_PERM_USER_READ);
+ switch (ret)
+ {
+ case GNUNET_OK:
+ break;
+ case GNUNET_NO:
+ AG_error ("File `%s' exists",
+ filename);
+ break;
+ case GNUNET_SYSERR:
+ AG_error ("Writing to file `%s' failed: %s",
+ filename,
+ strerror (errno));
+ break;
+ }
+ }
+ GNUNET_JSON_parse_free (spec);
+ GNUNET_free (filename);
+}
+
+
/**
* User clicked the "save as" button in the dialog with the recovered secret.
*
@@ -55,9 +120,29 @@ void
anastasis_gtk_secret_save_as_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
- // FIXME: open save-as dialog
- // dump secret to file
- GNUNET_break (0);
+ GtkWidget *ad;
+ GtkBuilder *builder;
+
+ builder = GNUNET_GTK_get_new_builder (
+ "anastasis_gtk_save_secret_dialog.glade",
+ NULL);
+ if (NULL == builder)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ ad = GTK_WIDGET (gtk_builder_get_object (builder,
+ "save_file_dialog"));
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (ad),
+ "untitled.secret");
+ {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+ gtk_window_set_transient_for (GTK_WINDOW (ad),
+ GTK_WINDOW (toplevel));
+ gtk_window_present (GTK_WINDOW (ad));
+ }
}
@@ -71,7 +156,24 @@ void
anastasis_gtk_secret_copy_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
- // FIXME: open save-as dialog
- // dump secret to file
- GNUNET_break (0);
+ size_t data_len;
+ void *data;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_varsize ("core_secret",
+ &data,
+ &data_len),
+ GNUNET_JSON_spec_end ()
+ };
+ GtkClipboard *cb;
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_JSON_parse (redux_state,
+ spec,
+ NULL, NULL));
+ cb = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ GNUNET_assert (NULL != cb);
+ gtk_clipboard_set_text (cb,
+ data,
+ data_len);
+ GNUNET_JSON_parse_free (spec);
}
diff --git a/src/anastasis/anastasis-gtk_io.c b/src/anastasis/anastasis-gtk_io.c
index bf73b32..ac9d06f 100644
--- a/src/anastasis/anastasis-gtk_io.c
+++ b/src/anastasis/anastasis-gtk_io.c
@@ -105,7 +105,6 @@ save_directory_dialog_response_cb (GtkDialog *dialog,
{
GtkBuilder *builder = GTK_BUILDER (user_data);
char *filename;
- const char *ana;
if (GTK_RESPONSE_ACCEPT != response_id)
{
@@ -121,18 +120,22 @@ save_directory_dialog_response_cb (GtkDialog *dialog,
GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
- ana = strstr (filename,
- ".ana");
- if ( (NULL == ana) ||
- (4 != strlen (ana)) )
{
- char *tmp;
-
- GNUNET_asprintf (&tmp,
- "%s.ana",
- filename);
- GNUNET_free (filename);
- filename = tmp;
+ const char *ana;
+
+ ana = strstr (filename,
+ ".ana");
+ if ( (NULL == ana) ||
+ (4 != strlen (ana)) )
+ {
+ char *tmp;
+
+ GNUNET_asprintf (&tmp,
+ "%s.ana",
+ filename);
+ GNUNET_free (filename);
+ filename = tmp;
+ }
}
if (0 !=
json_dump_file (redux_state,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis-gtk] branch master updated: implement secret display logic,
gnunet <=