From 02507ab8b495dda523673c1dd48ae2dadc7b601f Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 28 May 2016 22:43:51 +0300 Subject: [PATCH] v 0.1.3 --- docs/plugin_api.md | 17 +++++++++++++++++ docs/plugins.md | 3 +++ src/mainscreen.py | 1 + src/menu.py | 2 +- src/plugins/plugin_super_class.py | 9 +++++++++ src/profile.py | 5 +++-- src/translations/ru_RU.qm | Bin 10973 -> 10949 bytes src/translations/ru_RU.ts | 4 ++-- src/util.py | 2 +- 9 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docs/plugin_api.md b/docs/plugin_api.md index 93b3683..b4c81db 100644 --- a/docs/plugin_api.md +++ b/docs/plugin_api.md @@ -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 '. 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) diff --git a/docs/plugins.md b/docs/plugins.md index ca32b51..3fb13b7 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -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) \ No newline at end of file diff --git a/src/mainscreen.py b/src/mainscreen.py index 2d34e3a..4ed5b3b 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -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") diff --git a/src/menu.py b/src/menu.py index c2165b3..1fa5e68 100644 --- a/src/menu.py +++ b/src/menu.py @@ -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()) diff --git a/src/plugins/plugin_super_class.py b/src/plugins/plugin_super_class.py index 17089db..190c113 100644 --- a/src/plugins/plugin_super_class.py +++ b/src/plugins/plugin_super_class.py @@ -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. diff --git a/src/profile.py b/src/profile.py index ebda428..97baaf1 100644 --- a/src/profile.py +++ b/src/profile.py @@ -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 diff --git a/src/translations/ru_RU.qm b/src/translations/ru_RU.qm index 02cd9be38b5492f7e41d7a4dad3b484c2dc52a95..dffe08c42aad8c3acbb708cfd77e38b9f792336b 100644 GIT binary patch delta 923 zcmX9+eN0tl9DdF{?|aWZ=bn3yaut+76p$uO)Kq4OGC_tB_YXEu{79WBh5o^oW{r%a zGg#o%TYQ!uxYEXTUEM&J5{Zr=gZ07Eq+ED~KAffvr8!BhXYtpw_nhCy^YQzou)8o2 zqwIb!Hp;#RaX1JhnGoLz;(Umo0sziK{Lug?fWBmq-z$-j;s+d~Sn!l}t~lg0e93n^ zRMh-4J(tpR*ttST*M-%PA(ctrH0J9j&fn2El06Nq*yO4}F^yHR;<;0$2LwJH~k z1R!#cqbZw>Gx8jrD@Orsn&V=7A@IyUj%#)o;N9eS@OBn3tzSjt5bLk2v$j?M6N}WM zib`O@nA&UBad5Lxb6x-@1w~2YZ-CJwN<07NoC2})iz9%iO4R=NArS8sN8h;$8}a3$ z<=hDtB#FM?uT!om?#waBv{TM_{ydcp$%PG1ftW0rxsiiqip;-#mkTD#EpxM3ziS+m z*2qKeHgRF2{G{N(Bkyq+%z^Znx>?Z-Y z;at1A7?_;se03+4x<7NimBz-Y`OfN|2rk^<9PrZ_-%FbDkb|b2)E0+T5(tgs#11WQ z5#KZ2+TKY!faz1Tz*mewzp2%K|2m1qYNw+i+s(DXq)-s!ah0> zFprhh0&#vb_$KEf*Zf@BPC=^KyE~nZ2F-9Z9n{l2c1q1@AmO+t_0q3gJlj(+c7@E| z@T|LDJKtL`J&SdQ$Qii9ap{p4C;LEu`L1l$zT8GOuk!{+ak6SBCYt delta 952 zcmX9-e@v8R9RIxcKF_`PzV{w)a0Doza(B|grOXK#oUk-PQQT^viK#7-I@hL?QU{Bx zkrlQU$pL2umKuXUj4f;-QHpr#j>;%Zti>)VfAq^GHG`)0S?vAeyZ3#*&-e4|`$o#Y zFKU-34U&AkGWcl@OO20UU?8+5#wmzGRHw+u)sF3aBO)-C>{OeiXNy z25etpdEdW)ScoKEc8AVfo0T)}l$IY;Ngy&^ z<43eri}^m+tJNny3(U#Z8qYEUeNt=w@;MUA(YlilGs>8DEynpN@eVOBSU>{*I9@zD z&I=um{rPTM{EFk?%@|-tbai7h0WG~Sk4nXMeR((v*yrgbrCHpOJ<~OLME|_Mff@Je zUsvp7gr^OU!rdU`|5aUWJec61upf*~GbEijWmNXQ#@!e*UJmBc3a!>SP}oPMiAHCC z9+2E>oNJA6$=aQZ7JLERwZgfzaRZ5FIk(;Bd-^SBD4WVWpE-x?e&>0}TSx`Olfb_3piSMI=%1TJ!w zO^uM*F4yB1yd*H{YODH|&P>Log-O&1#AUtlA(t^~J+$m59XV#Ls}lSxPFgkNA23th zYIu^F%MPn+G(;yet>I$MHOs8a8-0wl+PYnJgLsJn;GPT>Xd1Wsd#vC0! cD8L-CP~?exv04<19I=GYO5yLhB!Bh&2a>`2O#lD@ diff --git a/src/translations/ru_RU.ts b/src/translations/ru_RU.ts index 9c4b0a5..83723b0 100644 --- a/src/translations/ru_RU.ts +++ b/src/translations/ru_RU.ts @@ -66,8 +66,8 @@ WARNING: using proxy with enabled UDP can produce IP leak - Предупреждение: -использование прокси со включенным UDP + Предупреждение: +использование прокси с UDP может привести к утечке IP diff --git a/src/util.py b/src/util.py index 0737bcf..d02a88b 100644 --- a/src/util.py +++ b/src/util.py @@ -3,7 +3,7 @@ import time from platform import system -program_version = '0.1.2' +program_version = '0.1.3' def log(data):