[geary/mjog/email-plugins: 60/61] Plugin.FolderStore: Add new list_containing_folders method
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-plugins: 60/61] Plugin.FolderStore: Add new list_containing_folders method
- Date: Mon, 30 Mar 2020 10:08:38 +0000 (UTC)
commit d81393458a21d3a89957bd6f9e39befcd39b07f3
Author: Michael Gratton <mike vee net>
Date: Mon Mar 23 00:05:53 2020 +1100
Plugin.FolderStore: Add new list_containing_folders method
Adds new abstract method and implementation.
.../application-email-store-factory.vala | 11 ++++----
.../application-folder-store-factory.vala | 31 ++++++++++++++++++++--
src/client/plugin/plugin-folder-store.vala | 6 +++++
3 files changed, 41 insertions(+), 7 deletions(-)
---
diff --git a/src/client/application/application-email-store-factory.vala
b/src/client/application/application-email-store-factory.vala
index 7d7c94f1..fe391320 100644
--- a/src/client/application/application-email-store-factory.vala
+++ b/src/client/application/application-email-store-factory.vala
@@ -88,7 +88,8 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
}
- private class EmailImpl : Geary.BaseObject, Plugin.Email {
+ /** Implementation of the plugin email interface. */
+ internal class EmailImpl : Geary.BaseObject, Plugin.Email {
public Plugin.EmailIdentifier identifier {
@@ -116,7 +117,7 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
internal Geary.AccountInformation account { get; private set; }
- public EmailImpl(Geary.Email backing,
+ internal EmailImpl(Geary.Email backing,
Geary.AccountInformation account) {
this.backing = backing;
this.account = account;
@@ -131,7 +132,7 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
}
- private class IdImpl : Geary.BaseObject,
+ internal class IdImpl : Geary.BaseObject,
Gee.Hashable<Plugin.EmailIdentifier>, Plugin.EmailIdentifier {
@@ -141,8 +142,8 @@ internal class Application.EmailStoreFactory : Geary.BaseObject {
internal Geary.AccountInformation account { get; private set; }
- public IdImpl(Geary.EmailIdentifier backing,
- Geary.AccountInformation account) {
+ internal IdImpl(Geary.EmailIdentifier backing,
+ Geary.AccountInformation account) {
this.backing = backing;
this.account = account;
}
diff --git a/src/client/application/application-folder-store-factory.vala
b/src/client/application/application-folder-store-factory.vala
index a419eaee..f69d91fd 100644
--- a/src/client/application/application-folder-store-factory.vala
+++ b/src/client/application/application-folder-store-factory.vala
@@ -24,10 +24,13 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
"(sv)"
);
+ private Client application;
private Gee.Map<Geary.Folder,FolderImpl> folders;
- public FolderStoreImpl(Gee.Map<Geary.Folder,FolderImpl> folders) {
+ public FolderStoreImpl(Client application,
+ Gee.Map<Geary.Folder,FolderImpl> folders) {
+ this.application = application;
this.folders = folders;
}
@@ -35,6 +38,30 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
return this.folders.values.read_only_view;
}
+ public async Gee.Collection<Plugin.Folder> list_containing_folders(
+ Plugin.EmailIdentifier target,
+ GLib.Cancellable? cancellable
+ ) throws GLib.Error {
+ var id = target as EmailStoreFactory.IdImpl;
+ var folders = new Gee.LinkedList<Plugin.Folder>();
+ AccountContext context =
+ this.application.controller.get_context_for_account(id.account);
+ if (id != null && context != null) {
+ Gee.MultiMap<Geary.EmailIdentifier,Geary.FolderPath>? multi_folders =
+ yield context.account.get_containing_folders_async(
+ Geary.Collection.single(id.backing),
+ cancellable
+ );
+ if (multi_folders != null) {
+ foreach (var path in multi_folders.get(id.backing)) {
+ var folder = context.account.get_folder(path);
+ folders.add(this.folders.get(folder));
+ }
+ }
+ }
+ return folders;
+ }
+
public Plugin.Folder? get_folder_from_variant(GLib.Variant variant) {
Plugin.Folder? found = null;
// XXX this is pretty inefficient
@@ -176,7 +203,7 @@ internal class Application.FolderStoreFactory : Geary.BaseObject {
/** Constructs a new folder store for use by plugin contexts. */
public Plugin.FolderStore new_folder_store() {
- var store = new FolderStoreImpl(this.folders);
+ var store = new FolderStoreImpl(this.application, this.folders);
this.stores.add(store);
return store;
}
diff --git a/src/client/plugin/plugin-folder-store.vala b/src/client/plugin/plugin-folder-store.vala
index 3cc8b977..08a05c5f 100644
--- a/src/client/plugin/plugin-folder-store.vala
+++ b/src/client/plugin/plugin-folder-store.vala
@@ -39,6 +39,12 @@ public interface Plugin.FolderStore : Geary.BaseObject {
/** Returns a read-only set of all known folders. */
public abstract Gee.Collection<Folder> get_folders();
+ /** Returns the set of folders that contains the given email. */
+ public abstract async Gee.Collection<Folder> list_containing_folders(
+ EmailIdentifier target,
+ GLib.Cancellable? cancellable
+ ) throws GLib.Error;
+
/**
* Returns the folder specified by the given identifier, if any.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]