Beispiel #1
0
        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 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();
            }
        }