[geary/mjog/plugin-api-update: 2/3] Plugin:NotificationContext: Remove FolderStore accessor method
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/plugin-api-update: 2/3] Plugin:NotificationContext: Remove FolderStore accessor method
- Date: Mon, 30 Mar 2020 10:46:43 +0000 (UTC)
commit 1e8f60a9e2c06c9d0ffe378a54e6f668fa384e2a
Author: Michael Gratton <mike vee net>
Date: Mon Mar 23 00:26:06 2020 +1100
Plugin:NotificationContext: Remove FolderStore accessor method
Now that FolderExtension exists, plugins can just get an instance of
the folder store by implementing that.
.../application-notification-context.vala | 8 --------
.../desktop-notifications.vala | 20 ++++++++++++++------
.../plugin/folder-highlight/folder-highlight.vala | 16 ++++++++++------
.../plugin/messaging-menu/messaging-menu.vala | 21 +++++++++++++--------
.../notification-badge/notification-badge.vala | 16 ++++++++++------
.../plugin/plugin-notification-extension.vala | 11 -----------
6 files changed, 47 insertions(+), 45 deletions(-)
---
diff --git a/src/client/application/application-notification-context.vala
b/src/client/application/application-notification-context.vala
index 9c628ccb..e45e9c04 100644
--- a/src/client/application/application-notification-context.vala
+++ b/src/client/application/application-notification-context.vala
@@ -67,7 +67,6 @@ internal class Application.NotificationContext :
private unowned Client application;
private FolderStoreFactory folders_factory;
- private Plugin.FolderStore folders;
private EmailStoreFactory email_factory;
@@ -76,15 +75,9 @@ internal class Application.NotificationContext :
EmailStoreFactory email_factory) {
this.application = application;
this.folders_factory = folders_factory;
- this.folders = folders_factory.new_folder_store();
this.email_factory = email_factory;
}
- public async Plugin.FolderStore get_folders()
- throws Plugin.Error.PERMISSION_DENIED {
- return this.folders;
- }
-
public async Plugin.ContactStore get_contacts_for_folder(Plugin.Folder source)
throws Plugin.Error.NOT_FOUND, Plugin.Error.PERMISSION_DENIED {
Geary.Folder? folder = this.folders_factory.get_engine_folder(source);
@@ -191,7 +184,6 @@ internal class Application.NotificationContext :
}
internal void destroy() {
- this.folders_factory.destroy_folder_store(this.folders);
// Get an array so the loop does not blow up when removing values.
foreach (Geary.Folder monitored in this.folder_information.keys.to_array()) {
remove_folder(monitored);
diff --git a/src/client/plugin/desktop-notifications/desktop-notifications.vala
b/src/client/plugin/desktop-notifications/desktop-notifications.vala
index 2c6e2084..301564e0 100644
--- a/src/client/plugin/desktop-notifications/desktop-notifications.vala
+++ b/src/client/plugin/desktop-notifications/desktop-notifications.vala
@@ -19,7 +19,11 @@ public void peas_register_types(TypeModule module) {
* Manages standard desktop application notifications.
*/
public class Plugin.DesktopNotifications :
- PluginBase, NotificationExtension, EmailExtension, TrustedExtension {
+ PluginBase,
+ NotificationExtension,
+ FolderExtension,
+ EmailExtension,
+ TrustedExtension {
private const Geary.SpecialFolderType[] MONITORED_TYPES = {
@@ -30,6 +34,10 @@ public class Plugin.DesktopNotifications :
get; set construct;
}
+ public FolderContext folders {
+ get; set construct;
+ }
+
public EmailContext email {
get; set construct;
}
@@ -56,17 +64,17 @@ public class Plugin.DesktopNotifications :
this.notifications.new_messages_arrived.connect(on_new_messages_arrived);
this.notifications.new_messages_retired.connect(on_new_messages_retired);
- FolderStore folders = yield this.notifications.get_folders();
- folders.folders_available.connect(
+ FolderStore folder_store = yield this.folders.get_folders();
+ folder_store.folders_available.connect(
(folders) => check_folders(folders)
);
- folders.folders_unavailable.connect(
+ folder_store.folders_unavailable.connect(
(folders) => check_folders(folders)
);
- folders.folders_type_changed.connect(
+ folder_store.folders_type_changed.connect(
(folders) => check_folders(folders)
);
- check_folders(folders.get_folders());
+ check_folders(folder_store.get_folders());
}
public override async void deactivate(bool is_shutdown) throws GLib.Error {
diff --git a/src/client/plugin/folder-highlight/folder-highlight.vala
b/src/client/plugin/folder-highlight/folder-highlight.vala
index 398a1622..bd8cdd81 100644
--- a/src/client/plugin/folder-highlight/folder-highlight.vala
+++ b/src/client/plugin/folder-highlight/folder-highlight.vala
@@ -19,7 +19,7 @@ public void peas_register_types(TypeModule module) {
* Manages highlighting folders that have newly delivered mail
*/
public class Plugin.FolderHighlight :
- PluginBase, NotificationExtension, TrustedExtension {
+ PluginBase, NotificationExtension, FolderExtension, TrustedExtension {
private const Geary.SpecialFolderType[] MONITORED_TYPES = {
@@ -31,6 +31,10 @@ public class Plugin.FolderHighlight :
get; construct set;
}
+ public FolderContext folders {
+ get; construct set;
+ }
+
public global::Application.Client client_application {
get; construct set;
}
@@ -43,17 +47,17 @@ public class Plugin.FolderHighlight :
this.notifications.new_messages_arrived.connect(on_new_messages_arrived);
this.notifications.new_messages_retired.connect(on_new_messages_retired);
- FolderStore folders = yield this.notifications.get_folders();
- folders.folders_available.connect(
+ FolderStore folder_store = yield this.folders.get_folders();
+ folder_store.folders_available.connect(
(folders) => check_folders(folders)
);
- folders.folders_unavailable.connect(
+ folder_store.folders_unavailable.connect(
(folders) => check_folders(folders)
);
- folders.folders_type_changed.connect(
+ folder_store.folders_type_changed.connect(
(folders) => check_folders(folders)
);
- check_folders(folders.get_folders());
+ check_folders(folder_store.get_folders());
}
public override async void deactivate(bool is_shutdown) throws GLib.Error {
diff --git a/src/client/plugin/messaging-menu/messaging-menu.vala
b/src/client/plugin/messaging-menu/messaging-menu.vala
index 7ce36ee8..32d7bb59 100644
--- a/src/client/plugin/messaging-menu/messaging-menu.vala
+++ b/src/client/plugin/messaging-menu/messaging-menu.vala
@@ -16,16 +16,21 @@ public void peas_register_types(TypeModule module) {
}
/** Updates the Unity messaging menu when new mail arrives. */
-public class Plugin.MessagingMenu : PluginBase, NotificationExtension {
+public class Plugin.MessagingMenu :
+ PluginBase, NotificationExtension, FolderExtension {
public NotificationContext notifications {
get; set construct;
}
+ public FolderContext folders {
+ get; set construct;
+ }
+
private global::MessagingMenu.App? app = null;
- private FolderStore? folders = null;
+ private FolderStore? folder_store = null;
public override async void activate() throws GLib.Error {
@@ -38,17 +43,17 @@ public class Plugin.MessagingMenu : PluginBase, NotificationExtension {
this.notifications.new_messages_arrived.connect(on_new_messages_changed);
this.notifications.new_messages_retired.connect(on_new_messages_changed);
- this.folders = yield this.notifications.get_folders();
- folders.folders_available.connect(
+ this.folder_store = yield this.folders.get_folders();
+ this.folder_store.folders_available.connect(
(folders) => check_folders(folders)
);
- folders.folders_unavailable.connect(
+ this.folder_store.folders_unavailable.connect(
(folders) => check_folders(folders)
);
- folders.folders_type_changed.connect(
+ this.folder_store.folders_type_changed.connect(
(folders) => check_folders(folders)
);
- check_folders(folders.get_folders());
+ check_folders(this.folder_store.get_folders());
}
public override async void deactivate(bool is_shutdown) throws GLib.Error {
@@ -89,7 +94,7 @@ public class Plugin.MessagingMenu : PluginBase, NotificationExtension {
private void on_activate_source(string source_id) {
if (this.folders != null) {
- foreach (Folder folder in this.folders.get_folders()) {
+ foreach (Folder folder in this.folder_store.get_folders()) {
if (source_id == get_source_id(folder)) {
this.plugin_application.show_folder(folder);
break;
diff --git a/src/client/plugin/notification-badge/notification-badge.vala
b/src/client/plugin/notification-badge/notification-badge.vala
index 304249a1..e1a2af3a 100644
--- a/src/client/plugin/notification-badge/notification-badge.vala
+++ b/src/client/plugin/notification-badge/notification-badge.vala
@@ -17,7 +17,7 @@ public void peas_register_types(TypeModule module) {
/** Updates Unity application badge with total new message count. */
public class Plugin.NotificationBadge :
- PluginBase, NotificationExtension, TrustedExtension {
+ PluginBase, NotificationExtension, FolderExtension, TrustedExtension {
private const Geary.SpecialFolderType[] MONITORED_TYPES = {
@@ -28,6 +28,10 @@ public class Plugin.NotificationBadge :
get; set construct;
}
+ public FolderContext folders {
+ get; set construct;
+ }
+
public global::Application.Client client_application {
get; set construct;
}
@@ -53,17 +57,17 @@ public class Plugin.NotificationBadge :
global::Application.Client.APP_ID + ".desktop"
);
- FolderStore folders = yield this.notifications.get_folders();
- folders.folders_available.connect(
+ FolderStore folder_store = yield this.folders.get_folders();
+ folder_store.folders_available.connect(
(folders) => check_folders(folders)
);
- folders.folders_unavailable.connect(
+ folder_store.folders_unavailable.connect(
(folders) => check_folders(folders)
);
- folders.folders_type_changed.connect(
+ folder_store.folders_type_changed.connect(
(folders) => check_folders(folders)
);
- check_folders(folders.get_folders());
+ check_folders(folder_store.get_folders());
this.notifications.notify["total-new-messages"].connect(on_total_changed);
update_count();
diff --git a/src/client/plugin/plugin-notification-extension.vala
b/src/client/plugin/plugin-notification-extension.vala
index 6a5bc8b3..d69c4d11 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 folders 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.FolderStore get_folders()
- throws Error.PERMISSION_DENIED;
-
/**
* Returns a store to lookup contacts for notifications.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]