<commit_before>/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

/*
 * A representation of IMAP's UIDVALIDITY.
 *
 * See [[tools.ietf.org/html/rfc3501#section-2.3.1.1]]
 *
 * @see UID
 */

public class Geary.Imap.UIDValidity : Geary.MessageData.Int64MessageData, Geary.Imap.MessageData {
    /**
     * Minimum valid value for a {@link UIDValidity}.
     */
    public const int64 MIN = 1;
    
    /**
     * Maximum valid value for a {@link UIDValidity}.
     */
    public const int64 MAX = 0xFFFFFFFF;
    
    /**
     * Invalid (placeholder) {@link UIDValidity} value.
     */
    public const int64 INVALID = -1;
    
    /**
     * Creates a new {@link UIDValidity} without checking for valid values.
     *
     * @see UIDValidity.UIDValidity.checked
     */
    public UIDValidity(int64 value) {
        base (value);
    }
    
    /**
     * Creates a new {@link UIDValidity}, throwing {@link ImapError.INVALID} if the supplied value
     * is invalid.
     *
     * @see is_value_valid
     */
    public UIDValidity.checked(int64 value) throws ImapError {
        if (!is_value_valid(value))
            throw new ImapError.INVALID("Invalid UIDVALIDITY %s", value.to_string());
        
        base (value);
    }
    
    /**
     * @see is_value_valid
     */
    public bool is_valid() {
        return is_value_valid(value);
    }
    
    /**
     * Returns true if the supplied value is between {@link MIN} and {@link MAX}, inclusive.
     */
    public static bool is_value_valid(int64 val) {
        return Numeric.int64_in_range_inclusive(val, MIN, MAX);
    }
}

<commit_msg>Fix connecting to servers with invalidly high UIDVALIDITY values.<commit_after>/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

/*
 * A representation of IMAP's UIDVALIDITY.
 *
 * See [[tools.ietf.org/html/rfc3501#section-2.3.1.1]]
 *
 * @see UID
 */

public class Geary.Imap.UIDValidity : Geary.MessageData.Int64MessageData, Geary.Imap.MessageData {
    /**
     * Minimum valid value for a {@link UIDValidity}.
     */
    public const int64 MIN = 1;
    
    /**
     * Maximum valid value for a {@link UIDValidity}.
     *
     * This is currently larger than what the spec allows for, since
     * at least one mail server was returning values greater than an
     * unsigned 32-bit integer. See Bug 755424.
     */
    public const int64 MAX = 0xFFFFFFFFFFFFFFF;

    /**
     * Invalid (placeholder) {@link UIDValidity} value.
     */
    public const int64 INVALID = -1;
    
    /**
     * Creates a new {@link UIDValidity} without checking for valid values.
     *
     * @see UIDValidity.UIDValidity.checked
     */
    public UIDValidity(int64 value) {
        base (value);
    }
    
    /**
     * Creates a new {@link UIDValidity}, throwing {@link ImapError.INVALID} if the supplied value
     * is invalid.
     *
     * @see is_value_valid
     */
    public UIDValidity.checked(int64 value) throws ImapError {
        if (!is_value_valid(value))
            throw new ImapError.INVALID("Invalid UIDVALIDITY %s", value.to_string());
        
        base (value);
    }
    
    /**
     * @see is_value_valid
     */
    public bool is_valid() {
        return is_value_valid(value);
    }
    
    /**
     * Returns true if the supplied value is between {@link MIN} and {@link MAX}, inclusive.
     */
    public static bool is_value_valid(int64 val) {
        return Numeric.int64_in_range_inclusive(val, MIN, MAX);
    }
}


{'fraction_non_alphanumeric': 0.1051650692225772, 'fraction_numerical': 0.019701810436634718, 'mean_word_length': 2.357462019660411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359335', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1154, 'n_words': 346}