diff --git a/app/index.js b/app/index.js index 7d0c11e88..6da280fd6 100644 --- a/app/index.js +++ b/app/index.js @@ -53,11 +53,17 @@ function CoreCommandRouter(server) { // Start the music library this.musicLibrary = new (require('./musiclibrary.js'))(this); - // Start plugins - this.pluginManager = new (require(__dirname + '/pluginmanager.js'))(this, server); + // Start plugins + this.configManager = new(require(__dirname+'/configManager.js'))(this.logger); + let myVolumioPluginManagerPath = '/myvolumio/app/myvolumio-pluginmanager'; + if (fs.existsSync(myVolumioPluginManagerPath)) { + this.logger.info('MYVOLUMIO Environment detected'); + let myVolumioPluginManager = new (require(myVolumioPluginManagerPath))(this, server, this.configManager); + this.extraPluginManager = myVolumioPluginManager; + } + this.pluginManager = new (require(__dirname + '/pluginmanager.js'))(this, server, this.extraPluginManager); this.pluginManager.checkIndex(); this.pluginManager.pluginFolderCleanup(); - this.configManager=new(require(__dirname+'/configManager.js'))(this.logger); this.pluginManager.startPlugins(); diff --git a/app/pluginmanager.js b/app/pluginmanager.js index 0d29fb006..140b4ffb5 100755 --- a/app/pluginmanager.js +++ b/app/pluginmanager.js @@ -18,7 +18,7 @@ var device = ''; module.exports = PluginManager; -function PluginManager(ccommand, server) { +function PluginManager(ccommand, server, extraPluginManager) { var self = this; self.corePlugins = new HashMap(); @@ -73,11 +73,9 @@ function PluginManager(ccommand, server) { } } - var myVolumioPMPath = '/myvolumio/app/myvolumio-pluginmanager'; - if (fs.existsSync(myVolumioPMPath)) { - this.logger.info('MYVOLUMIO Environment detected'); - self.myVolumioPluginManager = new (require(myVolumioPMPath))(self.coreCommand, self.websocketServer, self.configManager, self.config); - } + if (extraPluginManager !== undefined) { + self.extraPluginManager = extraPluginManager; + } } PluginManager.prototype.startPlugins = function () { @@ -89,8 +87,8 @@ PluginManager.prototype.startPlugins = function () { this.loadCorePlugins(); this.startCorePlugins(); - if (this.myVolumioPluginManager !== undefined) { - this.myVolumioPluginManager.startPlugins(); + if (this.extraPluginManager !== undefined) { + this.extraPluginManager.startPlugins(); } } @@ -446,9 +444,9 @@ PluginManager.prototype.getPluginCategories = function () { if (libFast.indexOf(categories, metadata.category) == -1) categories.push(metadata.category); } - if (self.myVolumioPluginManager !== undefined) { - let myVolumioCategories = self.myVolumioPluginManager.getPluginCategories(); - categories.concat(myVolumioCategories); + if (self.extraPluginManager !== undefined && typeof self.extraPluginManager.getPluginCategories === 'function') { + let extraPluginCategories = self.extraPluginManager.getPluginCategories(); + categories.concat(extraPluginCategories); } return categories @@ -466,9 +464,9 @@ PluginManager.prototype.getPluginNames = function (category) { names.push(metadata.name); } - if (self.myVolumioPluginManager !== undefined) { - let myVolumioNames = self.myVolumioPluginManager.getPluginNames(); - names.concat(myVolumioNames); + if (self.extraPluginManager !== undefined && typeof self.extraPluginManager.getPluginNames === 'function') { + let extraPluginNames = self.extraPluginManager.getPluginNames(); + names.concat(extraPluginNames); } return names @@ -621,8 +619,8 @@ PluginManager.prototype.getPlugin = function (category, name) { var self = this; if (self.corePlugins.get(category + '.' + name)) { return self.corePlugins.get(category + '.' + name).instance; - } else if (self.myVolumioPluginManager !== undefined) { - return self.myVolumioPluginManager.getPlugin(category, name); + } else if (self.extraPluginManager !== undefined && typeof self.extraPluginManager.getPlugin === 'function') { + return self.extraPluginManager.getPlugin(category, name); } else { self.logger.error('Could not retrieve plugin ' + category + ' ' + name); }