/// <summary> /// Encodes mailbox name. /// </summary> /// <param name="mailbox">Mailbox name.</param> /// <param name="encoding">Mailbox name encoding mechanism.</param> /// <returns>Renturns encoded mailbox name.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>mailbox</b> is null reference.</exception> public static string EncodeMailbox(string mailbox, IMAP_Mailbox_Encoding encoding) { if (mailbox == null) { throw new ArgumentNullException("mailbox"); } /* RFC 6855 3. * quoted = DQUOTE *uQUOTED-CHAR DQUOTE * uQUOTED-CHAR = QUOTED-CHAR / UTF8-2 / UTF8-3 / UTF8-4 */ if (encoding == IMAP_Mailbox_Encoding.ImapUtf7) { return("\"" + IMAP_Utils.Encode_IMAP_UTF7_String(mailbox) + "\""); } else if (encoding == IMAP_Mailbox_Encoding.ImapUtf8) { return("\"" + mailbox + "\""); } else { return("\"" + mailbox + "\""); } }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * LSUB (\Noselect) "/" ~/Mail/foo StringBuilder retVal = new StringBuilder(); retVal.Append("* LSUB ("); if (m_pFolderAttributes != null) { for (int i = 0; i < m_pFolderAttributes.Length; i++) { if (i > 0) { retVal.Append(" "); } retVal.Append(m_pFolderAttributes[i]); } } retVal.Append(") "); retVal.Append("\"" + m_Delimiter + "\" "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName, encoding)); retVal.Append("\r\n"); return(retVal.ToString()); }
/// <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> /// Starts writing response to the specified stream. /// </summary> /// <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> public bool ToStreamAsync(Stream stream,IMAP_Mailbox_Encoding mailboxEncoding,EventHandler<EventArgs<Exception>> completedAsyncCallback) { if(stream == null){ throw new ArgumentNullException("stream"); } return ToStreamAsync(null,stream,mailboxEncoding,completedAsyncCallback); }
/// <summary> /// Starts writing response to the specified stream. /// </summary> /// <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> public bool ToStreamAsync(Stream stream, IMAP_Mailbox_Encoding mailboxEncoding, EventHandler <EventArgs <Exception> > completedAsyncCallback) { if (stream == null) { throw new ArgumentNullException("stream"); } return(ToStreamAsync(null, stream, mailboxEncoding, completedAsyncCallback)); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) StringBuilder retVal = new StringBuilder(); retVal.Append("* STATUS"); retVal.Append(" " + IMAP_Utils.EncodeMailbox(m_FolderName, encoding)); retVal.Append(" ("); bool firstItem = true; if (m_MessageCount >= 0) { retVal.Append("MESSAGES " + m_MessageCount); firstItem = false; } if (m_RecentCount >= 0) { if (!firstItem) { retVal.Append(' '); } retVal.Append("RECENT " + m_RecentCount); firstItem = false; } if (m_UidNext >= 0) { if (!firstItem) { retVal.Append(' '); } retVal.Append("UIDNEXT " + m_UidNext); firstItem = false; } if (m_FolderUid >= 0) { if (!firstItem) { retVal.Append(' '); } retVal.Append("UIDVALIDITY " + m_FolderUid); firstItem = false; } if (m_UnseenCount >= 0) { if (!firstItem) { retVal.Append(' '); } retVal.Append("UNSEEN " + m_UnseenCount); firstItem = false; } retVal.Append(")\r\n"); return(retVal.ToString()); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * LISTRIGHTS ~/Mail/saved smith la r swicdkxte StringBuilder retVal = new StringBuilder(); retVal.Append("* LISTRIGHTS " + IMAP_Utils.EncodeMailbox(m_FolderName, encoding) + " \"" + m_RequiredRights + "\" " + m_OptionalRights + "\r\n"); return(retVal.ToString()); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * MYRIGHTS INBOX rwiptsldaex StringBuilder retVal = new StringBuilder(); retVal.Append("* MYRIGHTS " + IMAP_Utils.EncodeMailbox(m_FolderName, encoding) + " \"" + m_pRights + "\"\r\n"); return(retVal.ToString()); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * QUOTAROOT INBOX "" StringBuilder retVal = new StringBuilder(); retVal.Append("* QUOTAROOT " + IMAP_Utils.EncodeMailbox(m_FolderName,encoding)); foreach(string root in m_QuotaRoots){ retVal.Append(" \"" + root + "\""); } retVal.Append("\r\n"); return retVal.ToString(); }
/// <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> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * ACL INBOX Fred rwipslda test rwipslda StringBuilder retVal = new StringBuilder(); retVal.Append("* ACL "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName, encoding)); foreach (IMAP_Acl_Entry e in m_pEntries) { retVal.Append(" \"" + e.Identifier + "\" \"" + e.Rights + "\""); } retVal.Append("\r\n"); return(retVal.ToString()); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { /* * Example: S: * LIST (\Noselect) "/" ~/Mail/foo * * C: A101 LIST "" "" * S: * LIST (\Noselect) "/" "" * S: A101 OK LIST Completed */ // Hierarchy delimiter request. if (string.IsNullOrEmpty(m_FolderName)) { return("* LIST (\\Noselect) \"/\" \"\"\r\n"); } else { StringBuilder retVal = new StringBuilder(); retVal.Append("* LIST ("); if (m_pFolderAttributes != null) { for (int i = 0; i < m_pFolderAttributes.Length; i++) { if (i > 0) { retVal.Append(" "); } retVal.Append(m_pFolderAttributes[i]); } } retVal.Append(") "); retVal.Append("\"" + m_Delimiter + "\" "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName, encoding)); retVal.Append("\r\n"); return(retVal.ToString()); } }
/// <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. #if NETSTANDARD // NOTE synchronous now stream.Write(response, 0, response.Length); // Completed synchronously, process result. return(false); #else 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); } #endif }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { /* Example: S: * LIST (\Noselect) "/" ~/Mail/foo C: A101 LIST "" "" S: * LIST (\Noselect) "/" "" S: A101 OK LIST Completed */ // Hierarchy delimiter request. if(string.IsNullOrEmpty(m_FolderName)){ return "* LIST (\\Noselect) \"/\" \"\"\r\n"; } else{ StringBuilder retVal = new StringBuilder(); retVal.Append("* LIST ("); if(m_pFolderAttributes != null){ for(int i=0;i<m_pFolderAttributes.Length;i++){ if(i > 0){ retVal.Append(" "); } retVal.Append(m_pFolderAttributes[i]); } } retVal.Append(") "); retVal.Append("\"" + m_Delimiter + "\" "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName,encoding)); retVal.Append("\r\n"); return retVal.ToString(); } }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) StringBuilder retVal = new StringBuilder(); retVal.Append("* STATUS"); retVal.Append(" " + IMAP_Utils.EncodeMailbox(m_FolderName,encoding)); retVal.Append(" ("); bool firstItem = true; if(m_MessageCount >= 0){ retVal.Append("MESSAGES " + m_MessageCount); firstItem = false; } if(m_RecentCount >= 0){ if(!firstItem){ retVal.Append(' '); } retVal.Append("RECENT " + m_RecentCount); firstItem = false; } if(m_UidNext >= 0){ if(!firstItem){ retVal.Append(' '); } retVal.Append("UIDNEXT " + m_UidNext); firstItem = false; } if(m_FolderUid >= 0){ if(!firstItem){ retVal.Append(' '); } retVal.Append("UIDVALIDITY " + m_FolderUid); firstItem = false; } if(m_UnseenCount >= 0){ if(!firstItem){ retVal.Append(' '); } retVal.Append("UNSEEN " + m_UnseenCount); firstItem = false; } retVal.Append(")\r\n"); return retVal.ToString(); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * ACL INBOX Fred rwipslda test rwipslda StringBuilder retVal = new StringBuilder(); retVal.Append("* ACL "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName,encoding)); foreach(IMAP_Acl_Entry e in m_pEntries){ retVal.Append(" \"" + e.Identifier + "\" \"" + e.Rights + "\""); } retVal.Append("\r\n"); return retVal.ToString(); }
private void ENABLE(string cmdTag,string cmdText) { /* RFC 5161 3.1. The ENABLE Command. Arguments: capability names Result: OK: Relevant capabilities enabled BAD: No arguments, or syntax error in an argument The ENABLE command takes a list of capability names, and requests the server to enable the named extensions. Once enabled using ENABLE, each extension remains active until the IMAP connection is closed. For each argument, the server does the following: - If the argument is not an extension known to the server, the server MUST ignore the argument. - If the argument is an extension known to the server, and it is not specifically permitted to be enabled using ENABLE, the server MUST ignore the argument. (Note that knowing about an extension doesn't necessarily imply supporting that extension.) - If the argument is an extension that is supported by the server and that needs to be enabled, the server MUST enable the extension for the duration of the connection. At present, this applies only to CONDSTORE ([RFC4551]). Note that once an extension is enabled, there is no way to disable it. If the ENABLE command is successful, the server MUST send an untagged ENABLED response (see Section 3.2). Clients SHOULD only include extensions that need to be enabled by the server. At the time of publication, CONDSTORE is the only such extension (i.e., ENABLE CONDSTORE is an additional "CONDSTORE enabling command" as defined in [RFC4551]). Future RFCs may add to this list. The ENABLE command is only valid in the authenticated state (see [RFC3501]), before any mailbox is selected. Clients MUST NOT issue ENABLE once they SELECT/EXAMINE a mailbox; however, server implementations don't have to check that no mailbox is selected or was previously selected during the duration of a connection. The ENABLE command can be issued multiple times in a session. It is additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a single command "ENABLE a b c". When multiple ENABLE commands are issued, each corresponding ENABLED response SHOULD only contain extensions enabled by the corresponding ENABLE command. There are no limitations on pipelining ENABLE. For example, it is possible to send ENABLE and then immediately SELECT, or a LOGIN immediately followed by ENABLE. The server MUST NOT change the CAPABILITY list as a result of executing ENABLE; i.e., a CAPABILITY command issued right after an ENABLE command MUST list the same capabilities as a CAPABILITY command issued before the ENABLE command. This is demonstrated in the following example: C: t1 CAPABILITY S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA S: t1 OK foo C: t2 ENABLE CONDSTORE X-GOOD-IDEA S: * ENABLED X-GOOD-IDEA S: t2 OK foo C: t3 CAPABILITY S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA S: t3 OK foo again In the following example, the client enables CONDSTORE: C: a1 ENABLE CONDSTORE S: * ENABLED CONDSTORE S: a1 OK Conditional Store enabled */ // Capability disabled. if(!SupportsCap("ENABLE")){ m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"NO","Command 'ENABLE' not supported.")); return; } if(!this.IsAuthenticated){ m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"NO","Authentication required.")); return; } if(string.IsNullOrEmpty(cmdText)){ m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"BAD","No arguments, or syntax error in an argument.")); return; } foreach(string capa in cmdText.Split(' ')){ if(string.Equals("UTF8=ACCEPT",capa,StringComparison.InvariantCultureIgnoreCase)){ m_MailboxEncoding = IMAP_Mailbox_Encoding.ImapUtf8; m_pResponseSender.SendResponseAsync(new IMAP_r_u_Enable(new string[]{"UTF8=ACCEPT"})); } // Ignore as specification says. //else{ //} } m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"OK","ENABLE command completed.")); }
/// <summary> /// Encodes mailbox name. /// </summary> /// <param name="mailbox">Mailbox name.</param> /// <param name="encoding">Mailbox name encoding mechanism.</param> /// <returns>Renturns encoded mailbox name.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>mailbox</b> is null reference.</exception> public static string EncodeMailbox(string mailbox,IMAP_Mailbox_Encoding encoding) { if(mailbox == null){ throw new ArgumentNullException("mailbox"); } /* RFC 6855 3. quoted = DQUOTE *uQUOTED-CHAR DQUOTE uQUOTED-CHAR = QUOTED-CHAR / UTF8-2 / UTF8-3 / UTF8-4 */ if(encoding == IMAP_Mailbox_Encoding.ImapUtf7){ return "\"" + IMAP_Utils.Encode_IMAP_UTF7_String(mailbox) + "\""; } else if(encoding == IMAP_Mailbox_Encoding.ImapUtf8){ return "\"" + mailbox + "\""; } else{ return "\"" + mailbox + "\""; } }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * LSUB (\Noselect) "/" ~/Mail/foo StringBuilder retVal = new StringBuilder(); retVal.Append("* LSUB ("); if(m_pFolderAttributes != null){ for(int i=0;i<m_pFolderAttributes.Length;i++){ if(i > 0){ retVal.Append(" "); } retVal.Append(m_pFolderAttributes[i]); } } retVal.Append(") "); retVal.Append("\"" + m_Delimiter + "\" "); retVal.Append(IMAP_Utils.EncodeMailbox(m_FolderName,encoding)); retVal.Append("\r\n"); return retVal.ToString(); }
/// <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> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public virtual string ToString(IMAP_Mailbox_Encoding encoding) { return ToString(); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public virtual string ToString(IMAP_Mailbox_Encoding encoding) { return(ToString()); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * LISTRIGHTS ~/Mail/saved smith la r swicdkxte StringBuilder retVal = new StringBuilder(); retVal.Append("* LISTRIGHTS " + IMAP_Utils.EncodeMailbox(m_FolderName,encoding) + " \"" + m_RequiredRights + "\" " + m_OptionalRights + "\r\n"); return retVal.ToString(); }
/// <summary> /// Returns this as string. /// </summary> /// <param name="encoding">Specifies how mailbox name is encoded.</param> /// <returns>Returns this as string.</returns> public override string ToString(IMAP_Mailbox_Encoding encoding) { // Example: S: * MYRIGHTS INBOX rwiptsldaex StringBuilder retVal = new StringBuilder(); retVal.Append("* MYRIGHTS " + IMAP_Utils.EncodeMailbox(m_FolderName,encoding) + " \"" + m_pRights + "\"\r\n"); return retVal.ToString(); }