[Nmailserver-commits] SF.net SVN: nmailserver: [157] NMail/trunk/NMail
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-03-04 04:54:27
|
Revision: 157
http://svn.sourceforge.net/nmailserver/?rev=157&view=rev
Author: tmyroadctfig
Date: 2007-03-03 20:54:28 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
Added some calendar work. Changed some interfaces to use IList<> instead of List<>. Removed SpoolRecipient and altered SmtpMessage and SmtpMessageRecipient to be more generic.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Calendar/Attendee.cs
NMail/trunk/NMail/DataTypes/Host.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs
NMail/trunk/NMail/DataTypes/SmtpMessage.cs
NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs
NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs
NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs
NMail/trunk/NMail/DataTypes/Spool/SpoolEnvelope.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.ImapService/Response/SearchResponse.cs
NMail/trunk/NMail.ImapService/State/ExamineState.cs
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj
NMail/trunk/NMail.MessageRouter/MessageRouter.cs
NMail/trunk/NMail.Sendmail/Sendmail.cs
NMail/trunk/NMail.SmtpClient/SmtpClient.cs
NMail/trunk/NMail.SmtpService/Command/RecipientCommand.cs
NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs
NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.sql
NMail/trunk/NMail.SpoolData.MySql/NMail.SpoolData.MySql.csproj
NMail/trunk/NMail.SpoolFilter.RegexAddressRewriter/RegexAddressRewriter.cs
NMail/trunk/NMail.SpoolService/SpoolService.cs
Added Paths:
-----------
NMail/trunk/NMail/DataTypes/Calendar/AttendeeRole.cs
NMail/trunk/NMail/DataTypes/Calendar/AttendeeStatus.cs
NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs
Removed Paths:
-------------
NMail/trunk/NMail/DataTypes/Spool/SpoolRecipient.cs
Modified: NMail/trunk/NMail/DataTypes/Calendar/Attendee.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/Attendee.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Calendar/Attendee.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -20,6 +20,59 @@
using System.Text;
namespace NMail.DataTypes.Calendar {
+ /// <summary>
+ /// An attendee for a calandar entry.
+ /// </summary>
public class Attendee {
+
+ private EmailAddress address;
+
+ /// <summary>
+ /// The address of the attendee.
+ /// </summary>
+ public EmailAddress Address {
+ get { return address; }
+ set { address = value; }
+ }
+
+ private CalendarEntry calendarEntry;
+
+ /// <summary>
+ /// The calendar entry for the attendee.
+ /// </summary>
+ public CalendarEntry CalendarEntry {
+ get { return calendarEntry; }
+ set { calendarEntry = value; }
+ }
+
+ private AttendeeRole role;
+
+ /// <summary>
+ /// The role of this attendee in the event.
+ /// </summary>
+ public AttendeeRole Role {
+ get { return role; }
+ set { role = value; }
+ }
+
+ private AttendeeStatus status;
+
+ /// <summary>
+ /// The status of this attendee with respect to the event.
+ /// </summary>
+ public AttendeeStatus Status {
+ get { return status; }
+ set { status = value; }
+ }
+
+ private EmailAddress delegatedTo;
+
+ /// <summary>
+ /// The person this attendee has specified as their delegate if any.
+ /// </summary>
+ public EmailAddress DelegatedTo {
+ get { return delegatedTo; }
+ set { delegatedTo = value; }
+ }
}
}
Added: NMail/trunk/NMail/DataTypes/Calendar/AttendeeRole.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/AttendeeRole.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Calendar/AttendeeRole.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Calendar {
+ public enum AttendeeRole {
+ Chair,
+
+ RequiredParticipant,
+
+ OptionalParticipant,
+
+ NonParticipant
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Calendar/AttendeeStatus.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/AttendeeStatus.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Calendar/AttendeeStatus.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Calendar {
+ public enum AttendeeStatus {
+ Unknown,
+
+ Accepted,
+
+ Declined,
+
+ Tentative,
+
+ Delegated
+ }
+}
Added: NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/Calendar/Calendar.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.Calendar {
+ /// <summary>
+ /// Represents a calendar in the system.
+ /// </summary>
+ public class Calendar {
+
+ private string name;
+
+ /// <summary>
+ /// The name of the calendar.
+ /// </summary>
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ private int calendarId;
+
+ /// <summary>
+ /// The Id of this calendar.
+ /// </summary>
+ public int CalendarId {
+ get { return calendarId; }
+ set { calendarId = value; }
+ }
+
+ private int parentFolderId;
+
+ /// <summary>
+ /// The Id of the folder that contains this calendar.
+ /// </summary>
+ public int ParentFolderId {
+ get { return parentFolderId; }
+ set { parentFolderId = value; }
+ }
+
+ private int ownerUserId;
+
+ /// <summary>
+ /// The Id of the user that owns this calendar.
+ /// </summary>
+ public int OwnerUserId {
+ get { return ownerUserId; }
+ set { ownerUserId = value; }
+ }
+
+ private IList<CalendarEntry> entries;
+
+ /// <summary>
+ /// The calendar's entries.
+ /// </summary>
+ public IList<CalendarEntry> Entries {
+ get { return entries; }
+ set { entries = value; }
+ }
+ }
+}
Modified: NMail/trunk/NMail/DataTypes/Host.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Host.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Host.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -251,7 +251,7 @@
/// <returns>The host as a string.</returns>
public override string ToString() {
return this.Name;
- }
+ }
/// <summary>
/// The regex to check if the host string is an IP address
@@ -275,5 +275,21 @@
return base.ConvertFrom(context, culture, value);
}
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ return true;
+ }
+
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
+ if (destinationType == typeof(string)) {
+ return value.ToString();
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
}
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -21,6 +21,7 @@
using NMail.Authentication;
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
+using NMail.DataTypes.Calendar;
namespace NMail.DataTypes.LocalStore {
/// <summary>
@@ -216,7 +217,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The list of messages in the folder.</returns>
- List<int> GetMessageIds(IAuthenticationToken authToken, int folderId);
+ IList<int> GetMessageIds(IAuthenticationToken authToken, int folderId);
#endregion
#region Message Flags
@@ -569,6 +570,14 @@
/// <param name="identifier">The identifier to remove from the ACL.</param>
void RemoveAdministrationAce(IAuthenticationToken authToken, string identifier);
#endregion
+
+ LocalStoreCalendarResult CreateCalandar(IAuthenticationToken authToken, Calendar.Calendar calendar);
+
+ Calendar.Calendar GetCalandar(IAuthenticationToken authToken, string name, int parentFolderId);
+
+ Calendar.Calendar GetCalandar(IAuthenticationToken authToken, int calendarId);
+
+ LocalStoreCalendarResult DeleteCalandar(IAuthenticationToken authToken, int calendarId);
}
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -21,12 +21,20 @@
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
+using NMail.DataTypes.Calendar;
namespace NMail.DataTypes.LocalStore {
/// <summary>
/// The interface for a local store data provider.
/// </summary>
public interface ILocalStoreData {
+ /// <summary>
+ /// Reinstalls the database schema destroying any current data. Typically DROP
+ /// and CREATE database permissions will be disabled after install time thus
+ /// disabling this command.
+ /// </summary>
+ void ReinstallSchema();
+
#region Message Delivery
/// <summary>
/// Delivers the message into the given folder.
@@ -163,7 +171,7 @@
/// </summary>
/// <param name="folderId">The Id of the folder the message is in.</param>
/// <returns>The list of messages in the folder.</returns>
- List<int> GetMessageIds(int folderId);
+ IList<int> GetMessageIds(int folderId);
#endregion
#region Message Flags
@@ -435,5 +443,24 @@
/// <returns>The system ACL.</returns>
GenericAcl<SystemPrivilege> GetSystemPrivilegeAcl();
#endregion
- }
+
+ #region Calendar Manipulation
+
+ void SaveCalandar(Calendar.Calendar calendar);
+
+ Calendar.Calendar GetCalandar(string name, int parentFolderId);
+
+ Calendar.Calendar GetCalandar(int calendarId);
+
+ void DeleteCalandar(int calendarId);
+ #endregion
+
+ void SaveCalendarEntry(CalendarEntry entry);
+
+ CalendarEntry GetCalendarEntry(int entryId);
+
+ IList<CalendarEntry> GetCalendarEntries(DateTime startTime, DateTime endTime, int calendarId);
+
+ void DeleteCalendarEntry(int entryId);
+ }
}
Added: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs (rev 0)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.LocalStore {
+ public enum LocalStoreCalendarResult {
+ /// <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 operation failed because the parent 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 = 2,
+
+ /// <summary>
+ /// The user is not permitted to perform the operation.
+ /// </summary>
+ NotPermitted = 2
+ }
+}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreDelivery.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -29,7 +29,7 @@
public class LocalStoreDelivery {
public LocalStoreDelivery(SmtpMessageRecipient recipient, Folder nominalTargetFolder) {
- this.recipient = recipient;
+ this.recipient = recipient.Address;
this.sender = recipient.Message.Sender;
this.message = recipient.Message.Data;
Modified: NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/SmtpDeliveryResult.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -17,6 +17,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
namespace NMail.DataTypes {
/// <summary>
@@ -41,7 +42,7 @@
/// </summary>
/// <param name="recipients">The recipients to add.</param>
/// <param name="result">The result for the recipients.</param>
- public void AddRecipientResults(SmtpMessageRecipient[] recipients, DeliveryResult result) {
+ public void AddRecipientResults(IList<SmtpMessageRecipient> recipients, DeliveryResult result) {
foreach (SmtpMessageRecipient recipient in recipients) {
AddRecipientResult(new RecipientDeliveryResult(recipient, result));
}
Modified: NMail/trunk/NMail/DataTypes/SmtpMessage.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/SmtpMessage.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -16,7 +16,7 @@
*/
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Net;
namespace NMail.DataTypes {
@@ -30,83 +30,29 @@
/// </remarks>
public class SmtpMessage {
/// <summary>
- /// This message's unique id.
- /// </summary>
- private Guid messageId;
-
- /// <summary>
- /// The data (headers and body content) of the message.
- /// </summary>
- private Message data;
-
- /// <summary>
- /// A list of recipient for this message.
- /// </summary>
- private ArrayList recipients;
-
- /// <summary>
- /// The sender of this message.
- /// </summary>
- private EmailAddress sender;
-
- /// <summary>
- /// Gets or sets the host that the source claimed to be (i.e. the HELO host).
- /// </summary>
- private Host receivedFrom;
-
- /// <summary>
- /// Gets or sets the address from which this message was recieved.
- /// </summary>
- private IPAddress sourceAddress;
-
- /// <summary>
/// Creates a new SMTP message.
/// </summary>
- public SmtpMessage() {
- this.recipients = new ArrayList();
- this.messageId = Guid.NewGuid();
- }
+ public SmtpMessage() { }
/// <summary>
/// Adds the specified recipient to this message.
/// </summary>
/// <param name="recipient">The recipient to add</param>
- public void AddRecipient(SmtpMessageRecipient recipient) {
- this.recipients.Add(recipient);
- }
-
- /// <summary>
- /// Adds the specified recipient to this message.
- /// </summary>
- /// <param name="recipient">The recipient to add</param>
public void AddRecipient(EmailAddress recipient) {
- this.recipients.Add(new SmtpMessageRecipient(this, recipient.ToString()));
+ this.recipients.Add(new SmtpMessageRecipient(this, recipient));
}
- /// <summary>
- /// Removes the specified recipient to this message.
- /// </summary>
- /// <param name="recipient">The recipient to remove</param>
- public void RemoveRecipient(SmtpMessageRecipient recipient) {
- this.recipients.Remove(recipient);
- }
+ private IList<SmtpMessageRecipient> recipients = new List<SmtpMessageRecipient>();
/// <summary>
- /// Create and return an array of all recipients.
+ /// The list of recipients associated with this message.
/// </summary>
- /// <returns>An array of recipients of the message</returns>
- public SmtpMessageRecipient[] GetRecipients() {
- return (SmtpMessageRecipient[])this.recipients.ToArray(typeof(SmtpMessageRecipient));
- }
+ public IList<SmtpMessageRecipient> Recipients {
+ get { return recipients; }
+ set { recipients = value; }
+ }
- /// <summary>
- /// Returns the number of recipients for this message.
- /// </summary>
- public int RecipientCount {
- get {
- return this.recipients.Count;
- }
- }
+ private Guid messageId = Guid.Empty;
/// <summary>
/// This message's unique id.
@@ -120,7 +66,39 @@
}
}
+ private bool inProgress;
+
/// <summary>
+ /// True if the message is in progress.
+ /// </summary>
+ public bool InProgress {
+ get { return inProgress; }
+ set { inProgress = value; }
+ }
+
+ private bool filtered;
+
+ /// <summary>
+ /// True if the message has been filtered.
+ /// </summary>
+ public bool Filtered {
+ get { return filtered; }
+ set { filtered = value; }
+ }
+
+ private Envelope envelope;
+
+ /// <summary>
+ /// The message envelope.
+ /// </summary>
+ public Envelope Envelope {
+ get { return envelope; }
+ set { envelope = value; }
+ }
+
+ private Message data;
+
+ /// <summary>
/// Gets or sets the data (headers and body content) of the message.
/// </summary>
public Message Data {
@@ -129,9 +107,12 @@
}
set {
this.data = value;
+ this.envelope = this.data.GetEnvelope();
}
}
+ private EmailAddress sender;
+
/// <summary>
/// Gets or sets the message's sender.
/// </summary>
@@ -143,6 +124,8 @@
this.sender = value;
}
}
+
+ private Host receivedFrom;
/// <summary>
/// Gets or sets the host that the source claimed to be (i.e. the HELO host).
@@ -155,7 +138,9 @@
this.receivedFrom = value;
}
}
-
+
+ private IPAddress sourceAddress;
+
/// <summary>
/// Gets or sets the address from which this message was recieved.
/// </summary>
Modified: NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/SmtpMessageRecipient.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -21,63 +21,55 @@
/// <summary>
/// A recipient of a SMTP message.
/// </summary>
- public class SmtpMessageRecipient : EmailAddress {
+ public class SmtpMessageRecipient {
/// <summary>
- /// the number of delivery attempts for this message recipient combination.
+ /// Creates a new message recipient.
/// </summary>
- private int deliveryAttempts;
+ public SmtpMessageRecipient() { }
/// <summary>
- /// The time of the next scheduled delivery attempt.
- /// </summary>
- private DateTime nextDeliveryAttempt;
-
- /// <summary>
- /// The message associated with this instance.
- /// </summary>
- private SmtpMessage message;
-
- /// <summary>
/// Creates a new email address from the given string. This constructor will
/// work for strings of the form "mailbox@host" or "<mailbox@domain>".
/// </summary>
/// <param name="address">The address to parse.</param>
/// <param name="message">The message associated with this instance.</param>
- public SmtpMessageRecipient(SmtpMessage message, EmailAddress address) : base(address.ToString(), false) {
+ public SmtpMessageRecipient(SmtpMessage message, EmailAddress address) {
this.message = message;
+ this.mailbox = address.Mailbox;
+ this.host = address.Host;
}
+ private Mailbox mailbox;
+
/// <summary>
- /// Creates a new email address from the given string. This constructor will
- /// work for strings of the form "mailbox@host" or "<mailbox@domain>".
+ /// The recipient's mailbox.
/// </summary>
- /// <param name="address">The address to parse.</param>
- /// <param name="message">The message associated with this instance.</param>
- public SmtpMessageRecipient(SmtpMessage message, string address) : base(address, false) {
- this.message = message;
+ public Mailbox Mailbox {
+ get { return mailbox; }
+ set { mailbox = value; }
}
+ private Host host;
+
/// <summary>
- /// Creates a new email address from the given parameters.
+ /// The recipient's host.
/// </summary>
- /// <param name="mailbox">The mailbox or username for the address.</param>
- /// <param name="host">The host for the address.</param>
- /// <param name="message">The message associated with this instance.</param>
- public SmtpMessageRecipient(SmtpMessage message, Mailbox mailbox, Host host) : base(mailbox, host) {
- this.message = message;
+ public Host Host {
+ get { return host; }
+ set { host = value; }
}
/// <summary>
- /// Creates a new email address from the given string. This constructor will
- /// work for strings of the form "mailbox@host" or "<mailbox@domain>".
+ /// The recipient's email address.
/// </summary>
- /// <param name="address">The address to parse.</param>
- /// <param name="allowEmpty">Allow an empty address.</param>
- /// <param name="message">The message associated with this instance.</param>
- public SmtpMessageRecipient(SmtpMessage message, string address, bool allowEmpty) : base(address, allowEmpty) {
- this.message = message;
+ public EmailAddress Address {
+ get {
+ return new EmailAddress(this.mailbox, this.host);
+ }
}
+ private int deliveryAttempts;
+
/// <summary>
/// Gets or sets the number of delivery attempts for this message recipient
/// combination.
@@ -91,6 +83,8 @@
}
}
+ private DateTime nextDeliveryAttempt = DateTime.Now;
+
/// <summary>
/// The time of the next scheduled delivery attempt.
/// </summary>
@@ -102,6 +96,8 @@
this.nextDeliveryAttempt = value;
}
}
+
+ private SmtpMessage message;
/// <summary>
/// The message associated with this instance.
@@ -110,9 +106,36 @@
get {
return this.message;
}
+ set {
+ this.message = value;
+ }
}
+ private long recipientId;
+
/// <summary>
+ /// The Id of this recipient in the spool.
+ /// </summary>
+ public long RecipientId {
+ get {
+ return this.recipientId;
+ }
+ set {
+ this.recipientId = value;
+ }
+ }
+
+ private bool inProgress;
+
+ /// <summary>
+ /// True if a delivery attempt is currently underway.
+ /// </summary>
+ public bool InProgress {
+ get { return inProgress; }
+ set { inProgress = value; }
+ }
+
+ /// <summary>
/// Checks if the given message recipient is equal to this message recipient.
/// </summary>
/// <param name="other">The message recipient to compare.</param>
@@ -149,8 +172,8 @@
}
return (recipientA.message == recipientB.message) &&
- (recipientA.Mailbox == recipientB.Mailbox) &&
- (recipientA.Host == recipientB.Host);
+ (recipientA.mailbox == recipientB.mailbox) &&
+ (recipientA.host == recipientB.host);
}
/// <summary>
Modified: NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Spool/ISpoolData.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -27,6 +27,13 @@
/// </summary>
public interface ISpoolData {
/// <summary>
+ /// Reinstalls the database schema destroying any current data. Typically DROP
+ /// and CREATE database permissions will be disabled after install time thus
+ /// disabling this command.
+ /// </summary>
+ void ReinstallSchema();
+
+ /// <summary>
/// Initialises the data associated with the spool filter.
/// </summary>
void InitialiseSpoolFilterData();
@@ -92,6 +99,6 @@
/// Gets a list of message envelopes for messages currently in the spool.
/// </summary>
/// <returns>The list of envelopes.</returns>
- List<SpoolEnvelope> GetSpooledEnvelopes();
+ IList<SpoolEnvelope> GetSpooledEnvelopes();
}
}
Modified: NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Spool/ISpoolService.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -57,6 +57,6 @@
/// Gets a list of message envelopes for messages currently in the spool.
/// </summary>
/// <returns>The list of envelopes.</returns>
- List<SpoolEnvelope> GetSpooledEnvelopes();
+ IList<SpoolEnvelope> GetSpooledEnvelopes();
}
}
Modified: NMail/trunk/NMail/DataTypes/Spool/SpoolEnvelope.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/SpoolEnvelope.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Spool/SpoolEnvelope.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.Net;
using System.Text;
using NMail.DataTypes;
@@ -30,11 +31,13 @@
/// <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) {
+ public SpoolEnvelope() { }
+ /// <summary>
+ /// Sets the envelope details based on the given envelope.
+ /// </summary>
+ /// <param name="envelope">The envelope to copy.</param>
+ public void SetEnvelopeDetails(Envelope envelope) {
this.Bcc = envelope.Bcc;
this.Cc = envelope.Cc;
this.Date = envelope.Date;
@@ -44,19 +47,15 @@
this.Sender = envelope.Sender;
this.Subject = envelope.Subject;
this.To = envelope.To;
-
- this.messageId = messageId;
- this.filtered = filtered;
- this.recipients = recipients;
}
- private int messageId;
+ private Guid 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 SpoolMessageId {
+ public Guid SpoolMessageId {
get {
return this.messageId;
}
@@ -79,12 +78,52 @@
}
}
- private SpoolRecipient[] recipients;
+ private bool inProgress;
/// <summary>
+ /// True if the message is in the progress of being delivered or filtered.
+ /// </summary>
+ public bool InProgress {
+ get { return inProgress; }
+ set { inProgress = value; }
+ }
+
+ private IPAddress sourceAddress;
+
+ /// <summary>
+ /// The address that sent this message.
+ /// </summary>
+ public IPAddress SourceAddress {
+ get { return sourceAddress; }
+ set { sourceAddress = value; }
+ }
+
+ private Host reportedHost;
+
+ /// <summary>
+ /// The reported host.
+ /// </summary>
+ public Host ReportedHost {
+ get { return reportedHost; }
+ set { reportedHost = value; }
+ }
+
+ private EmailAddress smtpSender;
+
+ /// <summary>
+ /// The email address given as the sender during SMTP negotiations.
+ /// </summary>
+ public EmailAddress SmtpSender {
+ get { return smtpSender; }
+ set { smtpSender = value; }
+ }
+
+ private IList<SmtpMessageRecipient> recipients;
+
+ /// <summary>
/// The recipients of this message still awaiting delivery.
/// </summary>
- public SpoolRecipient[] Recipients {
+ public IList<SmtpMessageRecipient> Recipients {
get {
return this.recipients;
}
Deleted: NMail/trunk/NMail/DataTypes/Spool/SpoolRecipient.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Spool/SpoolRecipient.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/DataTypes/Spool/SpoolRecipient.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -1,98 +0,0 @@
-/*
- * 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;
-
-namespace NMail.DataTypes.Spool {
- /// <summary>
- /// Holds the details of a message recipient that is waiting delivery.
- /// </summary>
- [Serializable]
- 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 = nextDelivery;
- 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/trunk/NMail/NMail.csproj
===================================================================
--- NMail/trunk/NMail/NMail.csproj 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail/NMail.csproj 2007-03-04 04:54:28 UTC (rev 157)
@@ -132,18 +132,22 @@
<Compile Include="DataTypes\ACLs\UserGroupAdminPrivilege.cs" />
<Compile Include="DataTypes\BodyStructure.cs" />
<Compile Include="DataTypes\Calendar\Attendee.cs" />
+ <Compile Include="DataTypes\Calendar\AttendeeRole.cs" />
+ <Compile Include="DataTypes\Calendar\AttendeeStatus.cs" />
+ <Compile Include="DataTypes\Calendar\Calendar.cs" />
<Compile Include="DataTypes\Calendar\CalendarAlarm.cs" />
<Compile Include="DataTypes\Calendar\CalendarEntry.cs" />
<Compile Include="DataTypes\Calendar\CalendarEntryStatus.cs" />
+ <Compile Include="DataTypes\Calendar\CalendarEvent.cs" />
<Compile Include="DataTypes\Calendar\CountRecurreneRule.cs" />
<Compile Include="DataTypes\Calendar\DateRecurrenceRule.cs" />
- <Compile Include="DataTypes\Calendar\EventEntry.cs" />
<Compile Include="DataTypes\Calendar\JournalEntry.cs" />
<Compile Include="DataTypes\Calendar\RecurrenceFrequency.cs" />
<Compile Include="DataTypes\Calendar\RecurrenceRule.cs" />
<Compile Include="DataTypes\Calendar\ToDoEntry.cs" />
<Compile Include="DataTypes\Classification.cs" />
<Compile Include="DataTypes\LatLong.cs" />
+ <Compile Include="DataTypes\LocalStore\LocalStoreCalendarResult.cs" />
<Compile Include="DataTypes\Service\BaseService.cs" />
<Compile Include="DataTypes\Service\BaseSession.cs" />
<Compile Include="DataTypes\Envelope.cs" />
@@ -240,7 +244,6 @@
<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>
Modified: NMail/trunk/NMail.ImapService/Response/SearchResponse.cs
===================================================================
--- NMail/trunk/NMail.ImapService/Response/SearchResponse.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.ImapService/Response/SearchResponse.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -24,13 +24,13 @@
/// The response to a search command.
/// </summary>
public class SearchResponse : AbstractResponse {
- protected List<int> messageIds;
+ protected IList<int> messageIds;
/// <summary>
/// Creates a new search response with the given list of message Ids.
/// </summary>
/// <param name="messageIds">The list of message Ids that match the search criteria.</param>
- public SearchResponse(List<int> messageIds) {
+ public SearchResponse(IList<int> messageIds) {
this.messageIds = messageIds;
}
Modified: NMail/trunk/NMail.ImapService/State/ExamineState.cs
===================================================================
--- NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.ImapService/State/ExamineState.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -497,7 +497,7 @@
#region Process Search Command
- void matchUidSearch(UidSearchItem searchItem, List<int> messageUids) {
+ void matchUidSearch(UidSearchItem searchItem, IList<int> messageUids) {
List<int> removedIds = new List<int>();
foreach (int messageUid in messageUids) {
@@ -524,7 +524,7 @@
#region Search Command
public override void ProcessCommand(SearchCommand cmd) {
// Get a list of Ids for the folder
- List<int> messageUids = LocalStore.GetMessageIds(Session.AuthenticationToken, Session.SelectedFolder.FolderId);
+ IList<int> messageUids = LocalStore.GetMessageIds(Session.AuthenticationToken, Session.SelectedFolder.FolderId);
// Check if there was any messages in the folder
if (messageUids.Count > 0) {
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -24,6 +24,7 @@
using NMail.Authentication;
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
+using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
using NMail.Configuration;
using NMail.LocalStore.DeliveryActions;
@@ -49,10 +50,10 @@
/// <returns>The result of the validation.</returns>
public DeliveryResult ValidateRecipient(SmtpMessageRecipient recipient) {
// Extract out the raw mailbox. E.g. "Joh...@lo..." -> "John.Smith"
- string rawMailbox = recipient.Mailbox.MailboxName;
+ string rawMailbox = recipient.Address.Mailbox.MailboxName;
// Check if this local store will accept devliery for this recipient
- MailDomain mailDomain = ResolveMailDomain(recipient.Host);
+ MailDomain mailDomain = ResolveMailDomain(recipient.Address.Host);
if (mailDomain == null) {
return new DeliveryResult(DeliveryResultType.PermanentError, "Local Store does not accept this address.");
}
@@ -85,7 +86,7 @@
if (result.Type == DeliveryResultType.Success) {
// Pass through each allowed user validator
- IDictionaryEnumerator e = recipient.Mailbox.GetDataPairNames();
+ IDictionaryEnumerator e = recipient.Address.Mailbox.GetDataPairNames();
while (e.MoveNext() && result.Type == DeliveryResultType.Success) {
ILocalStoreRecipientValidator validator = mailDomain.GetRecipientValidator((string) e.Key);
@@ -118,10 +119,10 @@
/// <returns>The result of the delivery attempt.</returns>
public RecipientDeliveryResult DeliverMessage(SmtpMessageRecipient recipient) {
// Extract out the raw mailbox. E.g. "Joh...@lo..." -> "John.Smith"
- string rawMailbox = recipient.Mailbox.MailboxName;
+ string rawMailbox = recipient.Address.Mailbox.MailboxName;
// Check if this local store will accept devliery for this recipient
- MailDomain mailDomain = ResolveMailDomain(recipient.Host);
+ MailDomain mailDomain = ResolveMailDomain(recipient.Address.Host);
if (mailDomain == null) {
return new RecipientDeliveryResult(
recipient,
@@ -165,7 +166,7 @@
if (result.Type == DeliveryResultType.Success) {
// Pass through each allowed user action
- IDictionaryEnumerator e = recipient.Mailbox.GetDataPairNames();
+ IDictionaryEnumerator e = recipient.Address.Mailbox.GetDataPairNames();
while (e.MoveNext() && result.Type == DeliveryResultType.Success) {
ILocalStoreDeliveryAction action = mailDomain.GetDeliveryAction((string) e.Key);
@@ -695,7 +696,7 @@
#region Get Message Ids
- public List<int> GetMessageIds(IAuthenticationToken authToken, int folderId) {
+ public IList<int> GetMessageIds(IAuthenticationToken authToken, int folderId) {
// Ensure the user has rights to get the message Id
if (hasFolderPrivilege(authToken.Username, folderId, StoreFolderPrivilege.Read)) {
@@ -1276,6 +1277,24 @@
throw new NotImplementedException();
}
#endregion
+
+ public LocalStoreCalendarResult CreateCalandar(IAuthenticationToken authToken, Calendar calendar) {
+ LocalStoreData.SaveCalandar(calendar);
+ return LocalStoreCalendarResult.OkSuccessful;
+ }
+
+ public Calendar GetCalandar(IAuthenticationToken authToken, string name, int parentFolderId) {
+ return LocalStoreData.GetCalandar(name, parentFolderId);
+ }
+
+ public Calendar GetCalandar(IAuthenticationToken authToken, int calendarId) {
+ return LocalStoreData.GetCalandar(calendarId);
+ }
+
+ public LocalStoreCalendarResult DeleteCalandar(IAuthenticationToken authToken, int calendarId) {
+ LocalStoreData.DeleteCalandar(calendarId);
+ return LocalStoreCalendarResult.OkSuccessful;
+ }
#endregion
#region Privilege Checks
Modified: NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -24,9 +24,13 @@
using MySql.Data.MySqlClient;
+using NHibernate;
+using NHibernate.Expression;
+
using NMail.Configuration;
using NMail.DataTypes;
using NMail.DataTypes.ACLs;
+using NMail.DataTypes.Calendar;
using NMail.DataTypes.LocalStore;
using NMail.Helper;
@@ -38,6 +42,19 @@
/// </summary>
[Serializable]
public class MySqlLocalStoreData : MarshalByRefObject, ILocalStoreData {
+
+ NHibernate.Cfg.Configuration hibernateCfg;
+
+ ISessionFactory hibernateFactory;
+
+ public MySqlLocalStoreData() {
+ this.hibernateCfg = new NHibernate.Cfg.Configuration();
+ this.hibernateCfg.Configure(System.Reflection.Assembly.GetExecutingAssembly(), "NMail.LocalStoreData.MySql.Resources.hibernate-configuration.xml");
+ this.hibernateCfg.AddAssembly("NMail.LocalStoreData.MySql");
+
+ this.hibernateFactory = this.hibernateCfg.BuildSessionFactory();
+ }
+
#region ILocalStoreData Members
#region Message Delivery
@@ -554,7 +571,7 @@
#endregion
#region GetMessageIds
- public List<int> GetMessageIds(int folderId) {
+ public IList<int> GetMessageIds(int folderId) {
List<int> result = new List<int>();
using (MySqlConnection cnn = MySqlHelper.GetConnection()) {
@@ -1653,6 +1670,101 @@
}
}
#endregion
+
+ public void SaveCalandar(Calendar calendar) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ if (calendar.CalendarId == 0) {
+ // Check if any other calendars with the same name exists in this folder
+ ICriteria criteria = session.CreateCriteria(typeof(Calendar));
+ criteria.Add(Expression.Like("Name", calendar.Name));
+ criteria.Add(Expression.Eq("ParentFolderId", calendar.ParentFolderId));
+ IList existing = criteria.List();
+
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("Calendar with the same name already exists in this folder.");
+ }
+
+ session.Save(calendar);
+
+ } else {
+ session.Update(calendar);
+ }
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+
+ public Calendar GetCalandar(string name, int parentFolderId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ ICriteria criteria = session.CreateCriteria(typeof(Calendar));
+ criteria.Add(Expression.Like("Name", name));
+ criteria.Add(Expression.Eq("ParentFolderId", parentFolderId));
+ IList matches = criteria.List();
+
+ return (matches.Count == 1) ? (Calendar) matches[0] : null;
+ }
+ }
+
+ public Calendar GetCalandar(int calendarId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return (Calendar) session.Load(typeof(Calendar), calendarId);
+ }
+ }
+
+ public void DeleteCalandar(int calendarId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ session.Delete("from Calendar as cal where cal.CalendarId = ?", calendarId, NHibernateUtil.Int32);
+ }
+ }
+
+ public void SaveCalendarEntry(CalendarEntry entry) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ // Update the entry's change management fields
+ entry.LastModified = DateTime.Now;
+ entry.Sequence++;
+
+ // Save it to the database
+ session.SaveOrUpdate(entry);
+ session.Flush();
+ }
+ }
+
+ public CalendarEntry GetCalendarEntry(int entryId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ return (CalendarEntry) session.Load(typeof(CalendarEntry), entryId);
+ }
+ }
+
+ public IList<CalendarEntry> GetCalendarEntries(DateTime startTime, DateTime endTime, int calendarId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ ICriteria criteria = session.CreateCriteria(typeof(CalendarEntry));
+ criteria.Add(Expression.Eq("CalendarId", calendarId));
+ criteria.Add(Expression.Ge("StartTime", startTime));
+ IList matches = criteria.List();
+
+ List<CalendarEntry> result = new List<CalendarEntry>();
+ foreach (CalendarEntry entry in matches) {
+ result.Add(entry);
+ }
+
+ // TODO: catch recurrences, etc
+
+ return result;
+ }
+ }
+
+ public void DeleteCalendarEntry(int entryId) {
+ using (ISession session = this.hibernateFactory.OpenSession()) {
+ session.Delete("from CalendarEntry as calE where calE.EntryId = ?", entryId, NHibernateUtil.Int64);
+ }
+ }
#endregion
+
+ public void ReinstallSchema() {
+ new NHibernate.Tool.hbm2ddl.SchemaExport(this.hibernateCfg).Create(false, true);
+ }
}
}
Modified: NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj
===================================================================
--- NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.LocalStoreData.MySql/NMail.LocalStoreData.MySql.csproj 2007-03-04 04:54:28 UTC (rev 157)
@@ -82,6 +82,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\References\MySql.Data.dll</HintPath>
</Reference>
+ <Reference Include="NHibernate, Version=1.0.4.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\References\nhibernate\NHibernate.dll</HintPath>
+ </Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
@@ -115,10 +119,15 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="NMail.LocalStoreData.Mysql.build" />
+ <EmbeddedResource Include="Resources\hibernate-configuration.xml" />
+ <EmbeddedResource Include="Resources\NMail.LocalStoreData.MySql.hbm.xml" />
</ItemGroup>
<ItemGroup>
<None Include="MySqlLocalStoreData-1-to-2.sql" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Modified: NMail/trunk/NMail.MessageRouter/MessageRouter.cs
===================================================================
--- NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.MessageRouter/MessageRouter.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -56,7 +56,7 @@
NConfig.Current.LocalStore.WithinLocalStore(batch.Destination)) {
// To Local Store
foreach(SmtpMessage message in batch.GetMessages()) {
- foreach(SmtpMessageRecipient recipient in message.GetRecipients()) {
+ foreach(SmtpMessageRecipient recipient in message.Recipients) {
RecipientDeliveryResult result;
try {
result = NConfig.Current.LocalStore.DeliverMessage(recipient);
@@ -113,7 +113,7 @@
/// <param name="message">The message to update.</param>
/// <param name="result">The status of the delivery attempt.</param>
private void CompleteDeliveryAttempt(SmtpMessage message, DeliveryResult result) {
- foreach (SmtpMessageRecipient recipient in message.GetRecipients()) {
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
CompleteDeliveryAttempt(message, new RecipientDeliveryResult(recipient, result));
}
}
@@ -133,7 +133,7 @@
if (result.Type != DeliveryResultType.Success) {
if (result.Recipient.DeliveryAttempts >= Config.Current.WarningDeliveryAttempts) {
// Send a warning message
- if (!result.Recipient.IsEmpty) {
+ if (!result.Recipient.Address.IsEmpty) {
NConfig.Current.SpoolService.SpoolMessage(CreateWarningMessage(message, result));
}
} else if (result.Recipient.DeliveryAttempts >= Config.Current.MaximumDeliveryAttempts) {
@@ -142,7 +142,7 @@
result.Type = DeliveryResultType.PermanentError;
// Send a bounce message
- if (!result.Recipient.IsEmpty) {
+ if (!result.Recipient.Address.IsEmpty) {
NConfig.Current.SpoolService.SpoolMessage(CreateBounceMessage(message, result));
}
}
@@ -213,7 +213,7 @@
template = template.Replace("{DATE}",
DateTime.Now.ToString("r", DateTimeFormatInfo.InvariantInfo));
- template = template.Replace("{RECIPIENT}", deliveryResult.Recipient.ToString(true));
+ template = template.Replace("{RECIPIENT}", deliveryResult.Recipient.Address.ToString(true));
template = template.Replace("{MESSAGE}", deliveryResult.Message);
@@ -262,12 +262,12 @@
data["SourceIPAddress"] = messageRecipient.Message.SourceAddress;
data["HeloDomain"] = messageRecipient.Message.ReportedHost;
data["SourceDomain"] = NConfig.Current.DnsClient.ResolveHost((IPAddress) data["SourceIPAddress"]);
- if (messageRecipient.Host.IsDomain) {
- data["RecipientDomain"] = messageRecipient.Host.Domain;
+ if (messageRecipient.Address.Host.IsDomain) {
+ data["RecipientDomain"] = messageRecipient.Address.Host.Domain;
}
if (NConfig.Current.LocalStore != null &&
- NConfig.Current.LocalStore.WithinLocalStore(messageRecipient.Host)) {
+ NConfig.Current.LocalStore.WithinLocalStore(messageRecipient.Address.Host)) {
// Does localstore accept recipient?
return NConfig.Current.LocalStore.ValidateRecipient(messageRecipient);
} else {
Modified: NMail/trunk/NMail.Sendmail/Sendmail.cs
===================================================================
--- NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.Sendmail/Sendmail.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -90,7 +90,7 @@
foreach (EmailAddress recipient in options.Recipients) {
smtpMessage.AddRecipient(recipient);
}
- if (smtpMessage.RecipientCount == 0) {
+ if (smtpMessage.Recipients.Count == 0) {
throw new ArgumentException("No recipients supplied.");
}
Modified: NMail/trunk/NMail.SmtpClient/SmtpClient.cs
===================================================================
--- NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.SmtpClient/SmtpClient.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -17,6 +17,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
@@ -97,7 +98,7 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.TemporaryError,
"Timed out sending message data.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(message.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(message.Recipients, result);
}
}
@@ -107,7 +108,7 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.TemporaryError,
"Error sending message.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(message.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(message.Recipients, result);
return this.currentResult;
} catch (Exception) {
@@ -230,7 +231,7 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Remote server only supports 7BIT and message body is 8BITMIME.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
return false;
}
} else {
@@ -249,7 +250,7 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Message is larger than server message size limit.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
return false;
}
@@ -289,12 +290,12 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Server rejected sender address.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
return false;
}
- foreach (SmtpMessageRecipient recipient in currentMessage.GetRecipients()) {
- this.connection.RcptTo(recipient);
+ foreach (SmtpMessageRecipient recipient in currentMessage.Recipients) {
+ this.connection.RcptTo(recipient.Address);
this.response = this.connection.GetResponse(this.config.TimeoutRcptTo);
RecipientDeliveryResult recipientResult = new RecipientDeliveryResult(
@@ -320,11 +321,11 @@
// Sender
this.connection.MailFrom(this.currentMessage.Sender, mailFromParameters);
- SmtpMessageRecipient[] recipients = this.currentMessage.GetRecipients();
+ IList<SmtpMessageRecipient> recipients = this.currentMessage.Recipients;
// Recipients
foreach (SmtpMessageRecipient recipient in recipients) {
- this.connection.RcptTo(recipient);
+ this.connection.RcptTo(recipient.Address);
}
// Done TODO: BDAT action
@@ -339,7 +340,7 @@
DeliveryResult result = new DeliveryResult(DeliveryResultType.PermanentError,
"Server rejected sender address.");
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
return false;
}
@@ -363,7 +364,7 @@
// not ok to send data: no valid recipients, etc
DeliveryResult result = new DeliveryResult(this.response.Type, this.response.Message);
this.currentResult = new SmtpDeliveryResult();
- this.currentResult.AddRecipientResults(this.currentMessage.GetRecipients(), result);
+ this.currentResult.AddRecipientResults(this.currentMessage.Recipients, result);
return false;
}
Modified: NMail/trunk/NMail.SmtpService/Command/RecipientCommand.cs
===================================================================
--- NMail/trunk/NMail.SmtpService/Command/RecipientCommand.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.SmtpService/Command/RecipientCommand.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -60,21 +60,21 @@
DeliveryResult result = NMailConfiguration.Current.Router.ValidateRecipient(recipient);
switch (result.Type) {
case DeliveryResultType.PermanentError:
- session.Connection.ErrorBadRecipient(recipient);
+ session.Connection.ErrorBadRecipient(recipient.Address);
session.IncrementBadRecipientCount();
break;
case DeliveryResultType.TemporaryError:
- session.Connection.TemporaryBadRecipient(recipient);
+ session.Connection.TemporaryBadRecipient(recipient.Address);
break;
case DeliveryResultType.Success:
- if (session.Message.RecipientCount <= SmtpServiceConfiguration.Current.RecipientLimit) {
- session.Message.AddRecipient(recipient);
- session.Connection.OkRecipient(recipient);
+ if (session.Message.Recipients.Count <= SmtpServiceConfiguration.Current.RecipientLimit) {
+ session.Message.AddRecipient(recipient.Address);
+ session.Connection.OkRecipient(recipient.Address);
session.CurrentState = new RecipientRecievedState(session);
} else {
- session.Connection.TemporaryBadRecipient(recipient);
+ session.Connection.TemporaryBadRecipient(recipient.Address);
}
break;
}
Modified: NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs
===================================================================
--- NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs 2007-03-04 00:35:07 UTC (rev 156)
+++ NMail/trunk/NMail.SpoolData.MySql/MySqlSpoolData.cs 2007-03-04 04:54:28 UTC (rev 157)
@@ -19,7 +19,9 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
+using System.IO;
using System.Net;
+using System.Reflection;
using log4net;
using MySql.Data.MySqlClient;
@@ -47,10 +49,24 @@
}
#region ISpoolData Members
+
+ public void ReinstallSchema() {
+ Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NMail.SpoolData.MySql.MySqlSpoolData.sql");
+ TextReader reader = new StreamReader(stream);
+ string schemaSql = reader.ReadToEnd();
+
+ using (MySqlConnection cnn = GetConnection()) {
+ using (MySqlCommand cmd = cnn.CreateCommand()) {
+ cmd.CommandText = schemaSql;
+ cmd.ExecuteNonQuery();
+ }
+ }
+ }
+
#region CompleteDeliveryAttempt
public void CompleteDeliveryAttempt(SmtpMessage message, DeliveryResult result) {
// Update status for each recipient on the message
- foreach (SmtpMessageRecipient recipient in message.GetRecipients()) {
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
CompleteDeliveryAttempt(recipient, result);
}
}
@@ -64,9 +80,9 @@
// Look up the recipient Id
MySqlCommand cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
- cmd.CommandText = "SELECT MessageRecipientId FROM Message m, MessageRecipient mr WHERE m.MessageGuid = ?MessageGuid AND mr.Recipient = ?Recipient AND mr.MessageId = m.MessageId";
- cmd.Parameters.Add("?MessageGuid", recipient.Message.MessageId.ToByteArray());
- cmd.Parameters.Add("?Recipient", recipient.ToString());
+ cmd.CommandText = "SELECT MessageRecipientId FROM Message m, MessageRecipient mr WHERE m.MessageId = ?MessageId AND mr.Recipient = ?Recipient AND mr.MessageId = m.MessageId";
+ cmd.Parameters.Add("?MessageId", recipient.Message.MessageId.ToByteArray());
+ cmd.Parameters.Add("?Recipient", recipient.Address.ToString());
int messageRecipientId = (int)cmd.ExecuteScalar();
if (result.Type == DeliveryResultType.TemporaryError) {
@@ -140,17 +156,13 @@
// Get the message Id
MySqlTransaction trans = cnn.BeginTransaction();
- cmd.Transaction = trans;
- cmd.CommandText = "SELECT MessageId FROM Message WHERE MessageGuid = ?MessageGuid";
- cmd.Parameters.Add("?MessageGuid", message.MessageId.ToByteArray());
- int messageId = (int)cmd.ExecuteScalar();
if (filtered) {
// Update the message filtered status
cmd = cnn.CreateCommand();
cmd.Transaction = trans;
cmd.CommandText = "UPDATE Message SET Filtered = true, InProgress = false WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
if (cmd.ExecuteNonQuery() != 1) {
trans.Rollback();
throw new Exception("Error updating filtered status.");
@@ -159,7 +171,7 @@
cmd = cnn.CreateCommand();
cmd.Transaction = trans;
cmd.CommandText = "DELETE FROM MessageRecipient WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
if (cmd.ExecuteNonQuery() <= 0) {
trans.Rollback();
throw new Exception("Error removing previous recipients.");
@@ -167,13 +179,13 @@
// Insert each recipient of the message
DateTime deliveryTime = DateTime.Now;
- foreach (SmtpMessageRecipient recipient in message.GetRecipients()) {
+ foreach (SmtpMessageRecipient recipient in message.Recipients) {
cmd = cnn.CreateCommand();
cmd.Transaction = trans;
cmd.CommandText = "INSERT INTO MessageRecipient (MessageId, Host, Recipient, NextDeliveryAttempt, DeliveryAttempts, InProgress) VALUES (?MessageId, ?Host, ?Recipient, ?NextDeliveryAttempt, ?DeliveryAttempts - 1, ?InProgress)";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
cmd.Parameters.Add("?Host", recipient.Host.ToString());
- cmd.Parameters.Add("?Recipient", recipient.ToString());
+ cmd.Parameters.Add("?Recipient", recipient.Address.ToString());
cmd.Parameters.Add("?DeliveryAttempts", 1); // TODO: this is a fix for some NULL bug in the connector, chase it up
cmd.Parameters.Add("?NextDeliveryAttempt", deliveryTime);
cmd.Parameters.Add("?InProgress", false);
@@ -189,14 +201,14 @@
} else {
// Delete the message
cmd.CommandText = "DELETE FROM MessageRecipient WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
if (cmd.ExecuteNonQuery() <= 0) {
trans.Rollback();
throw new Exception("Error removing recipients.");
}
cmd.CommandText = "DELETE FROM Message WHERE MessageId = ?MessageId";
- cmd.Parameters.Add("?MessageId", messageId);
+ cmd.Parameters.Add("?MessageId", message.MessageId.ToByteArray());
if (cmd.ExecuteNonQuery() != 1) {
trans.Rollback();
throw new Exception("Error removing message.");
@@ -216,30 +228,31 @@
MySqlTransaction transaction = cnn.BeginTransaction();
MySqlCommand cmd = cnn.CreateCommand();
cmd.Transaction = transaction;
- cmd.CommandText = "SELECT MessageId, MessageGuid, Sender, ReportedHost, SourceAddress, MessageData FROM Message WHERE InProgress = false AND Filtered = false ORDER BY MessageId limit 1";
+ cmd.CommandText = "SELECT MessageId, Sender, ReportedHost, SourceAddress, MessageData FROM Message WHERE InProgress = false AND Filtered...
[truncated message content] |