From 89be47dc720d34806484daf63ca27944b5ef08c5 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 6 May 2016 02:00:10 +0300 Subject: [PATCH] stop call and file transfers on friend exit. --- README.md | 2 +- docs/compile.md | 2 ++ src/callbacks.py | 2 +- src/profile.py | 9 +++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 090cc2a..b355185 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ Toxygen is simple [Tox](https://tox.chat/) client written on pure Python - [x] Contact aliases - [x] Contact blocking - [x] Typing notifications +- [x] Changing nospam - [ ] Video - [ ] Save file encryption - [ ] File resuming -- [ ] Changing nospam - [ ] Plugins support - [ ] Group chats - [ ] Read receipts diff --git a/docs/compile.md b/docs/compile.md index cf3af40..4337e6f 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -1,3 +1,5 @@ +#Compile Toxygen + You can compile Toxygen using [PyInstaller](http://www.pyinstaller.org/) Install PyInstaller: ``pip install pyinstaller`` diff --git a/src/callbacks.py b/src/callbacks.py index 8a8ace5..8ab78fb 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -76,7 +76,7 @@ def friend_connection_status(tox, friend_num, new_status, user_data): profile = Profile.get_instance() friend = profile.get_friend_by_number(friend_num) if new_status == TOX_CONNECTION['NONE']: - invoke_in_main_thread(friend.set_status, None) + invoke_in_main_thread(profile.friend_exit, friend_num) invoke_in_main_thread(profile.update_filtration) if Settings.get_instance()['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']: sound_notification(SOUND_NOTIFICATION['FRIEND_CONNECTION_STATUS']) diff --git a/src/profile.py b/src/profile.py index 1c414cc..ed28109 100644 --- a/src/profile.py +++ b/src/profile.py @@ -466,6 +466,15 @@ class Profile(Contact, Singleton): if self._active_friend + 1: self.set_active(self._active_friend) + def friend_exit(self, friend_number): + self.get_friend_by_number(friend_number).status = None + self.friend_typing(friend_number, False) + if friend_number in self._call: + self._call.finish_call(friend_number, True) + for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()): + self._file_transfers[key].cancelled() + del self._file_transfers[key] + # ----------------------------------------------------------------------------------------------------------------- # Typing notifications # -----------------------------------------------------------------------------------------------------------------