// Token: 0x06000017 RID: 23 RVA: 0x00002920 File Offset: 0x00000B20 internal void ResetAsUidStore(string newCommandId, string uid, ImapMailFlags flags, bool addFlags) { this.Reset(ImapCommandType.Store, newCommandId, delegate(ImapCommand cmd) { StringBuilder cachedStringBuilder = cmd.CachedStringBuilder; cachedStringBuilder.Length = 0; cachedStringBuilder.Append(cmd.CommandId); cachedStringBuilder.Append(" UID STORE "); cachedStringBuilder.Append((string)cmd.CommandParameters[0]); if (addFlags) { cachedStringBuilder.Append(" +FLAGS.SILENT "); } else { cachedStringBuilder.Append(" -FLAGS.SILENT "); } ImapUtilities.AppendStringBuilderImapFlags((ImapMailFlags)cmd.CommandParameters[1], cachedStringBuilder); cachedStringBuilder.Append("\r\n"); return(cachedStringBuilder.ToString()); }, new object[] { uid, flags }); }
// Token: 0x06000144 RID: 324 RVA: 0x00007280 File Offset: 0x00005480 private void OnEndConnectInternalReadResponse(IAsyncResult asyncResult) { AsyncResult <ImapConnectionContext, ImapResultData> asyncResult2 = null; ImapConnectionContext imapConnectionContext = null; lock (this.syncRoot) { if (!this.ShouldCancelCallback()) { base.CheckDisposed(); asyncResult2 = (AsyncResult <ImapConnectionContext, ImapResultData>)asyncResult.AsyncState; imapConnectionContext = asyncResult2.State; try { Socket socket = this.socket; socket.EndConnect(asyncResult); if (this.cancellationRequested) { this.HandleCancellation(asyncResult2); this.socket = null; return; } this.networkConnection = new NetworkConnection(this.socket, 4096); this.socket = null; this.networkConnection.Timeout = (this.connectionParameters.Timeout + 999) / 1000; this.Log.Debug("Connection Completed. Connection ID : {0}, Remote End Point {1}", new object[] { this.networkConnection.ConnectionId, this.networkConnection.RemoteEndPoint }); } catch (SocketException ex) { ImapUtilities.LogExceptionDetails(this.Log, "Failed to connect, SocketException", ex); this.socket = null; asyncResult2.ProcessCompleted(new ImapConnectionException(CXStrings.ImapSocketException, RetryPolicy.Backoff, ex)); return; } this.Log.Info(string.Format(CultureInfo.InvariantCulture, "Connect, from:{0} to:{1}", new object[] { this.serverParameters.Server, this.networkConnection.RemoteEndPoint }), new object[0]); switch (imapConnectionContext.ImapSecurityMechanism) { case ImapSecurityMechanism.None: case ImapSecurityMechanism.Tls: asyncResult2.PendingAsyncResult = this.BeginNetworkRead(asyncResult2, new AsyncCallback(this.OnReadAndDiscardLine)); break; case ImapSecurityMechanism.Ssl: asyncResult2.PendingAsyncResult = this.networkConnection.BeginNegotiateTlsAsClient(null, this.networkConnection.RemoteEndPoint.Address.ToString(), new AsyncCallback(this.OnEndConnectNegotiateTlsAsClientInternalReadResponse), asyncResult2); break; default: throw new InvalidOperationException("Unexpected security mechanism " + imapConnectionContext.ImapSecurityMechanism); } } } }
internal static string GetShortFolderName(ImapFolder folder, string fullFolderName) { string result; if (!string.IsNullOrEmpty(fullFolderName)) { char?c = (folder == null) ? new char?('/') : folder.Mailbox.Separator; if (c != null) { int num = fullFolderName.LastIndexOf(c.Value); if (num >= 0) { ImapUtilities.FromModifiedUTF7(fullFolderName.Substring(num + 1), out result); return(result); } } } ImapUtilities.FromModifiedUTF7(fullFolderName, out result); return(result); }
// Token: 0x06000118 RID: 280 RVA: 0x00006760 File Offset: 0x00004960 private static void AddDefaultMappings() { ImapMailbox.AddPreferredMapping(ImapUtilities.ToModifiedUTF7(CXStrings.ImapDeletedItems), ImapDefaultFolderType.DeletedItems); ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapDeletedMessages)] = ImapDefaultFolderType.DeletedItems; ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapTrash)] = ImapDefaultFolderType.DeletedItems; ImapMailbox.secondaryDefaultFolderMappings[ImapMailbox.InboxPrefix + ImapUtilities.ToModifiedUTF7(CXStrings.ImapTrash)] = ImapDefaultFolderType.DeletedItems; ImapMailbox.secondaryDefaultFolderMappings["[Gmail]/" + ImapUtilities.ToModifiedUTF7(CXStrings.ImapTrash)] = ImapDefaultFolderType.DeletedItems; ImapMailbox.AddPreferredMapping(ImapUtilities.ToModifiedUTF7(CXStrings.ImapDrafts), ImapDefaultFolderType.Drafts); ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapDraft)] = ImapDefaultFolderType.Drafts; ImapMailbox.secondaryDefaultFolderMappings[ImapMailbox.InboxPrefix + ImapUtilities.ToModifiedUTF7(CXStrings.ImapDrafts)] = ImapDefaultFolderType.Drafts; ImapMailbox.secondaryDefaultFolderMappings["[Gmail]/" + ImapUtilities.ToModifiedUTF7(CXStrings.ImapDrafts)] = ImapDefaultFolderType.Drafts; ImapMailbox.AddPreferredMapping(ImapUtilities.ToModifiedUTF7(CXStrings.ImapJunkEmail), ImapDefaultFolderType.JunkEmail); ImapMailbox.AddPreferredMapping("[Gmail]/" + ImapUtilities.ToModifiedUTF7(CXStrings.ImapSpam), ImapDefaultFolderType.JunkEmail); ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapSpam)] = ImapDefaultFolderType.JunkEmail; ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapJunk)] = ImapDefaultFolderType.JunkEmail; ImapMailbox.secondaryDefaultFolderMappings["[Gmail]/" + ImapUtilities.ToModifiedUTF7(CXStrings.ImapAllMail)] = ImapDefaultFolderType.JunkEmail; ImapMailbox.AddPreferredMapping(ImapUtilities.ToModifiedUTF7(CXStrings.ImapSentItems), ImapDefaultFolderType.SentItems); ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapSentMessages)] = ImapDefaultFolderType.SentItems; ImapMailbox.secondaryDefaultFolderMappings[ImapUtilities.ToModifiedUTF7(CXStrings.ImapSent)] = ImapDefaultFolderType.SentItems; ImapMailbox.secondaryDefaultFolderMappings[ImapMailbox.InboxPrefix + ImapUtilities.ToModifiedUTF7(CXStrings.ImapSentItems)] = ImapDefaultFolderType.SentItems; ImapMailbox.secondaryDefaultFolderMappings[ImapMailbox.InboxPrefix + ImapUtilities.ToModifiedUTF7(CXStrings.ImapSent)] = ImapDefaultFolderType.SentItems; ImapMailbox.secondaryDefaultFolderMappings["[Gmail]/" + ImapUtilities.ToModifiedUTF7(CXStrings.ImapSentMail)] = ImapDefaultFolderType.SentItems; }
// Token: 0x06000016 RID: 22 RVA: 0x00002824 File Offset: 0x00000A24 internal void ResetAsAppend(string newCommandId, string mailboxName, ImapMailFlags messageFlags, Stream messageBody) { this.Reset(ImapCommandType.Append, newCommandId, delegate(ImapCommand cmd) { string value = cmd.ConvertToQuotableString((string)cmd.CommandParameters[0]); StringBuilder cachedStringBuilder = cmd.CachedStringBuilder; cachedStringBuilder.Length = 0; cachedStringBuilder.Append(cmd.CommandId); cachedStringBuilder.Append(" APPEND \""); cachedStringBuilder.Append(value); cachedStringBuilder.Append("\" "); ImapUtilities.AppendStringBuilderImapFlags((ImapMailFlags)cmd.CommandParameters[1], cachedStringBuilder); cachedStringBuilder.Append(" {"); cachedStringBuilder.Append((long)cmd.CommandParameters[3]); cachedStringBuilder.Append("}\r\n"); return(cachedStringBuilder.ToString()); }, new object[] { mailboxName, messageFlags, messageBody, messageBody.Length }); }
// Token: 0x0600014A RID: 330 RVA: 0x00007AA4 File Offset: 0x00005CA4 private void OnReadMoreResponse(IAsyncResult asyncResult) { lock (this.syncRoot) { if (this.ShouldCancelCallback()) { NetworkConnection networkConnection = this.ExtractNetworkConnectionFrom(asyncResult); byte[] data; int offset; int num; object obj2; networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); } else { base.CheckDisposed(); AsyncResult <ImapConnectionContext, ImapResultData> asyncResult2 = (AsyncResult <ImapConnectionContext, ImapResultData>)asyncResult.AsyncState; ImapResponse imapResponse = this.currentResponse; byte[] data; int offset; int num; object obj2; this.networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); if (obj2 != null) { ImapNetworkFacade.HandleError(obj2, asyncResult2); } else if (this.cancellationRequested) { this.HandleCancellation(asyncResult2); } else { ExTraceGlobals.FaultInjectionTracer.TraceTest(2674273597U); this.totalBytesReceived += (long)num; DownloadCompleteEventArgs eventArgs = new DownloadCompleteEventArgs((long)num, 0L); asyncResult2.State.ActivatePerfDownloadEvent(asyncResult2.State, eventArgs); if (this.totalBytesReceived > this.connectionParameters.MaxBytesToTransfer) { ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesReceivedExceeded(), asyncResult2); } else { int num2 = imapResponse.AddData(data, offset, num); int num3 = num - num2; this.Log.Assert(num3 >= 0, "The unconsumed bytes must be non-negative.", new object[0]); if (num3 > 0) { this.networkConnection.PutBackReceivedBytes(num3); } if (imapResponse.IsComplete) { ImapNetworkFacade.CountCommand(asyncResult2, true); asyncResult2.State.Log.Debug("Command complete: [{0}]. Status = {1}", new object[] { this.currentCommand.ToPiiCleanString(), imapResponse.Status }); this.currentResultData.Status = imapResponse.Status; if (asyncResult.CompletedSynchronously) { asyncResult2.SetCompletedSynchronously(); } if (imapResponse.Status == ImapStatus.No || imapResponse.Status == ImapStatus.Bad || imapResponse.Status == ImapStatus.Bye) { this.LogFailureDetails(this.currentCommand, imapResponse); asyncResult2.ProcessCompleted(this.currentResultData); } else if (imapResponse.Status != ImapStatus.Ok) { this.LogFailureDetails(this.currentCommand, imapResponse); asyncResult2.ProcessCompleted(this.BuildAndLogUnknownCommandFailureException(asyncResult2.State)); } else { if (!imapResponse.TryParseIntoResult(this.currentCommand, ref this.currentResultData)) { if (this.currentResultData.FailureException == null) { if (this.currentResultData.MessageStream != null) { this.totalMessagesReceived += 1UL; } asyncResult2.ProcessCompleted(this.currentResultData, this.BuildAndLogUnknownParseFailureException(asyncResult2.State)); return; } ImapUtilities.LogExceptionDetails(asyncResult2.State.Log, this.currentCommand, this.currentResultData.FailureException); this.LogFailureDetails(this.currentCommand, this.currentResponse); } else { asyncResult2.State.Log.Debug("Parsed server response succesfully.", new object[0]); } asyncResult2.ProcessCompleted(this.currentResultData); } } else if (imapResponse.IsWaitingForLiteral) { Exception ex = null; Stream commandParameterStream = this.currentCommand.GetCommandParameterStream(this.serverParameters.Server, imapResponse.GetLastResponseLine(), out ex); if (ex != null) { if (commandParameterStream != null) { commandParameterStream.Close(); } ImapNetworkFacade.CountCommand(asyncResult2, false); asyncResult2.ProcessCompleted(ex); } else if (commandParameterStream == null) { ImapNetworkFacade.CountCommand(asyncResult2, false); asyncResult2.ProcessCompleted(this.BuildAndLogUnexpectedLiteralRequestException(asyncResult2.State)); } else { this.totalBytesSent += commandParameterStream.Length; if (this.totalBytesSent > this.connectionParameters.MaxBytesToTransfer) { ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesSentExceeded(), asyncResult2); } else { eventArgs = new DownloadCompleteEventArgs(0L, commandParameterStream.Length); asyncResult2.State.ActivatePerfDownloadEvent(asyncResult2.State, eventArgs); asyncResult2.State.Log.Debug("Begin writing literal stream.", new object[0]); asyncResult2.PendingAsyncResult = this.networkConnection.BeginWrite(commandParameterStream, new AsyncCallback(this.OnEndWriteLiteral), asyncResult2); } } } else if (imapResponse.TotalLiteralBytesExpected > 0 && this.totalBytesReceived + (long)imapResponse.LiteralBytesRemaining > this.connectionParameters.MaxBytesToTransfer) { this.totalBytesReceived += (long)imapResponse.LiteralBytesRemaining; ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesReceivedExceeded(), asyncResult2); } else { asyncResult2.PendingAsyncResult = this.BeginNetworkRead(asyncResult2, new AsyncCallback(this.OnReadMoreResponse)); } } } } } }