diff --git a/toxygen/profile.py b/toxygen/profile.py index 55f83c3..e6cf877 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -80,6 +80,8 @@ class Profile(contact.Contact, Singleton): super(Profile, self).set_status(status) if status is not None: self._tox.self_set_status(status) + else: + QtCore.QTimer.singleShot(30000, self.reconnect) def set_name(self, value): if self.name == value: @@ -787,8 +789,14 @@ class Profile(contact.Contact, Singleton): self.status = None for friend in self._friends: friend.status = None + friend.number = self._tox.friend_by_public_key(friend.tox_id) self.update_filtration() + def reconnect(self): + if self.status is None: + self.reset(self._screen.reset) + QtCore.QTimer.singleShot(30000, self.reconnect) + def close(self): if hasattr(self, '_call'): self._call.stop() @@ -1116,6 +1124,8 @@ class Profile(contact.Contact, Singleton): """User clicked audio button in main window""" num = self.get_active_number() if num not in self._call and self.is_active_online(): # start call + if not Settings.get_instance().audio['enabled']: + return self._call(num, audio, video) self._screen.active_call() if video: @@ -1134,6 +1144,8 @@ class Profile(contact.Contact, Singleton): """ Incoming call from friend. Only audio is supported now """ + if not Settings.get_instance().audio['enabled']: + return friend = self.get_friend_by_number(friend_number) if video: text = QtGui.QApplication.translate("incoming_call", "Incoming video call", None, diff --git a/toxygen/settings.py b/toxygen/settings.py index 48cb5bf..c7d80f3 100644 --- a/toxygen/settings.py +++ b/toxygen/settings.py @@ -34,10 +34,18 @@ class Settings(dict, Singleton): super(Settings, self).__init__(Settings.get_default_settings()) self.save() smileys.SmileyLoader(self) - p = pyaudio.PyAudio() self.locked = False - self.audio = {'input': p.get_default_input_device_info()['index'], - 'output': p.get_default_output_device_info()['index']} + p = pyaudio.PyAudio() + input_devices = output_devices = 0 + for i in range(p.get_device_count()): + device = p.get_device_info_by_index(i) + if device["maxInputChannels"]: + input_devices += 1 + if device["maxOutputChannels"]: + output_devices += 1 + self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1, + 'output': p.get_default_output_device_info()['index'] if output_devices else -1, + 'enabled': input_devices and output_devices} @staticmethod def get_auto_profile():