IMAP session.
Inheritance: ISocketServerSession
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">Owner IMAP session.</param>
        /// <param name="folderName">Folder name which ACL to get.</param>
        public IMAP_GETACL_eArgs(IMAP_Session session,string folderName)
        {
            m_pSession = session;
            m_pFolderName = folderName;

            m_ACLs = new Hashtable();
        }
示例#2
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Owner IMAP session.</param>
 /// <param name="referenceName">Folder Path. Eg. Inbox\.</param>
 /// <param name="folder">Folder name.</param>
 public IMAP_Folders(IMAP_Session session,string referenceName,string folder)
 {
     m_pSession  = session;
     m_Mailboxes = new ArrayList();
     m_RefName   = referenceName;
     m_Mailbox   = folder;
 }
示例#3
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Reference to IMAP session.</param>
 /// <param name="userName">Username.</param>
 /// <param name="passwData">Password data.</param>
 /// <param name="data">Authentication specific data(as tag).</param>
 /// <param name="authType">Authentication type.</param>
 public AuthUser_EventArgs(IMAP_Session session,string userName,string passwData,string data,AuthType authType)
 {
     m_pSession  = session;
     m_UserName  = userName;
     m_PasswData = passwData;
     m_Data      = data;
     m_AuthType  = authType;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Owner IMAP session.</param>
 /// <param name="folderName">Folder name which ACL to set.</param>
 /// <param name="userName">User name which ACL to set.</param>
 /// <param name="flagsSetType">Specifies how flags must be stored.</param>
 /// <param name="aclFlags">Flags which to store.</param>
 public IMAP_SETACL_eArgs(IMAP_Session session,string folderName,string userName,IMAP_Flags_SetType flagsSetType,IMAP_ACL_Flags aclFlags)
 {
     m_pSession     = session;
     m_pFolderName  = folderName;
     m_UserName     = userName;
     m_FlagsSetType = flagsSetType;
     m_ACL_Flags    = aclFlags;
 }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">IMAP session what calls this search.</param>
        /// <param name="folder">IMAP folder name which messages to search.</param>
        /// <param name="matcher">Matcher what must be used to check if message matches searching criterial.</param>
        public IMAP_eArgs_Search(IMAP_Session session,string folder,IMAP_SearchMatcher matcher)
        {
            m_pSession  = session;
            m_Folder    = folder;
            m_pMatcher  = matcher;

            m_pMessages = new IMAP_Messages(folder);
        }
示例#6
0
        /// <summary>
        /// Starts sending response to the specified IMAP session remote endpoint.
        /// </summary>
        /// <param name="session">Stream where to store response.</param>
        /// <param name="completedAsyncCallback">Callback to be called when this method completes asynchronously.</param>
        /// <returns>Returns true is method completed asynchronously(the completedAsyncCallback is raised upon completion of the operation).
        /// Returns false if operation completed synchronously.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>session</b> is null reference.</exception>
        internal bool SendAsync(IMAP_Session session,EventHandler<EventArgs<Exception>> completedAsyncCallback)
        {
            if(session == null){
                throw new ArgumentNullException("session");
            }

            return ToStreamAsync(session,session.TcpStream,session.MailboxEncoding,completedAsyncCallback);
        }
示例#7
0
        /// <summary>
        /// Starts writing response to the specified stream.
        /// </summary>
        /// <param name="session">Owner IMAP session.</param>
        /// <param name="stream">Stream where to store response.</param>
        /// <param name="mailboxEncoding">Specifies how mailbox name is encoded.</param>
        /// <param name="completedAsyncCallback">Callback to be called when this method completes asynchronously.</param>
        /// <returns>Returns true is method completed asynchronously(the completedAsyncCallback is raised upon completion of the operation).
        /// Returns false if operation completed synchronously.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> is null reference.</exception>
        protected virtual bool ToStreamAsync(IMAP_Session session,Stream stream,IMAP_Mailbox_Encoding mailboxEncoding,EventHandler<EventArgs<Exception>> completedAsyncCallback)
        {
            if(stream == null){
                throw new ArgumentNullException("stream");
            }

            string responseS = ToString(mailboxEncoding);
            byte[] response  = Encoding.UTF8.GetBytes(responseS);

            // Log.
            if(session != null){
                session.LogAddWrite(response.Length,responseS.TrimEnd());
            }

            // Starts writing response to stream.
            IAsyncResult ar = stream.BeginWrite(
                response,
                0,
                response.Length,
                delegate(IAsyncResult r){                    
                    if(r.CompletedSynchronously){
                        return;
                    }

                    try{
                        stream.EndWrite(r);

                        if(completedAsyncCallback != null){
                            completedAsyncCallback(this,new EventArgs<Exception>(null));
                        }
                    }
                    catch(Exception x){
                        if(completedAsyncCallback != null){
                            completedAsyncCallback(this,new EventArgs<Exception>(x));
                        }
                    }
                },
                null
            );
            // Completed synchronously, process result.
            if(ar.CompletedSynchronously){
                stream.EndWrite(ar);

                return false;
            }
            // Completed asynchronously, stream.BeginWrite AsyncCallback will continue processing.
            else{
                return true;
            }
        }
            /// <summary>
            /// Default constructor.
            /// </summary>
            /// <param name="session">Owner IMAP session.</param>
            /// <exception cref="ArgumentNullException">Is raised when <b>session</b> is null reference.</exception>
            public ResponseSender(IMAP_Session session)
            {
                if(session == null){
                    throw new ArgumentNullException("session");
                }

                m_pImap = session;

                m_pResponses = new Queue<QueueItem>();
            }
            /// <summary>
            /// Default constructor.
            /// </summary>
            /// <param name="session">Owner IMAP session.</param>
            /// <param name="initialCmdLine">IMAP client initial command line.</param>
            /// <param name="charset">IMAP literal strings charset encoding.</param>
            /// <exception cref="ArgumentNullException">Is raised when <b>session</b>,<b>initialCmdLine</b> or <b>charset</b> is null reference.</exception>
            public _CmdReader(IMAP_Session session,string initialCmdLine,Encoding charset)
            {    
                if(session == null){
                    throw new ArgumentNullException("session");
                }
                if(initialCmdLine == null){
                    throw new ArgumentNullException("initialCmdLine");
                }
                if(charset == null){
                    throw new ArgumentNullException("charset");
                }

                m_pSession       = session;
                m_InitialCmdLine = initialCmdLine;
                m_pCharset       = charset;
            }
示例#10
0
            /// <summary>
            /// Cleans up any resources being used.
            /// </summary>
            public void Dispose()
            {
                if(m_IsDisposed){
                    return;
                }
                m_IsDisposed = true;

                m_pSession.m_pIDLE = null;
                m_pSession = null;
                m_pTimer.Dispose();
                m_pTimer = null;
            }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Owner IMAP session.</param>
 /// <param name="folderName">Folder name which ACL to get.</param>
 /// <param name="userName">User name which ACL to get.</param>
 public IMAP_GetUserACL_eArgs(IMAP_Session session,string folderName,string userName)
 {
     m_pSession    = session;
     m_pFolderName = folderName;
     m_UserName    = userName;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Owner IMAP session.</param>
 public IMAP_eArgs_GetQuota(IMAP_Session session)
 {
     m_pSession = session;
 }
示例#13
0
        /// <summary>
        /// Starts writing response to the specified stream.
        /// </summary>
        /// <param name="session">Owner IMAP session.</param>
        /// <param name="stream">Stream where to store response.</param>
        /// <param name="mailboxEncoding">Specifies how mailbox name is encoded.</param>
        /// <param name="completedAsyncCallback">Callback to be called when this method completes asynchronously.</param>
        /// <returns>Returns true is method completed asynchronously(the completedAsyncCallback is raised upon completion of the operation).
        /// Returns false if operation completed synchronously.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> is null reference.</exception>
        protected override bool ToStreamAsync(IMAP_Session session,Stream stream,IMAP_Mailbox_Encoding mailboxEncoding,EventHandler<EventArgs<Exception>> completedAsyncCallback)
        {
            if(stream == null){
                throw new ArgumentNullException("stream");
            }

            StringBuilder buffer = new StringBuilder();
            buffer.Append("* " + m_MsgSeqNo + " FETCH (");

            for(int i=0;i<m_pDataItems.Count;i++){
                IMAP_t_Fetch_r_i dataItem = m_pDataItems[i];

                if(i > 0){
                    buffer.Append(" ");
                }

                if(dataItem is IMAP_t_Fetch_r_i_Flags){
                    buffer.Append("FLAGS (" + ((IMAP_t_Fetch_r_i_Flags)dataItem).Flags.ToString() + ")");
                }
                else if(dataItem is IMAP_t_Fetch_r_i_Uid){
                    buffer.Append("UID " + ((IMAP_t_Fetch_r_i_Uid)dataItem).UID.ToString());
                }
                else{
                    throw new NotImplementedException("Fetch response data-item '" + dataItem.ToString() + "' not implemented.");
                }
            }

            buffer.Append(")\r\n");

            string responseS = buffer.ToString();
            byte[] response  = Encoding.UTF8.GetBytes(responseS);

            // Log.
            if(session != null){
                session.LogAddWrite(response.Length,responseS.TrimEnd());
            }

            // Starts writing response to stream.
            IAsyncResult ar = stream.BeginWrite(
                response,
                0,
                response.Length,
                delegate(IAsyncResult r){
                    if(r.CompletedSynchronously){
                        return;
                    }

                    try{
                        stream.EndWrite(r);

                        if(completedAsyncCallback != null){
                            completedAsyncCallback(this,new EventArgs<Exception>(null));
                        }
                    }
                    catch(Exception x){
                        if(completedAsyncCallback != null){
                            completedAsyncCallback(this,new EventArgs<Exception>(x));
                        }
                    }
                },
                null
            );
            // Completed synchronously, process result.
            if(ar.CompletedSynchronously){
                stream.EndWrite(ar);

                return false;
            }
            // Completed asynchronously, stream.BeginWrite AsyncCallback will continue processing.
            else{
                return true;
            }
        }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public IMAP_eArgs_GetMessagesInfo(IMAP_Session session,IMAP_SelectedFolder folder)
 {
     m_pSession    = session;
     m_pFolderInfo = folder;
 }
示例#15
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="session">Reference to current IMAP session.</param>
 /// <param name="messageInfo">Message info what message items to get.</param>
 /// <param name="messageItems">Specifies message items what must be filled.</param>
 public IMAP_eArgs_MessageItems(IMAP_Session session,IMAP_Message messageInfo,IMAP_MessageItems_enum messageItems)
 {
     m_pSession     = session;
     m_pMessageInfo = messageInfo;
     m_MessageItems = messageItems;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public SharedRootFolders_EventArgs(IMAP_Session session)
 {
     m_pSession = session;
 }
示例#17
0
            /// <summary>
            /// Default constructor.
            /// </summary>
            /// <param name="session">Owner IMAP session.</param>
            /// <param name="cmdTag">IDLE command command-tag.</param>
            /// <exception cref="ArgumentNullException">Is raised when <b>session</b> or <b>cmdTag</b> is null reference.</exception>
            /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
            public Command_IDLE(IMAP_Session session,string cmdTag)
            {
                if(session == null){
                    throw new ArgumentNullException("session");
                }
                if(cmdTag == null){
                    throw new ArgumentNullException("cmdTag");
                }
                if(cmdTag == string.Empty){
                    throw new ArgumentException("Argument 'cmdTag' value must be specified.","cmdTag");
                }

                m_pSession = session;
                m_CmdTag   = cmdTag;

                Start();
            }