[csmaild-cvs] csmaild/src/Common Common.2002.csproj,1.1,1.2 Common.csproj,1.5,1.6 DataItem.cs,1.1,1.
Brought to you by:
tamc
Update of /cvsroot/csmaild/csmaild/src/Common
In directory sc8-pr-cvs1:/tmp/cvs-serv8950/src/Common
Modified Files:
Common.2002.csproj Common.csproj DataItem.cs Mailbox.cs
MailboxCollection.cs Message.cs MessageCollection.cs User.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: Common.2002.csproj
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/Common.2002.csproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Common.2002.csproj 25 Jul 2003 14:50:31 -0000 1.1
--- Common.2002.csproj 29 Jul 2003 00:46:28 -0000 1.2
***************
*** 93,96 ****
--- 93,101 ----
/>
<File
+ RelPath = "MailboxCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Message.cs"
SubType = "Code"
***************
*** 98,101 ****
--- 103,111 ----
/>
<File
+ RelPath = "MessageCollection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "User.cs"
SubType = "Code"
***************
*** 109,112 ****
--- 119,137 ----
<File
RelPath = "MailstoreProviders\XmlMailstoreProvider.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "NetworkManager\Connection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "NetworkManager\Listener.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "NetworkManager\NetworkManager.cs"
SubType = "Code"
BuildAction = "Compile"
Index: Common.csproj
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/Common.csproj,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Common.csproj 28 Jul 2003 00:15:16 -0000 1.5
--- Common.csproj 29 Jul 2003 00:46:28 -0000 1.6
***************
*** 129,132 ****
--- 129,147 ----
BuildAction = "Compile"
/>
+ <File
+ RelPath = "NetworkManager\Connection.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "NetworkManager\Listener.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "NetworkManager\NetworkManager.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
</Include>
</Files>
Index: DataItem.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/DataItem.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DataItem.cs 24 Jul 2003 04:32:13 -0000 1.1
--- DataItem.cs 29 Jul 2003 00:46:28 -0000 1.2
***************
*** 1,6 ****
- using System;
-
using Common.MailstoreProviders;
namespace Common
{
--- 1,7 ----
using Common.MailstoreProviders;
+ using System;
+ using System.Collections;
+
namespace Common
{
***************
*** 8,19 ****
/// Base class for all things data
/// </summary>
! public class DataItem
{
protected IMailstoreProvider mMailstoreProvider;
! public DataItem(IMailstoreProvider provider)
{
mMailstoreProvider = provider;
}
}
}
--- 9,49 ----
/// Base class for all things data
/// </summary>
! public abstract class DataItem
{
protected IMailstoreProvider mMailstoreProvider;
+ protected object mProvidersIdentifier;
! internal object ProvidersIdentifier
! {
! get
! {
! return mProvidersIdentifier;
! }
! set
! {
! mProvidersIdentifier = value;
! }
! }
!
! internal DataItem(IMailstoreProvider provider, object id)
{
mMailstoreProvider = provider;
+ mProvidersIdentifier = id;
}
+ }
+
+ /// <summary>
+ /// Base class for all collections of DataItems
+ /// </summary>
+ public abstract class DataItemCollection : IEnumerable
+ {
+ protected IMailstoreProvider mMailstoreProvider;
+
+ internal DataItemCollection(IMailstoreProvider provider)
+ {
+ mMailstoreProvider = provider;
+ }
+
+ public abstract IEnumerator GetEnumerator();
}
}
Index: Mailbox.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/Mailbox.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Mailbox.cs 28 Jul 2003 00:15:16 -0000 1.6
--- Mailbox.cs 29 Jul 2003 00:46:28 -0000 1.7
***************
*** 12,29 ****
#region Variables
private string mName;
- private string mFullName;
private uint mNextUniqueId;
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
--- 12,26 ----
#region Variables
private string mName;
private uint mNextUniqueId;
private uint mUniqueIdValidity;
private User mUser; // the owner of this mailbox
+ internal Mailbox mParent;
+ internal MailboxCollection mContainer; // the set of mailboxes that we are a part of
+
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"
#endregion
***************
*** 44,47 ****
--- 41,55 ----
}
+ public string FullName
+ {
+ get
+ {
+ if(mParent == null)
+ return mName;
+ else
+ return mParent.FullName + "/" + mName;
+ }
+ }
+
/// <summary>
/// The id that SHOULD be assigned to the next new message in this mailbox
***************
*** 92,96 ****
get
{
! return mChildren;
}
}
--- 100,104 ----
get
{
! return mMailstoreProvider.GetMailboxes(this);
}
}
***************
*** 103,107 ****
get
{
! return mMessages;
}
}
--- 111,115 ----
get
{
! return mMailstoreProvider.GetMessages(this);
}
}
***************
*** 128,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;
--- 136,140 ----
// TODO: make this more efficient then having to load all the messages
int rv = 0;
! foreach(Message msg in Messages)
if(msg.Recent)
++rv;
***************
*** 169,172 ****
--- 177,184 ----
return mNoSelect;
}
+ set
+ {
+ mNoSelect = value;
+ }
}
***************
*** 186,215 ****
}
}
-
#endregion
! public Mailbox(IMailstoreProvider provider, string name, string fullName, uint nextUniqueId, uint uniqueIdValidity, User user) : base(provider)
{
- mProvider = provider;
-
mNextUniqueId = nextUniqueId;
mUniqueIdValidity = uniqueIdValidity;
mName = name;
- 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);
}
}
--- 198,236 ----
}
}
#endregion
! public Mailbox(IMailstoreProvider provider, object providersId, string name, uint nextUniqueId, uint uniqueIdValidity, User user, bool noSelect, bool noInferiors, bool marked, bool unmarked) : base(provider, providersId)
{
mNextUniqueId = nextUniqueId;
mUniqueIdValidity = uniqueIdValidity;
mName = name;
mParent = null;
+ mContainer = null;
mUser = user;
! mNoSelect = noSelect;
! mNoInferiors = noInferiors;
! mMarked = marked;
! mUnmarked = unmarked;
! }
! public void MoveMessages(Mailbox destination)
! {
! destination.Messages.Add(Messages);
! Messages.Clear();
}
! public void Save()
{
! mMailstoreProvider.SaveMailbox(this);
! }
!
! public static string ExtractName(string fullName)
! {
! int idx = fullName.LastIndexOf('/');
! if(idx == -1)
! return fullName;
! else
! return fullName.Substring(idx+1);
}
}
Index: MailboxCollection.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/MailboxCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MailboxCollection.cs 28 Jul 2003 00:15:16 -0000 1.2
--- MailboxCollection.cs 29 Jul 2003 00:46:28 -0000 1.3
***************
*** 9,25 ****
/// Custom class representing a mailbox collection
/// </summary>
! public class MailboxCollection : IEnumerable
{
private User mUser;
private ArrayList mIndexedList = new ArrayList();
private SortedList mNamedList = new SortedList();
! private IMailstoreProvider mProvider;
!
! internal MailboxCollection(IMailstoreProvider provider, User usr)
{
! mProvider = provider;
! mUser = usr;
}
--- 9,24 ----
/// Custom class representing a mailbox collection
/// </summary>
! public class MailboxCollection : DataItemCollection
{
private User mUser;
+ private Mailbox mContainer;
private ArrayList mIndexedList = new ArrayList();
private SortedList mNamedList = new SortedList();
! internal MailboxCollection(IMailstoreProvider provider, User user, Mailbox container) : base(provider)
{
! mContainer = container;
! mUser = user;
}
***************
*** 40,45 ****
--- 39,54 ----
}
+ public int Count
+ {
+ get
+ {
+ return mIndexedList.Count;
+ }
+ }
+
internal void Add(Mailbox box)
{
+ box.mParent = mContainer;
+ box.mContainer = this;
mIndexedList.Add(box);
mNamedList.Add(box.Name.ToUpper(), box);
***************
*** 49,73 ****
{
// TODO: gather the uidvalidity to be unique for this name (suggested in the rfc to have 32-bit representation of day/time)
! Mailbox mbx = new Mailbox(mProvider, name, name, 1, 1, mUser);
! if(mProvider.InsertMailbox(mUser, mbx))
! {
! Add(mbx);
! return mbx;
! }
else
return null;
}
! public int Count
{
! get
{
! return mIndexedList.Count;
}
}
#region IEnumerable
! public IEnumerator GetEnumerator()
{
return mIndexedList.GetEnumerator();
--- 58,111 ----
{
// TODO: gather the uidvalidity to be unique for this name (suggested in the rfc to have 32-bit representation of day/time)
! Mailbox box = new Mailbox(mMailstoreProvider, null, name, 1, 1, mUser, false, false, false, false);
! Add(box);
! if(mMailstoreProvider.InsertMailbox(mUser, box))
! return box;
else
return null;
}
! /// <summary>
! /// Finds the containing MailboxCollection that a specified mailbox would reside in (regardless of it existing)
! /// </summary>
! /// <param name="fullName">The fullname of the mailbox</param>
! /// <param name="createToFind">Should the method create the mailboxes in order to "find" the container</param>
! /// <returns>The container found, null if not found or unable to create parent containers (if createToFind = true)</returns>
! public MailboxCollection FindContainer(string fullName, bool createToFind)
{
! int idx = fullName.IndexOf('/');
! if(idx == -1) // no hierarchy seperators, must go in this container
! return this;
! else if(idx == 0) // if it starts with a slash, get rid of it
! return FindContainer(fullName.Substring(1), createToFind);
! else
{
! string boxName = fullName.Substring(0, idx);
! Mailbox box = this[boxName];
! if(box == null)
! {
! if(createToFind)
! box = Add(boxName);
! else
! return null;
! }
! string childName = fullName.Substring(idx+1);
! if(childName == "/")
! return this;
! else
! return box.Children.FindContainer(childName, createToFind);
}
}
+ public void Remove(Mailbox box)
+ {
+ mMailstoreProvider.DeleteMailbox(box);
+ mIndexedList.Remove(box);
+ mNamedList.Remove(box.Name.ToUpper());
+ }
+
#region IEnumerable
! public override IEnumerator GetEnumerator()
{
return mIndexedList.GetEnumerator();
Index: Message.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/Message.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Message.cs 25 Jul 2003 23:35:24 -0000 1.3
--- Message.cs 29 Jul 2003 00:46:28 -0000 1.4
***************
*** 135,139 ****
#endregion
! public Message(IMailstoreProvider provider, uint uid, bool seen, bool answered, bool flagged, bool deleted, bool draft, int size) : base(provider)
{
mUniqueId = uid;
--- 135,139 ----
#endregion
! public Message(IMailstoreProvider provider, object providersId, uint uid, bool seen, bool answered, bool flagged, bool deleted, bool draft, int size) : base(provider, providersId)
{
mUniqueId = uid;
Index: MessageCollection.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/MessageCollection.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MessageCollection.cs 28 Jul 2003 00:15:16 -0000 1.1
--- MessageCollection.cs 29 Jul 2003 00:46:28 -0000 1.2
***************
*** 9,13 ****
/// Custom class representing a message collection
/// </summary>
! public class MessageCollection : IEnumerable
{
private Mailbox mMailbox;
--- 9,13 ----
/// Custom class representing a message collection
/// </summary>
! public class MessageCollection : DataItemCollection
{
private Mailbox mMailbox;
***************
*** 16,24 ****
private SortedList mUidList = new SortedList();
! private IMailstoreProvider mProvider;
!
! internal MessageCollection(IMailstoreProvider provider, Mailbox box)
{
- mProvider = provider;
mMailbox = box;
}
--- 16,21 ----
private SortedList mUidList = new SortedList();
! internal MessageCollection(IMailstoreProvider provider, Mailbox box) : base(provider)
{
mMailbox = box;
}
***************
*** 44,52 ****
public void Clear()
{
! mProvider.DeleteMessages(mMailbox);
}
#region IEnumerable
! public IEnumerator GetEnumerator()
{
return mSequenceList.GetEnumerator();
--- 41,57 ----
public void Clear()
{
! mMailstoreProvider.DeleteMessages(mMailbox);
! }
!
! public void Add(Message msg)
! {
! }
!
! public void Add(MessageCollection msgs)
! {
}
#region IEnumerable
! public override IEnumerator GetEnumerator()
{
return mSequenceList.GetEnumerator();
Index: User.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Common/User.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** User.cs 28 Jul 2003 00:15:16 -0000 1.3
--- User.cs 29 Jul 2003 00:46:28 -0000 1.4
***************
*** 13,18 ****
private string mUsername;
private string mPassword;
- private MailboxCollection mMailboxes;
- private IMailstoreProvider mProvider;
#endregion
--- 13,16 ----
***************
*** 44,58 ****
get
{
! if(mMailboxes == null)
! mMailboxes = mMailstoreProvider.GetMailboxes(this);
! return mMailboxes;
}
}
#endregion
! public User(IMailstoreProvider provider, string username, string password) : base(provider)
{
- mProvider = provider;
-
mUsername = username;
mPassword = password;
--- 42,52 ----
get
{
! return mMailstoreProvider.GetMailboxes(this);
}
}
#endregion
! public User(IMailstoreProvider provider, object providersId, string username, string password) : base(provider, providersId)
{
mUsername = username;
mPassword = password;
|