Beispiel #1
0
        private void SendMailCheckResponse(PUP p)
        {
            //
            // "Pup Contents: A string specifying the mailbox name."
            //

            //
            // See if there is any mail for the specified mailbox.
            //
            string mailboxName = Helpers.ArrayToString(p.Contents);

            //
            // If mailbox name has a host/registry appended, we will strip it off.
            // TODO: probably should validate host...
            //
            mailboxName = Authentication.GetUserNameFromFullName(mailboxName);

            IEnumerable <string> mailList = MailManager.EnumerateMail(mailboxName);

            if (mailList == null || mailList.Count() == 0)
            {
                PUPPort localPort   = new PUPPort(DirectoryServices.Instance.LocalHostAddress, p.DestinationPort.Socket);
                PUP     noMailReply = new PUP(PupType.NoNewMailExistsReply, p.ID, p.SourcePort, localPort, new byte[] { });

                Router.Instance.SendPup(noMailReply);
            }
            else
            {
                PUPPort localPort = new PUPPort(DirectoryServices.Instance.LocalHostAddress, p.DestinationPort.Socket);
                PUP     mailReply = new PUP(PupType.NewMailExistsReply, p.ID, p.SourcePort, localPort, Helpers.StringToArray("You've got mail!"));

                Router.Instance.SendPup(mailReply);
            }
        }