Thread: [csmaild-cvs] csmaild/src/Common/MailstoreProviders IMailstoreProvider.cs,1.8,1.9 XmlMailstoreProvid
Brought to you by:
tamc
|
From: <ta...@us...> - 2003-08-05 01:42:13
|
Update of /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders In directory sc8-pr-cvs1:/tmp/cvs-serv32691/src/Common/MailstoreProviders Modified Files: IMailstoreProvider.cs XmlMailstoreProvider.cs Log Message: Mail store provider has more functionality - Can save messages (flag changes) - Can expunge a message Fixed namespace issues User now has subscribed mailboxes Commands no longer "register" themselves, resorted back to switch statement Index: IMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/IMailstoreProvider.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IMailstoreProvider.cs 3 Aug 2003 01:04:27 -0000 1.8 --- IMailstoreProvider.cs 5 Aug 2003 01:42:09 -0000 1.9 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections.Specialized; using System.IO; *************** *** 15,19 **** #endregion ! #region User accessors /// <summary> /// Gets the user with the login info --- 16,20 ---- #endregion ! #region User stuff /// <summary> /// Gets the user with the login info *************** *** 23,38 **** /// <returns>The user with the username and password</returns> User GetUser(string username, string password); #endregion #region Mailbox stuff - #region Mailbox functions /// <summary> ! /// Gets the mailbox with the specified absolute path for a particular user /// </summary> /// <param name="user">The user that owns this mailbox</param> ! /// <param name="absoluteHiearchicalName">The absolute path of the mailbox to retreive</param> ! /// <returns>The mailbox or null if not found</returns> ! Mailbox GetMailbox(User user, string absoluteHiearchicalName); /// <summary> --- 24,44 ---- /// <returns>The user with the username and password</returns> User GetUser(string username, string password); + + /// <summary> + /// Saves the user to the data store + /// </summary> + /// <param name="user">The user to save</param> + void SaveUser(User user); #endregion #region Mailbox stuff /// <summary> ! /// Gets the mailbox with the specified fully qualified name for a particular user /// </summary> /// <param name="user">The user that owns this mailbox</param> ! /// <param name="absoluteHiearchicalName">The fully qualified name of the mailbox to retreive</param> ! /// <returns>The mailbox found (null if not)</returns> ! Mailbox GetMailbox(User user, string name); /// <summary> *************** *** 58,72 **** /// 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 /// </summary> /// <param name="box">The box to delete</param> void DeleteMailbox(Mailbox box); - #endregion #endregion --- 64,76 ---- /// Inserts a mailbox for a particular user /// </summary> ! /// <param name="user">The user to add this mailbox to</param> ! /// <param name="box">The prepopulated Mailbox object</param> ! void InsertMailbox(User user, Mailbox box); /// <summary> ! /// Permanently deletes the mailbox from the data store /// </summary> /// <param name="box">The box to delete</param> void DeleteMailbox(Mailbox box); #endregion *************** *** 103,106 **** --- 107,115 ---- void DeleteMessages(Mailbox box); + /// <summary> + /// Deletes the message from the mailstore + /// </summary> + /// <param name="msg">The message to delete</param> + void DeleteMessage(Message msg); /// <summary> *************** *** 108,113 **** /// </summary> /// <param name="msg">The message to insert</param> ! /// <returns>True is successful, false otherwise</returns> ! bool InsertMessage(Message msg, TextReader rawSrc); #endregion --- 117,127 ---- /// </summary> /// <param name="msg">The message to insert</param> ! void InsertMessage(Message msg, TextReader rawSrc); ! ! /// <summary> ! /// Saves the message into the data store ! /// </summary> ! /// <param name="msg">The message to save</param> ! void SaveMessage(Message msg); #endregion Index: XmlMailstoreProvider.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailstoreProviders/XmlMailstoreProvider.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** XmlMailstoreProvider.cs 3 Aug 2003 01:04:27 -0000 1.10 --- XmlMailstoreProvider.cs 5 Aug 2003 01:42:09 -0000 1.11 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections.Specialized; using System.Data; using System.IO; *************** *** 56,60 **** #endregion ! #region User accessors public User GetUser(string username, string password) { --- 57,80 ---- #endregion ! #region User stuff ! public void SaveUser(User user) ! { ! DataRow[] rows = mUsers.Select("Id = '" + user.ProvidersIdentifier + "'"); ! ! if(rows.Length == 1) ! { ! DataRow row = rows[0]; ! ! string subscribedBoxes = string.Empty; ! for(int idx = 0; idx < user.SubscribedMailboxes.Count; ++idx) ! subscribedBoxes += user.SubscribedMailboxes[idx] + (idx == user.SubscribedMailboxes.Count-1 ? string.Empty : ","); ! ! row["Password"] = user.Password; ! row["SubscribedMailboxes"] = subscribedBoxes; ! } ! ! Save(true, false, false); ! } ! public User GetUser(string username, string password) { *************** *** 65,70 **** 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; --- 85,96 ---- DataRow user = users[0]; + + StringCollection subs = new StringCollection(); + string[] s = (user["SubscribedMailboxes"] as string).Split(','); + if(s[0] != string.Empty) + subs.AddRange(s); + if((user["Password"] as string) == password) ! return new User(this, user["Id"], user["Username"] as string, user["Password"] as string, subs); else return null; *************** *** 138,142 **** #region Mailbox insert ! public bool InsertMailbox(User user, Mailbox box) { DataRow newBox = mMailboxes.NewRow(); --- 164,168 ---- #region Mailbox insert ! public void InsertMailbox(User user, Mailbox box) { DataRow newBox = mMailboxes.NewRow(); *************** *** 164,169 **** mMailboxes.Rows.Add(newBox); Save(false, true, false); - - return true; } #endregion --- 190,193 ---- *************** *** 216,219 **** --- 240,254 ---- #region Message deletes + public void DeleteMessage(Message msg) + { + DataRow[] rows = mMessages.Select("Id = '" + msg.ProvidersIdentifier + "'"); + + if(rows.Length == 1) + { + rows[0].Delete(); + Save(false, false, true); + } + } + public void DeleteMessages(Mailbox box) { *************** *** 226,230 **** #region Message insert ! public bool InsertMessage(Message msg, TextReader rawSrc) { DataRow newMsg = mMessages.NewRow(); --- 261,265 ---- #region Message insert ! public void InsertMessage(Message msg, TextReader rawSrc) { DataRow newMsg = mMessages.NewRow(); *************** *** 248,253 **** mMessages.Rows.Add(newMsg); Save(false, false, true); ! return true; } #endregion --- 283,313 ---- mMessages.Rows.Add(newMsg); Save(false, false, true); + } + #endregion ! #region Message updates ! public void SaveMessage(Message msg) ! { ! DataRow[] rows = mMessages.Select("Id = '" + msg.ProvidersIdentifier + "'"); ! ! if(rows.Length == 1) ! { ! DataRow row = rows[0]; ! ! // row["Id"] = msg.ProvidersIdentifier; ! // row["MailboxId"] = msg.Mailbox.ProvidersIdentifier; ! // row["UniqueIdentifier"] = msg.UniqueId; ! row["Seen"] = msg.Seen; ! row["Answered"] = msg.Answered; ! row["Flagged"] = msg.Flagged; ! row["Deleted"] = msg.Deleted; ! row["Draft"] = msg.Draft; ! row["Recent"] = msg.Recent; ! // row["Size"] = msg.Size; ! // row["InternalDate"] = msg.InternalDate; ! // row["RawMessage"] = rawSrc.ReadToEnd(); ! } ! ! Save(false, false, true); } #endregion |