Revision: 56
Author: tmyroadctfig
Date: 2006-07-05 05:05:15 -0700 (Wed, 05 Jul 2006)
ViewCVS: http://svn.sourceforge.net/nmailserver/?rev=56&view=rev
Log Message:
-----------
Fixed some small defects in the localstore. Work on spool administration. Added SASL plain authentication.
Modified Paths:
--------------
NMail/branches/luke-dev/NMail/DataTypes/Envelope.cs
NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolData.cs
NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolService.cs
NMail/branches/luke-dev/NMail/NMail.csproj
NMail/branches/luke-dev/NMail.Administration.Web/Login.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx
NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx
NMail/branches/luke-dev/NMail.ImapService/Command/AuthenticateCommand.cs
NMail/branches/luke-dev/NMail.ImapService/Configuration/ImapServiceConfiguration.cs
NMail/branches/luke-dev/NMail.ImapService/ImapSession.cs
NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs
NMail/branches/luke-dev/NMail.ImapService/State/ConnectedState.cs
NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.cs
NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.sql
NMail/branches/luke-dev/NMail.SpoolService/SpoolService.cs
Added Paths:
-----------
NMail/branches/luke-dev/NMail/Authentication/SaslPlainAuthMsg.cs
NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolEnvelope.cs
NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolRecipient.cs
NMail/branches/luke-dev/NMail.Administration.Web/App_Code/SpooledMessageDataSource.cs
Added: NMail/branches/luke-dev/NMail/Authentication/SaslPlainAuthMsg.cs
===================================================================
--- NMail/branches/luke-dev/NMail/Authentication/SaslPlainAuthMsg.cs (rev 0)
+++ NMail/branches/luke-dev/NMail/Authentication/SaslPlainAuthMsg.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.Authentication {
+ public class SaslPlainAuthMsg {
+
+ public SaslPlainAuthMsg(string base64Data) {
+ byte[] msgData = Convert.FromBase64String(base64Data);
+ string msgStr = Encoding.UTF8.GetString(msgData);
+
+ string[] tokens = msgStr.Split("\000u".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+
+ if (tokens.Length == 3) {
+ this.authorisationId = tokens[0];
+ this.authenticationId = tokens[1];
+ this.password = tokens[2];
+ } else {
+ this.authorisationId = tokens[0];
+ this.authenticationId = tokens[0];
+ this.password = tokens[1];
+ }
+ }
+
+ private string authenticationId;
+
+ public string AuthenticationId {
+ get {
+ return this.authenticationId;
+ }
+ }
+
+ private string authorisationId;
+
+ public string AuthorisationId {
+ get {
+ return this.authorisationId;
+ }
+ }
+
+ private string password;
+
+ public string Password {
+ get {
+ return this.password;
+ }
+ }
+ }
+}
Modified: NMail/branches/luke-dev/NMail/DataTypes/Envelope.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/Envelope.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail/DataTypes/Envelope.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -27,6 +27,9 @@
/// </summary>
[Serializable]
public class Envelope {
+
+ protected Envelope() { }
+
/// <summary>
/// Creates a new envelope from the message headers.
/// </summary>
Modified: NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolData.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolData.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolData.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using NMail.DataTypes;
@@ -86,5 +87,11 @@
/// <param name="message">The message to set the status for.</param>
/// <param name="filtered">True if filtered successfuly, false if failed.</param>
void SetFilterStatus(SmtpMessage message, bool filtered);
+
+ /// <summary>
+ /// Gets a list of message envelopes for messages currently in the spool.
+ /// </summary>
+ /// <returns>The list of envelopes.</returns>
+ List<SpoolEnvelope> GetSpooledEnvelopes();
}
}
Modified: NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolService.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolService.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail/DataTypes/Spool/ISpoolService.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using NMail.DataTypes;
@@ -50,5 +51,11 @@
/// Notifies the spool service thread that a message is waiting in the spool.
/// </summary>
void NotifyServiceThread();
+
+ /// <summary>
+ /// Gets a list of message envelopes for messages currently in the spool.
+ /// </summary>
+ /// <returns>The list of envelopes.</returns>
+ List<SpoolEnvelope> GetSpooledEnvelopes();
}
}
Added: NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolEnvelope.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolEnvelope.cs (rev 0)
+++ NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolEnvelope.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004-2006 Luke Quinane
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.DataTypes;
+
+namespace NMail.DataTypes.Spool {
+ /// <summary>
+ /// The envelope for a message in the spool.
+ /// </summary>
+ public class SpoolEnvelope : Envelope {
+ /// <summary>
+ /// Creates a new spool envelope.
+ /// </summary>
+ /// <param name="messageId">The Id of the message.</param>
+ /// <param name="filtered">True if the message has been filtered.</param>
+ /// <param name="recipients">The recipients for this message still awaiting delivery.</param>
+ public SpoolEnvelope(Envelope envelope, int messageId, bool filtered, SpoolRecipient[] recipients) {
+
+ this.Bcc = envelope.Bcc;
+ this.Cc = envelope.Cc;
+ this.Date = envelope.Date;
+ this.From = envelope.From;
+ this.InReplyTo = envelope.InReplyTo;
+ this.ReplyTo = envelope.ReplyTo;
+ this.Sender = envelope.Sender;
+ this.Subject = envelope.Subject;
+ this.To = envelope.To;
+
+ this.messageId = messageId;
+ this.filtered = filtered;
+ this.recipients = recipients;
+ }
+
+ private int messageId;
+
+ /// <summary>
+ /// The Id of this message in the spool.
+ /// </summary>
+ /// <remarks>This is different to the Id stored in the message headers.</remarks>
+ public int MessageId {
+ get {
+ return this.messageId;
+ }
+ set {
+ this.messageId = value;
+ }
+ }
+
+ private bool filtered;
+
+ /// <summary>
+ /// True if the message has been filtered.
+ /// </summary>
+ public bool Filtered {
+ get {
+ return this.filtered;
+ }
+ set {
+ this.filtered = value;
+ }
+ }
+
+ private SpoolRecipient[] recipients;
+
+ /// <summary>
+ /// The recipients of this message still awaiting delivery.
+ /// </summary>
+ public SpoolRecipient[] Recipients {
+ get {
+ return this.recipients;
+ }
+ set {
+ this.recipients = value;
+ }
+ }
+ }
+}
Added: NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolRecipient.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolRecipient.cs (rev 0)
+++ NMail/branches/luke-dev/NMail/DataTypes/Spool/SpoolRecipient.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Spool {
+ /// <summary>
+ /// Holds the details of a message recipient that is waiting delivery.
+ /// </summary>
+ public class SpoolRecipient {
+ /// <summary>
+ /// Creates a new spool recipient.
+ /// </summary>
+ /// <param name="address">The recipient's address.</param>
+ /// <param name="recipientId">The Id of the recipient in the spool.</param>
+ /// <param name="nextDelivery">The time for the next delivery attempt.</param>
+ /// <param name="deliveryAttempts">The number of delivery attempts.</param>
+ public SpoolRecipient(EmailAddress address, int recipientId, DateTime nextDelivery, int deliveryAttempts) {
+ this.address = address;
+ this.recipientId = recipientId;
+ this.nextDeliveryAttempt = nextDeliveryAttempt;
+ this.deliveryAttempts = deliveryAttempts;
+ }
+
+ private int recipientId;
+
+ /// <summary>
+ /// The Id of this recipient in the spool.
+ /// </summary>
+ public int RecipientId {
+ get {
+ return this.recipientId;
+ }
+ set {
+ this.recipientId = value;
+ }
+ }
+
+ private EmailAddress address;
+
+ /// <summary>
+ /// The recipient's address.
+ /// </summary>
+ public EmailAddress Address {
+ get {
+ return this.address;
+ }
+ set {
+ this.address = value;
+ }
+ }
+
+ private DateTime nextDeliveryAttempt;
+
+ /// <summary>
+ /// The time for the next delivery attempt.
+ /// </summary>
+ public DateTime NextDeliveryAttempt {
+ get {
+ return this.nextDeliveryAttempt;
+ }
+ set {
+ this.nextDeliveryAttempt = value;
+ }
+ }
+
+ private int deliveryAttempts;
+
+ /// <summary>
+ /// The number of delivery attempts for this message.
+ /// </summary>
+ public int DeliveryAttempts {
+ get {
+ return this.deliveryAttempts;
+ }
+ set {
+ this.deliveryAttempts = value;
+ }
+ }
+ }
+}
Modified: NMail/branches/luke-dev/NMail/NMail.csproj
===================================================================
--- NMail/branches/luke-dev/NMail/NMail.csproj 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail/NMail.csproj 2006-07-05 12:05:15 UTC (rev 56)
@@ -109,6 +109,7 @@
<Compile Include="Authentication\NullAuthentication.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Authentication\SaslPlainAuthMsg.cs" />
<Compile Include="Configuration\NamedServiceCollection.cs" />
<Compile Include="Configuration\IServiceCollection.cs" />
<Compile Include="Configuration\IPAddressCollection.cs" />
@@ -215,6 +216,8 @@
<Compile Include="DataTypes\Spool\ISpoolFilter.cs" />
<Compile Include="DataTypes\Spool\ISpoolFilterService.cs" />
<Compile Include="DataTypes\Spool\ISpoolService.cs" />
+ <Compile Include="DataTypes\Spool\SpoolEnvelope.cs" />
+ <Compile Include="DataTypes\Spool\SpoolRecipient.cs" />
<Compile Include="DataTypes\WildcardHost.cs" />
<Compile Include="Helper\ByteStringBuilder.cs">
<SubType>Code</SubType>
Added: NMail/branches/luke-dev/NMail.Administration.Web/App_Code/SpooledMessageDataSource.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/App_Code/SpooledMessageDataSource.cs (rev 0)
+++ NMail/branches/luke-dev/NMail.Administration.Web/App_Code/SpooledMessageDataSource.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -0,0 +1,27 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.SessionState;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+using NMail.DataTypes.Spool;
+
+namespace NMail.Administration.Web
+{
+ public static class SpooledMessageDataSource
+ {
+ public static List<SpoolEnvelope> GetSpooledMessages()
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ ISpoolService spool = (ISpoolService)session["Spool"];
+
+ return spool.GetSpooledEnvelopes();
+ }
+ }
+}
\ No newline at end of file
Modified: NMail/branches/luke-dev/NMail.Administration.Web/Login.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/Login.aspx.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.Administration.Web/Login.aspx.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -15,6 +15,8 @@
using System.Web.UI.HtmlControls;
using NMail.Authentication;
+using NMail.DataTypes;
+using NMail.DataTypes.Spool;
using NMail.IO;
using NMail.Server;
@@ -35,6 +37,15 @@
Session["AuthToken"] = authToken;
Session["RemoteAdministration"] = ra;
Session["LocalStore"] = ra.NMailServer.LocalStore;
+
+ foreach (IService service in ra.NMailServer.Services)
+ {
+ if (service is ISpoolService)
+ {
+ Session["Spool"] = service;
+ break;
+ }
+ }
}
}
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx 2006-07-05 12:05:15 UTC (rev 56)
@@ -2,5 +2,9 @@
<asp:Content ID="Content1" ContentPlaceHolderID="SiteContentPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SpoolMessagesDataSource">
+ </asp:Repeater>
+ <asp:ObjectDataSource ID="SpoolMessagesDataSource" runat="server" SelectMethod="GetSpooledMessages"
+ TypeName="NMail.Administration.Web.SpooledMessageDataSource"></asp:ObjectDataSource>
</asp:Content>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.Administration.Web/SpoolDetails.aspx.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -9,12 +9,13 @@
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
+using NMail.DataTypes.Spool;
+
public partial class SpoolDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
- NMail.Server.RemoteAdministration ra;
- // ra.NMailServer.Services[0].Service
+
}
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx 2006-07-05 12:05:15 UTC (rev 56)
@@ -1,4 +1,5 @@
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Users" %>
+<%@ Reference Control="~/TaskList.ascx" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
Modified: NMail/branches/luke-dev/NMail.ImapService/Command/AuthenticateCommand.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/Command/AuthenticateCommand.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.ImapService/Command/AuthenticateCommand.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -41,6 +41,8 @@
}
public enum ImapAuthenticationMethod {
+ Plain,
+
Ntlm
}
}
Modified: NMail/branches/luke-dev/NMail.ImapService/Configuration/ImapServiceConfiguration.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/Configuration/ImapServiceConfiguration.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.ImapService/Configuration/ImapServiceConfiguration.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -125,5 +125,18 @@
this["Timeout"] = value;
}
}
+
+ /// <summary>
+ /// True if unencrypted/protected logons are allowed.
+ /// </summary>
+ [ConfigurationProperty("AllowInsecureLogon", DefaultValue = false)]
+ public bool AllowInsecureLogon {
+ get {
+ return (bool) this["AllowInsecureLogon"];
+ }
+ set {
+ this["AllowInsecureLogon"] = value;
+ }
+ }
}
}
Modified: NMail/branches/luke-dev/NMail.ImapService/ImapSession.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/ImapSession.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.ImapService/ImapSession.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -29,7 +29,6 @@
using NMail.DataTypes.LocalStore;
using NMail.ImapService.Command;
using NMail.ImapService.Response;
-using NMail.ImapService.Configuration;
using NMail.ImapService.State;
namespace NMail.ImapService {
Modified: NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -136,12 +136,17 @@
#region Process Subscribe Command
public override void ProcessCommand(SubscribeCommand cmd) {
try {
- // Attempt to subscribe to the folder
StoreFolder folder = LocalStore.GetStoreFolder(Session.AuthenticationToken, cmd.Folder);
- LocalStore.Subscribe(Session.AuthenticationToken, folder);
-
- // Finish off the request
- QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "SUBSCRIBE Completed."));
+
+ if (folder != null) {
+ // Attempt to subscribe to the folder
+ LocalStore.Subscribe(Session.AuthenticationToken, folder);
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "SUBSCRIBE Completed."));
+
+ } else {
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "SUBSCRIBE No such folder."));
+ }
+
} catch (Exception ex) {
// Error occured subscribing folder
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "SUBSCRIBE: " + ex.Message));
Modified: NMail/branches/luke-dev/NMail.ImapService/State/ConnectedState.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/State/ConnectedState.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.ImapService/State/ConnectedState.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -24,6 +24,7 @@
using NMail.Authentication;
using NMail.Configuration;
using NMail.ImapService.Command;
+using NMail.ImapService.Configuration;
using NMail.ImapService.Response;
namespace NMail.ImapService.State {
@@ -63,7 +64,7 @@
capabilities += " AUTH=NTLM";
}
- if (this.Session.Connection.Encrypted) {
+ if (this.Session.Connection.Encrypted || ImapServiceConfiguration.Current.AllowInsecureLogon) {
capabilities += " AUTH=PLAIN";
} else {
capabilities += " STARTTLS LOGINDISABLED";
@@ -79,12 +80,13 @@
} else {
QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "Start Tls negotiation."));
+ Session.Connection.Flush();
Session.Connection.StartTlsAsServer();
}
}
public override void ProcessCommand(LoginCommand cmd) {
- if (Session.Connection.Encrypted) {
+ if (Session.Connection.Encrypted || ImapServiceConfiguration.Current.AllowInsecureLogon) {
IAuthenticationProvider authProvider = (IAuthenticationProvider) NMailConfiguration.Current.AuthenticationProvider;
IAuthenticationToken authToken = authProvider.Authenticate(cmd.Username, cmd.Password);
@@ -101,9 +103,32 @@
}
public override void ProcessCommand(AuthenticateCommand cmd) {
- if (cmd.AuthenticationMethod == ImapAuthenticationMethod.Ntlm && this.supportsNtlmAuth) {
+ if (cmd.AuthenticationMethod == ImapAuthenticationMethod.Plain) {
+ // Ensure the connection is secure
+ if (!Session.Connection.Encrypted) {
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "AUTH: Need to STARTTLS first."));
+ return;
+ }
+
+ // Get the username and password
QueueResponse(new ContinuationResponse(string.Empty));
+ SaslPlainAuthMsg authMsg = new SaslPlainAuthMsg(Session.Connection.ReadLine());
+ // Check the password against our copy
+ IAuthenticationProvider authProvider = (IAuthenticationProvider) NMailConfiguration.Current.AuthenticationProvider;
+ IAuthenticationToken authToken = authProvider.Authenticate(authMsg.AuthenticationId, authMsg.Password);
+
+ if (authToken != null) {
+ this.Session.AuthenticationToken = authToken;
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.Ok, "AUTHENTICATE Completed."));
+ ChangeState(ImapState.Authenticated);
+ } else {
+ QueueResponse(new SimpleResponse(cmd.Tag, ResponseType.No, "AUTHENTICATE: Bad username or password."));
+ }
+
+ } else if (cmd.AuthenticationMethod == ImapAuthenticationMethod.Ntlm && this.supportsNtlmAuth) {
+ QueueResponse(new ContinuationResponse(string.Empty));
+
// Read in client cababilities
string type1MsgStr = Session.Connection.ReadLine();
Type1Message type1Msg = new Type1Message(Convert.FromBase64String(type1MsgStr));
Modified: NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
===================================================================
--- NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2006-07-05 12:05:15 UTC (rev 56)
@@ -3,9 +3,17 @@
USE NMailLocalStore;
+DROP TABLE IF EXISTS SchemaVersion;
+CREATE TABLE SchemaVersion (
+ Version INT NOT NULL
+);
+
+INSERT INTO SchemaVersion (Version) VALUES (1);
+
+
-- -----------------------------------------------------------------------
--
--- Tables
+-- Data Tables
--
-- -----------------------------------------------------------------------
@@ -1107,7 +1115,7 @@
-- -----------------------------------------------------------------------
INSERT INTO Namespace (Name) VALUES ("LocalMail");
-INSERT INTO User (UserName, Password, UserFolderId) VALUES ("Administrator", "changeme", 2);
+INSERT INTO User (UserName, Password, UserFolderId) VALUES ("Administrator", "changeme", 1);
INSERT INTO Folder (NamespaceId, Name, OwnerUserId, NextMessageId) VALUES (1, "Administrator", 1, 1);
INSERT INTO Folder (NamespaceId, Name, OwnerUserId, NextMessageId, ParentFolderId) VALUES (1, "Administrator.INBOX", 1, 1, 1);
INSERT INTO FolderAcl (FolderId, Identifier, Allow, Privilege) VALUES (1, "Administrator", 1, 0xffffff); -- All privs
Modified: NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -202,9 +202,10 @@
cmd.Parameters.Add("NameSpace", folder.NameSpace);
cmd.Parameters["FolderId"].Direction = ParameterDirection.Output;
- cmd.ExecuteNonQuery();
+ int count = cmd.ExecuteNonQuery();
- int? folderId = (int?) cmd.Parameters["FolderId"].Value;
+ object o = cmd.Parameters["FolderId"].Value;
+ int? folderId = (o == DBNull.Value) ? null : (int?) o;
if (folderId.HasValue) {
return GetStoreFolder(folderId.Value);
Modified: NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.cs
===================================================================
--- NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -17,6 +17,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Net;
using log4net;
@@ -276,9 +277,10 @@
cmd.Transaction = transaction;
// Insert the sender details and message data
- cmd.CommandText = "INSERT INTO Message (MessageGuid, MessageData, ReportedHost, SourceAddress, Sender, InProgress, Filtered) VALUES (?MessageGuid, ?MessageData, ?ReportedHost, ?SourceAddress, ?Sender, ?InProgress, ?Filtered);";
+ cmd.CommandText = "INSERT INTO Message (MessageGuid, MessageData, MessageEnvelope, ReportedHost, SourceAddress, Sender, InProgress, Filtered) VALUES (?MessageGuid, ?MessageData, ?MessageEnvelope, ?ReportedHost, ?SourceAddress, ?Sender, ?InProgress, ?Filtered);";
cmd.Parameters.Add("MessageGuid", message.MessageId.ToByteArray());
cmd.Parameters.Add("MessageData", SerializationHelper.Serialize(message.Data));
+ cmd.Parameters.Add("MessageEnvelope", SerializationHelper.Serialize(message.Data.GetEnvelope()));
cmd.Parameters.Add("ReportedHost", message.ReportedHost.ToString());
cmd.Parameters.Add("SourceAddress", message.SourceAddress.ToString());
cmd.Parameters.Add("Sender", message.Sender.ToString());
@@ -484,6 +486,65 @@
}
}
#endregion
+
+ private SpoolRecipient[] getSpoolRecipients(int messageId) {
+ using (MySqlConnection cnn = GetConnection()) {
+ using (MySqlCommand cmd = cnn.CreateCommand()) {
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.CommandText = "GetSpoolRecipient";
+ cmd.Parameters.Add("MessageId", messageId);
+
+ List<SpoolRecipient> result = new List<SpoolRecipient>();
+ MySqlDataReader reader = cmd.ExecuteReader();
+
+ // Get a list of recipients for the message
+ while (reader.Read()) {
+ int recipientId = (int) reader["MessageRecipientId"];
+ EmailAddress address = new EmailAddress((string) reader["Recipient"]);
+ int deliveryAttempts = (int) reader["DeliveryAttempts"];
+ DateTime nextAttempt = (DateTime) reader["NextDeliveryAttempt"];
+
+ result.Add(new SpoolRecipient(address, recipientId, nextAttempt, deliveryAttempts));
+ }
+
+ return result;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of message envelopes for messages currently in the spool.
+ /// </summary>
+ /// <returns>The list of envelopes.</returns>
+ public List<SpoolEnvelope> GetSpooledEnvelopes() {
+ using (MySqlConnection cnn = GetConnection()) {
+ using (MySqlCommand cmd = cnn.CreateCommand()) {
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.CommandText = "GetSpooledEnvelopes";
+
+ List<SpoolEnvelope> result = new List<SpoolEnvelope>();
+ MySqlDataReader reader = cmd.ExecuteReader();
+
+ // Get a list of messages
+ while (reader.Read()) {
+ int messageId = (int) reader["MessageId"];
+ bool filtered = ((sbyte) reader["Filtered"] == 1) ? true : false;
+ Envelope envelope = (Envelope) SerializationHelper.Deserialize((byte[]) reader["MessageEnvelope"]);
+
+ result.Add(new SpoolEnvelope(envelope, messageId, filtered, null));
+ }
+
+ reader.Close();
+
+ // Add the message's recipients
+ foreach (SpoolEnvelope spoolEnvelope in result) {
+ spoolEnvelope.Recipients = getSpoolRecipients(spoolEnvelope.MessageId);
+ }
+
+ return result;
+ }
+ }
+ }
#endregion
}
}
Modified: NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.sql
===================================================================
--- NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.sql 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.SpoolData.MySql/MySqlSpoolData.sql 2006-07-05 12:05:15 UTC (rev 56)
@@ -2,6 +2,13 @@
CREATE DATABASE NMailSpool;
USE NMailSpool;
+DROP TABLE IF EXISTS SchemaVersion;
+CREATE TABLE SchemaVersion (
+ Version INT NOT NULL
+);
+
+INSERT INTO SchemaVersion (Version) VALUES (1);
+
DROP TABLE IF EXISTS Message;
CREATE TABLE Message (
MessageId INT AUTO_INCREMENT NOT NULL,
@@ -12,19 +19,64 @@
InProgress BOOL NOT NULL,
Filtered BOOL NOT NULL,
MessageData LONGBLOB NOT NULL,
+ MessageEnvelope LONGBLOB NOT NULL,
PRIMARY KEY(MessageId)
-) TYPE=InnoDB;
-
-DROP TABLE IF EXISTS MessageRecipient;
-CREATE TABLE MessageRecipient (
- MessageRecipientId INT AUTO_INCREMENT NOT NULL,
- MessageId INT NOT NULL,
- Host VARCHAR(255) NOT NULL,
- Recipient VARCHAR(990) NOT NULL,
- DeliveryAttempts INT NOT NULL,
- NextDeliveryAttempt DATETIME NOT NULL,
- InProgress BOOL NOT NULL,
- PRIMARY KEY(MessageRecipientId),
- INDEX MessageId (MessageId),
- FOREIGN KEY (MessageId) REFERENCES Message (MessageId)
-) TYPE=InnoDB;
\ No newline at end of file
+) TYPE=InnoDB;
+
+DROP TABLE IF EXISTS MessageRecipient;
+CREATE TABLE MessageRecipient (
+ MessageRecipientId INT AUTO_INCREMENT NOT NULL,
+ MessageId INT NOT NULL,
+ Host VARCHAR(255) NOT NULL,
+ Recipient VARCHAR(990) NOT NULL,
+ DeliveryAttempts INT NOT NULL,
+ NextDeliveryAttempt DATETIME NOT NULL,
+ InProgress BOOL NOT NULL,
+ PRIMARY KEY(MessageRecipientId),
+ INDEX MessageId (MessageId),
+ FOREIGN KEY (MessageId) REFERENCES Message (MessageId)
+) TYPE=InnoDB;
+
+
+delimiter //
+
+
+-- -----------------------------------------------------------------------
+--
+-- Stored procedures
+--
+-- -----------------------------------------------------------------------
+
+DROP PROCEDURE IF EXISTS GetSpoolEnvelopes //
+CREATE PROCEDURE GetSpoolEnvelopes
+(
+)
+BEGIN
+
+ SELECT
+ MessageId, Filtered, MessageEnvelope
+ FROM
+ Message;
+
+END
+//
+
+DROP PROCEDURE IF EXISTS GetSpoolRecipients //
+CREATE PROCEDURE GetSpoolRecipients
+(
+ MessageId INT
+)
+BEGIN
+
+ SELECT
+ mr.MessageRecipientId,
+ mr.Recipient,
+ mr.DeliveryAttempts,
+ mr.NextDeliveryAttempt
+ FROM
+ MessageRecipient mr
+ WHERE
+ mr.MessageId = MessageId;
+
+END
+//
\ No newline at end of file
Modified: NMail/branches/luke-dev/NMail.SpoolService/SpoolService.cs
===================================================================
--- NMail/branches/luke-dev/NMail.SpoolService/SpoolService.cs 2006-07-01 15:34:40 UTC (rev 55)
+++ NMail/branches/luke-dev/NMail.SpoolService/SpoolService.cs 2006-07-05 12:05:15 UTC (rev 56)
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using System.Threading;
using log4net;
@@ -69,6 +70,14 @@
Monitor.PulseAll(this);
Monitor.Exit(this);
}
+
+ /// <summary>
+ /// Gets a list of message envelopes for messages currently in the spool.
+ /// </summary>
+ /// <returns>The list of envelopes.</returns>
+ public List<SpoolEnvelope> GetSpooledEnvelopes() {
+ return this.data.GetSpooledEnvelopes();
+ }
#endregion
#region IService Members
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|