[libsecret/wip/dueno/backend: 2/4] secret-backend: New interface to represent password storage backend
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsecret/wip/dueno/backend: 2/4] secret-backend: New interface to represent password storage backend
- Date: Mon, 1 Jul 2019 05:48:01 +0000 (UTC)
commit 480966b25037b819b63b9b3880cf8d6d41a5fc3f
Author: Daiki Ueno <dueno src gnome org>
Date: Sat Jun 29 16:56:03 2019 +0200
secret-backend: New interface to represent password storage backend
libsecret/Makefile.am | 2 +
libsecret/meson.build | 2 +
libsecret/secret-backend.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++
libsecret/secret-backend.h | 81 +++++++++++++++++++++++++++++++++++++++
4 files changed, 180 insertions(+)
---
diff --git a/libsecret/Makefile.am b/libsecret/Makefile.am
index 0e661b8..0e34ea3 100644
--- a/libsecret/Makefile.am
+++ b/libsecret/Makefile.am
@@ -7,6 +7,7 @@ incdir = $(includedir)/libsecret-@SECRET_MAJOR@/libsecret
libsecret_HEADS = \
libsecret/secret.h \
libsecret/secret-attributes.h \
+ libsecret/secret-backend.h \
libsecret/secret-collection.h \
libsecret/secret-item.h \
libsecret/secret-password.h \
@@ -38,6 +39,7 @@ libsecret_BUILT = \
libsecret_PUBLIC = \
libsecret/secret-attributes.h libsecret/secret-attributes.c \
+ libsecret/secret-backend.h libsecret/secret-backend.c \
libsecret/secret-collection.h libsecret/secret-collection.c \
libsecret/secret-item.h libsecret/secret-item.c \
libsecret/secret-methods.c \
diff --git a/libsecret/meson.build b/libsecret/meson.build
index 60fa11e..165d06f 100644
--- a/libsecret/meson.build
+++ b/libsecret/meson.build
@@ -2,6 +2,7 @@ installed_headers_subdir = join_paths('libsecret-@0@'.format(api_version_major),
libsecret_sources = [
'secret-attributes.c',
+ 'secret-backend.c',
'secret-collection.c',
'secret-item.c',
'secret-methods.c',
@@ -20,6 +21,7 @@ libsecret_sources = [
libsecret_headers = [
'secret.h',
'secret-attributes.h',
+ 'secret-backend.h',
'secret-collection.h',
'secret-item.h',
'secret-password.h',
diff --git a/libsecret/secret-backend.c b/libsecret/secret-backend.c
new file mode 100644
index 0000000..1cd3f1f
--- /dev/null
+++ b/libsecret/secret-backend.c
@@ -0,0 +1,95 @@
+/* libsecret - GLib wrapper for Secret Service
+ *
+ * Copyright 2019 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the licence or (at
+ * your option) any later version.
+ *
+ * See the included COPYING file for more information.
+ *
+ * Author: Daiki Ueno
+ */
+
+#include "config.h"
+
+#include "secret-backend.h"
+#include "secret-private.h"
+
+/**
+ * SECTION:secret-backend
+ * @title: SecretBackend
+ * @short_description: A backend implementation of password storage
+ *
+ * #SecretBackend represents a backend implementation of password
+ * storage.
+ *
+ * Stability: Stable
+ */
+
+/**
+ * SecretBackend:
+ *
+ * An object representing a backend implementation of password storage.
+ */
+
+/**
+ * SecretBackendInterface:
+ * @parent_iface: the parent interface
+ * @store: implementation of secret_password_store(), required
+ * @store_finish: implementation of secret_password_store_finish(), required
+ * @lookup: implementation of secret_password_lookup(), required
+ * @lookup_finish: implementation of secret_password_lookup_finish(), required
+ * @clear: implementation of secret_password_clear(), required
+ * @clear_finish: implementation of secret_password_clear_finish(), required
+ * @search: implementation of secret_password_search(), required
+ * @search_finish: implementation of secret_password_search_finish(), required
+ *
+ * The interface for #SecretBackend.
+ */
+
+/**
+ * SecretBackendFlags:
+ * @SECRET_BACKEND_NONE: no flags for initializing the #SecretBackend
+ * @SECRET_BACKEND_OPEN_SESSION: establish a session for transfer of secrets
+ * while initializing the #SecretBackend
+ * @SECRET_BACKEND_LOAD_COLLECTIONS: load collections while initializing the
+ * #SecretBackend
+ *
+ * Flags which determine which parts of the #SecretBackend are initialized.
+ */
+
+G_DEFINE_INTERFACE_WITH_CODE (SecretBackend, secret_backend, G_TYPE_OBJECT,
+ g_type_interface_add_prerequisite(g_define_type_id, G_TYPE_ASYNC_INITABLE);
+);
+
+static void
+secret_backend_default_init (SecretBackendInterface *iface)
+{
+ /**
+ * SecretBackend:flags:
+ *
+ * A set of flags describing which parts of the secret backend have
+ * been initialized.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_flags ("flags", "Flags", "Service flags",
+ secret_service_flags_get_type (), SECRET_SERVICE_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+}
+
+void
+_secret_backend_ensure_extension_point (void)
+{
+ GIOExtensionPoint *ep;
+ static gboolean registered = FALSE;
+
+ if (registered)
+ return;
+
+ ep = g_io_extension_point_register (SECRET_BACKEND_EXTENSION_POINT_NAME);
+ g_io_extension_point_set_required_type (ep, SECRET_TYPE_BACKEND);
+
+ registered = TRUE;
+}
diff --git a/libsecret/secret-backend.h b/libsecret/secret-backend.h
new file mode 100644
index 0000000..eb7f0ab
--- /dev/null
+++ b/libsecret/secret-backend.h
@@ -0,0 +1,81 @@
+/* libsecret - GLib wrapper for Secret Service
+ *
+ * Copyright 2019 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the licence or (at
+ * your option) any later version.
+ *
+ * See the included COPYING file for more information.
+ *
+ * Author: Daiki Ueno
+ */
+
+#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION)
+#error "Only <libsecret/secret.h> can be included directly."
+#endif
+
+#ifndef __SECRET_BACKEND_H__
+#define __SECRET_BACKEND_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define SECRET_TYPE_BACKEND secret_backend_get_type ()
+G_DECLARE_INTERFACE (SecretBackend, secret_backend, SECRET, BACKEND, GObject)
+
+struct _SecretBackendInterface
+{
+ GTypeInterface parent_iface;
+
+ void (*store) (SecretBackend *self,
+ const SecretSchema *schema,
+ GHashTable *attributes,
+ const gchar *collection,
+ const gchar *label,
+ SecretValue *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*store_finish) (SecretBackend *self,
+ GAsyncResult *result,
+ GError **error);
+ void (*lookup) (SecretBackend *self,
+ const SecretSchema *schema,
+ GHashTable *attributes,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ SecretValue *(*lookup_finish) (SecretBackend *self,
+ GAsyncResult *result,
+ GError **error);
+ void (*clear) (SecretBackend *self,
+ const SecretSchema *schema,
+ GHashTable *attributes,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*clear_finish) (SecretBackend *self,
+ GAsyncResult *result,
+ GError **error);
+ void (*search) (SecretBackend *self,
+ const SecretSchema *schema,
+ GHashTable *attributes,
+ SecretSearchFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GList * (*search_finish) (SecretBackend *self,
+ GAsyncResult *result,
+ GError **error);
+};
+
+#define SECRET_BACKEND_EXTENSION_POINT_NAME "secret-backend"
+
+void _secret_backend_ensure_extension_point (void);
+
+G_END_DECLS
+
+#endif /* __SECRET_BACKEND_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]