01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.core.config;
18:
19: import java.io.File;
20:
21: import org.columba.core.xml.XmlElement;
22:
23: public class OptionsXmlConfig extends DefaultXmlConfig {
24:
25: private GuiItem guiItem;
26:
27: private static final String OPTIONS_PROXY = "/options/proxy"; //$NON-NLS-1$
28:
29: private static final String OPTIONS_GUI = "/options/gui"; //$NON-NLS-1$
30:
31: private static final String HTTP_PROXYHOST = "http.proxyHost"; //$NON-NLS-1$
32:
33: private static final String HTTP_PROXYPORT = "http.proxyPort"; //$NON-NLS-1$
34:
35: private static final String PROXY_HOST = "host"; //$NON-NLS-1$
36:
37: private static final String PROXY_PORT = "port"; //$NON-NLS-1$
38:
39: public OptionsXmlConfig(final File file) {
40: super (file);
41: }
42:
43: @Override
44: public boolean load() {
45: final boolean result = super .load();
46:
47: final XmlElement proxy = getRoot().getElement(OPTIONS_PROXY);
48: if ((proxy != null)
49: && (System.getProperty(HTTP_PROXYHOST) != null)) {
50: System.setProperty(HTTP_PROXYHOST, proxy
51: .getAttribute(PROXY_HOST));
52: System.setProperty(HTTP_PROXYPORT, proxy
53: .getAttribute(PROXY_PORT));
54: }
55:
56: return result;
57: }
58:
59: public GuiItem getGuiItem() {
60: if (guiItem == null) {
61: guiItem = new GuiItem(getRoot().getElement(OPTIONS_GUI));
62: }
63:
64: return guiItem;
65: }
66: }
|