diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala index 83686424..b50581f8 100644 --- a/libdino/src/service/database.vala +++ b/libdino/src/service/database.vala @@ -103,16 +103,6 @@ public class Database : Qlite.Database { } } - public class PgpTable : Table { - public Column jid = new Column.Text("jid") { primary_key = true }; - public Column key = new Column.Text("key") { not_null = true }; - - protected PgpTable(Database db) { - base(db, "pgp"); - init({jid, key}); - } - } - public class EntityFeatureTable : Table { public Column entity = new Column.Text("entity"); public Column feature = new Column.Text("feature"); @@ -129,7 +119,6 @@ public class Database : Qlite.Database { public RealJidTable real_jid { get; private set; } public ConversationTable conversation { get; private set; } public AvatarTable avatar { get; private set; } - public PgpTable pgp { get; private set; } public EntityFeatureTable entity_feature { get; private set; } public Database(string fileName) { @@ -140,9 +129,8 @@ public class Database : Qlite.Database { real_jid = new RealJidTable(this); conversation = new ConversationTable(this); avatar = new AvatarTable(this); - pgp = new PgpTable(this); entity_feature = new EntityFeatureTable(this); - init({ account, jid, message, real_jid, conversation, avatar, pgp, entity_feature }); + init({ account, jid, message, real_jid, conversation, avatar, entity_feature }); } public override void migrate(long oldVersion) { @@ -420,17 +408,6 @@ public class Database : Qlite.Database { return ret; } - public void set_pgp_key(Jid jid, string key) { - pgp.insert().or("REPLACE") - .value(pgp.jid, jid.to_string()) - .value(pgp.key, key) - .perform(); - } - - public string? get_pgp_key(Jid jid) { - return pgp.select({pgp.key}).with(pgp.jid, "=", jid.to_string())[pgp.key]; - } - public void add_entity_features(string entity, ArrayList features) { foreach (string feature in features) { entity_feature.insert() diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/gpgme-vala/src/gpgme_helper.vala index 9efa2b4c..429c96f0 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/gpgme-vala/src/gpgme_helper.vala @@ -28,12 +28,13 @@ public static string decrypt(string encr) throws GLib.Error { return get_string_from_data(dec_data); } -public static string sign(string plain, SigMode mode) throws GLib.Error { +public static string sign(string plain, SigMode mode, Key? key = null) throws GLib.Error { initialize(); global_mutex.lock(); Data plain_data = Data.create_from_memory(plain.data, false); Context context = Context.create(); + if (key != null) context.signers_add(key); Data signed_data = context.op_sign(plain_data, mode); global_mutex.unlock(); return get_string_from_data(signed_data); @@ -76,11 +77,19 @@ public static Gee.List get_keylist(string? pattern = null, bool secret_only } public static Key? get_public_key(string sig) throws GLib.Error { + return get_key(sig, false); +} + +public static Key? get_private_key(string sig) throws GLib.Error { + return get_key(sig, true); +} + +private static Key? get_key(string sig, bool priv) throws GLib.Error { initialize(); global_mutex.lock(); Context context = Context.create(); - Key key = context.get_key(sig, false); + Key key = context.get_key(sig, priv); global_mutex.unlock(); return key; } diff --git a/plugins/openpgp/CMakeLists.txt b/plugins/openpgp/CMakeLists.txt index a230872e..09a4ca7f 100644 --- a/plugins/openpgp/CMakeLists.txt +++ b/plugins/openpgp/CMakeLists.txt @@ -31,12 +31,13 @@ vala_precompile(OPENPGP_VALA_C SOURCES src/account_settings_entry.vala src/account_settings_widget.vala + src/database.vala src/encryption_list_entry.vala src/manager.vala src/plugin.vala src/register_plugin.vala - src/xmpp_flag.vala - src/xmpp_module.vala + src/stream_flag.vala + src/stream_module.vala CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/gpgme.vapi ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi diff --git a/plugins/openpgp/data/account_settings_item.ui b/plugins/openpgp/data/account_settings_item.ui index 95f09046..299b9a89 100644 --- a/plugins/openpgp/data/account_settings_item.ui +++ b/plugins/openpgp/data/account_settings_item.ui @@ -3,11 +3,11 @@