package be.iminds.ilabt.jfed.preferences;

import be.iminds.ilabt.jfed.util.OSDetector;

/**
* GuiPreferenceKey
*/
public enum GuiPreferenceKey implements JFedPreferences.PreferenceKey {
    /**
     * Command to start a Unix/Mac terminal
     */
    PREF_COMMAND_UNIX_TERMINAL("command.unix-terminal", OSDetector.getUnixLikeOsFilter()),
    /**
     * The SSH command WITHOUT proxy to be used in a terminal
     */
    PREF_COMMAND_SSH("command.ssh", OSDetector.getUnixLikeOsFilter()),
    /**
     * The SSH command WITH proxy to be used in a terminal
     */
    PREF_COMMAND_SSH_PROXY("command.ssh-proxy", OSDetector.getUnixLikeOsFilter()),
    /**
     * Choose SSH command automatically
     */
    PREF_COMMAND_SSH_AUTO("command.ssh-proxy-auto"),

    /**
     * Directory of PuTTY-installation
     */
    PREF_PUTTY_DIRECTORY("putty.dir", new OSDetector.OneOsFilter(OSDetector.OS.WIN)),
    /**
     * Whether X11-forwarding on windows must be activated (Windows only)
     */
    PREF_PUTTY_X11_FORWARD("putty.x11forward", new OSDetector.OneOsFilter(OSDetector.OS.WIN)),
    /**
     * Whether ssh-gent forwarding on windows must be activated (Windows only)
     */
    PREF_PUTTY_AGENT_FORWARD("putty.agentforward", new OSDetector.OneOsFilter(OSDetector.OS.WIN)),

    /**
     * Is SSH-agent enabled? (Unix/Mac only, use @link{PREF_PUTTY_PAGEANT} for Windows)
     */
    PREF_SSHAGENT_USE("sshagent.use"),
    PREF_SHOW_MAC_TERMINAL_WARNING("show-mac-terminal-warning"),

    PREF_TERMINAL_DEBUG("terminal.debug"),
    PREF_TERMINAL_KEEP_TMP_FILES("terminal.keep-tmp-files"),

    //SSH keys. If not specified, keys from "user login file" (that are also used for SSL) are used.
    //These keys are only used for SSH, never for SSL (login file is used for that)
    //on windows, the SSH keypair needs to be in putty format! (ppk)
    PREF_SSH_USE_LOGIN_KEY("sshkeys.use_login_key"),
    PREF_SSH_USE_CUSTOM_KEY("sshkeys.use_custom_key"),
    PREF_SSH_PRIVATE_KEY_FILE("sshkeys.private_key.file"),
    PREF_SSH_PUBLIC_KEY_FILE("sshkeys.public_key.file"),
    PREF_SSH_PUTTY_KEY_FILE("sshkeys.putty_key.file"), //putty key file takes precedence over other files and text, on windows
    PREF_SSH_PRIVATE_KEY("sshkeys.private_key.text"),
    PREF_SSH_PUBLIC_KEY("sshkeys.public_key.text"),

    PREF_FIRSTRUN_VERSION("firstrunversion"), //a number.

    PREF_RSPECFOLDER_REQUEST("files.rspec_folder"),
    PREF_RSPECFOLDER_MANIFEST("files.manifest_rspec_folder"),

    PREF_SHOW_SLICE_INITIALIZATION_DIALOG("slice.show_init_dialog"),
    PREF_SHOW_CONNECTIVITY_WARNING_DIALOG("slice.show_connectivity_warning_dialog"),
    PREF_SHOW_DOUBLE_PROXY_WARNING_DIALOG("slice.show_double_proxy_warning_dialog"),
    PREF_SHOW_CLOSE_TAB_WARNING_DIALOG("slice.show_close_tab_warning_dialog"),

    PREF_IS_DEMO("is_demo"),

    PREF_EXPIRATION_WARNING_ENABLED("expiration_warning.enabled"),
    PREF_EXPIRATION_WARNING_TIME("expiration_warning.time"),

    PREF_RECOVER_EXPIRATION_WARNING_ENABLED("expiration_warning.recover.enabled"),
    PREF_RECOVER_EXPIRATION_WARNING_TIME("expiration_warning.recover.time"),

    PREF_ADD_PROJECT_MEMBERS_SSH_KEYS("experiment.default_add_project_members_ssh_keys"),


    PREF_GENI_LOGIN_COOKIE("cookies.geni_login"),

    ;

    final String key;
    final OSDetector.OSFilter osFilter;

    GuiPreferenceKey(String key) {
        this.key = key;
        this.osFilter = null;
    }

    GuiPreferenceKey(String key, OSDetector.OSFilter osFilter) {
        this.key = key;
        this.osFilter = osFilter;
    }

    @Override
    public String toString() {
        return key;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public boolean isOSSpecific() {
        return osFilter != null;
    }

    @Override
    public OSDetector.OSFilter getOSFilter() {
        return osFilter;
    }
}
