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/
|---settings.json
|---logs.txt
|---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.
- start - plugin was started.
- 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.
- lossless_packet - callback - incoming lossless packet from friend.
- lossy_packet - callback - incoming lossy packet from friend.
@ -33,4 +35,19 @@ Other methods:
- 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.
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
Toxygen comes without preinstalled plugins.
1. Put plugin and directory with it's data into /src/plugins/
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!
[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.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.setCurrentIndex(int(Settings.get_instance()['show_online_friends']))
def setup_right_bottom(self, Form):
Form.setObjectName("right_bottom")

View file

@ -275,7 +275,7 @@ class NetworkSettings(CenteredWidget):
self.proxyport.setText(unicode(settings['proxy_port']))
self.http.setChecked(settings['proxy_type'] == 1)
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.retranslateUi()
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 + '/'
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):
"""
Superclass for all plugins. Plugin is python module with at least one class derived from PluginSuperClass.

View file

@ -881,8 +881,9 @@ class Profile(Contact, Singleton):
friend.status = None
def close(self):
self._call.stop()
del self._call
if hasattr(self, '_stop'):
self._call.stop()
del self._call
# -----------------------------------------------------------------------------------------------------------------
# File transfers support

Binary file not shown.

View file

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

View file

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