Ver código fonte

Issue 0001341

Installing action packs now works

git-svn-id: http://svn.dmdirc.com/trunk@4612 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6.3m1rc1
Chris Smith 16 anos atrás
pai
commit
bf997af9ce

+ 26
- 4
src/com/dmdirc/addons/addonbrowser/InstallListener.java Ver arquivo

@@ -22,11 +22,15 @@
22 22
 
23 23
 package com.dmdirc.addons.addonbrowser;
24 24
 
25
+import com.dmdirc.actions.ActionManager;
26
+import com.dmdirc.logger.ErrorLevel;
27
+import com.dmdirc.logger.Logger;
25 28
 import com.dmdirc.util.Downloader;
26 29
 
27 30
 import java.awt.event.ActionEvent;
28 31
 import java.awt.event.ActionListener;
29 32
 
33
+import java.io.File;
30 34
 import java.io.IOException;
31 35
 
32 36
 /**
@@ -35,7 +39,7 @@ import java.io.IOException;
35 39
 public class InstallListener implements ActionListener {
36 40
 
37 41
     /** Addon info. */
38
-    private AddonInfo info;
42
+    private final AddonInfo info;
39 43
 
40 44
     /**
41 45
      * Instantiates a new install listener.
@@ -53,9 +57,27 @@ public class InstallListener implements ActionListener {
53 57
      */
54 58
     @Override
55 59
     public void actionPerformed(final ActionEvent e) {
56
-        /*try {
57
-            Downloader.downloadPage("http://addons.dmdirc.com/addondownload/" + info.getId(), "");
60
+        try {
61
+            final File file = File.createTempFile("dmdirc-addon", ".tmp");
62
+            file.deleteOnExit();
63
+
64
+            Downloader.downloadPage("http://addons.dmdirc.com/addondownload/"
65
+                    + info.getStableDownload(), file.getAbsolutePath());
66
+
67
+            switch (info.getType()) {
68
+                case TYPE_ACTION_PACK:
69
+                    ActionManager.installActionPack(file.getAbsolutePath());
70
+                    break;
71
+                case TYPE_PLUGIN:
72
+                    throw new UnsupportedOperationException("Not supported yet");
73
+                    //break;
74
+                case TYPE_THEME:
75
+                    throw new UnsupportedOperationException("Not supported yet");
76
+                    //break;
77
+            }
58 78
         } catch (IOException ex) {
59
-        }*/
79
+            Logger.userError(ErrorLevel.MEDIUM, "Unable to download addon: "
80
+                    + ex.getMessage(), ex);
81
+        }
60 82
     }
61 83
 }

Carregando…
Cancelar
Salvar