internal override bool ParseResponse(string Response)
        {
            Response = Response.Remove(Response.Length - MultilineTerminator.Length);
            string[] Lines     = Response.Split(new string[] { EOL }, StringSplitOptions.None);
            int      LineCount = Lines.Length;

            if (LineCount == 0)
            {
                return(false);
            }
            if (!Lines[0].StartsWith(OK))
            {
                return(false);
            }

            MailMessage CurrentMsg = CurrentDir.GetMessage(CurrentUid);

            if (CurrentMsg == null)
            {
                return(false);
            }
            if (CurrentMsg.PopReceived)
            {
                return(true);
            }

            for (int i = 1; i < LineCount; ++i)
            {
                CurrentMsg.Message += Lines[i] + EOL;
            }
            CurrentMsg.PopReceived = true;
            CurrentMsg.OnMessageUpdated(CurrentMsg, new EventArgs());
            return(true);
        }
예제 #2
0
        private void ListboxMessages_SelectedMessage(object sender, EventArgs e)
        {
            if (ListboxMessages.SelectedIndex == -1)
            {
                return;
            }
            string      Uid     = ListboxMessages.Items[ListboxMessages.SelectedIndex].ToString();
            MailMessage Message = Inbox.GetMessage(Uid);

            if (Message == null)
            {
                MessageBox.Show("internal error while reading message from memory");
                return;
            }

            MessageBox.Show(Message.Message);
        }
        internal override bool ParseResponse(string Response)
        {
            Response = Response.Remove(Response.Length - MultilineTerminator.Length);
            string[] Lines     = Response.Split(new string[] { EOL }, StringSplitOptions.None);
            int      LineCount = Lines.Length;

            if (!Lines[0].StartsWith(OK))
            {
                return(false);
            }
            for (int i = 1; i < LineCount; ++i)
            {
                string[] Verbs = Lines[i].Split(new string[] { Whitespace }, StringSplitOptions.None);
                int      It    = 0;

                //Poczta WP odsyła dwie okejki, więc spradzam czy pominąć linijkę
                if (!int.TryParse(Verbs[0], out It))
                {
                    continue;
                }
                string Uid = Verbs[1];

                //szukam wiadomości w folderze, pomijam dodanie jej
                //do listy ściąganych jeśli już istnieje i jest pobrana
                MailMessage Msg = CurrentDir.GetMessage(Uid);
                if (Msg == null)
                {
                    Msg = new MailMessage();
                    CurrentDir.AddMessage(Uid, Msg);
                }

                Msg.PopUid = Uid;
                if (!Msg.PopReceived)
                {
                    NewMessages[It] = Uid;
                }
            }

            OnNewMessagesReceived(NewMessages);
            return(true);
        }