// // IMailStore.cs // // Author: Jeffrey Stedfast // // Copyright (c) 2013-2020 .NET Foundation and Contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; namespace MailKit { /// /// An interface for retreiving messages from a message store such as IMAP. /// /// /// Implemented by . /// public interface IMailStore : IMailService { /// /// Get the personal namespaces. /// /// /// The personal folder namespaces contain a user's personal mailbox folders. /// /// The personal namespaces. FolderNamespaceCollection PersonalNamespaces { get; } /// /// Get the shared namespaces. /// /// /// The shared folder namespaces contain mailbox folders that are shared with the user. /// /// The shared namespaces. FolderNamespaceCollection SharedNamespaces { get; } /// /// Get the other namespaces. /// /// /// The other folder namespaces contain other mailbox folders. /// /// The other namespaces. FolderNamespaceCollection OtherNamespaces { get; } /// /// Get whether or not the mail store supports quotas. /// /// /// Gets whether or not the mail store supports quotas. /// /// true if the mail store supports quotas; otherwise, false. bool SupportsQuotas { get; } /// /// Get the threading algorithms supported by the mail store. /// /// /// The threading algorithms are queried as part of the /// Connect /// and Authenticate methods. /// /// /// /// /// The threading algorithms. HashSet ThreadingAlgorithms { get; } /// /// Get the Inbox folder. /// /// /// The Inbox folder is the default folder and is typically the folder /// where all new messages are delivered. /// /// The Inbox folder. IMailFolder Inbox { get; } /// /// Enable the quick resynchronization feature. /// /// /// Enables quick resynchronization when a folder is opened using the /// /// method. /// If this feature is enabled, the event /// is replaced with the event. /// This method needs to be called immediately after /// , /// before the opening of any folders. /// /// The cancellation token. /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// Quick resynchronization needs to be enabled before selecting a folder. /// /// /// The mail store does not support quick resynchronization. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// void EnableQuickResync (CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously enable the quick resynchronization feature. /// /// /// Enables quick resynchronization when a folder is opened using the /// /// method. /// If this feature is enabled, the event /// is replaced with the event. /// This method needs to be called immediately after /// , /// before the opening of any folders. /// /// An asynchronous task context. /// The cancellation token. /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// Quick resynchronization needs to be enabled before selecting a folder. /// /// /// The mail store does not support quick resynchronization. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// Task EnableQuickResyncAsync (CancellationToken cancellationToken = default (CancellationToken)); /// /// Get the specified special folder. /// /// /// Not all message stores support the concept of special folders, /// so this method may return null. /// /// The folder if available; otherwise null. /// The type of special folder. /// /// is out of range. /// IMailFolder GetFolder (SpecialFolder folder); /// /// Get the folder for the specified namespace. /// /// /// The main reason to get the toplevel folder in a namespace is /// to list its child folders. /// /// The folder. /// The namespace. /// /// is null. /// /// /// The folder could not be found. /// IMailFolder GetFolder (FolderNamespace @namespace); /// /// Get all of the folders within the specified namespace. /// /// /// Gets all of the folders within the specified namespace. /// /// The folders. /// The namespace. /// If set to true, only subscribed folders will be listed. /// The cancellation token. /// /// is null. /// /// /// The has been disposed. /// /// /// The operation was canceled via the cancellation token. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The namespace folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// IList GetFolders (FolderNamespace @namespace, bool subscribedOnly, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously get all of the folders within the specified namespace. /// /// /// Asynchronously gets all of the folders within the specified namespace. /// /// The folders. /// The namespace. /// If set to true, only subscribed folders will be listed. /// The cancellation token. /// /// is null. /// /// /// The has been disposed. /// /// /// The operation was canceled via the cancellation token. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The namespace folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// Task> GetFoldersAsync (FolderNamespace @namespace, bool subscribedOnly, CancellationToken cancellationToken = default (CancellationToken)); /// /// Get all of the folders within the specified namespace. /// /// /// Gets all of the folders within the specified namespace. /// /// The folders. /// The namespace. /// The status items to pre-populate. /// If set to true, only subscribed folders will be listed. /// The cancellation token. /// /// is null. /// /// /// The has been disposed. /// /// /// The operation was canceled via the cancellation token. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The namespace folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// IList GetFolders (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously get all of the folders within the specified namespace. /// /// /// Asynchronously gets all of the folders within the specified namespace. /// /// The folders. /// The namespace. /// The status items to pre-populate. /// If set to true, only subscribed folders will be listed. /// The cancellation token. /// /// is null. /// /// /// The has been disposed. /// /// /// The operation was canceled via the cancellation token. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The namespace folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// Task> GetFoldersAsync (FolderNamespace @namespace, StatusItems items = StatusItems.None, bool subscribedOnly = false, CancellationToken cancellationToken = default (CancellationToken)); /// /// Get the folder for the specified path. /// /// /// Gets the folder for the specified path. /// /// The folder. /// The folder path. /// The cancellation token. /// /// is null. /// /// /// The operation was canceled via the cancellation token. /// /// /// The folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// IMailFolder GetFolder (string path, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously get the folder for the specified path. /// /// /// Asynchronously gets the folder for the specified path. /// /// The folder. /// The folder path. /// The cancellation token. /// /// is null. /// /// /// The operation was canceled via the cancellation token. /// /// /// The folder could not be found. /// /// /// An I/O error occurred. /// /// /// A protocol error occurred. /// /// /// The command failed. /// Task GetFolderAsync (string path, CancellationToken cancellationToken = default (CancellationToken)); /// /// Gets the specified metadata. /// /// /// Gets the specified metadata. /// /// The requested metadata value. /// The metadata tag. /// The cancellation token. string GetMetadata (MetadataTag tag, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously gets the specified metadata. /// /// /// Asynchronously gets the specified metadata. /// /// The requested metadata value. /// The metadata tag. /// The cancellation token. Task GetMetadataAsync (MetadataTag tag, CancellationToken cancellationToken = default (CancellationToken)); /// /// Gets the specified metadata. /// /// /// Gets the specified metadata. /// /// The requested metadata. /// The metadata tags. /// The cancellation token. MetadataCollection GetMetadata (IEnumerable tags, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously gets the specified metadata. /// /// /// Asynchronously gets the specified metadata. /// /// The requested metadata. /// The metadata tags. /// The cancellation token. Task GetMetadataAsync (IEnumerable tags, CancellationToken cancellationToken = default (CancellationToken)); /// /// Gets the specified metadata. /// /// /// Gets the specified metadata. /// /// The requested metadata. /// The metadata options. /// The metadata tags. /// The cancellation token. MetadataCollection GetMetadata (MetadataOptions options, IEnumerable tags, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously gets the specified metadata. /// /// /// Asynchronously gets the specified metadata. /// /// The requested metadata. /// The metadata options. /// The metadata tags. /// The cancellation token. Task GetMetadataAsync (MetadataOptions options, IEnumerable tags, CancellationToken cancellationToken = default (CancellationToken)); /// /// Sets the specified metadata. /// /// /// Sets the specified metadata. /// /// The metadata. /// The cancellation token. void SetMetadata (MetadataCollection metadata, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously sets the specified metadata. /// /// /// Asynchronously sets the specified metadata. /// /// An asynchronous task context. /// The metadata. /// The cancellation token. Task SetMetadataAsync (MetadataCollection metadata, CancellationToken cancellationToken = default (CancellationToken)); /// /// Occurs when a remote message store receives an alert message from the server. /// /// /// Some implementations, such as , /// will emit Alert events when they receive alert messages from the server. /// event EventHandler Alert; /// /// Occurs when a folder is created. /// /// /// The event is emitted when a new folder is created. /// event EventHandler FolderCreated; /// /// Occurs when metadata changes. /// /// /// The event is emitted when metadata changes. /// event EventHandler MetadataChanged; } }