[csmaild-cvs] csmaild/src/Common MessageCollection.cs,NONE,1.1 Common.csproj,1.4,1.5 Mailbox.cs,1.5,
Brought to you by:
tamc
From: <ta...@us...> - 2003-07-28 00:15:24
|
Update of /cvsroot/csmaild/csmaild/src/Common In directory sc8-pr-cvs1:/tmp/cvs-serv22151/src/Common Modified Files: Common.csproj Mailbox.cs MailboxCollection.cs User.cs Added Files: MessageCollection.cs Log Message: Added MessageCollection to store the collection of messages in a mailbox DELETE should work now, had to modify the mail store to support deleting of messages and mailboxes --- NEW FILE: MessageCollection.cs --- using Common.MailstoreProviders; using System; using System.Collections; namespace Common { /// <summary> /// Custom class representing a message collection /// </summary> public class MessageCollection : IEnumerable { private Mailbox mMailbox; private SortedList mSequenceList = new SortedList(); private SortedList mUidList = new SortedList(); private IMailstoreProvider mProvider; internal MessageCollection(IMailstoreProvider provider, Mailbox box) { mProvider = provider; mMailbox = box; } public Message BySeq(uint sequenceNumber) { return (Message)mSequenceList[sequenceNumber]; } public Message ByUID(uint uid) { return (Message)mUidList[uid]; } public int Count { get { return mSequenceList.Count; } } public void Clear() { mProvider.DeleteMessages(mMailbox); } #region IEnumerable public IEnumerator GetEnumerator() { return mSequenceList.GetEnumerator(); } #endregion } } Index: Common.csproj =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/Common.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Common.csproj 27 Jul 2003 19:32:58 -0000 1.4 --- Common.csproj 28 Jul 2003 00:15:16 -0000 1.5 *************** *** 110,113 **** --- 110,118 ---- /> <File + RelPath = "MessageCollection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "User.cs" SubType = "Code" Index: Mailbox.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/Mailbox.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Mailbox.cs 27 Jul 2003 16:52:19 -0000 1.5 --- Mailbox.cs 28 Jul 2003 00:15:16 -0000 1.6 *************** *** 16,21 **** private uint mUniqueIdValidity; private Mailbox mParent; ! private Mailbox[] mChildren; // TODO: Make a strongly typed collection private User mUser; // the owner of this mailbox #endregion --- 16,29 ---- private uint mUniqueIdValidity; private Mailbox mParent; ! private MailboxCollection mChildren; ! private MessageCollection mMessages; private User mUser; // the owner of this mailbox + + private bool mNoInferiors; /// Does NOT and MUST NOT have children + private bool mNoSelect; /// MUST NOT be selected + private bool mMarked; /// Marked "interesting": probably contains new messages since last select + private bool mUnmarked; /// Not marked "interesting" + + private IMailstoreProvider mProvider; #endregion *************** *** 69,76 **** } /// <summary> /// The child Mailboxes for this mailbox (valid array of size 0 if none) /// </summary> ! public Mailbox[] Children { get --- 77,92 ---- } + public bool HasChildren + { + get + { + return (Children.Count > 0); + } + } + /// <summary> /// The child Mailboxes for this mailbox (valid array of size 0 if none) /// </summary> ! public MailboxCollection Children { get *************** *** 83,91 **** /// The Messages contained in this mailbox /// </summary> ! public Message[] Messages { get { ! return mMailstoreProvider.GetMessages(this); } } --- 99,107 ---- /// The Messages contained in this mailbox /// </summary> ! public MessageCollection Messages { get { ! return mMessages; } } *************** *** 99,103 **** { // TODO: make this more efficient then having to load all the messages ! return Messages.Length; } } --- 115,119 ---- { // TODO: make this more efficient then having to load all the messages ! return Messages.Count; } } *************** *** 111,117 **** { // TODO: make this more efficient then having to load all the messages - Message[] msgs = Messages; int rv = 0; ! foreach(Message msg in msgs) if(msg.Recent) ++rv; --- 127,132 ---- { // TODO: make this more efficient then having to load all the messages int rv = 0; ! foreach(Message msg in mMessages) if(msg.Recent) ++rv; *************** *** 120,139 **** } ! public int FirstUnseenMessageSeqNum { get { // TODO: make this more efficient then having to load all the messages ! Message[] msgs = Messages; ! for(int idx = 0; idx < msgs.Length; ++idx) ! if(!msgs[idx].Seen) return idx; return 0; } } #endregion public Mailbox(IMailstoreProvider provider, string name, string fullName, uint nextUniqueId, uint uniqueIdValidity, User user) : base(provider) { mNextUniqueId = nextUniqueId; mUniqueIdValidity = uniqueIdValidity; --- 135,196 ---- } ! public uint FirstUnseenMessageSeqNum { get { // TODO: make this more efficient then having to load all the messages ! for(uint idx = 0; idx < Messages.Count; ++idx) ! if(!Messages.BySeq(idx).Seen) return idx; return 0; } } + + public User User + { + get + { + return mUser; + } + } + + public bool NoInferiors + { + get + { + return mNoInferiors; + } + } + + public bool NoSelect + { + get + { + return mNoSelect; + } + } + + public bool Marked + { + get + { + return mMarked; + } + } + + public bool Unmarked + { + get + { + return mUnmarked; + } + } + #endregion public Mailbox(IMailstoreProvider provider, string name, string fullName, uint nextUniqueId, uint uniqueIdValidity, User user) : base(provider) { + mProvider = provider; + mNextUniqueId = nextUniqueId; mUniqueIdValidity = uniqueIdValidity; *************** *** 141,146 **** mFullName = fullName; mParent = null; - mChildren = null; mUser = user; } } --- 198,215 ---- mFullName = fullName; mParent = null; mUser = user; + + mChildren = new MailboxCollection(mProvider, mUser); + mMessages = new MessageCollection(mProvider, this); + + mNoInferiors = false; + mNoSelect = false; + mMarked = false; + mUnmarked = false; + } + + public void Delete() + { + mMailstoreProvider.DeleteMailbox(this); } } Index: MailboxCollection.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/MailboxCollection.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MailboxCollection.cs 27 Jul 2003 19:32:58 -0000 1.1 --- MailboxCollection.cs 28 Jul 2003 00:15:16 -0000 1.2 *************** *** 14,18 **** private ArrayList mIndexedList = new ArrayList(); ! private Hashtable mNamedList = new Hashtable(); private IMailstoreProvider mProvider; --- 14,18 ---- private ArrayList mIndexedList = new ArrayList(); ! private SortedList mNamedList = new SortedList(); private IMailstoreProvider mProvider; *************** *** 58,61 **** --- 58,69 ---- else return null; + } + + public int Count + { + get + { + return mIndexedList.Count; + } } Index: User.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Common/User.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** User.cs 27 Jul 2003 19:32:58 -0000 1.2 --- User.cs 28 Jul 2003 00:15:16 -0000 1.3 *************** *** 14,17 **** --- 14,18 ---- private string mPassword; private MailboxCollection mMailboxes; + private IMailstoreProvider mProvider; #endregion *************** *** 52,59 **** public User(IMailstoreProvider provider, string username, string password) : base(provider) { mUsername = username; mPassword = password; } } - } --- 53,61 ---- public User(IMailstoreProvider provider, string username, string password) : base(provider) { + mProvider = provider; + mUsername = username; mPassword = password; } } } |