stop call and file transfers on friend exit.

This commit is contained in:
ingvar1995 2016-05-06 02:00:10 +03:00
parent f5782c2dcb
commit 89be47dc72
4 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -1,3 +1,5 @@
#Compile Toxygen
You can compile Toxygen using [PyInstaller](http://www.pyinstaller.org/)
Install PyInstaller:
``pip install pyinstaller``

View File

@ -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'])

View File

@ -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
# -----------------------------------------------------------------------------------------------------------------