001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle.
005 *
006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package pt.ua.dicoogle.core;
020
021import pt.ua.dicoogle.server.users.HashService;
022
023/**
024 *
025 * @author Samuel da Costa Campos <samuelcampos@ua.pt>
026 * @see XMLClientSupport
027 *
028 */
029public class ClientSettings {
030
031    private String tempFilesDir;
032    private String externalViewer;
033    private String defaultServerHost;
034    private int defaultServerPort;
035    private String defaultUserName;
036    private String defaultPassword;
037    private boolean autoConnect;
038    
039    private static ClientSettings instance = null;
040
041    public static synchronized ClientSettings getInstance()
042    {
043        if (instance == null) {
044            instance = new ClientSettings();
045        }
046        return instance;
047    }
048
049    private ClientSettings() {
050        tempFilesDir = "";
051        externalViewer = "";
052        defaultServerHost = "";
053        defaultServerPort = 0;
054        defaultUserName = "";
055        defaultPassword = "";
056    }
057
058    public void setDefaultSettings()
059    {
060        tempFilesDir = System.getProperty("java.io.tmpdir");
061        externalViewer = "";
062        defaultServerHost = "localhost";
063        defaultServerPort = 9014;
064        defaultUserName = "dicoogle";
065        defaultPassword = HashService.getSHA1Hash("dicoogle");
066    }
067
068    public void setExtV(String EV)
069    {
070        externalViewer = EV;
071    }
072
073    public String getExtV()
074    {
075        return externalViewer;
076    }
077
078    /**
079     * @return the defaultServerHost
080     */
081    public String getDefaultServerHost() {
082        return defaultServerHost;
083    }
084
085    /**
086     * @param defaultServerHost the defaultServerHost to set
087     */
088    public void setDefaultServerHost(String defaultServerHost) {
089        this.defaultServerHost = defaultServerHost;
090    }
091
092    /**
093     * @return the defaultServerPort
094     */
095    public int getDefaultServerPort() {
096        return defaultServerPort;
097    }
098
099    /**
100     * @param defaultServerPort the defaultServerPort to set
101     */
102    public void setDefaultServerPort(int defaultServerPort) {
103        this.defaultServerPort = defaultServerPort;
104    }
105
106    /**
107     * @return the tempFilesDir
108     */
109    public String getTempFilesDir() {
110        return tempFilesDir;
111    }
112
113    /**
114     * @param tempFilesDir the tempFilesDir to set
115     */
116    public void setTempFilesDir(String tempFilesPath) {
117        this.tempFilesDir = tempFilesPath;
118    }
119
120    /**
121     * @return the defaultUserName
122     */
123    public String getDefaultUserName() {
124        return defaultUserName;
125    }
126
127    /**
128     * @param defaultUserName the defaultUserName to set
129     */
130    public void setDefaultUserName(String defaultUserName) {
131        this.defaultUserName = defaultUserName;
132    }
133
134    /**
135     *
136     * @return the default password
137     */
138    public String getDefaultPassword(){
139       return defaultPassword;
140    }
141
142    /**
143     *
144     * @param passHash - new default password
145     */
146    public void setDefaultPassword(String passHash){
147        defaultPassword = passHash;
148    }
149
150    public boolean getAutoConnect(){
151        return autoConnect;
152    }
153
154    public void setAutoConnect(boolean value){
155        autoConnect = value;
156    }
157
158
159}