Explorar el Código

Work on making the IRC Parser a plugin

Core now auto-extracts the IRC parser

Fixes issue 3589
Issue 3588

Depends-On: I595bd3e7ffc62ef7f059ae53beb8d6957c22c541
Change-Id: I8db9f60494939f6581dfc2a5fc8bf8b2d216c580
Reviewed-on: http://gerrit.dmdirc.com/1061
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4rc1
Chris Smith hace 14 años
padre
commit
9e6dd897c3

+ 6
- 0
build-jar.xml Ver fichero

@@ -24,6 +24,12 @@
24 24
             <zipfileset src="modules/plugins/lib/jetty-util-6.1.22.jar" includes="org/mortbay/**"/>
25 25
             <zipfileset src="modules/plugins/lib/servlet-api-2.5-20081211.jar" includes="javax/servlet/**"/>
26 26
         </jar>
27
+
28
+        <jar destfile="plugins/parser_irc.jar" compress="${jar.compress}" keepcompression="true" update="true">
29
+            <fileset dir="${build.classes.dir}">
30
+                <include name="com/dmdirc/parser/irc/**/*.class"/>
31
+            </fileset>
32
+        </jar>
27 33
     </target>
28 34
 
29 35
 </project>

+ 1
- 1
createAllPluginJar.sh Ver fichero

@@ -15,7 +15,7 @@ if [ ${?} = "0" ]; then
15 15
 fi
16 16
 
17 17
 # Plugins to bundle into development jars.
18
-plugins="ui_swing.jar tabcompletion_bash.jar tabcompletion_mirc.jar"
18
+plugins="ui_swing.jar tabcompletion_bash.jar tabcompletion_mirc.jar parser_irc.jar"
19 19
 mkdir -p ${PWD}/build/classes/plugins
20 20
 for PLUGIN in ${plugins}; do
21 21
 	ln -sf ${PWD}/plugins/${PLUGIN} ${PWD}/build/classes/plugins/${PLUGIN};

+ 1
- 1
nbproject/project.properties Ver fichero

@@ -24,7 +24,7 @@ build.test.results.dir=${build.dir}/test/results
24 24
 dist.dir=dist
25 25
 dist.jar=${dist.dir}/DMDirc.jar
26 26
 dist.javadoc.dir=${dist.dir}/javadoc
27
-dist.jar.excludes=com/dmdirc/addons/**
27
+dist.jar.excludes=com/dmdirc/addons/**,com/dmdirc/parser/irc/**
28 28
 excludes=
29 29
 includes=**
30 30
 jar.compress=false

+ 6
- 1
src/com/dmdirc/Main.java Ver fichero

@@ -123,10 +123,15 @@ public final class Main {
123 123
 
124 124
         CommandManager.initCommands();
125 125
 
126
-        for (String service : new String[]{"ui", "tabcompletion"}) {
126
+        for (String service : new String[]{"ui", "tabcompletion", "parser"}) {
127 127
             ensureExists(pm, service);
128 128
         }
129 129
 
130
+        // The user may have an existing parser plugin (e.g. twitter) which
131
+        // will satisfy the service existance check above, but will render the
132
+        // client pretty useless, so we'll force IRC extraction for now.
133
+        extractCorePlugins("parser_irc");
134
+
130 135
         loadUI(pm, IdentityManager.getGlobalConfig());
131 136
         if (getUI() == null) {
132 137
             handleMissingUI();

+ 24
- 28
src/com/dmdirc/ParserFactory.java Ver fichero

@@ -25,13 +25,13 @@ package com.dmdirc;
25 25
 import com.dmdirc.logger.ErrorLevel;
26 26
 import com.dmdirc.logger.Logger;
27 27
 import com.dmdirc.parser.interfaces.Parser;
28
-import com.dmdirc.parser.irc.IRCParser;
29 28
 import com.dmdirc.parser.common.MyInfo;
30 29
 import com.dmdirc.plugins.ExportedService;
31 30
 import com.dmdirc.plugins.NoSuchProviderException;
32 31
 import com.dmdirc.plugins.PluginManager;
33 32
 import com.dmdirc.plugins.Service;
34 33
 import com.dmdirc.plugins.ServiceProvider;
34
+
35 35
 import java.net.URI;
36 36
 
37 37
 /**
@@ -41,10 +41,10 @@ import java.net.URI;
41 41
  * @author chris
42 42
  */
43 43
 public class ParserFactory {
44
-    
44
+
45 45
     /**
46 46
      * Retrieves a parser instance.
47
-     * 
47
+     *
48 48
      * @param myInfo The client information to use
49 49
      * @param address The address of the server to connect to
50 50
      * @return An appropriately configured parser
@@ -62,38 +62,34 @@ public class ParserFactory {
62 62
             }
63 63
         }
64 64
 
65
-        if (address.getScheme() == null || "irc".equals(address.getScheme())
66
-                || "ircs".equals(address.getScheme())) {
67
-            return new IRCParser(myInfo, address);
68
-        } else {
69
-            try {
70
-                final Service service = PluginManager.getPluginManager()
71
-                        .getService("parser", address.getScheme());
65
+        // TODO: Move default scheme to a setting
66
+        final String scheme = address.getScheme() == null ? "irc" : address.getScheme();
72 67
 
73
-                if (service != null && !service.getProviders().isEmpty()) {
74
-                    final ServiceProvider provider = service.getProviders().get(0);
68
+        try {
69
+            final Service service = PluginManager.getPluginManager().getService("parser", scheme);
75 70
 
76
-                    if (provider != null) {
77
-                        provider.activateServices();
71
+            if (service != null && !service.getProviders().isEmpty()) {
72
+                final ServiceProvider provider = service.getProviders().get(0);
78 73
 
79
-                        final ExportedService exportService = provider
80
-                                .getExportedService("getParser");
81
-                        final Object obj = exportService.execute(myInfo, address);
82
-                        if (obj != null && obj instanceof Parser) {
83
-                            return (Parser)obj;
84
-                        } else {
85
-                            Logger.userError(ErrorLevel.MEDIUM,
86
-                                    "Unable to create parser for: " + address.getScheme());
87
-                        }
74
+                if (provider != null) {
75
+                    provider.activateServices();
76
+
77
+                    final ExportedService exportService = provider.getExportedService("getParser");
78
+                    final Object obj = exportService.execute(myInfo, address);
79
+                    if (obj != null && obj instanceof Parser) {
80
+                        return (Parser) obj;
81
+                    } else {
82
+                        Logger.userError(ErrorLevel.MEDIUM,
83
+                                "Unable to create parser for: " + address.getScheme());
88 84
                     }
89 85
                 }
90
-            } catch (NoSuchProviderException nspe) {
91
-                Logger.userError(ErrorLevel.MEDIUM,
92
-                        "No parser found for: " + address.getScheme(), nspe);
93 86
             }
94
-
95
-            return null;
87
+        } catch (NoSuchProviderException nspe) {
88
+            Logger.userError(ErrorLevel.MEDIUM,
89
+                    "No parser found for: " + address.getScheme(), nspe);
96 90
         }
91
+
92
+        return null;
97 93
     }
98 94
 
99 95
 }

Loading…
Cancelar
Guardar