[csmaild-cvs] csmaild/src/Common/MailstoreProviders IMailstoreProvider.cs,1.5,1.6 XmlMailstoreProvid
Brought to you by:
tamc
From: <ta...@us...> - 2003-07-29 00:46:33
|
Update of /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders In directory sc8-pr-cvs1:/tmp/cvs-serv8950/src/Common/MailstoreProviders Modified Files: IMailstoreProvider.cs XmlMailstoreProvider.cs Log Message: Updated 2002 project files for people using legacy IDE's ;) Added initial POP project, no code, just a project Changes to the mail store to support DELETE, RENAME, CREATE commands Nearly finished with said commands, more testing needed Moved NetworkManager to common, so POP can use it Index: IMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/IMailstoreProvider.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IMailstoreProvider.cs 28 Jul 2003 00:15:17 -0000 1.5 --- IMailstoreProvider.cs 29 Jul 2003 00:46:28 -0000 1.6 *************** *** 20,24 **** #region Mailbox stuff ! #region Mailbox accessors /// <summary> /// Gets the mailbox with the specified absolute path for a particular user --- 20,24 ---- #region Mailbox stuff ! #region Mailbox functions /// <summary> /// Gets the mailbox with the specified absolute path for a particular user *************** *** 30,51 **** /// <summary> ! /// Gets all the mailboxes that are in the mail store for a particular user /// </summary> ! /// <returns>An array containing the mailboxes (valid array of size 0 if none)</returns> MailboxCollection GetMailboxes(User user); /// <summary> ! /// Gets the mailboxes that are immediate children /// </summary> /// <param name="parent">The parent mailbox to gather children for</param> ! /// <returns>An array containing the mailboxes (valid array of size 0 if none)</returns> ! Mailbox[] GetMailboxes(Mailbox parent); ! #endregion ! #region Mailbox insert ! bool InsertMailbox(User user, Mailbox mbx); ! #endregion - #region Mailbox delete /// <summary> /// Permanently deletes the mailbox --- 30,59 ---- /// <summary> ! /// Gets all the mailboxes that are in the mail store for a particular user at the root /// </summary> ! /// <returns>A collection of mailboxes</returns> MailboxCollection GetMailboxes(User user); /// <summary> ! /// Gets the mailboxes that are immediate children of a mailbox /// </summary> /// <param name="parent">The parent mailbox to gather children for</param> ! /// <returns>A collection of mailboxes</returns> ! MailboxCollection GetMailboxes(Mailbox parent); ! /// <summary> ! /// Saves the mailbox to the data store ! /// </summary> ! /// <param name="box">The mailbox to save</param> ! void SaveMailbox(Mailbox box); ! ! /// <summary> ! /// Inserts a mailbox for a particular user ! /// </summary> ! /// <param name="user"></param> ! /// <param name="box"></param> ! /// <returns></returns> ! bool InsertMailbox(User user, Mailbox box); /// <summary> /// Permanently deletes the mailbox *************** *** 73,77 **** /// <param name="box">The mailbox to gather messages for</param> /// <returns>An array containing the mailboxes (valid array of size 0 if none)</returns> ! Message[] GetMessages(Mailbox box); #endregion --- 81,85 ---- /// <param name="box">The mailbox to gather messages for</param> /// <returns>An array containing the mailboxes (valid array of size 0 if none)</returns> ! MessageCollection GetMessages(Mailbox box); #endregion Index: XmlMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/XmlMailstoreProvider.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XmlMailstoreProvider.cs 28 Jul 2003 00:15:17 -0000 1.6 --- XmlMailstoreProvider.cs 29 Jul 2003 00:46:28 -0000 1.7 *************** *** 15,18 **** --- 15,22 ---- private DataTable mUsers; + private uint mNextMessageId; + private uint mNextMailboxId; + private uint mNextUserId; + public XmlMailstoreProvider(string folderPath) { *************** *** 25,28 **** --- 29,36 ---- 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]; *************** *** 42,46 **** DataRow user = users[0]; if((user["Password"] as string) == password) ! return new User(this, username, password); else return null; --- 50,54 ---- DataRow user = users[0]; if((user["Password"] as string) == password) ! return new User(this, user["Id"], user["Username"] as string, user["Password"] as string); else return null; *************** *** 59,97 **** DataRow box = boxes[0]; ! return new Mailbox(this, box["Name"] as string, box["FullName"] as string, uint.Parse(box["NextUniqueId"] as string), uint.Parse(box["UniqueIdValidity"] as string), user); } public MailboxCollection GetMailboxes(User user) { ! DataRow[] rows = mMailboxes.Select("UserIdentifier = '" + user.Username + "'"); ! MailboxCollection mbxCollection = new MailboxCollection(this, user); for(int idx = 0; idx < rows.Length; ++idx) { DataRow box = rows[idx]; ! mbxCollection.Add(new Mailbox(this, box["Name"] as string, box["FullName"] as string, uint.Parse(box["NextUniqueId"] as string), uint.Parse(box["UniqueIdValidity"] as string), user)); } ! return mbxCollection; } ! public Mailbox[] GetMailboxes(Mailbox parent) { ! return null; } #endregion #region Mailbox insert ! public bool InsertMailbox(User user, Mailbox mbx) { ! DataRow newMbx = mMailboxes.NewRow(); ! newMbx["UserIdentifier"] = user.Username; ! newMbx["Name"] = mbx.Name; ! newMbx["FullName"] = mbx.Name; ! newMbx["NextUniqueId"] = mbx.NextUniqueId; ! newMbx["UniqueIdValidity"] = mbx.UniqueIdValidity; ! mMailboxes.Rows.Add(newMbx); Save(false, true, false); --- 67,148 ---- DataRow box = boxes[0]; ! return new Mailbox(this, box["Id"], box["Name"] as string, uint.Parse(box["NextUniqueId"] as string), uint.Parse(box["UniqueIdValidity"] as string), user, bool.Parse(box["NoSelect"] as string), bool.Parse(box["NoInferiors"] as string), bool.Parse(box["Marked"] as string), bool.Parse(box["Unmarked"] as string)); } public MailboxCollection GetMailboxes(User user) { ! return GetMailboxes(user, null); ! } ! ! public MailboxCollection GetMailboxes(Mailbox parent) ! { ! return GetMailboxes(parent.User, parent); ! } ! ! private MailboxCollection GetMailboxes(User user, Mailbox parent) ! { ! DataRow[] rows = mMailboxes.Select("ParentId = '" + (parent == null ? "0" : parent.ProvidersIdentifier) + "' AND UserId = '" + user.ProvidersIdentifier + "'"); ! MailboxCollection boxes = new MailboxCollection(this, user, parent); for(int idx = 0; idx < rows.Length; ++idx) { DataRow box = rows[idx]; ! boxes.Add(new Mailbox(this, box["Id"], box["Name"] as string, uint.Parse(box["NextUniqueId"] as string), uint.Parse(box["UniqueIdValidity"] as string), user, bool.Parse(box["NoSelect"] as string), bool.Parse(box["NoInferiors"] as string), bool.Parse(box["Marked"] as string), bool.Parse(box["Unmarked"] as string))); } ! return boxes; } + #endregion ! #region Mailbox update ! public void SaveMailbox(Mailbox box) { ! DataRow[] rows = mMailboxes.Select("Id = '" + box.ProvidersIdentifier + "' AND UserId = '" + box.User.ProvidersIdentifier + "'"); ! ! if(rows.Length == 1) ! { ! DataRow row = rows[0]; ! if(box.Parent != null) ! row["ParentId"] = box.Parent.ProvidersIdentifier; ! else ! row["ParentId"] = "0"; ! ! row["Name"] = box.Name; ! row["NextUniqueId"] = box.NextUniqueId; ! row["UniqueIdValidity"] = box.UniqueIdValidity; ! row["NoSelect"] = box.NoSelect; ! row["NoInferiors"] = box.NoInferiors; ! row["Marked"] = box.Marked; ! row["Unmarked"] = box.Unmarked; ! } } #endregion #region Mailbox insert ! public bool InsertMailbox(User user, Mailbox box) { ! DataRow newBox = mMailboxes.NewRow(); ! box.ProvidersIdentifier = mNextMailboxId++; ! // set provider specific unique id ! newBox["Id"] = box.ProvidersIdentifier; ! ! newBox["UserId"] = box.User.ProvidersIdentifier; ! ! if(box.Parent != null) ! newBox["ParentId"] = box.Parent.ProvidersIdentifier; ! else ! newBox["ParentId"] = "0"; ! ! newBox["Name"] = box.Name; ! newBox["NextUniqueId"] = box.NextUniqueId; ! newBox["UniqueIdValidity"] = box.UniqueIdValidity; ! newBox["NoSelect"] = box.NoSelect; ! newBox["NoInferiors"] = box.NoInferiors; ! newBox["Marked"] = box.Marked; ! newBox["Unmarked"] = box.Unmarked; ! ! mMailboxes.Rows.Add(newBox); Save(false, true, false); *************** *** 103,109 **** public void DeleteMailbox(Mailbox box) { ! DataRow[] boxes = mMailboxes.Select("FullName = '" + box.Name + "' AND UserIdentifier = '" + box.User.Username + "'"); ! boxes[0].Delete(); ! Save(false, true, false); } #endregion --- 154,163 ---- public void DeleteMailbox(Mailbox box) { ! DataRow[] boxes = mMailboxes.Select("Id = '" + box.ProvidersIdentifier + "' AND UserId = '" + box.User.ProvidersIdentifier + "'"); ! if(boxes.Length == 1) ! { ! boxes[0].Delete(); ! Save(false, true, false); ! } } #endregion *************** *** 119,131 **** } ! public Message[] GetMessages(Mailbox box) { ! DataRow[] messages = mMessages.Select("MailboxIdentifier = '" + box.Name + "'"); ! Message[] msgs = new Message[messages.Length]; for(int idx = 0; idx < messages.Length; ++idx) { DataRow message = messages[idx]; ! msgs[idx] = new Message(this, uint.Parse(message["UniqueIdentifier"].ToString()), bool.Parse(message["Seen"].ToString()), bool.Parse(message["Answered"].ToString()), bool.Parse(message["Flagged"].ToString()), bool.Parse(message["Deleted"].ToString()), bool.Parse(message["Draft"].ToString()), int.Parse(message["Size"].ToString())); } --- 173,185 ---- } ! public MessageCollection GetMessages(Mailbox box) { ! DataRow[] messages = mMessages.Select("MailboxId = '" + box.ProvidersIdentifier + "'"); ! MessageCollection msgs = new MessageCollection(this, box); for(int idx = 0; idx < messages.Length; ++idx) { DataRow message = messages[idx]; ! msgs.Add(new Message(this, message["Id"], uint.Parse(message["UniqueIdentifier"].ToString()), bool.Parse(message["Seen"].ToString()), bool.Parse(message["Answered"].ToString()), bool.Parse(message["Flagged"].ToString()), bool.Parse(message["Deleted"].ToString()), bool.Parse(message["Draft"].ToString()), int.Parse(message["Size"].ToString()))); } *************** *** 137,141 **** public void DeleteMessages(Mailbox box) { ! DataRow[] messages = mMessages.Select("MailboxIdentifier = '" + box.Name + "'"); foreach(DataRow msg in messages) msg.Delete(); --- 191,195 ---- public void DeleteMessages(Mailbox box) { ! DataRow[] messages = mMessages.Select("Id = '" + box.ProvidersIdentifier + "'"); foreach(DataRow msg in messages) msg.Delete(); |