[geary/mjog/email-plugins: 1/13] Plugin: Add EmailExtension plugin extension type
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-plugins: 1/13] Plugin: Add EmailExtension plugin extension type
- Date: Sun, 22 Mar 2020 13:38:12 +0000 (UTC)
commit 84d94fd7ba49daf60560044076456411fce28e52
Author: Michael Gratton <mike vee net>
Date: Sat Mar 21 09:27:31 2020 +1100
Plugin: Add EmailExtension plugin extension type
Add EmailExtension plugin extenion with context object and
Application.EmailContext implementing it. Check for plugins with
this type in PluginManager and init/deinit their contexts as needed.
po/POTFILES.in | 2 +
.../application/application-email-context.vala | 36 +++++++++++++++
.../application/application-plugin-manager.vala | 22 +++++++--
src/client/meson.build | 2 +
src/client/plugin/plugin-email-extension.vala | 53 ++++++++++++++++++++++
5 files changed, 112 insertions(+), 3 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d2494804..b2bc897a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,6 +23,7 @@ src/client/application/application-configuration.vala
src/client/application/application-contact-store.vala
src/client/application/application-contact.vala
src/client/application/application-controller.vala
+src/client/application/application-email-context.vala
src/client/application/application-email-store-factory.vala
src/client/application/application-folder-context.vala
src/client/application/application-folder-store-factory.vala
@@ -92,6 +93,7 @@ src/client/plugin/plugin-account.vala
src/client/plugin/plugin-application.vala
src/client/plugin/plugin-button.vala
src/client/plugin/plugin-contact-store.vala
+src/client/plugin/plugin-email-extension.vala
src/client/plugin/plugin-email-store.vala
src/client/plugin/plugin-email.vala
src/client/plugin/plugin-error.vala
diff --git a/src/client/application/application-email-context.vala
b/src/client/application/application-email-context.vala
new file mode 100644
index 00000000..7f78567e
--- /dev/null
+++ b/src/client/application/application-email-context.vala
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2020 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/**
+ * Implementation of the email plugin extension context.
+ */
+internal class Application.EmailContext :
+ Geary.BaseObject, Plugin.EmailContext {
+
+
+ private unowned Client application;
+ private EmailStoreFactory email_factory;
+ private Plugin.EmailStore email;
+
+
+ internal EmailContext(Client application,
+ EmailStoreFactory email_factory) {
+ this.application = application;
+ this.email_factory = email_factory;
+ this.email = email_factory.new_email_store();
+ }
+
+ public async Plugin.EmailStore get_email()
+ throws Plugin.Error.PERMISSION_DENIED {
+ return this.email;
+ }
+
+ internal void destroy() {
+ this.email_factory.destroy_email_store(this.email);
+ }
+
+}
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
index f3c9ce11..7ffc9972 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -313,6 +313,14 @@ public class Application.PluginManager : GLib.Object {
notification.notifications = context;
}
+ var email = plugin as Plugin.EmailExtension;
+ if (email != null) {
+ email.email = new EmailContext(
+ this.application,
+ this.email_factory
+ );
+ }
+
var folder = plugin as Plugin.FolderExtension;
if (folder != null) {
folder.folders = new FolderContext(
@@ -389,9 +397,17 @@ public class Application.PluginManager : GLib.Object {
var folder = context.plugin as Plugin.FolderExtension;
if (folder != null) {
- var folders = folder.folders as FolderContext;
- if (folders != null) {
- folders.destroy();
+ var folder_context = folder.folders as FolderContext;
+ if (folder_context != null) {
+ folder_context.destroy();
+ }
+ }
+
+ var email = context.plugin as Plugin.EmailExtension;
+ if (email != null) {
+ var email_context = email.email as Application.EmailContext;
+ if (email_context != null) {
+ email_context.destroy();
}
}
diff --git a/src/client/meson.build b/src/client/meson.build
index 2f6b250d..99a37fb6 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -10,6 +10,7 @@ geary_client_vala_sources = files(
'application/application-contact-store.vala',
'application/application-contact.vala',
'application/application-controller.vala',
+ 'application/application-email-context.vala',
'application/application-email-store-factory.vala',
'application/application-folder-context.vala',
'application/application-folder-store-factory.vala',
@@ -101,6 +102,7 @@ geary_client_vala_sources = files(
'plugin/plugin-application.vala',
'plugin/plugin-button.vala',
'plugin/plugin-contact-store.vala',
+ 'plugin/plugin-email-extension.vala',
'plugin/plugin-email-store.vala',
'plugin/plugin-email.vala',
'plugin/plugin-error.vala',
diff --git a/src/client/plugin/plugin-email-extension.vala b/src/client/plugin/plugin-email-extension.vala
new file mode 100644
index 00000000..3106d301
--- /dev/null
+++ b/src/client/plugin/plugin-email-extension.vala
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2020 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/**
+ * A plugin extension point for working with email messages.
+ */
+public interface Plugin.EmailExtension : PluginBase {
+
+ /**
+ * Context object for accessing email.
+ *
+ * This will be set during (or just after) plugin construction,
+ * before {@link PluginBase.activate} is called.
+ */
+ public abstract EmailContext email {
+ get; set construct;
+ }
+
+}
+
+
+// XXX this should be an inner interface of EmailExtension, but
+// GNOME/vala#918 prevents that.
+
+/**
+ * Provides a context for email plugins.
+ *
+ * The context provides an interface for email plugins to interface
+ * with the Geary client application. Plugins that implement the
+ * {@link EmailExtension} interface will be given an instance of this
+ * class.
+ *
+ * @see Plugin.EmailExtension.email
+ */
+public interface Plugin.EmailContext : Geary.BaseObject {
+
+
+ /**
+ * Returns a store to lookup email.
+ *
+ * This method may prompt for permission before returning.
+ *
+ * @throws Error.PERMISSIONS if permission to access
+ * this resource was not given
+ */
+ public abstract async EmailStore get_email()
+ throws Error.PERMISSION_DENIED;
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]