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 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.ui.preferences;
15
 
156 ilm 16
import org.openconcerto.utils.FileUtils;
17
 
18
import java.io.File;
19
import java.io.IOException;
20
 
17 ilm 21
public class EmailProps extends AbstractProps {
22
    public static final int DEFAULT = 0;
23
    public static final int THUNDERBIRD = 1;
24
    public static final int OUTLOOK = 2;
25
    protected static EmailProps instance;
41 ilm 26
    private String propsFileName = null;
156 ilm 27
    private static String DEFAULT_FILE = "./Configuration/Email.properties";
28
    private String defaultPropsFileName = DEFAULT_FILE;
17 ilm 29
 
30
    public synchronized static EmailProps getInstance() {
31
        if (instance == null) {
32
            instance = new EmailProps();
33
        }
34
        return instance;
35
    }
36
 
37
    @Override
38
    protected String getPropsFileName() {
41 ilm 39
        if (this.propsFileName == null) {
156 ilm 40
            return getDefaultPropsFileName();
41 ilm 41
        } else {
42
            return this.propsFileName;
43
        }
17 ilm 44
    }
45
 
156 ilm 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
 
41 ilm 58
    public void setPropsFileName(String propsFileName) {
59
        this.propsFileName = propsFileName;
156 ilm 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
        }
73 ilm 70
        load();
41 ilm 71
    }
72
 
17 ilm 73
    public String getThunderbirdPath() {
74
        final String stringProperty = this.getStringProperty("thunderbird.path");
75
        if (stringProperty.trim().length() == 0) {
76
            return "C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe";
77
        }
78
        return stringProperty;
79
    }
80
 
81
    public void setThunderbirdPath(String text) {
82
        this.setProperty("thunderbird.path", text);
83
    }
84
 
85
    public int getMode() {
86
        return this.getIntProperty("mode");
87
    }
88
 
89
    public void setMode(int mode) {
90
        this.setProperty("mode", String.valueOf(mode));
91
    }
92
 
93
    public void setTitle(String text) {
94
        this.setProperty("title", String.valueOf(text));
95
    }
96
 
97
    public String getTitle() {
98
        return this.getStringProperty("title");
99
    }
100
 
101
    public void setHeader(String text) {
102
        this.setProperty("header", String.valueOf(text));
103
    }
104
 
105
    public String getHeader() {
106
        return this.getStringProperty("header");
107
    }
108
 
109
    public void setFooter(String text) {
110
        this.setProperty("footer", String.valueOf(text));
111
    }
112
 
113
    public void setEncodingCharsetName(String charset) {
114
        this.setProperty("encoding", charset);
115
    }
116
 
117
    public String getFooter() {
118
        return this.getStringProperty("footer");
119
    }
120
 
121
    public String getEncodingCharsetName() {
122
        String charset = "UTF-8";
123
        String tmp = this.getStringProperty("encoding");
124
        if (tmp.trim().length() > 0) {
125
            charset = tmp;
126
        }
127
        return charset;
128
    }
129
 
130
    @Override
131
    protected int getDefautIntValue() {
132
        return DEFAULT;
133
    }
134
 
135
}