diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index d4c61fb92..4c4049cfb 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -81,6 +81,7 @@ class JSON(resource.Resource, component.Component): component.Component.__init__(self, "JSON") self._remote_methods = [] self._local_methods = {} + client.disconnect_callback = self._on_client_disconnect def connect(self, host="localhost", port=58846, username="", password=""): """ @@ -105,9 +106,13 @@ class JSON(resource.Resource, component.Component): """ d = client.daemon.get_method_list() d.addCallback(on_get_methods) + component.get("PluginManager").start() _d.addCallback(on_client_connected) return d + def _on_client_disconnect(self, *args): + component.get("PluginManager").stop() + def _exec_local(self, method, params): """ Handles executing all local methods. diff --git a/deluge/ui/web/pluginmanager.py b/deluge/ui/web/pluginmanager.py new file mode 100644 index 000000000..797d28508 --- /dev/null +++ b/deluge/ui/web/pluginmanager.py @@ -0,0 +1,51 @@ +# +# pluginmanager.py +# +# Copyright (C) 2009 Damien Churchill +# +# Deluge is free software. +# +# You may redistribute it and/or modify it under the terms of the +# GNU General Public License, as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) +# any later version. +# +# deluge is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with deluge. If not, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# + +import logging + +from deluge.component import Component +from deluge.pluginmanagerbase import PluginManagerBase +from deluge.ui.client import client +from deluge.configmanager import ConfigManager + +log = logging.getLogger(__name__) + +class PluginManager(PluginManagerBase, Component): + def __init__(self): + Component.__init__(self, "PluginManager") + self.config = ConfigManager("web.conf") + PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web") + + def start(self): + """Start up the plugin manager""" + + # Update the enabled plugins from the core + d = client.core.get_enabled_plugins() + d.addCallback(self._on_get_enabled_plugins) + + def stop(self): + self.disable_plugins() + + def update(self): + pass \ No newline at end of file diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index c6173ea1d..21b0e8606 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -46,6 +46,7 @@ from deluge.ui import common as uicommon from deluge.ui.tracker_icons import TrackerIcons from deluge.ui.web.common import Template from deluge.ui.web.json_api import JSON, WebApi +from deluge.ui.web.pluginmanager import PluginManager log = logging.getLogger(__name__) # Initialize gettext @@ -303,6 +304,9 @@ class DelugeWeb(component.Component): self.__shutdown() return 1 SetConsoleCtrlHandler(win_handler) + + # Initalize the plugins + self.plugins = PluginManager() def start(self): log.info("%s %s.", _("Starting server in PID"), os.getpid())