Просмотр исходного кода

Fixes issue 3778: Addon browser should support nightly channel

Change-Id: I6779f22d28316190e043c2a12757cc8004f8a3d1
Reviewed-on: http://gerrit.dmdirc.com/895
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.4
Gregory Holmes 14 лет назад
Родитель
Сommit
79b235be87

+ 16
- 3
src/com/dmdirc/addons/ui_swing/components/addonbrowser/AddonInfo.java Просмотреть файл

@@ -39,6 +39,7 @@ public class AddonInfo {
39 39
     private final int id;
40 40
     private final String stableDownload;
41 41
     private final String unstableDownload;
42
+    private final String nightlyDownload;
42 43
     private final String title;
43 44
     private final String author;
44 45
     private final int rating;
@@ -61,8 +62,9 @@ public class AddonInfo {
61 62
         this.type = entry.get("type").equals("plugin") ?
62 63
             AddonType.TYPE_PLUGIN : entry.get("type").equals("theme") ?
63 64
                 AddonType.TYPE_THEME : AddonType.TYPE_ACTION_PACK;
64
-        this.stableDownload = entry.get("stable");
65
-        this.unstableDownload = entry.get("unstable");
65
+        this.stableDownload = entry.containsKey("stable") ? entry.get("stable") : "";
66
+        this.unstableDownload = entry.containsKey("unstable") ? entry.get("unstable") : "";
67
+        this.nightlyDownload = entry.containsKey("nightly") ? entry.get("nightly") : "";
66 68
         this.description = entry.get("description");
67 69
         this.verified = entry.get("verified").equals("yes");
68 70
         this.date = Integer.parseInt(entry.get("date"));
@@ -158,6 +160,15 @@ public class AddonInfo {
158 160
         return unstableDownload;
159 161
     }
160 162
 
163
+    /**
164
+     * Returns the nightly download location.
165
+     *
166
+     * @return Nightly download location
167
+     */
168
+    public String getNightlyDownload() {
169
+        return nightlyDownload;
170
+    }
171
+
161 172
     /**
162 173
      * Returns whether the addon is verified.
163 174
      *
@@ -201,8 +212,10 @@ public class AddonInfo {
201 212
                 getOption("updater", "channel");
202 213
         if ("STABLE".equals(channel)) {
203 214
             return !stableDownload.isEmpty();
204
-        } else {
215
+        } else if ("UNSTABLE".equals(channel)) {
205 216
             return !unstableDownload.isEmpty();
217
+        } else {
218
+            return !nightlyDownload.isEmpty();
206 219
         }
207 220
     }
208 221
 

+ 7
- 3
src/com/dmdirc/addons/ui_swing/components/addonbrowser/InstallListener.java Просмотреть файл

@@ -78,13 +78,17 @@ public class InstallListener implements ActionListener {
78 78
             final File file = File.createTempFile("dmdirc-addon", ".tmp");
79 79
             file.deleteOnExit();
80 80
 
81
-            if ("STABLE".equals(IdentityManager.getGlobalConfig().getOption(
82
-                    "updater", "channel"))) {
81
+            final String channel = IdentityManager.getGlobalConfig().getOption(
82
+                    "updater", "channel");
83
+            if ("STABLE".equals(channel)) {
83 84
                 Downloader.downloadPage("http://addons.dmdirc.com/addondownload/"
84 85
                         + info.getStableDownload(), file.getAbsolutePath());
85
-            } else {
86
+            } else if ("UNSTABLE".equals(channel)) {
86 87
                 Downloader.downloadPage("http://addons.dmdirc.com/addondownload/"
87 88
                         + info.getUnstableDownload(), file.getAbsolutePath());
89
+            } else {
90
+                Downloader.downloadPage("http://addons.dmdirc.com/addondownload/"
91
+                        + info.getNightlyDownload(), file.getAbsolutePath());
88 92
             }
89 93
 
90 94
             switch (info.getType()) {

Загрузка…
Отмена
Сохранить