[csmaild-cvs] csmaild/src/Imap/Commands SelectExamineCommand.cs,NONE,1.1 ExamineCommand.cs,1.4,NONE
Brought to you by:
tamc
|
From: <ta...@us...> - 2003-07-27 17:26:27
|
Update of /cvsroot/csmaild/csmaild/src/Imap/Commands
In directory sc8-pr-cvs1:/tmp/cvs-serv1812/src/Imap/Commands
Added Files:
SelectExamineCommand.cs
Removed Files:
ExamineCommand.cs SelectCommand.cs
Log Message:
SELECT and EXAMINE are nearly identical commands so I've combined the handlers into one.
--- NEW FILE: SelectExamineCommand.cs ---
using Common;
using System;
namespace Imap.Commands
{
/// <summary>
/// Summary description for SelectExamineCommand.
/// </summary>
public class SelectExamineCommand : ImapCommand
{
private bool mIsSelect; // true if we're actually SELECT false if we're EXAMINE
public SelectExamineCommand(bool isSelect, ImapServer svr) : base(svr, "SELECT", ImapCommand.AuthSelectedState, ArgumentType.AString)
{
mIsSelect = isSelect;
}
override protected bool InternalProcess()
{
mConnection.Mailbox = Server.MailstoreProvider.GetMailbox(mConnection.User, mParsedArguments[0] as string);
if(mConnection.Mailbox == null)
{
mConnection.State = ImapConnectionState.Authenticated;
mConnection.SendTaggedMessage("NO");
}
else
{
mConnection.State = ImapConnectionState.Selected;
Mailbox mbx = mConnection.Mailbox;
mConnection.SendUntaggedMessage("FLAGS (\\Seen \\Answered \\Flagged \\Deleted \\Draft \\Recent)");
mConnection.SendUntaggedMessage(mbx.MessageCount.ToString() + " EXISTS");
mConnection.SendUntaggedMessage(mbx.MessageRecentCount.ToString() + " RECENT");
if(mbx.FirstUnseenMessageSeqNum != 0)
mConnection.SendUntaggedMessage("OK [UNSEEN " + mbx.FirstUnseenMessageSeqNum + "]");
if(mIsSelect)
mConnection.SendUntaggedMessage("OK [PERMANENTFLAGS (\\Seen \\Answered \\Flagged \\Deleted \\Draft)]");
else
mConnection.SendUntaggedMessage("OK [PERMANENTFLAGS ()]");
mConnection.SendUntaggedMessage("OK [UIDVALIDITY " + mbx.UniqueIdValidity.ToString() + "]");
mConnection.SendUntaggedMessage("OK [UIDNEXT " + mbx.NextUniqueId + "]");
mConnection.SendTaggedMessage(mIsSelect ? "OK [READ-WRITE]" : "OK [READ-ONLY]");
}
return true;
}
}
}
--- ExamineCommand.cs DELETED ---
--- SelectCommand.cs DELETED ---
|