reconnect/disconnect functionality
This commit is contained in:
parent
329ab23f89
commit
6538cedcf2
@ -338,6 +338,7 @@ class App:
|
||||
self._group_factory = GroupFactory(self._profile_manager, self._settings, self._tox, db, contact_items_factory)
|
||||
self._contacts_provider = ContactProvider(self._tox, self._friend_factory, self._group_factory)
|
||||
self._profile = Profile(self._profile_manager, self._tox, self._ms, self._contacts_provider, self._reset)
|
||||
self._init_profile()
|
||||
self._plugin_loader = PluginLoader(self._settings, self)
|
||||
history = None
|
||||
messages_items_factory = MessagesItemsFactory(self._settings, self._plugin_loader, self._smiley_loader,
|
||||
@ -349,7 +350,8 @@ class App:
|
||||
history.set_contacts_manager(self._contacts_manager)
|
||||
self._calls_manager = CallsManager(self._tox.AV, self._settings, self._ms, self._contacts_manager)
|
||||
self._messenger = Messenger(self._tox, self._plugin_loader, self._ms, self._contacts_manager,
|
||||
self._contacts_provider, messages_items_factory, self._profile, self._calls_manager)
|
||||
self._contacts_provider, messages_items_factory, self._profile,
|
||||
self._calls_manager)
|
||||
file_transfers_message_service = FileTransfersMessagesService(self._contacts_manager, messages_items_factory,
|
||||
self._profile, self._ms)
|
||||
self._file_transfer_handler = FileTransfersHandler(self._tox, self._settings, self._contacts_provider,
|
||||
@ -387,3 +389,7 @@ class App:
|
||||
callbacks.init_callbacks(self._tox, self._profile, self._settings, self._plugin_loader, self._contacts_manager,
|
||||
self._calls_manager, self._file_transfer_handler, self._ms, self._tray,
|
||||
self._messenger, self._groups_service, self._contacts_provider)
|
||||
|
||||
def _init_profile(self):
|
||||
if not self._profile.has_avatar():
|
||||
self._profile.reset_avatar(self._settings['identicons'])
|
||||
|
@ -30,6 +30,12 @@ class ContactMenuBuilder:
|
||||
|
||||
return self
|
||||
|
||||
def with_optional_action(self, text, handler, show_action):
|
||||
if show_action:
|
||||
self._add_action(text, handler)
|
||||
|
||||
return self
|
||||
|
||||
def with_actions(self, actions):
|
||||
for action in actions:
|
||||
(text, handler) = action
|
||||
@ -175,6 +181,11 @@ class GroupMenuGenerator(BaseContactMenuGenerator):
|
||||
menu = (builder
|
||||
.with_action(util_ui.tr('Set alias'), lambda: main_screen.set_alias(number))
|
||||
.with_submenu(copy_menu_builder)
|
||||
.with_action(util_ui.tr('Reconnect to group'),
|
||||
lambda: groups_service.reconnect_to_group(self._contact.number))
|
||||
.with_optional_action(util_ui.tr('Disconnect from group'),
|
||||
lambda: groups_service.disconnect_from_group(self._contact.number),
|
||||
self._contact.status is not None)
|
||||
.with_action(util_ui.tr('Leave group'), lambda: groups_service.leave_group(self._contact.number))
|
||||
.with_action(util_ui.tr('Notes'), lambda: main_screen.show_note(self._contact))
|
||||
).build()
|
||||
|
@ -490,10 +490,13 @@ class ContactsManager(ToxSave):
|
||||
del self._settings['notes'][contact.tox_id]
|
||||
self._settings.save()
|
||||
self._history.delete_history(contact)
|
||||
if contact.has_avatar():
|
||||
avatar_path = contact.get_contact_avatar_path()
|
||||
remove(avatar_path)
|
||||
|
||||
def _delete_contact(self, num):
|
||||
if num == self._active_contact: # active friend was deleted
|
||||
self.set_active(0 if len(self._contacts) - 1 else -1)
|
||||
self.set_active(0 if len(self._contacts) > 1 else -1)
|
||||
self._contact_provider.remove_contact_from_cache(self._contacts[num].tox_id)
|
||||
del self._contacts[num]
|
||||
self._screen.friends_list.takeItem(num)
|
||||
|
@ -11,7 +11,8 @@ class GroupChat(contact.Contact, ToxSave):
|
||||
def __init__(self, tox, profile_manager, message_getter, number, name, status_message, widget, tox_id):
|
||||
super().__init__(profile_manager, message_getter, number, name, status_message, widget, tox_id)
|
||||
ToxSave.__init__(self, tox)
|
||||
self.set_status(constants.TOX_USER_STATUS['NONE'])
|
||||
status = self._tox.group_is_connected(number)
|
||||
self.set_status(constants.TOX_USER_STATUS['NONE'] if status else None)
|
||||
self._peers = []
|
||||
self._add_self_to_gc()
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import common.tox_save as tox_save
|
||||
import utils.ui as util_ui
|
||||
from groups.peers_list import PeersListGenerator
|
||||
import wrapper.toxcore_enums_and_consts as constants
|
||||
|
||||
|
||||
class GroupsService(tox_save.ToxSave):
|
||||
@ -42,6 +43,16 @@ class GroupsService(tox_save.ToxSave):
|
||||
self._contacts_manager.delete_group(group_number)
|
||||
self._contacts_manager.update_groups_numbers()
|
||||
|
||||
def disconnect_from_group(self, group_number):
|
||||
self._tox.group_disconnect(group_number)
|
||||
group = self._get_group(group_number)
|
||||
group.status = None
|
||||
|
||||
def reconnect_to_group(self, group_number):
|
||||
self._tox.group_reconnect(group_number)
|
||||
group = self._get_group(group_number)
|
||||
group.status = constants.TOX_USER_STATUS['NONE']
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Group invites
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user