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.
This commit is contained in:
parent
77def2d9c2
commit
9bb7b77f17
5 changed files with 112 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
36
src/client/application/application-email-context.vala
Normal file
36
src/client/application/application-email-context.vala
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,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',
|
||||
|
|
@ -111,6 +112,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',
|
||||
|
|
|
|||
53
src/client/plugin/plugin-email-extension.vala
Normal file
53
src/client/plugin/plugin-email-extension.vala
Normal file
|
|
@ -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;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue