File Source: DefaultsComponent.java
/*
P/P * Method: com.dmdirc.updater.components.DefaultsComponent__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.updater.components;
24
25 import com.dmdirc.config.ConfigManager;
26 import com.dmdirc.config.IdentityManager;
27 import com.dmdirc.updater.UpdateComponent;
28 import com.dmdirc.updater.Version;
29 import com.dmdirc.util.resourcemanager.ZipResourceManager;
30
31 import java.io.File;
32 import java.io.IOException;
33
34 /**
35 * Represents the default identities.
36 *
37 * @author chris
38 */
/*
P/P * Method: void com.dmdirc.updater.components.DefaultsComponent()
*/
39 public class DefaultsComponent implements UpdateComponent {
40
41 /** {@inheritDoc} */
42 @Override
43 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* return_value == &"defaultsettings"
*/
44 return "defaultsettings";
45 }
46
47 /** {@inheritDoc} */
48 @Override
49 public String getFriendlyName() {
/*
P/P * Method: String getFriendlyName()
*
* Postconditions:
* return_value == &"Default settings"
*/
50 return "Default settings";
51 }
52
53 /** {@inheritDoc} */
54 @Override
55 public String getFriendlyVersion() {
/*
P/P * Method: String getFriendlyVersion()
*
* Postconditions:
* java.lang.String:valueOf(...)._tainted == 0
* return_value == &java.lang.String:valueOf(...)
*/
56 return String.valueOf(getVersion());
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public Version getVersion() {
/*
P/P * Method: Version getVersion()
*
* Presumptions:
* com.dmdirc.config.ConfigManager:getOption(...)@65 != null
* com.dmdirc.config.IdentityManager:getGlobalConfig(...)@62 != null
*
* Postconditions:
* return_value in Addr_Set{&new Version(getVersion#2),&new Version(getVersion#1)}
* new Version(getVersion#1) num objects <= 1
* init'ed(new Version(getVersion#1).intVersion)
* init'ed(new Version(getVersion#1).strVersion)
* new Version(getVersion#2) num objects <= 1
* new Version(getVersion#2).intVersion == -1
* new Version(getVersion#2).strVersion == null
*
* Test Vectors:
* com.dmdirc.config.ConfigManager:hasOptionString(...)@64: {0}, {1}
*/
62 final ConfigManager globalConfig = IdentityManager.getGlobalConfig();
63
64 if (globalConfig.hasOptionString("identity", "defaultsversion")) {
65 return new Version(globalConfig.getOption("identity", "defaultsversion"));
66 } else {
67 return new Version(-1);
68 }
69 }
70
71 /**
72 * {@inheritDoc}
73 *
74 * @throws java.io.IOException On i/o exception when reading zip file
75 */
76 @Override
77 public boolean doInstall(final String path) throws IOException {
/*
P/P * Method: bool doInstall(String)
*
* Postconditions:
* return_value == 0
*/
78 final ZipResourceManager ziprm = ZipResourceManager.getInstance(path);
79
80 ziprm.extractResources("", IdentityManager.getDirectory());
81
82 IdentityManager.loadUser();
83
84 new File(path).delete();
85
86 return false;
87 }
88
89 }
SofCheck Inspector Build Version : 2.17854
| DefaultsComponent.java |
2009-Jun-25 01:54:24 |
| DefaultsComponent.class |
2009-Sep-02 17:04:17 |