|
@@ -47,10 +47,11 @@ import com.dmdirc.logger.ErrorLevel;
|
47
|
47
|
import com.dmdirc.logger.ErrorManager;
|
48
|
48
|
import com.dmdirc.logger.Logger;
|
49
|
49
|
import com.dmdirc.messages.MessagesModule;
|
|
50
|
+import com.dmdirc.plugins.CorePluginExtractor;
|
|
51
|
+import com.dmdirc.plugins.CorePluginHelper;
|
50
|
52
|
import com.dmdirc.plugins.LegacyServiceLocator;
|
51
|
53
|
import com.dmdirc.plugins.PluginInjectorInitialiser;
|
52
|
54
|
import com.dmdirc.plugins.PluginManager;
|
53
|
|
-import com.dmdirc.plugins.PluginMetaData;
|
54
|
55
|
import com.dmdirc.plugins.ServiceLocator;
|
55
|
56
|
import com.dmdirc.plugins.ServiceManager;
|
56
|
57
|
import com.dmdirc.ui.IconManager;
|
|
@@ -58,7 +59,6 @@ import com.dmdirc.ui.WarningDialog;
|
58
|
59
|
import com.dmdirc.ui.messages.ColourManager;
|
59
|
60
|
import com.dmdirc.ui.themes.ThemeManager;
|
60
|
61
|
import com.dmdirc.updater.UpdaterModule;
|
61
|
|
-import com.dmdirc.updater.Version;
|
62
|
62
|
import com.dmdirc.updater.manager.UpdateManager;
|
63
|
63
|
import com.dmdirc.util.URLBuilder;
|
64
|
64
|
import com.dmdirc.util.io.Downloader;
|
|
@@ -219,14 +219,16 @@ public class ClientModule {
|
219
|
219
|
final UpdateManager updateManager,
|
220
|
220
|
final Provider<PluginInjectorInitialiser> initialiserProvider,
|
221
|
221
|
final ObjectGraph objectGraph,
|
|
222
|
+ final CorePluginHelper pluginHelper,
|
222
|
223
|
@Directory(DirectoryType.PLUGINS) final String directory) {
|
223
|
224
|
final PluginManager manager = new PluginManager(eventBus, identityController,
|
224
|
225
|
updateManager, initialiserProvider, objectGraph, directory);
|
225
|
226
|
final CorePluginExtractor extractor = new CorePluginExtractor(manager, directory, eventBus);
|
226
|
|
- checkBundledPlugins(extractor, manager, identityController.getGlobalConfiguration());
|
|
227
|
+ pluginHelper.checkBundledPlugins(extractor, manager,
|
|
228
|
+ identityController.getGlobalConfiguration());
|
227
|
229
|
|
228
|
230
|
for (String service : new String[]{"ui", "tabcompletion", "parser"}) {
|
229
|
|
- ensureExists(extractor, manager, service);
|
|
231
|
+ pluginHelper.ensureExists(extractor, manager, service);
|
230
|
232
|
}
|
231
|
233
|
|
232
|
234
|
// The user may have an existing parser plugin (e.g. twitter) which
|
|
@@ -351,49 +353,4 @@ public class ClientModule {
|
351
|
353
|
}
|
352
|
354
|
}
|
353
|
355
|
|
354
|
|
- /**
|
355
|
|
- * Ensures that there is at least one provider of the specified service type by extracting
|
356
|
|
- * matching core plugins. Plugins must be named so that their file name starts with the service
|
357
|
|
- * type, and then an underscore.
|
358
|
|
- *
|
359
|
|
- * @param corePluginExtractor Extractor to use if the service doesn't exist
|
360
|
|
- * @param pm The plugin manager to use to access services
|
361
|
|
- * @param serviceType The type of service that should exist
|
362
|
|
- */
|
363
|
|
- public void ensureExists(
|
364
|
|
- final CorePluginExtractor corePluginExtractor,
|
365
|
|
- final PluginManager pm,
|
366
|
|
- final String serviceType) {
|
367
|
|
- if (pm.getServicesByType(serviceType).isEmpty()) {
|
368
|
|
- corePluginExtractor.extractCorePlugins(serviceType + "_");
|
369
|
|
- pm.refreshPlugins();
|
370
|
|
- }
|
371
|
|
- }
|
372
|
|
-
|
373
|
|
- /**
|
374
|
|
- * Checks whether the plugins bundled with this release of DMDirc are newer than the plugins
|
375
|
|
- * known by the specified {@link PluginManager}. If the bundled plugins are newer, they are
|
376
|
|
- * automatically extracted.
|
377
|
|
- *
|
378
|
|
- * @param corePluginExtractor Extractor to use if plugins need updating.
|
379
|
|
- * @param pm The plugin manager to use to check plugins
|
380
|
|
- * @param config The configuration source for bundled versions
|
381
|
|
- */
|
382
|
|
- private void checkBundledPlugins(
|
383
|
|
- final CorePluginExtractor corePluginExtractor,
|
384
|
|
- final PluginManager pm,
|
385
|
|
- final AggregateConfigProvider config) {
|
386
|
|
- for (PluginMetaData plugin : pm.getAllPlugins()) {
|
387
|
|
- if (config.hasOptionString("bundledplugins_versions", plugin.getName())) {
|
388
|
|
- final Version bundled = new Version(config.getOption("bundledplugins_versions",
|
389
|
|
- plugin.getName()));
|
390
|
|
- final Version installed = plugin.getVersion();
|
391
|
|
-
|
392
|
|
- if (installed.compareTo(bundled) < 0) {
|
393
|
|
- corePluginExtractor.extractCorePlugins(plugin.getName());
|
394
|
|
- }
|
395
|
|
- }
|
396
|
|
- }
|
397
|
|
- }
|
398
|
|
-
|
399
|
356
|
}
|