[csmaild-cvs] csmaild/src/Common/MailstoreProviders IMailstoreProvider.cs,1.6,1.7 XmlMailstoreProvid
Brought to you by:
tamc
From: <ta...@us...> - 2003-08-01 22:02:40
|
Update of /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders In directory sc8-pr-cvs1:/tmp/cvs-serv25503/src/Common/MailstoreProviders Modified Files: IMailstoreProvider.cs XmlMailstoreProvider.cs Log Message: Updated 1.0 project files to include new stuff Added blank SMTP project Added initial rfc2822 message parser and object model (not finished but it's lightening outside ;)) Can now add messages to the messagecollection The enumerator for messagecollection works properly now Added method to mailstore provider to allow for accessing the raw message via a reader Added ability to have optional arguments on IMAP commands Fixed literal string parsing External accessors to the sequence range Very high level generic exception handling to handle all those errors I don't want to fix (and don't want them to mess up the connection) Index: IMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/IMailstoreProvider.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IMailstoreProvider.cs 29 Jul 2003 00:46:28 -0000 1.6 --- IMailstoreProvider.cs 1 Aug 2003 22:02:37 -0000 1.7 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.IO; namespace Common.MailstoreProviders *************** *** 8,11 **** --- 9,18 ---- public interface IMailstoreProvider { + #region "General stuff" + void BeginTransaction(); + void CommitTransaction(); + void RollbackTransaction(); + #endregion + #region User accessors /// <summary> *************** *** 75,78 **** --- 82,93 ---- /// <returns>The message found, or null if none found</returns> Message GetMessage(Mailbox box, int uniqueId); + + /// <summary> + /// Gets a reader for the raw text of the message (be sure to close it when you're done) + /// </summary> + /// <param name="box">The mailbox the message is located in</param> + /// <param name="uniqueId">The unique identifier of the message</param> + /// <returns>An open TextReader for the message text if found, or null if not</returns> + TextReader GetRawMessageReader(object providersId); /// <summary> Index: XmlMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/XmlMailstoreProvider.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** XmlMailstoreProvider.cs 29 Jul 2003 00:46:28 -0000 1.7 --- XmlMailstoreProvider.cs 1 Aug 2003 22:02:37 -0000 1.8 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Data; + using System.IO; namespace Common.MailstoreProviders *************** *** 6,14 **** public class XmlMailstoreProvider : IMailstoreProvider { private string mFolderPath; ! private DataSet mMessageSet = new DataSet(); ! private DataSet mMailboxSet = new DataSet(); ! private DataSet mUserSet = new DataSet(); private DataTable mMessages; private DataTable mMailboxes; --- 7,16 ---- public class XmlMailstoreProvider : IMailstoreProvider { + #region Variables private string mFolderPath; ! private DataSet mMessageSet; ! private DataSet mMailboxSet; ! private DataSet mUserSet; private DataTable mMessages; private DataTable mMailboxes; *************** *** 18,22 **** --- 20,26 ---- private uint mNextMailboxId; private uint mNextUserId; + #endregion + #region Constructor public XmlMailstoreProvider(string folderPath) { *************** *** 26,43 **** mFolderPath += @"\"; - mMessageSet.ReadXml(mFolderPath + "Messages.xml"); - mMessages = mMessageSet.Tables[0]; - mNextMessageId = (uint)DateTime.Now.Ticks; mNextMailboxId = (uint)DateTime.Now.Ticks; mNextUserId = (uint)DateTime.Now.Ticks; ! mMailboxSet.ReadXml(mFolderPath + "Mailboxes.xml"); ! mMailboxes = mMailboxSet.Tables[0]; ! ! mUserSet.ReadXml(mFolderPath + "Users.xml"); ! mUsers = mUserSet.Tables[0]; } #region User accessors public User GetUser(string username, string password) --- 30,59 ---- mFolderPath += @"\"; mNextMessageId = (uint)DateTime.Now.Ticks; mNextMailboxId = (uint)DateTime.Now.Ticks; mNextUserId = (uint)DateTime.Now.Ticks; ! Load(true, true, true); } + #endregion + + #region General Stuff + public void BeginTransaction() + { + throw new NotImplementedException(); + } + + public void CommitTransaction() + { + throw new NotImplementedException(); + } + + public void RollbackTransaction() + { + throw new NotImplementedException(); + } + #endregion + #region User accessors public User GetUser(string username, string password) *************** *** 172,176 **** return null; } ! public MessageCollection GetMessages(Mailbox box) { --- 188,201 ---- return null; } ! ! public TextReader GetRawMessageReader(object providersId) ! { ! DataRow[] msgs = mMessages.Select("Id = '" + providersId + "'"); ! if(msgs.Length == 1) ! return new StringReader(msgs[0]["RawMessage"] as string); ! else ! return null; ! } ! public MessageCollection GetMessages(Mailbox box) { *************** *** 199,202 **** --- 224,242 ---- #endregion + + private void Load(bool loadUsers, bool loadMailboxes, bool loadMessages) + { + mMessageSet = new DataSet(); + mMessageSet.ReadXml(mFolderPath + "Messages.xml"); + mMessages = mMessageSet.Tables[0]; + + mMailboxSet = new DataSet(); + mMailboxSet.ReadXml(mFolderPath + "Mailboxes.xml"); + mMailboxes = mMailboxSet.Tables[0]; + + mUserSet = new DataSet(); + mUserSet.ReadXml(mFolderPath + "Users.xml"); + mUsers = mUserSet.Tables[0]; + } private void Save(bool saveUsers, bool saveMailboxes, bool saveMessages) |