OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 73 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 73 Rev 156
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.ui.preferences;
14
 package org.openconcerto.ui.preferences;
15
 
15
 
-
 
16
import org.openconcerto.utils.FileUtils;
-
 
17
 
-
 
18
import java.io.File;
-
 
19
import java.io.IOException;
-
 
20
 
16
public class EmailProps extends AbstractProps {
21
public class EmailProps extends AbstractProps {
17
    public static final int DEFAULT = 0;
22
    public static final int DEFAULT = 0;
18
    public static final int THUNDERBIRD = 1;
23
    public static final int THUNDERBIRD = 1;
19
    public static final int OUTLOOK = 2;
24
    public static final int OUTLOOK = 2;
20
    protected static EmailProps instance;
25
    protected static EmailProps instance;
21
    private String propsFileName = null;
26
    private String propsFileName = null;
-
 
27
    private static String DEFAULT_FILE = "./Configuration/Email.properties";
-
 
28
    private String defaultPropsFileName = DEFAULT_FILE;
22
 
29
 
23
    public synchronized static EmailProps getInstance() {
30
    public synchronized static EmailProps getInstance() {
24
        if (instance == null) {
31
        if (instance == null) {
25
            instance = new EmailProps();
32
            instance = new EmailProps();
26
        }
33
        }
Line 28... Line 35...
28
    }
35
    }
29
 
36
 
30
    @Override
37
    @Override
31
    protected String getPropsFileName() {
38
    protected String getPropsFileName() {
32
        if (this.propsFileName == null) {
39
        if (this.propsFileName == null) {
33
            return "./Configuration/Email.properties";
40
            return getDefaultPropsFileName();
34
        } else {
41
        } else {
35
            return this.propsFileName;
42
            return this.propsFileName;
36
        }
43
        }
37
    }
44
    }
38
 
45
 
-
 
46
    public void setDefaultPropsFileName(String defaultPropsFileName) {
-
 
47
        this.defaultPropsFileName = defaultPropsFileName;
-
 
48
    }
-
 
49
 
-
 
50
    protected String getDefaultPropsFileName() {
-
 
51
        if (this.defaultPropsFileName == null) {
-
 
52
            return DEFAULT_FILE;
-
 
53
        } else {
-
 
54
            return defaultPropsFileName;
-
 
55
        }
-
 
56
    }
-
 
57
 
39
    public void setPropsFileName(String propsFileName) {
58
    public void setPropsFileName(String propsFileName) {
40
        this.propsFileName = propsFileName;
59
        this.propsFileName = propsFileName;
-
 
60
        final File file = new File(getPropsFileName());
-
 
61
        final File fileDefault = new File(getDefaultPropsFileName());
-
 
62
        if (!file.exists() && fileDefault.exists()) {
-
 
63
            try {
-
 
64
                FileUtils.copyFile(fileDefault, file);
-
 
65
            } catch (IOException e) {
-
 
66
                // TODO Auto-generated catch block
-
 
67
                e.printStackTrace();
-
 
68
            }
-
 
69
        }
41
        load();
70
        load();
42
    }
71
    }
43
 
72
 
44
    public String getThunderbirdPath() {
73
    public String getThunderbirdPath() {
45
        final String stringProperty = this.getStringProperty("thunderbird.path");
74
        final String stringProperty = this.getStringProperty("thunderbird.path");