[csmaild-cvs] csmaild/src/Imap Connection.cs,1.9,1.10 Server.cs,1.8,1.9
Brought to you by:
tamc
|
From: <ta...@us...> - 2003-08-05 01:42:13
|
Update of /cvsroot/csmaild/csmaild/src/Imap
In directory sc8-pr-cvs1:/tmp/cvs-serv32691/src/Imap
Modified Files:
Connection.cs Server.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: Connection.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Imap/Connection.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Connection.cs 3 Aug 2003 01:08:38 -0000 1.9
--- Connection.cs 5 Aug 2003 01:42:10 -0000 1.10
***************
*** 2,6 ****
using Imap.Commands;
! using Imap.NetworkManager;
using System;
--- 2,6 ----
using Imap.Commands;
! using Common.NetworkManager;
using System;
***************
*** 13,18 ****
/// The various states an ImapConnection can be in
/// </summary>
! [Flags()]
! public enum ImapConnectionState : byte
{
NotAuthenticated = 1, /// user is not authenticated, generally right after a connect
--- 13,17 ----
/// The various states an ImapConnection can be in
/// </summary>
! public enum ImapConnectionState
{
NotAuthenticated = 1, /// user is not authenticated, generally right after a connect
***************
*** 166,182 ****
if(idxCommandEnd == -1) // nothing after the command
{
! cmd = line.Substring(idxTagEnd).ToUpper(); // one space past the tag til the end
mCurrentArguments = string.Empty; // no arguments
}
else
{
! cmd = line.Substring(idxTagEnd, idxCommandEnd-idxTagEnd).ToUpper(); // one space past tag til the next space
mCurrentArguments = line.Substring(idxCommandEnd); // args will include the preceding space
}
! if(mCurrentCommandUID)
! mCurrentCommand = (ImapCommand)Server.UidCommands[cmd];
! else
! mCurrentCommand = (ImapCommand)Server.Commands[cmd];
if(mCurrentCommand == null)
--- 165,178 ----
if(idxCommandEnd == -1) // nothing after the command
{
! cmd = line.Substring(idxTagEnd); // one space past the tag til the end
mCurrentArguments = string.Empty; // no arguments
}
else
{
! cmd = line.Substring(idxTagEnd, idxCommandEnd-idxTagEnd); // one space past tag til the next space
mCurrentArguments = line.Substring(idxCommandEnd); // args will include the preceding space
}
! mCurrentCommand = Server.CreateCommand(cmd, mCurrentCommandUID);
if(mCurrentCommand == null)
***************
*** 199,211 ****
private void Connection_ReceivedLine(Connection cnn, string line)
{
- // this shouldn't ever be a problem, but what the heck, clock cycles are cheap ;)
- if(cnn != mConnection)
- throw new Exception("Fucked up, this is just fucked up!");
-
ParseAndValidate(line);
try
{
! if(mCurrentCommand.Process())
{
}
--- 195,203 ----
private void Connection_ReceivedLine(Connection cnn, string line)
{
ParseAndValidate(line);
try
{
! if(mCurrentCommand.Process(mCurrentArguments, this, mCurrentCommandUID))
{
}
***************
*** 216,219 ****
--- 208,212 ----
Console.WriteLine(ex.ToString());
}
+
ReadCommand();
}
Index: Server.cs
===================================================================
RCS file: /cvsroot/csmaild/csmaild/src/Imap/Server.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Server.cs 3 Aug 2003 01:08:38 -0000 1.8
--- Server.cs 5 Aug 2003 01:42:10 -0000 1.9
***************
*** 1,18 ****
! using System;
using Imap.Commands;
! using Imap.NetworkManager;
using System.Collections;
using System.IO;
- //using System.Net.Sockets;
- //using System.Text;
-
- using Common.MailstoreProviders;
-
namespace Imap
{
public class ImapServer
{
! private NetworkManager.NetworkManager mNetwork;
private Hashtable mImapConnections = new Hashtable();
private Hashtable mImapCommands = new Hashtable();
--- 1,16 ----
! using Common.MailstoreProviders;
! using Common.NetworkManager;
!
using Imap.Commands;
!
! using System;
using System.Collections;
using System.IO;
namespace Imap
{
public class ImapServer
{
! private NetworkManager mNetwork = new NetworkManager();
private Hashtable mImapConnections = new Hashtable();
private Hashtable mImapCommands = new Hashtable();
***************
*** 22,59 ****
public ImapServer(IMailstoreProvider provider)
{
- mNetwork = new NetworkManager.NetworkManager();
mMailstoreProvider = provider;
-
- #region Register handlers
- mImapCommands.Add("APPEND", new AppendCommand(this));
- mImapCommands.Add("AUTHENTICATE", new AuthenticateCommand(this));
- mImapCommands.Add("CAPABILITY", new CapabilityCommand(this));
- mImapCommands.Add("CHECK", new CheckCommand(this));
- mImapCommands.Add("CLOSE", new CloseCommand(this));
- mImapCommands.Add("COPY", new CopyCommand(this));
- mImapCommands.Add("CREATE", new CreateCommand(this));
- mImapCommands.Add("DELETE", new DeleteCommand(this));
- mImapCommands.Add("EXAMINE", new SelectExamineCommand(false, this));
- mImapCommands.Add("EXPUNGE", new ExpungeCommand(this));
- mImapCommands.Add("FETCH", new FetchCommand(this));
- mImapCommands.Add("LIST", new ListCommand(this));
- mImapCommands.Add("LOGIN", new LoginCommand(this));
- mImapCommands.Add("LOGOUT", new LogoutCommand(this));
- mImapCommands.Add("LSUB", new LsubCommand(this));
- mImapCommands.Add("NOOP", new NoopCommand(this));
- mImapCommands.Add("RENAME", new RenameCommand(this));
- mImapCommands.Add("SEARCH", new SearchCommand(this));
- mImapCommands.Add("SELECT", new SelectExamineCommand(true, this));
- mImapCommands.Add("STARTTLS", new StarttlsCommand(this));
- mImapCommands.Add("STATUS", new StatusCommand(this));
- mImapCommands.Add("STORE", new StoreCommand(this));
- mImapCommands.Add("SUBSCRIBE", new SubscribeCommand(this));
- mImapCommands.Add("UNSUBSCRIBE", new UnsubscribeCommand(this));
-
- mUidImapCommands.Add("COPY", mImapCommands["COPY"]);
- mUidImapCommands.Add("FETCH", mImapCommands["FETCH"]);
- mUidImapCommands.Add("STORE", mImapCommands["STORE"]);
- mUidImapCommands.Add("SEARCH", mImapCommands["SEARCH"]);
- #endregion
}
--- 20,24 ----
***************
*** 74,93 ****
}
- public Hashtable Commands
- {
- get
- {
- return mImapCommands;
- }
- }
-
- public Hashtable UidCommands
- {
- get
- {
- return mUidImapCommands;
- }
- }
-
public void Start()
{
--- 39,42 ----
***************
*** 104,108 ****
mImapConnections.Add(con, cnn);
-
}
--- 53,56 ----
***************
*** 113,116 ****
--- 61,138 ----
}
+ #region Command handler switches
+ public ImapCommand CreateCommand(string name, bool uid)
+ {
+ if(uid)
+ {
+ switch(name.ToUpper())
+ {
+ case "COPY":
+ return new CopyCommand(this);
+ case "FETCH":
+ return new FetchCommand(this);
+ case "STORE":
+ return new StoreCommand(this);
+ case "SEARCH":
+ return new SearchCommand(this);
+ }
+ }
+ else
+ {
+ switch(name.ToUpper())
+ {
+ case "APPEND":
+ return new AppendCommand(this);
+ case "AUTHENTICATE":
+ return new AuthenticateCommand(this);
+ case "CAPABILITY":
+ return new CapabilityCommand(this);
+ case "CHECK":
+ return new CheckCommand(this);
+ case "CLOSE":
+ return new CloseCommand(this);
+ case "COPY":
+ return new CopyCommand(this);
+ case "CREATE":
+ return new CreateCommand(this);
+ case "DELETE":
+ return new DeleteCommand(this);
+ case "EXAMINE":
+ return new SelectExamineCommand(false, this);
+ case "EXPUNGE":
+ return new ExpungeCommand(this);
+ case "FETCH":
+ return new FetchCommand(this);
+ case "LIST":
+ return new ListCommand(this);
+ case "LOGIN":
+ return new LoginCommand(this);
+ case "LOGOUT":
+ return new LogoutCommand(this);
+ case "LSUB":
+ return new LsubCommand(this);
+ case "NOOP":
+ return new NoopCommand(this);
+ case "RENAME":
+ return new RenameCommand(this);
+ case "SEARCH":
+ return new SearchCommand(this);
+ case "SELECT":
+ return new SelectExamineCommand(true, this);
+ case "STARTTLS":
+ return new StarttlsCommand(this);
+ case "STATUS":
+ return new StatusCommand(this);
+ case "STORE":
+ return new StoreCommand(this);
+ case "SUBSCRIBE":
+ return new SubscribeCommand(this);
+ case "UNSUBSCRIBE":
+ return new UnsubscribeCommand(this);
+ }
+ }
+ return null;
+ }
+ #endregion
}
}
|