This commit is contained in:
ingvar1995 2016-05-28 22:43:51 +03:00
parent c27c35fcc0
commit 02507ab8b4
9 changed files with 37 additions and 6 deletions

View File

@ -12,6 +12,7 @@ All plugin's data should be stored in following structure:
|---plugin_short_name.py |---plugin_short_name.py
|---/plugin_short_name/ |---/plugin_short_name/
|---settings.json |---settings.json
|---logs.txt
|---other_files |---other_files
``` ```
@ -21,6 +22,7 @@ Plugin can override following methods:
- get_window - plugins can have GUI, this method should return window instance or None for plugins without GUI. - get_window - plugins can have GUI, this method should return window instance or None for plugins without GUI.
- start - plugin was started. - start - plugin was started.
- stop - plugin was stopped. - stop - plugin was stopped.
- close - app is closing, stop plugin.
- command - new command to plugin. Command can be entered in message field in format '/plugin <plugin_short_name> <command>'. Command 'help' should show user list of supported commands. - command - new command to plugin. Command can be entered in message field in format '/plugin <plugin_short_name> <command>'. Command 'help' should show user list of supported commands.
- lossless_packet - callback - incoming lossless packet from friend. - lossless_packet - callback - incoming lossless packet from friend.
- lossy_packet - callback - incoming lossy packet from friend. - lossy_packet - callback - incoming lossy packet from friend.
@ -33,4 +35,19 @@ Other methods:
- save_settings - saves settings to default location. - save_settings - saves settings to default location.
- load_translator - loads translations. Translations must be stored in directory with plugin's data. Files with translations must have the same name as in main app. - load_translator - loads translations. Translations must be stored in directory with plugin's data. Files with translations must have the same name as in main app.
About import:
import statement will not work in case you import module that wasn't previously imported by main program and user use precompiled binary. It's recommended to use imp module and dynamic import instead.
About GUI:
It's strictly recommended to support both PySide and PyQt4 in GUI.
Exceptions:
Plugin's methods should not raise exceptions.
#Examples
You can find example of a plugin in [official repo](https://github.com/ingvar1995/toxygen_plugins)

View File

@ -8,6 +8,8 @@ Check [Plugin API](/docs/plugin_api.md) for more info
#How to install plugin #How to install plugin
Toxygen comes without preinstalled plugins.
1. Put plugin and directory with it's data into /src/plugins/ 1. Put plugin and directory with it's data into /src/plugins/
2. Restart Toxygen 2. Restart Toxygen
@ -15,3 +17,4 @@ Check [Plugin API](/docs/plugin_api.md) for more info
WARNING: It is unsecure to install plugin not from this list! WARNING: It is unsecure to install plugin not from this list!
[Main repo](https://github.com/ingvar1995/toxygen_plugins)

View File

@ -128,6 +128,7 @@ class MainWindow(QtGui.QMainWindow):
self.online_contacts.clear() self.online_contacts.clear()
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "All", None, QtGui.QApplication.UnicodeUTF8)) self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "All", None, QtGui.QApplication.UnicodeUTF8))
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "Online", None, QtGui.QApplication.UnicodeUTF8)) self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "Online", None, QtGui.QApplication.UnicodeUTF8))
self.online_contacts.setCurrentIndex(int(Settings.get_instance()['show_online_friends']))
def setup_right_bottom(self, Form): def setup_right_bottom(self, Form):
Form.setObjectName("right_bottom") Form.setObjectName("right_bottom")

View File

@ -275,7 +275,7 @@ class NetworkSettings(CenteredWidget):
self.proxyport.setText(unicode(settings['proxy_port'])) self.proxyport.setText(unicode(settings['proxy_port']))
self.http.setChecked(settings['proxy_type'] == 1) self.http.setChecked(settings['proxy_type'] == 1)
self.warning = QtGui.QLabel(self) self.warning = QtGui.QLabel(self)
self.warning.setGeometry(QtCore.QRect(40, 270, 200, 60)) self.warning.setGeometry(QtCore.QRect(5, 270, 290, 60))
self.warning.setStyleSheet('QLabel { color: #F70D1A; }') self.warning.setStyleSheet('QLabel { color: #F70D1A; }')
self.retranslateUi() self.retranslateUi()
self.proxy.stateChanged.connect(lambda x: self.activate()) self.proxy.stateChanged.connect(lambda x: self.activate())

View File

@ -20,6 +20,15 @@ def path_to_data(name):
return os.path.dirname(os.path.realpath(__file__)) + '/' + name + '/' return os.path.dirname(os.path.realpath(__file__)) + '/' + name + '/'
def log(name, data):
"""
:param name: plugin unique name
:param data: data for saving in log
"""
with open(path_to_data(name) + 'logs.txt', 'a') as fl:
fl.write(str(data) + '\n')
class PluginSuperClass(object): class PluginSuperClass(object):
""" """
Superclass for all plugins. Plugin is python module with at least one class derived from PluginSuperClass. Superclass for all plugins. Plugin is python module with at least one class derived from PluginSuperClass.

View File

@ -881,6 +881,7 @@ class Profile(Contact, Singleton):
friend.status = None friend.status = None
def close(self): def close(self):
if hasattr(self, '_stop'):
self._call.stop() self._call.stop()
del self._call del self._call

Binary file not shown.

View File

@ -66,8 +66,8 @@
<source>WARNING: <source>WARNING:
using proxy with enabled UDP using proxy with enabled UDP
can produce IP leak</source> can produce IP leak</source>
<translation>Предупреждение: <translation type="unfinished">Предупреждение:
использование прокси со включенным UDP использование прокси с UDP
может привести к утечке IP</translation> может привести к утечке IP</translation>
</message> </message>
</context> </context>

View File

@ -3,7 +3,7 @@ import time
from platform import system from platform import system
program_version = '0.1.2' program_version = '0.1.3'
def log(data): def log(data):