UI to choose PGP key/disabled in account settings
This commit is contained in:
parent
7bb6ff6250
commit
47ab19b3a0
|
@ -12,7 +12,7 @@ pkg_check_modules(GPGME_VALA REQUIRED ${GPGME_VALA_PACKAGES})
|
||||||
|
|
||||||
vala_precompile(GPGME_VALA_C
|
vala_precompile(GPGME_VALA_C
|
||||||
SOURCES
|
SOURCES
|
||||||
"src/gpgme-helper.vala"
|
"src/gpgme_helper.vala"
|
||||||
CUSTOM_VAPIS
|
CUSTOM_VAPIS
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi"
|
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi"
|
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi"
|
||||||
|
@ -30,7 +30,7 @@ OPTIONS
|
||||||
|
|
||||||
set(CFLAGS ${VALA_CFLAGS} ${GPGME_VALA_CFLAGS} ${GPGME_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
|
set(CFLAGS ${VALA_CFLAGS} ${GPGME_VALA_CFLAGS} ${GPGME_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
add_definitions(${CFLAGS})
|
add_definitions(${CFLAGS})
|
||||||
add_library(gpgme-vala SHARED ${GPGME_VALA_C} src/fix.c)
|
add_library(gpgme-vala SHARED ${GPGME_VALA_C} src/gpgme_fix.c)
|
||||||
target_link_libraries(gpgme-vala ${GPGME_VALA_LIBRARIES} ${GPGME_LIBRARIES})
|
target_link_libraries(gpgme-vala ${GPGME_VALA_LIBRARIES} ${GPGME_LIBRARIES})
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi
|
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#include <fix.h>
|
|
||||||
|
|
||||||
static GRecMutex gpgme_global_mutex = {0};
|
|
|
@ -1,8 +0,0 @@
|
||||||
#ifndef GPGME_FIX
|
|
||||||
#define GPGME_FIX 1
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
static GRecMutex gpgme_global_mutex;
|
|
||||||
|
|
||||||
#endif
|
|
12
gpgme-vala/src/gpgme_fix.c
Normal file
12
gpgme-vala/src/gpgme_fix.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <gpgme_fix.h>
|
||||||
|
|
||||||
|
static GRecMutex gpgme_global_mutex = {0};
|
||||||
|
|
||||||
|
gpgme_key_t gpgme_key_ref_vapi (gpgme_key_t key) {
|
||||||
|
gpgme_key_ref(key);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
gpgme_key_t gpgme_key_unref_vapi (gpgme_key_t key) {
|
||||||
|
gpgme_key_unref(key);
|
||||||
|
return key;
|
||||||
|
}
|
12
gpgme-vala/src/gpgme_fix.h
Normal file
12
gpgme-vala/src/gpgme_fix.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef GPGME_FIX
|
||||||
|
#define GPGME_FIX 1
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
static GRecMutex gpgme_global_mutex;
|
||||||
|
|
||||||
|
gpgme_key_t gpgme_key_ref_vapi (gpgme_key_t key);
|
||||||
|
gpgme_key_t gpgme_key_unref_vapi (gpgme_key_t key);
|
||||||
|
|
||||||
|
#endif
|
|
@ -58,8 +58,7 @@ public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only
|
||||||
keys.add(key);
|
keys.add(key);
|
||||||
}
|
}
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
// if (e.message != GPGError.ErrorCode.EOF.to_string()) throw e;
|
if (e.code != GPGError.ErrorCode.EOF) throw e;
|
||||||
if (e.message != "EOF") throw e;
|
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")]
|
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")]
|
||||||
namespace GPG {
|
namespace GPG {
|
||||||
[CCode (cheader_filename = "fix.h")]
|
[CCode (cheader_filename = "gpgme_fix.h")]
|
||||||
public static GLib.RecMutex global_mutex;
|
public static GLib.RecMutex global_mutex;
|
||||||
|
|
||||||
[CCode (cname = "struct _gpgme_engine_info")]
|
[CCode (cname = "struct _gpgme_engine_info")]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")]
|
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h,gpgme_fix.h")]
|
||||||
namespace GPG {
|
namespace GPG {
|
||||||
|
|
||||||
[CCode (cname = "gpgme_check_version")]
|
[CCode (cname = "gpgme_check_version")]
|
||||||
public unowned string check_version(string? required_version = null);
|
public unowned string check_version(string? required_version = null);
|
||||||
|
|
||||||
[Compact]
|
[Compact]
|
||||||
[CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref", ref_function_void = true, unref_function = "gpgme_key_unref", free_function = "gpgme_key_release")]
|
[CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref_vapi", unref_function = "gpgme_key_unref_vapi", free_function = "gpgme_key_release")]
|
||||||
public class Key {
|
public class Key {
|
||||||
public bool revoked;
|
public bool revoked;
|
||||||
public bool expired;
|
public bool expired;
|
||||||
|
@ -14,19 +14,20 @@ public class Key {
|
||||||
public bool can_encrypt;
|
public bool can_encrypt;
|
||||||
public bool can_sign;
|
public bool can_sign;
|
||||||
public bool can_certify;
|
public bool can_certify;
|
||||||
public bool secret;
|
|
||||||
public bool can_authenticate;
|
public bool can_authenticate;
|
||||||
public bool is_qualified;
|
public bool is_qualified;
|
||||||
|
public bool secret;
|
||||||
public Protocol protocol;
|
public Protocol protocol;
|
||||||
public string issuer_serial;
|
public string issuer_serial;
|
||||||
public string issuer_name;
|
public string issuer_name;
|
||||||
public string issuer_id;
|
public string chain_id;
|
||||||
public Validity owner_trust;
|
public Validity owner_trust;
|
||||||
[CCode(array_null_terminated = true)]
|
[CCode(array_null_terminated = true)]
|
||||||
public SubKey[] subkeys;
|
public SubKey[] subkeys;
|
||||||
[CCode(array_null_terminated = true)]
|
[CCode(array_null_terminated = true)]
|
||||||
public UserID[] uids;
|
public UserID[] uids;
|
||||||
public KeylistMode keylist_mode;
|
public KeylistMode keylist_mode;
|
||||||
|
public string fpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CCode (cname = "struct _gpgme_user_id")]
|
[CCode (cname = "struct _gpgme_user_id")]
|
||||||
|
|
|
@ -128,8 +128,9 @@ SOURCES
|
||||||
src/ui/unified_window.vala
|
src/ui/unified_window.vala
|
||||||
src/ui/util.vala
|
src/ui/util.vala
|
||||||
CUSTOM_VAPIS
|
CUSTOM_VAPIS
|
||||||
${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi
|
"${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi"
|
||||||
${CMAKE_BINARY_DIR}/qlite/qlite.vapi
|
"${CMAKE_BINARY_DIR}/qlite/qlite.vapi"
|
||||||
|
"${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi"
|
||||||
PACKAGES
|
PACKAGES
|
||||||
${LIBDINO_PACKAGES}
|
${LIBDINO_PACKAGES}
|
||||||
GENERATE_VAPI
|
GENERATE_VAPI
|
||||||
|
@ -144,11 +145,11 @@ OPTIONS
|
||||||
--thread
|
--thread
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite)
|
set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite -I${CMAKE_BINARY_DIR}/gpgme-vala -I${CMAKE_SOURCE_DIR}/gpgme-vala/src)
|
||||||
add_definitions(${CFLAGS})
|
add_definitions(${CFLAGS})
|
||||||
add_library(libdino SHARED ${LIBDINO_VALA_C} ${LIBDINO_GRESOURCES_TARGET})
|
add_library(libdino SHARED ${LIBDINO_VALA_C} ${LIBDINO_GRESOURCES_TARGET})
|
||||||
add_dependencies(libdino xmpp-vala-vapi qlite-vapi)
|
add_dependencies(libdino xmpp-vala-vapi qlite-vapi gpgme-vapi)
|
||||||
target_link_libraries(libdino xmpp-vala qlite ${LIBDINO_LIBRARIES} -lm)
|
target_link_libraries(libdino xmpp-vala qlite gpgme-vala ${LIBDINO_LIBRARIES} -lm)
|
||||||
set_target_properties(libdino PROPERTIES PREFIX "")
|
set_target_properties(libdino PROPERTIES PREFIX "")
|
||||||
|
|
||||||
add_custom_target(dino-vapi
|
add_custom_target(dino-vapi
|
||||||
|
|
|
@ -282,7 +282,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxText" id="pgp_combobox">
|
<object class="GtkComboBox" id="pgp_combobox">
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="width_request">200</property>
|
<property name="width_request">200</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Gdk;
|
using Gdk;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using Markup;
|
||||||
|
|
||||||
using Dino.Entities;
|
using Dino.Entities;
|
||||||
|
|
||||||
|
@ -34,13 +35,17 @@ public class Dialog : Gtk.Window {
|
||||||
[GtkChild] public Stack pgp_stack;
|
[GtkChild] public Stack pgp_stack;
|
||||||
[GtkChild] public Label pgp_label;
|
[GtkChild] public Label pgp_label;
|
||||||
[GtkChild] public Button pgp_button;
|
[GtkChild] public Button pgp_button;
|
||||||
[GtkChild] public ComboBoxText pgp_combobox;
|
[GtkChild] public ComboBox pgp_combobox;
|
||||||
|
|
||||||
|
|
||||||
private Database db;
|
private Database db;
|
||||||
private StreamInteractor stream_interactor;
|
private StreamInteractor stream_interactor;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
|
CellRendererText renderer = new Gtk.CellRendererText();
|
||||||
|
pgp_combobox.pack_start(renderer, true);
|
||||||
|
pgp_combobox.add_attribute(renderer, "markup", 0);
|
||||||
|
|
||||||
account_list.row_selected.connect(account_list_row_selected);
|
account_list.row_selected.connect(account_list_row_selected);
|
||||||
add_button.clicked.connect(add_button_clicked);
|
add_button.clicked.connect(add_button_clicked);
|
||||||
no_accounts_add.clicked.connect(add_button_clicked);
|
no_accounts_add.clicked.connect(add_button_clicked);
|
||||||
|
@ -126,9 +131,41 @@ public class Dialog : Gtk.Window {
|
||||||
|
|
||||||
password_button.clicked.connect(() => { set_active_stack(password_stack); });
|
password_button.clicked.connect(() => { set_active_stack(password_stack); });
|
||||||
alias_button.clicked.connect(() => { set_active_stack(alias_stack); });
|
alias_button.clicked.connect(() => { set_active_stack(alias_stack); });
|
||||||
|
pgp_button.clicked.connect(() => { set_active_stack(pgp_stack); pgp_combobox.popup(); });
|
||||||
active_switch.state_set.connect(on_active_switch_state_changed);
|
active_switch.state_set.connect(on_active_switch_state_changed);
|
||||||
|
|
||||||
|
populate_pgp_combobox(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populate_pgp_combobox(Account account) {
|
||||||
|
|
||||||
|
Gtk.ListStore list_store = new Gtk.ListStore(2, typeof(string), typeof(string?));
|
||||||
|
Gtk.TreeIter iter;
|
||||||
|
|
||||||
|
pgp_combobox.set_model(list_store);
|
||||||
|
|
||||||
|
list_store.append(out iter);
|
||||||
|
list_store.set(iter, 0, "Disabled", 1, null);
|
||||||
|
Gee.List<GPG.Key> list = GPGHelper.get_keylist(null, true);
|
||||||
|
foreach (GPG.Key key in list) {
|
||||||
|
list_store.append(out iter);
|
||||||
|
list_store.set(iter, 0, @"<span font='11'>$(escape_text(key.uids[0].uid))</span>\n<span font='9'>0x$(escape_text(key.fpr[0:16]))</span>");
|
||||||
|
list_store.set(iter, 1, key.fpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
pgp_combobox.set_active(0);
|
||||||
|
|
||||||
|
pgp_combobox.changed.connect(() => {
|
||||||
|
TreeIter selected;
|
||||||
|
pgp_combobox.get_active_iter(out selected);
|
||||||
|
Value text;
|
||||||
|
list_store.get_value(selected, 0, out text);
|
||||||
|
pgp_label.set_markup((string) text);
|
||||||
|
pgp_stack.set_visible_child_name("label");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void on_image_button_clicked() {
|
private void on_image_button_clicked() {
|
||||||
FileChooserDialog chooser = new FileChooserDialog (
|
FileChooserDialog chooser = new FileChooserDialog (
|
||||||
"Select avatar", this, FileChooserAction.OPEN,
|
"Select avatar", this, FileChooserAction.OPEN,
|
||||||
|
|
Loading…
Reference in a new issue