2018-04-21 01:20:26 +00:00
|
|
|
'''
|
2019-06-16 06:06:32 +00:00
|
|
|
Onionr - Private P2P Communication
|
2018-04-21 01:20:26 +00:00
|
|
|
|
|
|
|
This file deals with the object that is passed with each event
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
This program is free software: you can 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.
|
|
|
|
|
|
|
|
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
'''
|
|
|
|
|
2019-07-20 15:52:03 +00:00
|
|
|
import onionrplugins, logger
|
2019-06-23 17:41:07 +00:00
|
|
|
from onionrutils import localcommand
|
2018-04-21 03:10:50 +00:00
|
|
|
|
2018-04-21 01:20:26 +00:00
|
|
|
class PluginAPI:
|
2018-04-21 03:10:50 +00:00
|
|
|
def __init__(self, pluginapi):
|
|
|
|
self.pluginapi = pluginapi
|
|
|
|
|
|
|
|
def start(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
onionrplugins.start(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
|
|
|
def stop(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
onionrplugins.stop(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
|
|
|
def reload(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
onionrplugins.reload(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
|
|
|
def enable(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
onionrplugins.enable(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
|
|
|
def disable(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
onionrplugins.disable(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
2018-04-21 05:04:03 +00:00
|
|
|
def event(self, name, data = {}):
|
2019-08-05 04:08:56 +00:00
|
|
|
events.event(name, data = data)
|
2018-04-21 05:04:03 +00:00
|
|
|
|
2018-04-21 03:10:50 +00:00
|
|
|
def is_enabled(self, name):
|
2018-05-13 03:45:32 +00:00
|
|
|
return onionrplugins.is_enabled(name)
|
2018-04-21 03:10:50 +00:00
|
|
|
|
|
|
|
def get_enabled_plugins(self):
|
2018-05-13 03:45:32 +00:00
|
|
|
return onionrplugins.get_enabled()
|
2018-04-21 03:10:50 +00:00
|
|
|
|
2018-04-23 03:42:37 +00:00
|
|
|
def get_folder(self, name = None, absolute = True):
|
2018-05-13 03:45:32 +00:00
|
|
|
return onionrplugins.get_plugins_folder(name = name, absolute = absolute)
|
2018-04-23 03:42:37 +00:00
|
|
|
|
|
|
|
def get_data_folder(self, name, absolute = True):
|
2018-05-13 03:45:32 +00:00
|
|
|
return onionrplugins.get_plugin_data_folder(name, absolute = absolute)
|
2018-04-23 03:42:37 +00:00
|
|
|
|
|
|
|
def daemon_event(self, event, plugin = None):
|
|
|
|
return # later make local command like /client/?action=makeEvent&event=eventname&module=modulename
|
|
|
|
|
2018-04-21 03:10:50 +00:00
|
|
|
class CommandAPI:
|
|
|
|
def __init__(self, pluginapi):
|
|
|
|
self.pluginapi = pluginapi
|
|
|
|
|
|
|
|
def call(self, name):
|
|
|
|
self.pluginapi.get_onionr().execute(name)
|
|
|
|
|
2019-07-29 18:43:50 +00:00
|
|
|
class SharedAPI:
|
2019-08-05 00:34:57 +00:00
|
|
|
def __init__(self, data):
|
2018-04-21 03:10:50 +00:00
|
|
|
self.data = data
|
|
|
|
self.plugins = PluginAPI(self)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
2018-04-21 01:20:26 +00:00
|
|
|
def get_daemonapi(self):
|
|
|
|
return self.daemon
|
2018-04-21 03:10:50 +00:00
|
|
|
|
2018-04-21 01:20:26 +00:00
|
|
|
def get_pluginapi(self):
|
2019-08-05 04:08:56 +00:00
|
|
|
return self.plugins
|