File Source: ClientComponent.java
/*
P/P * Method: com.dmdirc.updater.components.ClientComponent__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.Main;
26 import com.dmdirc.config.IdentityManager;
27 import com.dmdirc.updater.UpdateComponent;
28 import com.dmdirc.updater.Version;
29 import com.dmdirc.util.resourcemanager.DMDircResourceManager;
30
31 import java.io.File;
32
33 /**
34 * Represents the client component, which covers the core client resources.
35 *
36 * @author chris
37 */
/*
P/P * Method: void com.dmdirc.updater.components.ClientComponent()
*/
38 public class ClientComponent implements UpdateComponent {
39
40 /** {@inheritDoc} */
41 @Override
42 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* return_value == &"client"
*/
43 return "client";
44 }
45
46 /** {@inheritDoc} */
47 @Override
48 public String getFriendlyName() {
/*
P/P * Method: String getFriendlyName()
*
* Postconditions:
* return_value == &"DMDirc client"
*/
49 return "DMDirc client";
50 }
51
52 /** {@inheritDoc} */
53 @Override
54 public Version getVersion() {
/*
P/P * Method: Version getVersion()
*
* Presumptions:
* com.dmdirc.config.ConfigManager:getOption(...)@61 != null
*
* Postconditions:
* return_value == &new Version(getVersion#1)
* new Version(getVersion#1) num objects == 1
* init'ed(return_value.intVersion)
* init'ed(return_value.strVersion)
*/
55 return new Version(getFriendlyVersion());
56 }
57
58 /** {@inheritDoc} */
59 @Override
60 public String getFriendlyVersion() {
/*
P/P * Method: String getFriendlyVersion()
*
* Presumptions:
* com.dmdirc.config.IdentityManager:getGlobalConfig(...)@61 != null
*
* Postconditions:
* init'ed(return_value)
*/
61 return IdentityManager.getGlobalConfig().getOption("version", "version");
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public boolean doInstall(final String path) {
/*
P/P * Method: bool doInstall(String)
*
* Preconditions:
* init'ed(com/dmdirc/updater/components/LauncherComponent.version)
*
* Presumptions:
* com.dmdirc.Main:getUI(...)@98 != null
* init'ed(java.io.File.separator)
*
* Postconditions:
* return_value == 1
*
* Test Vectors:
* com/dmdirc/updater/components/LauncherComponent.version: {-231..-2, 0..232-1}, {-1}
* java.io.File:exists(...)@70: {0}, {1}
* java.lang.String:equals(...)@82: {0}, {1}
*/
67 final File tmpFile = new File(path);
68 final File targetFile = new File(tmpFile.getParent() + File.separator + ".DMDirc.jar");
69
70 if (targetFile.exists()) {
71 targetFile.delete();
72 }
73
74 tmpFile.renameTo(targetFile);
75
76 if (!LauncherComponent.isUsingLauncher()) {
77 final String message;
78 if (DMDircResourceManager.isRunningFromJar()) {
79 message = "A new version of DMDirc has been downloaded, but as you\n"
80 + "do not seem to be using the DMDirc launcher, it will\n"
81 + "not be installed automatically.\n\n"
82 + "To install this update manually, please replace the\n"
83 + "existing DMDirc.jar file, located at:\n"
84 + " " + DMDircResourceManager.getCurrentWorkingDirectory() + "\n"
85 + "with the following file:\n"
86 + " " + targetFile.getAbsolutePath();
87 } else {
88 message = "A new version of DMDirc has been downloaded, but as you\n"
89 + "do not seem to be using the DMDirc launcher, it will\n"
90 + "not be installed automatically.\n\n"
91 + "To install this update manually, please extract the\n"
92 + "new DMDirc.jar file, located at:\n"
93 + " " + targetFile.getAbsolutePath() + "\n"
94 + "over your existing DMDirc install located in:\n"
95 + " " + DMDircResourceManager.getCurrentWorkingDirectory();
96 }
97
98 Main.getUI().showMessageDialog("Client update downloaded", message);
99 }
100
101 return true;
102 }
103
104 }
SofCheck Inspector Build Version : 2.17854
| ClientComponent.java |
2009-Jun-25 01:54:24 |
| ClientComponent.class |
2009-Sep-02 17:04:17 |