瀏覽代碼

Launcher update component and CL option. (backport)


git-svn-id: http://svn.dmdirc.com/branches/0.5.5@3060 00569f92-eb28-0410-84fd-f71c24880f
remotes/0.5.5
Gregory Holmes 16 年之前
父節點
當前提交
95799cef67

+ 13
- 1
src/com/dmdirc/commandline/CommandLineParser.java 查看文件

@@ -26,9 +26,10 @@ import com.dmdirc.util.InvalidAddressException;
26 26
 import com.dmdirc.util.IrcAddress;
27 27
 import com.dmdirc.Main;
28 28
 import com.dmdirc.config.IdentityManager;
29
+import com.dmdirc.updater.components.LauncherComponent;
29 30
 import com.dmdirc.util.resourcemanager.ResourceManager;
30
-import java.rmi.RemoteException;
31 31
 
32
+import java.rmi.RemoteException;
32 33
 import java.util.ArrayList;
33 34
 import java.util.List;
34 35
 
@@ -49,6 +50,7 @@ public class CommandLineParser {
49 50
         {'d', "directory", "Use the specified configuration directory", Boolean.TRUE},
50 51
         {'e', "existing", "Try to use an existing instance of DMDirc (use with -c)", Boolean.FALSE},
51 52
         {'h', "help", "Show command line options and exit", Boolean.FALSE},
53
+        {'l', "launcher", "Specifies the version of DMDirc's launcher", Boolean.TRUE},
52 54
         {'p', "portable", "Enable portable mode", Boolean.FALSE},
53 55
         {'r', "disable-reporting", "Disable automatic error reporting", Boolean.FALSE},
54 56
         {'v', "version", "Display client version and exit", Boolean.FALSE},
@@ -63,6 +65,9 @@ public class CommandLineParser {
63 65
     /** Whether or not to try and use an existing client. */
64 66
     private boolean useExisting = false;
65 67
     
68
+    /** The version string passed for the launcher. */
69
+    private String launcherVersion = "";
70
+    
66 71
     /**
67 72
      * Creates a new instance of CommandLineParser.
68 73
      *
@@ -194,6 +199,9 @@ public class CommandLineParser {
194 199
         case 'h':
195 200
             doHelp();
196 201
             break;
202
+        case 'l':
203
+            launcherVersion = param;
204
+            break;
197 205
         case 'p':
198 206
             doDirectory(ResourceManager.getCurrentWorkingDirectory());
199 207
             break;
@@ -312,6 +320,10 @@ public class CommandLineParser {
312 320
         if (disablereporting) {
313 321
             IdentityManager.getConfigIdentity().setOption("temp", "noerrorreporting", true);
314 322
         }
323
+        
324
+        if (!launcherVersion.isEmpty()) {
325
+            LauncherComponent.setLauncherInfo(launcherVersion);
326
+        }
315 327
     }
316 328
     
317 329
     /**

+ 81
- 0
src/com/dmdirc/updater/components/LauncherComponent.java 查看文件

@@ -0,0 +1,81 @@
1
+/*
2
+ * Copyright (c) 2006-2007 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.updater.UpdateChecker;
26
+import com.dmdirc.updater.UpdateComponent;
27
+
28
+/**
29
+ * Component for updates of DMDirc's launcher.
30
+ * 
31
+ * @author chris
32
+ */
33
+public class LauncherComponent implements UpdateComponent {
34
+    
35
+    /** The platform of our current launcher. */
36
+    private static String platform = "";
37
+    
38
+    /** The version of our current launcher. */
39
+    private static int version = -1;
40
+    
41
+    /**
42
+     * Parses the specified launcher information.
43
+     * 
44
+     * @param info The platform and version of the launcher, separated by '-'.
45
+     */
46
+    public static void setLauncherInfo(final String info) {
47
+        final int hpos = info.indexOf('-');
48
+        
49
+        if (hpos == -1) {
50
+            return;
51
+        }
52
+        
53
+        try {
54
+            platform = info.substring(0, hpos);
55
+            version = Integer.parseInt(info.substring(hpos + 1));
56
+        } catch (NumberFormatException ex) {
57
+            return;
58
+        }
59
+        
60
+        UpdateChecker.registerComponent(new LauncherComponent());
61
+    }
62
+
63
+    /** {@inheritDoc} */
64
+    @Override
65
+    public String getName() {
66
+        return "launcher-" + platform;
67
+    }
68
+
69
+    /** {@inheritDoc} */
70
+    @Override
71
+    public int getVersion() {
72
+        return version;
73
+    }
74
+
75
+    /** {@inheritDoc} */
76
+    @Override
77
+    public void doInstall(final String path) throws Throwable {
78
+        throw new UnsupportedOperationException("Not supported yet.");
79
+    }
80
+
81
+}

Loading…
取消
儲存