[Nmailserver-commits] SF.net SVN: nmailserver: [189] NMail/trunk/NMail
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-05-08 11:35:57
|
Revision: 189
http://svn.sourceforge.net/nmailserver/?rev=189&view=rev
Author: tmyroadctfig
Date: 2007-05-08 04:35:52 -0700 (Tue, 08 May 2007)
Log Message:
-----------
Further work on local store data, local store and related sub-systems.
Modified Paths:
--------------
NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs
NMail/trunk/NMail/Authentication/NullAuthentication.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreUserMap.cs
NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
NMail/trunk/NMail.ImapService/State/ExamineState.cs
NMail/trunk/NMail.ImapService/State/SelectedState.cs
NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlAuthProvider.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlUserMap.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/AuthenticationUser.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.AuthenticationUser.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateAuthProvider.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateUserMap.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
NMail/trunk/NMail.Server.Console/NMail.config
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.UserMailboxMapping.hbm.xml
NMail/trunk/NMail.LocalStoreData.NHibernate/UserMailboxMapping.cs
NMail/trunk/NMail.UnitTests/AuthProvider/
NMail/trunk/NMail.UnitTests/AuthProvider/BaseAuthTest.cs
NMail/trunk/NMail.UnitTests/AuthProvider/PasswordAutenticationTest1.cs
Modified: NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs
===================================================================
--- NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail/Authentication/IAuthenticationProvider.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -87,5 +87,11 @@
/// <param name="newPassword">The new password.</param>
/// <returns>True on success, false otherwise.</returns>
bool ChangePassword(IAuthenticationToken user, string newPassword);
+
+ /// <summary>
+ /// Reinstalls the auth provider's data store if required. This is only used
+ /// during deployment and testing.
+ /// </summary>
+ void Reinstall();
}
}
Modified: NMail/trunk/NMail/Authentication/NullAuthentication.cs
===================================================================
--- NMail/trunk/NMail/Authentication/NullAuthentication.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail/Authentication/NullAuthentication.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -62,6 +62,8 @@
public bool IsEnabled(IAuthenticationToken user) {
return true;
}
+
+ public void Reinstall() { }
#endregion
}
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -63,9 +63,9 @@
/// </summary>
/// <param name="authToken">The authentication credentials of the current user.</param>
/// <param name="message">The message to deliver.</param>
- /// <param name="folder">The folder to deliver the message into.</param>
+ /// <param name="folderId">The Id of the folder to deliver the message into.</param>
/// <returns>The result of the delivery.</returns>
- DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message.Message message, StoreFolder folder);
+ DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message.Message message, int folderId);
#endregion
#region Folder Retrieval and Manipulation
@@ -100,8 +100,10 @@
/// </remarks>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="newFolder">The folder to create.</param>
- /// <returns>The result of the create attempt.</returns>
- LocalStoreFolderResult CreateFolder(IAuthenticationToken authToken, string newFolder);
+ /// <exception cref="System.Data.DuplicateNameException">If a folder with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the folder are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ void CreateFolder(IAuthenticationToken authToken, string newFolder);
/// <summary>
/// Deletes an existing folder.
@@ -109,7 +111,8 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="folderId">The Id of the folder to delete.</param>
/// <returns>The result of the delete attempt.</returns>
- LocalStoreFolderResult DeleteFolder(IAuthenticationToken authToken, int folderId);
+ /// <exception cref="System.ArgumentException">The folder is invalid.</exception>
+ void DeleteFolder(IAuthenticationToken authToken, int folderId);
/// <summary>
/// Moves an existing folder in the local store to another location.
@@ -144,9 +147,9 @@
/// Gets a list of child folders for the given parent folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="parent">The parent to get the children from.</param>
+ /// <param name="parentId">The Id of the parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- IList<StoreFolder> GetChildren(IAuthenticationToken authToken, StoreFolder parent);
+ IList<StoreFolder> GetChildren(IAuthenticationToken authToken, int parentId);
/// <summary>
/// Gets a list of all folders
@@ -169,16 +172,15 @@
/// Subscribes to a folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to subscribe to.</param>
- /// <returns>The result of the subscribe attempt.</returns>
- LocalStoreFolderResult Subscribe(IAuthenticationToken authToken, StoreFolder folder);
+ /// <param name="folderId">The Id of the folder to subscribe to.</param>
+ void Subscribe(IAuthenticationToken authToken, int folderId);
/// <summary>
/// Un-subscribes from a folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to unsubscribe from.</param>
- void UnSubscribe(IAuthenticationToken authToken, StoreFolder folder);
+ /// <param name="folderId">The Id of the folder to unsubscribe from.</param>
+ void UnSubscribe(IAuthenticationToken authToken, int folderId);
#endregion
#region Message Id and Offset
@@ -187,35 +189,35 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="currentId">The Id to start looking from.</param>
- /// <param name="folder"></param>
+ /// <param name="folderId">The Id of the folder to get the next message Id in.</param>
/// <returns>The Id of the next existing message or 0 if there is none.</returns>
- int GetNextMessageId(IAuthenticationToken authToken, int currentId, StoreFolder folder);
+ int GetNextMessageId(IAuthenticationToken authToken, int currentId, int folderId);
/// <summary>
/// Gets the Id for the next message to be added into the folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The next message Id or 0 if insufficient privileges.</returns>
- int GetNextMessageId(IAuthenticationToken authToken, StoreFolder folder);
+ int GetNextMessageId(IAuthenticationToken authToken, int folderId);
/// <summary>
/// Gets the message Id (UID) corresponding to the given message offset.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageOffset">The offset of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message Id or 0 if there is no such message.</returns>
- int GetMessageId(IAuthenticationToken authToken, int messageOffset, StoreFolder folder);
+ int GetMessageId(IAuthenticationToken authToken, int messageOffset, int folderId);
/// <summary>
/// Gets the message offset corresponding the to given message Id (UID).
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message offset or 0 if there is no such message.</returns>
- int GetMessageOffset(IAuthenticationToken authToken, int messageId, StoreFolder folder);
+ int GetMessageOffset(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Gets a list of message Ids for a given folder.
@@ -232,9 +234,9 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message flags or null if invalid folder or privileges.</returns>
- StoreMessageFlags? GetMessageFlags(IAuthenticationToken authToken, int messageId, StoreFolder folder);
+ StoreMessageFlags? GetMessageFlags(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Sets the message flags for a message.
@@ -242,9 +244,9 @@
/// <remarks>This will replace any existing flags on the message.</remarks>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to set the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="flags">The flags to set.</param>
- void SetMessageFlags(IAuthenticationToken authToken, int messageId, StoreFolder folder, StoreMessageFlags flags);
+ void SetMessageFlags(IAuthenticationToken authToken, int messageId, int folderId, StoreMessageFlags flags);
#endregion
#region Message Retrieval
@@ -253,18 +255,18 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the date for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message date or null if invalid folder or privileges.</returns>
- DateTime? GetInternalDate(IAuthenticationToken authToken, int messageId, StoreFolder folder);
+ DateTime? GetInternalDate(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Gets the size of the message.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the size from.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message size in bytes or null if invalid folder or privileges.</returns>
- int? GetMessageSize(IAuthenticationToken authToken, int messageId, StoreFolder folder);
+ int? GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId);
/// <summary>
/// Gets the headers for the message.
@@ -309,30 +311,30 @@
/// Gets the number of messages in the given store folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to count the messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the messages in.</param>
/// <returns>The message count or null if invalid folder or privileges.</returns>
- int? GetMessageCount(IAuthenticationToken authToken, StoreFolder folder);
+ int? GetMessageCount(IAuthenticationToken authToken, int folderId);
/// <summary>
/// Gets the number of messages with the specified flags set.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to count the flagged messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the flagged messages in.</param>
/// <param name="flags">The flags to check for when counting.</param>
/// <returns>The number of messages or null if invalid folder or privileges.</returns>
- int? GetMessageCountWithFlags(IAuthenticationToken authToken, StoreFolder folder, StoreMessageFlags flags);
+ int? GetMessageCountWithFlags(IAuthenticationToken authToken, int folderId, StoreMessageFlags flags);
#endregion
/// <summary>
/// Permanently removes messages flagged as deleted.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to delete messages in.</param>
+ /// <param name="folderId">The Id of the folder to delete messages in.</param>
/// <returns>
/// The list of message offsets for the deleted messages or null if insufficient
/// privileges or invalid folder.
/// </returns>
- int[] PurgeDeletedMessages(IAuthenticationToken authToken, StoreFolder folder);
+ int[] PurgeDeletedMessages(IAuthenticationToken authToken, int folderId);
#region Folder ACLs
/// <summary>
@@ -340,17 +342,17 @@
/// identifier one is added.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to set the ACE on.</param>
+ /// <param name="folderId">The Id of the folder to set the ACE on.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- void SetStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, GenericAce<StoreFolderPrivilege> ace);
+ void SetStoreFolderAce(IAuthenticationToken authToken, int folderId, GenericAce<StoreFolderPrivilege> ace);
/// <summary>
/// Removes any ACE associated with the given user.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to remove the ACE from.</param>
+ /// <param name="folderId">The Id of the folder to remove the ACE from.</param>
/// <param name="identifier">The identifier to remove from the ACL.</param>
- void RemoveStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, string identifier);
+ void RemoveStoreFolderAce(IAuthenticationToken authToken, int folderId, string identifier);
/// <summary>
/// Gets the ACL for the given folder.
@@ -582,141 +584,4 @@
LocalStoreCalendarResult DeleteCalandar(IAuthenticationToken authToken, int calendarId);
}
-
- /// <summary>
- /// Possible return results for local store folder operations.
- /// </summary>
- public enum LocalStoreFolderResult {
- /// <summary>
- /// The operation was completed successfully.
- /// </summary>
- OkSuccessful = 0,
-
- /// <summary>
- /// The create or rename failed because a folder with the same name already existed.
- /// </summary>
- AlreadyExists = 1,
-
- /// <summary>
- /// The folder was not deleted because it contained child folders.
- /// </summary>
- HasChildren = 2,
-
- /// <summary>
- /// The operation failed because the source folder was not found on the server.
- /// If the operation is on a subfolder that the user can't see due to permissions
- /// this will be returned.
- /// </summary>
- NonExistent = 3,
-
- /// <summary>
- /// The user is not permitted to perform the operation.
- /// </summary>
- NotPermitted = 4
- }
-
- /// <summary>
- /// Possible return results for local store user operations.
- /// </summary>
- public enum LocalStoreUserResult {
- /// <summary>
- /// The operation completed successfully.
- /// </summary>
- OkSuccessful = 0,
-
- /// <summary>
- /// A user with the same name already exists.
- /// </summary>
- AlreadyExists = 1,
-
- /// <summary>
- /// No matching user exists in the local store.
- /// </summary>
- NoSuchUser = 2,
-
- /// <summary>
- /// Cannot add or remove the user from the mail domain because it doens't exist.
- /// </summary>
- NoSuchMailDomain = 3,
-
- /// <summary>
- /// The user cannot be deleted because they still own folders.
- /// </summary>
- UserStillHasFolders = 4,
-
- /// <summary>
- /// The user is not permitted to perform the operation.
- /// </summary>
- NotPermitted = 5,
-
- /// <summary>
- /// The user cannot be created because there is existing folders with the same details.
- /// </summary>
- FoldersAlreadyExist = 6,
-
- /// <summary>
- /// An unknown error occurred trying to perform the operation.
- /// </summary>
- UnknownError = 7
- }
-
- /// <summary>
- /// Possible return results for local store group operations.
- /// </summary>
- public enum LocalStoreGroupResult {
- /// <summary>
- /// The operation completed successfully.
- /// </summary>
- OkSuccessful = 0,
-
- /// <summary>
- /// A group with the same name already exists.
- /// </summary>
- AlreadyExists = 1,
-
- /// <summary>
- /// No matching group exists in the local store.
- /// </summary>
- NoSuchGroup = 2,
-
- /// <summary>
- /// Cannot add or remove the group from the mail domain because it doens't exist.
- /// </summary>
- NoSuchMailDomain = 3,
-
- /// <summary>
- /// The user is not permitted to perform the operation.
- /// </summary>
- NotPermitted = 4
- }
-
- /// <summary>
- /// Possible return results for local store mail domain operations.
- /// </summary>
- public enum LocalStoreMailDomainResult {
- /// <summary>
- /// The operation completed successfully.
- /// </summary>
- OkSuccessful = 0,
-
- /// <summary>
- /// A mail domain with the same primary host already exists.
- /// </summary>
- AlreadyExists = 1,
-
- /// <summary>
- /// No matching mail domain exists in the local store.
- /// </summary>
- NoSuchMailDomain = 2,
-
- /// <summary>
- /// The user is not permitted to perform the operation.
- /// </summary>
- NotPermitted = 3,
-
- /// <summary>
- /// The user doesn't exist in the mail domain.
- /// </summary>
- NoSuchUser = 4
- }
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreUserMap.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreUserMap.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreUserMap.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -16,7 +16,7 @@
*/
using System;
-using System.Xml;
+using System.Collections.Generic;
using NMail.DataTypes;
@@ -37,7 +37,7 @@
/// </summary>
/// <param name="username">The user to look up the mailboxes for.</param>
/// <returns>The user's mailboxes.</returns>
- Mailbox[] GetUserMailboxes(string username);
+ IList<Mailbox> GetUserMailboxes(string username);
/// <summary>
/// Adds the given mailbox the to list of mailboxes for the user.
Modified: NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail.ImapService/State/AuthenticatedState.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -88,7 +88,7 @@
if (folder.HasChildren) {
// Get a list of child folders
IList<StoreFolder> children =
- LocalStore.GetChildren(Session.AuthenticationToken, folder);
+ LocalStore.GetChildren(Session.AuthenticationToken, folder.FolderId);
// Output each matching folder to the client
foreach (StoreFolder current in children) {
@@ -142,7 +142,7 @@
if (folder != null) {
// Attempt to subscribe to the folder
- LocalStore.Subscribe(Session.AuthenticationToken, folder);
+ LocalStore.Subscribe(Session.AuthenticationToken, folder.FolderId);
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "SUBSCRIBE Completed."));
} else {
@@ -162,7 +162,7 @@
// Attempt to subscribe to the folder
StoreFolder folder = LocalStore.GetStoreFolder(Session.AuthenticationToken, cmd.Folder);
if (folder != null) {
- LocalStore.UnSubscribe(Session.AuthenticationToken, folder);
+ LocalStore.UnSubscribe(Session.AuthenticationToken, folder.FolderId);
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "UNSUBSCRIBE Completed."));
} else {
@@ -193,9 +193,9 @@
#region Process Select and Examine Commands
protected void sendSelectResponses(StoreFolder folder) {
QueueResponse(new SimpleResponse(ResponseType.Flags, @"(\Answered \Flagged \Deleted \Seen \Draft)"));
- QueueResponse(new SimpleResponse(LocalStore.GetMessageCount(Session.AuthenticationToken, folder) + " EXISTS"));
- QueueResponse(new SimpleResponse(LocalStore.GetMessageCountWithFlags(Session.AuthenticationToken, folder, StoreMessageFlags.Recent) + " RECENT"));
- QueueResponse(new SimpleResponse(ResponseType.Ok, "[UIDNEXT " + LocalStore.GetNextMessageId(Session.AuthenticationToken, folder) + "]"));
+ QueueResponse(new SimpleResponse(LocalStore.GetMessageCount(Session.AuthenticationToken, folder.FolderId) + " EXISTS"));
+ QueueResponse(new SimpleResponse(LocalStore.GetMessageCountWithFlags(Session.AuthenticationToken, folder.FolderId, StoreMessageFlags.Recent) + " RECENT"));
+ QueueResponse(new SimpleResponse(ResponseType.Ok, "[UIDNEXT " + LocalStore.GetNextMessageId(Session.AuthenticationToken, folder.FolderId) + "]"));
QueueResponse(new SimpleResponse(ResponseType.Ok, "[UIDVALIDITY " + folder.FolderId + "]"));
// TODO: OK [UNSEEN #]
@@ -252,13 +252,13 @@
StatusResponse response = new StatusResponse(cmd.Folder);
if ((cmd.Items & StatusItems.Messages) != StatusItems.None) {
- response.AppendResponseItem("MESSAGES " + LocalStore.GetMessageCount(Session.AuthenticationToken, folder));
+ response.AppendResponseItem("MESSAGES " + LocalStore.GetMessageCount(Session.AuthenticationToken, folder.FolderId));
}
if ((cmd.Items & StatusItems.Recent) != StatusItems.None) {
- response.AppendResponseItem("RECENT " + LocalStore.GetMessageCountWithFlags(Session.AuthenticationToken, folder, StoreMessageFlags.Recent));
+ response.AppendResponseItem("RECENT " + LocalStore.GetMessageCountWithFlags(Session.AuthenticationToken, folder.FolderId, StoreMessageFlags.Recent));
}
if ((cmd.Items & StatusItems.UidNext) != StatusItems.None) {
- response.AppendResponseItem("UIDNEXT " + LocalStore.GetNextMessageId(Session.AuthenticationToken, folder));
+ response.AppendResponseItem("UIDNEXT " + LocalStore.GetNextMessageId(Session.AuthenticationToken, folder.FolderId));
}
if ((cmd.Items & StatusItems.UidValidity) != StatusItems.None) {
response.AppendResponseItem("UIDVALIDITY " + folder.FolderId);
@@ -278,9 +278,9 @@
StoreFolder folder = LocalStore.GetStoreFolder(Session.AuthenticationToken, cmd.Folder);
if (folder != null) {
- LocalStoreFolderResult result = LocalStore.DeleteFolder(Session.AuthenticationToken, folder.FolderId);
+ try {
+ LocalStore.DeleteFolder(Session.AuthenticationToken, folder.FolderId);
- if (result == LocalStoreFolderResult.OkSuccessful) {
// Re-create the inbox folder if it is deleted.
if (LocalStore.GetStoreFolder(Session.AuthenticationToken, Folder.Inbox) == null) {
LocalStore.CreateFolder(Session.AuthenticationToken, Folder.Inbox);
@@ -288,16 +288,16 @@
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "DELETE Completed."));
- } else if (result == LocalStoreFolderResult.HasChildren) {
+ } catch (ConstraintException) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "DELETE: Folder:[" + cmd.Folder + "] has children."));
- } else if (result == LocalStoreFolderResult.NonExistent) {
+ } catch (ArgumentException) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "DELETE: No such folder:[" + cmd.Folder + "]"));
- } else if (result == LocalStoreFolderResult.NotPermitted) {
+ } catch (InvalidOperationException) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "DELETE: Insufficient privileges to delete folder:[" + cmd.Folder + "]."));
- } else {
+ } catch (Exception) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "DELETE: Unknown error."));
}
@@ -381,7 +381,7 @@
}
// Attempt to spool the message
- DeliveryResult result = LocalStore.DeliverMessage(Session.AuthenticationToken, message, folder);
+ DeliveryResult result = LocalStore.DeliverMessage(Session.AuthenticationToken, message, folder.FolderId);
if (result.Type == DeliveryResultType.Success) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "APPEND Completed"));
@@ -436,7 +436,7 @@
// Set the new privileges
currentAce.Privilege = newPrivileges;
- this.LocalStore.SetStoreFolderAce(Session.AuthenticationToken, folder, currentAce);
+ this.LocalStore.SetStoreFolderAce(Session.AuthenticationToken, folder.FolderId, currentAce);
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "SETACL Completed."));
} else {
@@ -457,7 +457,7 @@
if (folder != null) {
// Remove the ACE from the folder
- LocalStore.RemoveStoreFolderAce(Session.AuthenticationToken, folder, cmd.Identifier);
+ LocalStore.RemoveStoreFolderAce(Session.AuthenticationToken, folder.FolderId, cmd.Identifier);
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "DELETEACL Completed."));
} else {
Modified: NMail/trunk/NMail.ImapService/State/ExamineState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -56,14 +56,14 @@
if (usingUid) {
messageUid = messageId;
} else {
- messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
}
// Get the message
Message message = LocalStore.GetMessage(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
// Attempt to copy the message
- DeliveryResult result = LocalStore.DeliverMessage(Session.AuthenticationToken, message, dstFolder);
+ DeliveryResult result = LocalStore.DeliverMessage(Session.AuthenticationToken, message, dstFolder.FolderId);
}
public override void ProcessCommand(CopyCommand cmd) {
@@ -81,12 +81,12 @@
// Process each message in the specified range
if (cmd.UidCommand) {
int i = 0;
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (i < (listItem.End - listItem.Start) && messageId != 0 && messageId <= listItem.End) {
processMessageCopy(messageId, true, dstFolder);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
i++;
}
} else {
@@ -97,16 +97,16 @@
} else if (listItem.ItemType == ImapMessageListItemType.UnboundedRange) {
if (cmd.UidCommand) {
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (messageId != 0) {
processMessageCopy(messageId, true, dstFolder);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
}
} else {
// Process each message in the specified range
- int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder);
+ int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder.FolderId);
if (!messageCount.HasValue) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "COPY: Access to folder denied."));
@@ -166,7 +166,7 @@
string flagsString = "FLAGS ";
// Get the message flags
- StoreMessageFlags? flags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ StoreMessageFlags? flags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (flags.HasValue) {
flagsString += StoreMessageFlagsHelper.ToImapFlagsString(flags.Value);
@@ -223,8 +223,8 @@
#endregion
#region sendMessageSize
- protected virtual void sendMessageSize(FetchResponse response, int messageUid) {
- int? messageSize = LocalStore.GetMessageSize(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ protected virtual void sendMessageSize(FetchResponse response, int messageUid) {
+ int? messageSize = LocalStore.GetMessageSize(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (messageSize.HasValue) {
response.AppendResponseItem("RFC822.SIZE " + messageSize.Value);
@@ -234,7 +234,7 @@
#region sendInternalDate
protected virtual void sendInternalDate(FetchResponse response, int messageUid) {
- DateTime? internalDate = LocalStore.GetInternalDate(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ DateTime? internalDate = LocalStore.GetInternalDate(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (internalDate.HasValue) {
response.AppendResponseItem("INTERNALDATE \"" + internalDate.Value.ToString("r") + "\"");
@@ -351,10 +351,10 @@
if (usingUid) {
messageUid = messageId;
- messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
} else {
messageOffset = messageId;
- messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageOffset, this.selectedFolder);
+ messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageOffset, this.selectedFolder.FolderId);
}
// Ensure the message exists
@@ -450,12 +450,12 @@
// Process each message in the specified range
if (cmd.UidCommand) {
int i = 0;
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (i <= (listItem.End - listItem.Start) && messageId != 0 && messageId <= listItem.End) {
processMessageFetch(messageId, true, cmd.DataList);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
i++;
}
} else {
@@ -466,16 +466,16 @@
} else if (listItem.ItemType == ImapMessageListItemType.UnboundedRange) {
if (cmd.UidCommand) {
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (messageId != 0) {
processMessageFetch(messageId, true, cmd.DataList);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
}
} else {
// Process each message in the specified range
- int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder);
+ int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder.FolderId);
if (!messageCount.HasValue) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "FETCH: Access denied."));
@@ -545,7 +545,7 @@
List<int> messageOffsets = new List<int>();
foreach (int messageUid in messageUids) {
- int messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageUid, Session.SelectedFolder);
+ int messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageUid, Session.SelectedFolder.FolderId);
messageOffsets.Add(messageOffset);
}
Modified: NMail/trunk/NMail.ImapService/State/SelectedState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/SelectedState.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail.ImapService/State/SelectedState.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -36,7 +36,7 @@
#region Process Expunge Command
public override void ProcessCommand(ExpungeCommand cmd) {
- int[] messageOffsets = LocalStore.PurgeDeletedMessages(Session.AuthenticationToken, this.selectedFolder);
+ int[] messageOffsets = LocalStore.PurgeDeletedMessages(Session.AuthenticationToken, this.selectedFolder.FolderId);
for (int i = 0; i < messageOffsets.Length; i++) {
QueueResponse(new ExpungeResponse(messageOffsets[i] - i));
@@ -53,33 +53,33 @@
if (usingUid) {
messageUid = messageId;
- messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageOffset = LocalStore.GetMessageOffset(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
} else {
messageOffset = messageId;
- messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageOffset, this.selectedFolder);
+ messageUid = LocalStore.GetMessageId(Session.AuthenticationToken, messageOffset, this.selectedFolder.FolderId);
}
if (command == StoreFlagsCommand.Replace || command == StoreFlagsCommand.ReplaceSilently) {
// Simply replace the existing flags
- LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder, flags);
+ LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, flags);
} else if (command == StoreFlagsCommand.Add || command == StoreFlagsCommand.AddSilently) {
// Add the set flags to the existing flags
- StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (currentFlags.HasValue) {
StoreMessageFlags newFlags = currentFlags.Value | flags;
- LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder, newFlags);
+ LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, newFlags);
}
} else {
// Remove the set flags from the existing flags
- StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (currentFlags.HasValue) {
StoreMessageFlags newFlags = currentFlags.Value ^ flags;
newFlags &= currentFlags.Value;
- LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder, newFlags);
+ LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, newFlags);
}
}
@@ -102,12 +102,12 @@
// Process each message in the specified range
if (cmd.UidCommand) {
int i = 0;
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (i < (listItem.End - listItem.Start) && messageId != 0 && messageId <= listItem.End) {
processMessageStore(messageId, true, cmd.Command, cmd.Flags);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
i++;
}
} else {
@@ -118,16 +118,16 @@
} else if (listItem.ItemType == ImapMessageListItemType.UnboundedRange) {
if (cmd.UidCommand) {
- int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder);
+ int messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, listItem.Start - 1, this.selectedFolder.FolderId);
while (messageId != 0) {
processMessageStore(messageId, true, cmd.Command, cmd.Flags);
- messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder);
+ messageId = LocalStore.GetNextMessageId(Session.AuthenticationToken, messageId, this.selectedFolder.FolderId);
}
} else {
// Process each message in the specified range
- int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder);
+ int? messageCount = LocalStore.GetMessageCount(Session.AuthenticationToken, this.selectedFolder.FolderId);
if (!messageCount.HasValue) {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "Access denied."));
@@ -151,7 +151,7 @@
public override void ProcessCommand(CloseCommand cmd) {
base.ProcessCommand(cmd);
- LocalStore.PurgeDeletedMessages(Session.AuthenticationToken, this.selectedFolder);
+ LocalStore.PurgeDeletedMessages(Session.AuthenticationToken, this.selectedFolder.FolderId);
}
#endregion
@@ -161,11 +161,11 @@
if (!peek) {
// Remove the RECENT flag from the existing flags
- StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder);
+ StoreMessageFlags? currentFlags = LocalStore.GetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId);
if (currentFlags.HasValue) {
StoreMessageFlags newFlags = (StoreMessageFlags)((int)currentFlags.Value - (int)StoreMessageFlags.Recent);
- LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder, newFlags);
+ LocalStore.SetMessageFlags(Session.AuthenticationToken, messageUid, this.selectedFolder.FolderId, newFlags);
}
}
}
Modified: NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail.LocalStore/DeliveryActions/ManageWhiteList.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -85,9 +85,9 @@
// Ensure the user has a quarantined folder
if (quarantineFolder == null) {
- LocalStoreFolderResult createResult = localStore.CreateFolder(username, "Quarantined");
-
- if (createResult != LocalStoreFolderResult.OkSuccessful) {
+ try {
+ localStore.CreateFolder(username, "Quarantined");
+ } catch (Exception) {
return new DeliveryResult(DeliveryResultType.TemporaryError, "Error creating user's quarantined folder.");
}
}
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-01 13:46:57 UTC (rev 188)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-08 11:35:52 UTC (rev 189)
@@ -201,11 +201,11 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="message">The message to deliver.</param>
- /// <param name="folder">The folder to deliver the message into.</param>
+ /// <param name="folderId">The Id of the folder to deliver the message into.</param>
/// <returns>The result of the delivery.</returns>
- public DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message message, StoreFolder folder) {
+ public DeliveryResult DeliverMessage(IAuthenticationToken authToken, Message message, int folderId) {
- LocalStoreData.DeliverMessage(message, folder.FolderId);
+ LocalStoreData.DeliverMessage(message, folderId);
return new DeliveryResult(DeliveryResultType.Success, null);
// TODO: lookup a maildomain or a system wide delivery chain to process the message
@@ -348,7 +348,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="newFolder">The folder to create.</param>
/// <returns>The result of the create attempt.</returns>
- public LocalStoreFolderResult CreateFolder(IAuthenticationToken authToken, string newFolder) {
+ public void CreateFolder(IAuthenticationToken authToken, string newFolder) {
Folder resolvedFolder = getResolvedFolder(authToken, newFolder);
if (resolvedFolder.Parent != null) {
@@ -376,21 +376,19 @@
GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(authToken.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
LocalStoreData.SetStoreFolderAce(createdFolder.FolderId, ace);
- return LocalStoreFolderResult.OkSuccessful;
-
} else {
// Don't have privileges to create the folder
- return LocalStoreFolderResult.NotPermitted;
+ throw new ArgumentException("Invalid folder Id.");
}
} else {
// Invalid parent folder
- return LocalStoreFolderResult.NonExistent;
+ throw new ArgumentException("Invalid folder Id.");
}
} else {
// Currently can't create a folder without a parent
- return LocalStoreFolderResult.NotPermitted;
+ throw new ArgumentException("Invalid folder Id.");
}
}
#endregion
@@ -401,18 +399,16 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="folderId">The Id of the folder to delete.</param>
- /// <returns>The result of the delete attempt.</returns>
- public LocalStoreFolderResult DeleteFolder(IAuthenticationToken authToken, int folderId) {
+ public void DeleteFolder(IAuthenticationToken authToken, int folderId) {
// Ensure the user has rights to delete the folder
if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Delete)) {
// Delete the folder
- throw new NotImplementedException("Need to adjust localstore iface before implementing...");
- //return LocalStoreData.DeleteFolder(folderId);
+ LocalStoreData.DeleteFolder(folderId, false);
} else {
- return LocalStoreFolderResult.NotPermitted;
+ throw new ArgumentException("Invalid folder Id.");
}
}
#endregion
@@ -499,7 +495,7 @@
/// <returns>The list of folders.</returns>
private void GetDescendants(IAuthenticationToken authToken, StoreFolder parent, IList<StoreFolder> result) {
// Get a list of folders for this parent
- IList<StoreFolder> children = GetChildren(authToken, parent);
+ IList<StoreFolder> children = GetChildren(authToken, parent.FolderId);
foreach (StoreFolder child in children) {
// Add the current child and get any descendants
@@ -516,16 +512,15 @@
/// Gets a list of child folders for the given parent folder.
/// </summary>
/// <param name="authToken">The authentication credentials</param>
- /// <param name="parent">The parent to get the children from.</param>
+ /// <param name="parentId">The Id of the parent to get the children from.</param>
/// <returns>The list of folders.</returns>
- public IList<StoreFolder> GetChildren(IAuthenticationToken authToken, StoreFolder parent) {
+ public IList<StoreFolder> GetChildren(IAuthenticationToken authToken, int parentId) {
// Ensure the user has rights to list the folders
- if (parent != null
- && hasFolderPrivilege(authToken.Username, parent.FolderId, StoreFolderPrivilege.Lookup)) {
+ if (hasFolderPrivilege(authToken.Username, parentId, StoreFolderPrivilege.Lookup)) {
// Return the children
- return LocalStoreData.GetChildren(parent.FolderId);
+ return LocalStoreData.GetChildren(parentId);
} else {
return new List<StoreFolder>();
@@ -584,20 +579,18 @@
/// Subscribes to a folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to subscribe to.</param>
- /// <returns>The result of the subscribe attempt.</returns>
- public LocalStoreFolderResult Subscribe(IAuthenticationToken authToken, StoreFolder folder) {
+ /// <param name="folderId">The Id of the folder to subscribe to.</param>
+ public void Subscribe(IAuthenticationToken authToken, int folderId) {
// Ensure the user has rights to subscribe to the folder
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Lookup)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Lookup)) {
// Subscribe to the folder
LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
- LocalStoreData.Subscribe(user.UserId, folder.FolderId);
- return LocalStoreFolderResult.OkSuccessful;
+ LocalStoreData.Subscribe(user.UserId, folderId);
} else {
- return LocalStoreFolderResult.NonExistent;
+ throw new ArgumentException("Invalid folder Id.");
}
}
#endregion
@@ -607,11 +600,11 @@
/// Un-subscribes from a folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to unsubscribe from.</param>
- public void UnSubscribe(IAuthenticationToken authToken, StoreFolder folder) {
+ /// <param name="folderId">The Id of the folder to unsubscribe from.</param>
+ public void UnSubscribe(IAuthenticationToken authToken, int folderId) {
// Un-subscribe from the folder
LocalStoreUser user = LocalStoreData.GetUser(authToken.Username);
- LocalStoreData.UnSubscribe(user.UserId, folder.FolderId);
+ LocalStoreData.UnSubscribe(user.UserId, folderId);
}
#endregion
#endregion
@@ -623,15 +616,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="currentId">The Id to start looking from.</param>
- /// <param name="folder"></param>
+ /// <param name="folderId"></param>
/// <returns>The Id of the next existing message or 0 if there is none.</returns>
- public int GetNextMessageId(IAuthenticationToken authToken, int currentId, StoreFolder folder) {
+ public int GetNextMessageId(IAuthenticationToken authToken, int currentId, int folderId) {
// Ensure the user has rights to get the message Id
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetNextMessageId(currentId, folder.FolderId);
+ return LocalStoreData.GetNextMessageId(currentId, folderId);
} else {
return 0;
@@ -642,15 +635,15 @@
/// Gets the Id for the next message to be added into the folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The next message Id or 0 if insufficient privileges.</returns>
- public int GetNextMessageId(IAuthenticationToken authToken, StoreFolder folder) {
+ public int GetNextMessageId(IAuthenticationToken authToken, int folderId) {
// Ensure the user has rights to get the message Id
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetNextMessageId(folder.FolderId);
+ return LocalStoreData.GetNextMessageId(folderId);
} else {
return 0;
@@ -664,15 +657,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageOffset">The offset of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message Id or 0 if there is no such message.</returns>
- public int GetMessageId(IAuthenticationToken authToken, int messageOffset, StoreFolder folder) {
+ public int GetMessageId(IAuthenticationToken authToken, int messageOffset, int folderId) {
// Ensure the user has rights to get the message Id
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetMessageId(messageOffset, folder.FolderId);
+ return LocalStoreData.GetMessageId(messageOffset, folderId);
} else {
return 0;
@@ -686,15 +679,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to lookup.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message offset or 0 if there is no such message.</returns>
- public int GetMessageOffset(IAuthenticationToken authToken, int messageId, StoreFolder folder) {
+ public int GetMessageOffset(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message Id
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message Id
- return LocalStoreData.GetMessageOffset(messageId, folder.FolderId);
+ return LocalStoreData.GetMessageOffset(messageId, folderId);
} else {
return 0;
@@ -726,15 +719,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message flags or null if invalid folder or privileges.</returns>
- public StoreMessageFlags? GetMessageFlags(IAuthenticationToken authToken, int messageId, StoreFolder folder) {
+ public StoreMessageFlags? GetMessageFlags(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message flags
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message flags
- return LocalStoreData.GetMessageFlags(messageId, folder.FolderId);
+ return LocalStoreData.GetMessageFlags(messageId, folderId);
} else {
return null;
@@ -749,10 +742,10 @@
/// <remarks>This will replace any existing flags on the message.</remarks>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to set the flags for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <param name="flags">The flags to set.</param>
- public void SetMessageFlags(IAuthenticationToken authToken, int messageId, StoreFolder folder, StoreMessageFlags flags) {
- StoreMessageFlags? tmpFlags = LocalStoreData.GetMessageFlags(messageId, folder.FolderId);
+ public void SetMessageFlags(IAuthenticationToken authToken, int messageId, int folderId, StoreMessageFlags flags) {
+ StoreMessageFlags? tmpFlags = LocalStoreData.GetMessageFlags(messageId, folderId);
if (!tmpFlags.HasValue) {
throw new ArgumentException("Invalid message or folder Id.");
}
@@ -762,7 +755,7 @@
if ((changedFlags & StoreMessageFlags.Deleted) == StoreMessageFlags.Deleted) {
// Ensure the user has rights to delete a message
- if (!hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Delete)) {
+ if (!hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Delete)) {
// No rights, replace with the current deleted flag
flags |= StoreMessageFlags.Deleted;
flags ^= StoreMessageFlags.Deleted;
@@ -773,7 +766,7 @@
if ((changedFlags & StoreMessageFlags.Seen) == StoreMessageFlags.Seen) {
// Ensure the user has rights to alter the seen flag
- if (!hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.AlterSeenFlag)) {
+ if (!hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.AlterSeenFlag)) {
// No rights, replace with the current seen flag
flags |= StoreMessageFlags.Seen;
flags ^= StoreMessageFlags.Seen;
@@ -784,7 +777,7 @@
if ((changedFlags ^ (StoreMessageFlags.Deleted | StoreMessageFlags.Seen)) != StoreMessageFlags.None) {
// Ensure the user has rights to alter the other flags
- if (!hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Write)) {
+ if (!hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Write)) {
// No rights, replace with the current flags (excluding \Seen and \Deleted)
flags &= (StoreMessageFlags.Deleted | StoreMessageFlags.Seen);
currentFlags |= (StoreMessageFlags.Deleted | StoreMessageFlags.Seen);
@@ -794,7 +787,7 @@
}
}
- LocalStoreData.SetMessageFlags(messageId, folder.FolderId, flags);
+ LocalStoreData.SetMessageFlags(messageId, folderId, flags);
}
#endregion
#endregion
@@ -806,15 +799,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the date for.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message date or null if invalid folder or privileges.</returns>
- public DateTime? GetInternalDate(IAuthenticationToken authToken, int messageId, StoreFolder folder) {
+ public DateTime? GetInternalDate(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message date time
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the internal date
- return LocalStoreData.GetInternalDate(messageId, folder.FolderId);
+ return LocalStoreData.GetInternalDate(messageId, folderId);
} else {
return null;
@@ -828,15 +821,15 @@
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
/// <param name="messageId">The Id of the message to get the size from.</param>
- /// <param name="folder">The folder the message is in.</param>
+ /// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The message size in bytes or null if invalid folder or privileges.</returns>
- public int? GetMessageSize(IAuthenticationToken authToken, int messageId, StoreFolder folder) {
+ public int? GetMessageSize(IAuthenticationToken authToken, int messageId, int folderId) {
// Ensure the user has rights to get the message size
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message size
- return LocalStoreData.GetMessageSize(messageId, folder.FolderId);
+ return LocalStoreData.GetMessageSize(messageId, folderId);
} else {
return null;
@@ -942,15 +935,15 @@
/// Gets the number of messages in the given store folder.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to count the messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the messages in.</param>
/// <returns>The message count or null if invalid folder or privileges.</returns>
- public int? GetMessageCount(IAuthenticationToken authToken, StoreFolder folder) {
+ public int? GetMessageCount(IAuthenticationToken authToken, int folderId) {
// Ensure the user has rights to get the message count
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Read)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
// Return the message count
- return LocalStoreData.GetMessageCount(folder.FolderId);
+ return LocalStoreData.GetMessageCount(folderId);
} else {
return null;
@@ -963,16 +956,16 @@
/// Gets the number of messages with the specified flags set.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to count the flagged messages in.</param>
+ /// <param name="folderId">The Id of the folder to count the flagged messages in.</param>
/// <param name="flags">The flags to check for when counting.</param>
/// <returns>The number of messages or null if invalid folder or privileges.</returns>
- public int? GetMessageCountWithFlags(IAuthenticationToken authToken, StoreFolder folder, StoreMessageFlags flags) {
+ public int? GetMessageCountWithFlags(IAuthenticationToken authToken, int folderId, StoreMessageFlags flags) {
// Ensure the user has rights to get the message count
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Lookup)) {
+ if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Lookup)) {
// Return the count
- return LocalStoreData.GetMessageCountWithFlags(folder.FolderId, flags);
+ return LocalStoreData.GetMessageCountWithFlags(folderId, flags);
} else {
return null;
@@ -986,18 +979,18 @@
/// Permanently removes messages flagged as deleted.
/// </summary>
/// <param name="authToken">The authentication credentials.</param>
- /// <param name="folder">The folder to delete messages in.</param>
+ /// <param name="folderId">The Id of the folder to delete messages in.</param>
/// <returns>
/// The list of message offsets for the deleted messages or null if insufficient
/// pri...
[truncated message content] |