From b591ac13ba09e7fb409a21f668a3f25c2f43fb04 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 19 May 2018 19:38:54 +0300 Subject: [PATCH] utf-8 decoding moved from contacts --- toxygen/contacts/basecontact.py | 2 -- toxygen/contacts/contacts_manager.py | 1 - toxygen/contacts/profile.py | 2 +- toxygen/groups/groups_service.py | 4 ++-- toxygen/middleware/callbacks.py | 4 ++-- toxygen/ui/menu.py | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/toxygen/contacts/basecontact.py b/toxygen/contacts/basecontact.py index 988b0bc..0357809 100644 --- a/toxygen/contacts/basecontact.py +++ b/toxygen/contacts/basecontact.py @@ -39,7 +39,6 @@ class BaseContact: return self._name def set_name(self, value): - value = str(value, 'utf-8') if self._name != value: self._name = value self._widget.name.setText(self._name) @@ -61,7 +60,6 @@ class BaseContact: return self._status_message def set_status_message(self, value): - value = str(value, 'utf-8') if self._status_message != value: self._status_message = value self._widget.status_message.setText(self._status_message) diff --git a/toxygen/contacts/contacts_manager.py b/toxygen/contacts/contacts_manager.py index f56f13a..c140b59 100644 --- a/toxygen/contacts/contacts_manager.py +++ b/toxygen/contacts/contacts_manager.py @@ -224,7 +224,6 @@ class ContactsManager: friend = self.get_friend_by_number(number) tmp = friend.name friend.set_name(name) - name = str(name, 'utf-8') if friend.name == name and tmp != name: # TODO: move to friend? message = util_ui.tr('User {} is now known as {}') diff --git a/toxygen/contacts/profile.py b/toxygen/contacts/profile.py index c775268..4e29147 100644 --- a/toxygen/contacts/profile.py +++ b/toxygen/contacts/profile.py @@ -49,7 +49,7 @@ class Profile(basecontact.BaseContact): def set_name(self, value): if self.name == value: return - super().set_name(value.encode('utf-8')) + super().set_name(value) self._tox.self_set_name(self._name.encode('utf-8')) def set_status_message(self, value): diff --git a/toxygen/groups/groups_service.py b/toxygen/groups/groups_service.py index c5be5cf..5b0dd67 100644 --- a/toxygen/groups/groups_service.py +++ b/toxygen/groups/groups_service.py @@ -53,8 +53,8 @@ class GroupsService(tox_save.ToxSave): # ----------------------------------------------------------------------------------------------------------------- def update_group_info(self, group): - group.name = self._tox.group_get_name(group.number).encode('utf-8') - group.status_message = self._tox.group_get_topic(group.number).encode('utf-8') + group.name = self._tox.group_get_name(group.number) + group.status_message = self._tox.group_get_topic(group.number) # ----------------------------------------------------------------------------------------------------------------- # Private methods diff --git a/toxygen/middleware/callbacks.py b/toxygen/middleware/callbacks.py index 1182466..99f9db8 100644 --- a/toxygen/middleware/callbacks.py +++ b/toxygen/middleware/callbacks.py @@ -86,7 +86,7 @@ def friend_name(contacts_manager): Friend changed his name """ print('New name friend #' + str(friend_number)) - invoke_in_main_thread(contacts_manager.new_name, friend_number, name) + invoke_in_main_thread(contacts_manager.new_name, friend_number, str(name, 'utf-8')) return wrapped @@ -98,7 +98,7 @@ def friend_status_message(contacts_manager, messenger): and calls window repaint """ friend = contacts_manager.get_friend_by_number(friend_number) - invoke_in_main_thread(friend.set_status_message, status_message) + invoke_in_main_thread(friend.set_status_message, str(status_message, 'utf-8')) print('User #{} has new status'.format(friend_number)) invoke_in_main_thread(messenger.send_messages, friend_number) diff --git a/toxygen/ui/menu.py b/toxygen/ui/menu.py index d912619..e98405d 100644 --- a/toxygen/ui/menu.py +++ b/toxygen/ui/menu.py @@ -272,7 +272,7 @@ class ProfileSettings(CenteredWidget): def closeEvent(self, event): self._profile.set_name(self.nick.text()) - self._profile.set_status_message(self.status_message.text().encode('utf-8')) + self._profile.set_status_message(self.status_message.text()) self._profile.set_status(self.status.currentIndex())