diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-19 14:52:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-19 14:52:21 +0000 |
commit | d1772d410235592b482e3b08b1863f6624d9fe6b (patch) | |
tree | accfb4b99c32e5e435089f8023d62e67a6951603 /deluge/plugins/pluginbase.py | |
parent | Initial commit. (diff) | |
download | deluge-d1772d410235592b482e3b08b1863f6624d9fe6b.tar.xz deluge-d1772d410235592b482e3b08b1863f6624d9fe6b.zip |
Adding upstream version 2.0.3.upstream/2.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/plugins/pluginbase.py')
-rw-r--r-- | deluge/plugins/pluginbase.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py new file mode 100644 index 0000000..e80199d --- /dev/null +++ b/deluge/plugins/pluginbase.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com> +# +# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with +# the additional special exception to link portions of this program with the OpenSSL library. +# See LICENSE for more details. +# + +from __future__ import unicode_literals + +import logging + +import deluge.component as component + +log = logging.getLogger(__name__) + + +class PluginBase(component.Component): + + update_interval = 1 + + def __init__(self, name): + super(PluginBase, self).__init__(name, self.update_interval) + + def enable(self): + raise NotImplementedError('Need to define an enable method!') + + def disable(self): + raise NotImplementedError('Need to define a disable method!') + + +class CorePluginBase(PluginBase): + def __init__(self, plugin_name): + super(CorePluginBase, self).__init__('CorePlugin.' + plugin_name) + # Register RPC methods + component.get('RPCServer').register_object(self, plugin_name.lower()) + log.debug('CorePlugin initialized..') + + def __del__(self): + component.get('RPCServer').deregister_object(self) + + def enable(self): + super(CorePluginBase, self).enable() + + def disable(self): + super(CorePluginBase, self).disable() + + +class Gtk3PluginBase(PluginBase): + def __init__(self, plugin_name): + super(Gtk3PluginBase, self).__init__('Gtk3Plugin.' + plugin_name) + log.debug('Gtk3Plugin initialized..') + + def enable(self): + super(Gtk3PluginBase, self).enable() + + def disable(self): + super(Gtk3PluginBase, self).disable() + + +class WebPluginBase(PluginBase): + + scripts = [] + debug_scripts = [] + + stylesheets = [] + debug_stylesheets = [] + + def __init__(self, plugin_name): + super(WebPluginBase, self).__init__('WebPlugin.' + plugin_name) + + # Register JSON rpc methods + component.get('JSON').register_object(self, plugin_name.lower()) + log.debug('WebPlugin initialized..') + + def __del__(self): + component.get('JSON').deregister_object(self) + + def enable(self): + pass + + def disable(self): + pass |