Exemple #1
0
    def reset(self):
        """
        Create new tox instance (new network settings)
        :return: tox instance
        """
        self.mainloop.stop = True
        self.init.stop = True
        self.avloop.stop = True
        self.mainloop.wait()
        self.init.wait()
        self.avloop.wait()
        data = self.tox.get_savedata()
        ProfileHelper.get_instance().save_profile(data)
        del self.tox
        # create new tox instance
        self.tox = profile.tox_factory(data, Settings.get_instance())
        # init thread
        self.init = self.InitThread(self.tox, self.ms, self.tray)
        self.init.start()

        # starting threads for tox iterate and toxav iterate
        self.mainloop = self.ToxIterateThread(self.tox)
        self.mainloop.start()

        self.avloop = self.ToxAVIterateThread(self.tox.AV)
        self.avloop.start()

        plugin_helper = PluginLoader.get_instance()
        plugin_helper.set_tox(self.tox)

        return self.tox
Exemple #2
0
def lossy_packet(tox, friend_number, data, length, user_data):
    """
    Incoming lossy packet
    """
    data = data[:length]
    plugin = PluginLoader.get_instance()
    invoke_in_main_thread(plugin.callback_lossy, friend_number, data)
Exemple #3
0
    def reset(self):
        """
        Create new tox instance (new network settings)
        :return: tox instance
        """
        self.mainloop.stop = True
        self.init.stop = True
        self.avloop.stop = True
        self.mainloop.wait()
        self.init.wait()
        self.avloop.wait()
        data = self.tox.get_savedata()
        ProfileHelper.get_instance().save_profile(data)
        del self.tox
        # create new tox instance
        self.tox = profile.tox_factory(data, Settings.get_instance())
        # init thread
        self.init = self.InitThread(self.tox, self.ms, self.tray)
        self.init.start()

        # starting threads for tox iterate and toxav iterate
        self.mainloop = self.ToxIterateThread(self.tox)
        self.mainloop.start()

        self.avloop = self.ToxAVIterateThread(self.tox.AV)
        self.avloop.start()

        plugin_helper = PluginLoader.get_instance()
        plugin_helper.set_tox(self.tox)

        return self.tox
Exemple #4
0
def lossy_packet(tox, friend_number, data, length, user_data):
    """
    Incoming lossy packet
    """
    data = data[:length]
    plugin = PluginLoader.get_instance()
    invoke_in_main_thread(plugin.callback_lossy, friend_number, data)
Exemple #5
0
def lossless_packet(tox, friend_number, data, length, user_data):
    """
    Incoming lossless packet
    """
    plugin = PluginLoader.get_instance()
    invoke_in_main_thread(plugin.callback_lossless, friend_number, data,
                          length)
Exemple #6
0
def friend_connection_status(tox, friend_num, new_status, user_data):
    """
    Check friend's connection status (offline, udp, tcp)
    """
    print("Friend #{} connection status: {}".format(friend_num, new_status))
    profile = Profile.get_instance()
    friend = profile.get_friend_by_number(friend_num)
    if new_status == TOX_CONNECTION['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'])
    elif friend.status is None:
        invoke_in_main_thread(profile.send_avatar, friend_num)
        invoke_in_main_thread(PluginLoader.get_instance().friend_online, friend_num)
Exemple #7
0
def friend_connection_status(tox, friend_num, new_status, user_data):
    """
    Check friend's connection status (offline, udp, tcp)
    """
    print("Friend #{} connection status: {}".format(friend_num, new_status))
    profile = Profile.get_instance()
    friend = profile.get_friend_by_number(friend_num)
    if new_status == TOX_CONNECTION['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'])
    elif friend.status is None:
        invoke_in_main_thread(profile.send_avatar, friend_num)
        invoke_in_main_thread(PluginLoader.get_instance().friend_online, friend_num)