Browse Source

Get licenses from plugins.

Fixes issue 2642.
Returns an InputStream because thats what the license panel uses for everything else.

Change-Id: I487257961ac40bb421ef8b8c92da32a221ce2ce9
Reviewed-on: http://gerrit.dmdirc.com/106
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3b1
Shane Mc Cormack 14 years ago
parent
commit
c04b824345
1 changed files with 18 additions and 0 deletions
  1. 18
    0
      src/com/dmdirc/plugins/PluginInfo.java

+ 18
- 0
src/com/dmdirc/plugins/PluginInfo.java View File

36
 import com.dmdirc.updater.Version;
36
 import com.dmdirc.updater.Version;
37
 import java.io.File;
37
 import java.io.File;
38
 import java.io.IOException;
38
 import java.io.IOException;
39
+import java.io.InputStream;
39
 import java.lang.reflect.Constructor;
40
 import java.lang.reflect.Constructor;
40
 import java.lang.reflect.InvocationTargetException;
41
 import java.lang.reflect.InvocationTargetException;
41
 import java.util.List;
42
 import java.util.List;
306
      * This will load a ConfigFile
307
      * This will load a ConfigFile
307
      *
308
      *
308
      * @return the ConfigFile object for this plugin, or null if the plugin has no config
309
      * @return the ConfigFile object for this plugin, or null if the plugin has no config
310
+     * @throws IOException if there is an error with the ResourceManager.
309
      */
311
      */
310
     private ConfigFile getConfigFile() throws IOException {
312
     private ConfigFile getConfigFile() throws IOException {
311
         ConfigFile file = null;
313
         ConfigFile file = null;
328
         return file;
330
         return file;
329
     }
331
     }
330
 
332
 
333
+    /**
334
+     * Get the license for this plugin if it exists.
335
+     *
336
+     * @return An InputStream for the license of this plugin, or null if no
337
+     *         license found.
338
+     * @throws IOException if there is an error with the ResourceManager.
339
+     */
340
+    public InputStream getLicenseStream() throws IOException {
341
+        final ResourceManager res = getResourceManager();
342
+        if (res.resourceExists("META-INF/license.txt")) {
343
+            return res.getResourceInputStream("META-INF/license.txt");
344
+        }
345
+
346
+        return null;
347
+    }
348
+
331
     /**
349
     /**
332
      * Get the defaults, formatters and icons for this plugin.
350
      * Get the defaults, formatters and icons for this plugin.
333
      */
351
      */

Loading…
Cancel
Save