[geary/mjog/plugin-api-update: 1/3] Plugin:NotificationContext: Remove EmailStore accessor method
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/plugin-api-update: 1/3] Plugin:NotificationContext: Remove EmailStore accessor method
- Date: Mon, 30 Mar 2020 10:46:38 +0000 (UTC)
commit fd09105136bb86f1169f725b3fdbb2b9cabbfe01
Author: Michael Gratton <mike vee net>
Date: Mon Mar 23 00:12:15 2020 +1100
Plugin:NotificationContext: Remove EmailStore accessor method
Now that EmailExtenion exists, plugins can just get an instance of
the email store by implementing that.
src/client/application/application-controller.vala | 8 --------
.../application-notification-context.vala | 22 ----------------------
.../desktop-notifications.vala | 12 ++++++++----
.../plugin/plugin-notification-extension.vala | 11 -----------
src/client/plugin/sent-sound/sent-sound.vala | 6 +++---
5 files changed, 11 insertions(+), 48 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index 28d80331..00b37cd3 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -1297,10 +1297,6 @@ internal class Application.Controller : Geary.BaseObject {
/** Notifies plugins of new email being displayed. */
internal void email_loaded(Geary.AccountInformation account,
Geary.Email loaded) {
- foreach (NotificationContext plugin in
- this.plugins.get_notification_contexts()) {
- plugin.email_displayed(account, loaded);
- }
foreach (EmailContext plugin in
this.plugins.get_email_contexts()) {
plugin.email_displayed(account, loaded);
@@ -1481,10 +1477,6 @@ internal class Application.Controller : Geary.BaseObject {
AccountContext? context = this.accounts.get(service.account);
if (context != null) {
- foreach (NotificationContext plugin in
- this.plugins.get_notification_contexts()) {
- plugin.email_sent(context.account.information, sent);
- }
foreach (EmailContext plugin in
this.plugins.get_email_contexts()) {
plugin.email_sent(context.account.information, sent);
diff --git a/src/client/application/application-notification-context.vala
b/src/client/application/application-notification-context.vala
index 1587b049..9c628ccb 100644
--- a/src/client/application/application-notification-context.vala
+++ b/src/client/application/application-notification-context.vala
@@ -69,7 +69,6 @@ internal class Application.NotificationContext :
private FolderStoreFactory folders_factory;
private Plugin.FolderStore folders;
private EmailStoreFactory email_factory;
- private Plugin.EmailStore email;
internal NotificationContext(Client application,
@@ -79,12 +78,6 @@ internal class Application.NotificationContext :
this.folders_factory = folders_factory;
this.folders = folders_factory.new_folder_store();
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;
}
public async Plugin.FolderStore get_folders()
@@ -203,21 +196,6 @@ internal class Application.NotificationContext :
foreach (Geary.Folder monitored in this.folder_information.keys.to_array()) {
remove_folder(monitored);
}
- this.email_factory.destroy_email_store(this.email);
- }
-
- internal void email_displayed(Geary.AccountInformation account,
- Geary.Email email) {
- this.email.email_displayed(
- this.email_factory.to_plugin_email(email, account)
- );
- }
-
- internal void email_sent(Geary.AccountInformation account,
- Geary.Email email) {
- this.email.email_sent(
- this.email_factory.to_plugin_email(email, account)
- );
}
internal void clear_new_messages(Geary.Folder location,
diff --git a/src/client/plugin/desktop-notifications/desktop-notifications.vala
b/src/client/plugin/desktop-notifications/desktop-notifications.vala
index a37ec922..2c6e2084 100644
--- a/src/client/plugin/desktop-notifications/desktop-notifications.vala
+++ b/src/client/plugin/desktop-notifications/desktop-notifications.vala
@@ -19,7 +19,7 @@ public void peas_register_types(TypeModule module) {
* Manages standard desktop application notifications.
*/
public class Plugin.DesktopNotifications :
- PluginBase, NotificationExtension, TrustedExtension {
+ PluginBase, NotificationExtension, EmailExtension, TrustedExtension {
private const Geary.SpecialFolderType[] MONITORED_TYPES = {
@@ -30,6 +30,10 @@ public class Plugin.DesktopNotifications :
get; set construct;
}
+ public EmailContext email {
+ get; set construct;
+ }
+
public global::Application.Client client_application {
get; set construct;
}
@@ -40,14 +44,14 @@ public class Plugin.DesktopNotifications :
private const string ARRIVED_ID = "email-arrived";
- private EmailStore? email = null;
+ private EmailStore? email_store = null;
private GLib.Notification? arrived_notification = null;
private GLib.Cancellable? cancellable = null;
public override async void activate() throws GLib.Error {
this.cancellable = new GLib.Cancellable();
- this.email = yield this.notifications.get_email();
+ this.email_store = yield this.email.get_email();
this.notifications.new_messages_arrived.connect(on_new_messages_arrived);
this.notifications.new_messages_retired.connect(on_new_messages_retired);
@@ -234,7 +238,7 @@ public class Plugin.DesktopNotifications :
bool notified = false;
try {
Email? message = Geary.Collection.first(
- yield this.email.get_email(
+ yield this.email_store.get_email(
Geary.Collection.single(Geary.Collection.first(added)),
this.cancellable
)
diff --git a/src/client/plugin/plugin-notification-extension.vala
b/src/client/plugin/plugin-notification-extension.vala
index aad10982..6a5bc8b3 100644
--- a/src/client/plugin/plugin-notification-extension.vala
+++ b/src/client/plugin/plugin-notification-extension.vala
@@ -76,17 +76,6 @@ public interface Plugin.NotificationContext : Geary.BaseObject {
public signal void new_messages_retired(Plugin.Folder parent, int total);
- /**
- * Returns a store to lookup email for notifications.
- *
- * This method may prompt for permission before returning.
- *
- * @throws Error.PERMISSIONS if permission to access
- * this resource was not given
- */
- public abstract async Plugin.EmailStore get_email()
- throws Error.PERMISSION_DENIED;
-
/**
* Returns a store to lookup folders for notifications.
*
diff --git a/src/client/plugin/sent-sound/sent-sound.vala b/src/client/plugin/sent-sound/sent-sound.vala
index a986b348..650a9ae5 100644
--- a/src/client/plugin/sent-sound/sent-sound.vala
+++ b/src/client/plugin/sent-sound/sent-sound.vala
@@ -15,10 +15,10 @@ public void peas_register_types(TypeModule module) {
}
/** Plays the desktop sent-mail sound when an email is sent. */
-public class Plugin.SentSound : PluginBase, NotificationExtension {
+public class Plugin.SentSound : PluginBase, EmailExtension {
- public NotificationContext notifications {
+ public EmailContext email {
get; set construct;
}
@@ -31,7 +31,7 @@ public class Plugin.SentSound : PluginBase, NotificationExtension {
this.context = new GSound.Context();
this.context.init();
- this.store = yield this.notifications.get_email();
+ this.store = yield this.email.get_email();
this.store.email_sent.connect(on_sent);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]