From 157a109e7feb6786fab7b31fdf8f384ca6ad7ea4 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Thu, 26 Oct 2017 22:03:24 +1100 Subject: [PATCH] Remove custom libsecret VAPI in favour of the system-provided one. This gives us access to the full libsecret API. * bindings/vapi/libsecret-1.vapi: Deleted. * src/client/application/secret-mediator.vala (Object): Use an internal binding to the missing SCHEMA_COMPAT_NETWORK constant. --- bindings/vapi/libsecret-1.vapi | 82 --------------------- src/client/application/secret-mediator.vala | 14 ++-- 2 files changed, 9 insertions(+), 87 deletions(-) delete mode 100644 bindings/vapi/libsecret-1.vapi diff --git a/bindings/vapi/libsecret-1.vapi b/bindings/vapi/libsecret-1.vapi deleted file mode 100644 index 57cd5143..00000000 --- a/bindings/vapi/libsecret-1.vapi +++ /dev/null @@ -1,82 +0,0 @@ -/* libsecret-1.vapi generated by vapigen-0.18 and hand-edited to add SCHEMA_COMPAT_NETWORK */ - -[CCode (cprefix = "Secret", gir_namespace = "Secret", gir_version = "1", lower_case_cprefix = "secret_")] -namespace Secret { - [CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_SCHEMA_COMPAT_NETWORK")] - public Secret.Schema SCHEMA_COMPAT_NETWORK; - - [CCode (cheader_filename = "libsecret/secret.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "secret_schema_get_type ()")] - [Compact] - public class Schema { - [CCode (array_length = false, array_null_terminated = true)] - public weak Secret.SchemaAttribute[] attributes; - public Secret.SchemaFlags flags; - public weak string name; - [CCode (has_construct_function = false)] - public Schema (string name, Secret.SchemaFlags flags, ...); - [CCode (cname = "secret_schema_newv", has_construct_function = false)] - public Schema.newv (string name, Secret.SchemaFlags flags, GLib.HashTable attribute_names_and_types); - public Secret.Schema @ref (); - public void unref (); - } - [CCode (cheader_filename = "libsecret/secret.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "secret_schema_attribute_get_type ()")] - [Compact] - public class SchemaAttribute { - public weak string name; - public Secret.SchemaAttributeType type; - } - [CCode (cheader_filename = "libsecret/secret.h", cprefix = "SECRET_ERROR_", has_type_id = false)] - public enum Error { - PROTOCOL, - IS_LOCKED, - NO_SUCH_OBJECT, - ALREADY_EXISTS; - public static GLib.Quark get_quark (); - } - [CCode (cheader_filename = "libsecret/secret.h", cprefix = "SECRET_SCHEMA_ATTRIBUTE_", has_type_id = false)] - public enum SchemaAttributeType { - STRING, - INTEGER, - BOOLEAN - } - [CCode (cheader_filename = "libsecret/secret.h", cprefix = "SECRET_SCHEMA_", has_type_id = false)] - [Flags] - public enum SchemaFlags { - NONE, - DONT_MATCH_NAME - } - [CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_COLLECTION_DEFAULT")] - public const string COLLECTION_DEFAULT; - [CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_COLLECTION_SESSION")] - public const string COLLECTION_SESSION; - [CCode (cheader_filename = "libsecret/secret.h")] - public static GLib.HashTable attributes_build (Secret.Schema schema, ...); - [CCode (cheader_filename = "libsecret/secret.h")] - public static GLib.HashTable attributes_buildv (Secret.Schema schema, va_list va); - [CCode (cheader_filename = "libsecret/secret.h")] - public static async bool password_clear (Secret.Schema schema, GLib.Cancellable? cancellable, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static bool password_clear_sync (Secret.Schema schema, GLib.Cancellable? cancellable = null, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h", finish_name = "secret_password_clear_finish")] - public static async bool password_clearv (Secret.Schema schema, GLib.HashTable attributes, GLib.Cancellable? cancellable) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static bool password_clearv_sync (Secret.Schema schema, GLib.HashTable attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static async string password_lookup (Secret.Schema schema, GLib.Cancellable? cancellable, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static string password_lookup_sync (Secret.Schema schema, GLib.Cancellable? cancellable = null, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h", finish_name = "secret_password_lookup_finish")] - public static async string password_lookupv (Secret.Schema schema, GLib.HashTable attributes, GLib.Cancellable? cancellable) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static string password_lookupv_sync (Secret.Schema schema, GLib.HashTable attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static async bool password_store (Secret.Schema schema, string? collection, string label, string password, GLib.Cancellable? cancellable, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static bool password_store_sync (Secret.Schema schema, string? collection, string label, string password, GLib.Cancellable? cancellable = null, ...) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h", finish_name = "secret_password_store_finish")] - public static async bool password_storev (Secret.Schema schema, GLib.HashTable attributes, string? collection, string label, string password, GLib.Cancellable? cancellable) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static bool password_storev_sync (Secret.Schema schema, GLib.HashTable attributes, string? collection, string label, string password, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "libsecret/secret.h")] - public static void password_wipe (string? password); -} diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala index f9bbc34b..4b37325c 100644 --- a/src/client/application/secret-mediator.vala +++ b/src/client/application/secret-mediator.vala @@ -23,6 +23,10 @@ public class SecretMediator : Geary.CredentialsMediator, Object { private GearyApplication instance; private Geary.Nonblocking.Mutex dialog_mutex = new Geary.Nonblocking.Mutex(); + // See Bug 697681 + [CCode (cheader_filename = "libsecret/secret.h", cname = "SECRET_SCHEMA_COMPAT_NETWORK")] + private Secret.Schema SCHEMA_COMPAT_NETWORK; + public SecretMediator(GearyApplication instance) { this.instance = instance; @@ -71,13 +75,13 @@ public class SecretMediator : Geary.CredentialsMediator, Object { // Remove legacy formats // <= 0.11 yield Secret.password_clear( - Secret.SCHEMA_COMPAT_NETWORK, + SCHEMA_COMPAT_NETWORK, cancellable, "user", get_legacy_user(service, account.primary_mailbox.address) ); // <= 0.6 yield Secret.password_clear( - Secret.SCHEMA_COMPAT_NETWORK, + SCHEMA_COMPAT_NETWORK, cancellable, "user", get_legacy_user(service, credentials.user) ); @@ -195,7 +199,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object { throws Error { // <= 0.11 string? password = yield Secret.password_lookup( - Secret.SCHEMA_COMPAT_NETWORK, + SCHEMA_COMPAT_NETWORK, cancellable, "user", get_legacy_user(service, account.primary_mailbox.address) ); @@ -205,7 +209,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object { Geary.Credentials creds = get_credentials(service, account); string user = get_legacy_user(service, creds.user); password = yield Secret.password_lookup( - Secret.SCHEMA_COMPAT_NETWORK, + SCHEMA_COMPAT_NETWORK, cancellable, "user", user ); @@ -213,7 +217,7 @@ public class SecretMediator : Geary.CredentialsMediator, Object { // Clear the old password if (password != null) { yield Secret.password_clear( - Secret.SCHEMA_COMPAT_NETWORK, + SCHEMA_COMPAT_NETWORK, cancellable, "user", user );