
import * as path from "path";
import { IMAPFolderInfoNativeBinding } from "../types";
import { NodeTrustedMailcore2NativeBinding } from '../types/NodeTrustedMailcore2NativeBinding'

// tslint:disable-next-line: no-var-requires
let bindings: NodeTrustedMailcore2NativeBinding;
try {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2.node"));
} catch(e) {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2_no_crypto.node"));
}

// tslint:disable-next-line
const { IMAPFolderInfo: _IMAPFolderInfo } = bindings

/**
 * IMAPFolderInfo Class
 *
 * @public
 */
class IMAPFolderInfo extends bindings.IMAPFolderInfo {
    protected handle: IMAPFolderInfoNativeBinding

    constructor() {
        super()

        const handle = new _IMAPFolderInfo();
        this.handle = handle;
    }

    /**
     * Get uidNext
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get uidNext(): number {
        return this.handle.uidNext;
    }

    /**
     * Set uidNext
     *
     * @memberof IMAPFolderInfo
     */
    set uidNext(uid: number) {
        this.handle.uidNext = uid;
    }

    /**
     * Get uidValidity
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get uidValidity(): number {
        return this.handle.uidValidity;
    }

    /**
     * Set uidValidity
     *
     * @memberof IMAPFolderInfo
     */
    set uidValidity(uid: number) {
        this.handle.uidValidity = uid;
    }

    /**
     * Get modSequenceValue
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get modSequenceValue(): number {
        return this.handle.modSequenceValue;
    }

    /**
     * Set modSequenceValue
     *
     * @memberof IMAPFolderInfo
     */
    set modSequenceValue(mod: number) {
        this.handle.modSequenceValue = mod;
    }

    /**
     * Get messageCount
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get messageCount(): number {
        return this.handle.messageCount;
    }

    /**
     * Set messageCount
     *
     * @memberof IMAPFolderInfo
     */
    set messageCount(count: number) {
        this.handle.messageCount = count;
    }

    /**
     * Get firstUnseenUid
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get firstUnseenUid(): number {
        return this.handle.firstUnseenUid;
    }

    /**
     * Set firstUnseenUid
     *
     * @memberof IMAPFolderInfo
     */
    set firstUnseenUid(uid: number) {
        this.handle.firstUnseenUid = uid;
    }

    /**
     * Get allowsNewPermanentFlags
     *
     * @type {number}
     * @memberof IMAPFolderInfo
     */
    get allowsNewPermanentFlags(): boolean {
        return this.handle.allowsNewPermanentFlags;
    }

    /**
     * Set allowsNewPermanentFlags
     *
     * @memberof IMAPFolderInfo
     */
    set allowsNewPermanentFlags(allow: boolean) {
        this.handle.allowsNewPermanentFlags = allow;
    }
}

export { IMAPFolderInfo }
