浏览代码

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 年前
父节点
当前提交
c04b824345
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18
    0
      src/com/dmdirc/plugins/PluginInfo.java

+ 18
- 0
src/com/dmdirc/plugins/PluginInfo.java 查看文件

@@ -36,6 +36,7 @@ import com.dmdirc.logger.ErrorLevel;
36 36
 import com.dmdirc.updater.Version;
37 37
 import java.io.File;
38 38
 import java.io.IOException;
39
+import java.io.InputStream;
39 40
 import java.lang.reflect.Constructor;
40 41
 import java.lang.reflect.InvocationTargetException;
41 42
 import java.util.List;
@@ -306,6 +307,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
306 307
      * This will load a ConfigFile
307 308
      *
308 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 312
     private ConfigFile getConfigFile() throws IOException {
311 313
         ConfigFile file = null;
@@ -328,6 +330,22 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
328 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 350
      * Get the defaults, formatters and icons for this plugin.
333 351
      */

正在加载...
取消
保存