internal void ReceiveIdleStatusUpdates(ImapResponseReader reader) { reader.ReadNextLine(); if (reader.IsCompleted) { return; } StopIdleAsync(); var e = new StatusUpdateReceivedEventArgs(SelectedMailbox) { IsIdleUpdate = true }; while (true) { if (reader.IsCompleted) { InvokeStatusUpdateReceived(e); break; } if (reader.IsStatusUpdate) { e.MailboxInfo.InjectLine(reader.CurrentLine); } // We must check seperately for FETCH updates since we cannot include them into regular status update checks. // If included they would be processed as a status update and not as a FETCH response, thus corrupting the stack. // We can only check for this kind of update inside the IDLE loop, since we know here that no previous FETCH command has been issued and // it is therefor safe to process a FETCH update response. if (reader.CurrentLine.Contains("FETCH")) { if (e.MailboxInfo.MessageStateChanges == null) { e.MailboxInfo.MessageStateChanges = new List <MessageState>(); } var state = new MessageState(); state.InjectLine(reader.CurrentLine); ((IList <MessageState>)e.MailboxInfo.MessageStateChanges).Add(state); } reader.ReadNextLine(); } if (!e.IsIdleCancelled) { StartIdle(); } }
internal void CheckForStatusUpdates(ImapResponseReader reader) { StatusUpdateReceivedEventArgs e = null; while (true) { if (!reader.IsStatusUpdate) { break; } if (e == null) { e = new StatusUpdateReceivedEventArgs(SelectedMailbox); } e.MailboxInfo.InjectLine(reader.CurrentLine); reader.ReadNextLine(); continue; } if (e != null) { InvokeStatusUpdateReceived(e); } }
/// <summary> /// Receives a response from the server. /// </summary> /// <returns>Returns a response reader.</returns> public ImapResponseReader Receive(bool processStatusUpdatesAutomatically = true) { var reader = new ImapResponseReader(this); reader.ReadNextLine(); if (processStatusUpdatesAutomatically) { CheckForStatusUpdates(reader); } return(reader); }
public static ImapServerCapability ReadCapabilities(this ImapResponseReader response) { var cap = new ImapServerCapability(); while (true) { var values = response.CurrentLine.Split(Characters.Space); foreach (var value in values.Where(value => value != "*" && value != CommandStrings.Capability)) { cap.Store(value); } response.ReadNextLine(); if (response.IsCompleted) { break; } } return(cap); }
internal void ReceiveIdleStatusUpdates(ImapResponseReader reader) { reader.ReadNextLine(); if (reader.IsCompleted) { return; } StopIdleAsync(); var e = new StatusUpdateReceivedEventArgs(SelectedMailbox) {IsIdleUpdate = true}; while (true) { if (reader.IsCompleted) { InvokeStatusUpdateReceived(e); break; } if (reader.IsStatusUpdate) { e.MailboxInfo.InjectLine(reader.CurrentLine); } // We must check seperately for FETCH updates since we cannot include them into regular status update checks. // If included they would be processed as a status update and not as a FETCH response, thus corrupting the stack. // We can only check for this kind of update inside the IDLE loop, since we know here that no previous FETCH command has been issued and // it is therefor safe to process a FETCH update response. if (reader.CurrentLine.Contains("FETCH")) { if (e.MailboxInfo.MessageStateChanges == null) { e.MailboxInfo.MessageStateChanges = new List<MessageState>(); } var state = new MessageState(); state.InjectLine(reader.CurrentLine); ((IList<MessageState>) e.MailboxInfo.MessageStateChanges).Add(state); } reader.ReadNextLine(); } if (!e.IsIdleCancelled) { StartIdle(); } }
/// <summary> /// Receives a response from the server. /// </summary> /// <returns>Returns a response reader.</returns> public ImapResponseReader Receive(bool processStatusUpdatesAutomatically = true) { var reader = new ImapResponseReader(this); reader.ReadNextLine(); if (processStatusUpdatesAutomatically) { CheckForStatusUpdates(reader); } return reader; }