Пример #1
0
        public static bool ValidatePopSettings(bool leaveOnServer, bool mirrored, string host, int port, string username, SecureString password, Pop3AuthenticationMechanism authentication, Pop3SecurityMechanism security, string userLegacyDN, ILog log, out LocalizedException validationException)
        {
            validationException = null;
            bool result2;

            using (IPop3Connection pop3Connection = Pop3Connection.CreateInstance(null))
            {
                Pop3ResultData result = pop3Connection.VerifyAccount();
                if (mirrored && !Pop3AutoProvision.SupportsMirroredSubscription(result))
                {
                    validationException = new Pop3MirroredAccountNotPossibleException();
                    result2             = false;
                }
                else if (leaveOnServer && !Pop3AutoProvision.SupportsLeaveOnServer(result))
                {
                    validationException = new Pop3LeaveOnServerNotPossibleException();
                    result2             = false;
                }
                else
                {
                    result2 = true;
                }
            }
            return(result2);
        }
Пример #2
0
        internal Exception TryParseUIDLResponse(Pop3ResultData pop3ResultData)
        {
            if (this.listings == null || this.listings.Count != pop3ResultData.EmailDropCount)
            {
                return(new FormatException("'uidl listing' must match the number of emails."));
            }
            pop3ResultData.AllocateUniqueIds();
            List <int> list = null;

            for (int i = 0; i < this.listings.Count; i++)
            {
                string[] array = this.listings[i].Split(Pop3Response.wordDelimiters, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length < 2)
                {
                    return(new FormatException("'uidl listing' must have at least 2 words"));
                }
                int num;
                if (!int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
                {
                    return(new FormatException("'id' must be a number."));
                }
                if (num <= 0)
                {
                    return(new FormatException("'id' must be greater than zero."));
                }
                if (num <= pop3ResultData.EmailDropCount)
                {
                    string text = array[1];
                    if (!string.IsNullOrEmpty(text))
                    {
                        if (!pop3ResultData.HasUniqueId(num))
                        {
                            pop3ResultData.SetUniqueId(num, text);
                        }
                        else
                        {
                            if (list == null)
                            {
                                list = new List <int>();
                            }
                            list.Add(num);
                        }
                    }
                }
            }
            if (list != null)
            {
                foreach (int id in list)
                {
                    pop3ResultData.SetUniqueId(id, null);
                }
            }
            return(null);
        }
Пример #3
0
 internal Exception TryParseLISTResponse(Pop3ResultData pop3ResultData)
 {
     if (this.listings == null || this.listings.Count != pop3ResultData.EmailDropCount)
     {
         return(new FormatException("'scan listing' must match the number of emails."));
     }
     pop3ResultData.AllocateEmailSizes();
     for (int i = 0; i < this.listings.Count; i++)
     {
         string[] array = this.listings[i].Split(Pop3Response.wordDelimiters, StringSplitOptions.RemoveEmptyEntries);
         if (array.Length < 2)
         {
             return(new FormatException("'scan listing' must have at least 2 words"));
         }
         int num;
         if (!int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
         {
             return(new FormatException("'id' must be a number."));
         }
         long num2;
         if (!long.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out num2))
         {
             return(new FormatException("'size' must be a number."));
         }
         if (num <= 0)
         {
             return(new FormatException("'id' must be greater than zero."));
         }
         if (num2 < 0L)
         {
             return(new FormatException("'size' must be non-negative."));
         }
         if (num <= pop3ResultData.EmailDropCount)
         {
             pop3ResultData.SetEmailSize(num, num2);
         }
     }
     return(null);
 }
Пример #4
0
 private static bool SupportsMirroredSubscription(Pop3ResultData result)
 {
     return(result.RetentionDays == null || !(result.RetentionDays != int.MaxValue));
 }
Пример #5
0
 private static bool SupportsLeaveOnServer(Pop3ResultData result)
 {
     return(result.UidlCommandSupported && (result.RetentionDays == null || result.RetentionDays.Value > 0));
 }