Commit f4ae2397 authored by Dan Pascu's avatar Dan Pascu

Improved tracking of blink sessions from the session manager

parent 21086ea9
...@@ -5204,16 +5204,10 @@ class SessionManager(object): ...@@ -5204,16 +5204,10 @@ class SessionManager(object):
notification_center.add_observer(self, name='SIPSessionNewIncoming') notification_center.add_observer(self, name='SIPSessionNewIncoming')
notification_center.add_observer(self, name='SIPSessionDidFail') notification_center.add_observer(self, name='SIPSessionDidFail')
notification_center.add_observer(self, name='BlinkFileTransferDidChangeState') notification_center.add_observer(self, name='BlinkSessionWasCreated')
notification_center.add_observer(self, name='BlinkFileTransferDidEnd') notification_center.add_observer(self, name='BlinkFileTransferWasCreated')
notification_center.add_observer(self, name='BlinkFileTransferWillRetry') notification_center.add_observer(self, name='BlinkFileTransferWillRetry')
notification_center.add_observer(self, name='BlinkSessionDidChangeState')
notification_center.add_observer(self, name='BlinkSessionDidChangeHoldState')
notification_center.add_observer(self, name='BlinkSessionDidRemoveStream')
notification_center.add_observer(self, name='BlinkSessionDidEnd')
notification_center.add_observer(self, name='BlinkSessionWasDeleted')
notification_center.add_observer(self, name='BlinkSessionListSelectionChanged') notification_center.add_observer(self, name='BlinkSessionListSelectionChanged')
def create_session(self, contact, contact_uri, streams, account=None, connect=True, sibling=None): def create_session(self, contact, contact_uri, streams, account=None, connect=True, sibling=None):
...@@ -5228,7 +5222,6 @@ class SessionManager(object): ...@@ -5228,7 +5222,6 @@ class SessionManager(object):
reinitialize = True reinitialize = True
except StopIteration: except StopIteration:
session = BlinkSession() session = BlinkSession()
self.sessions.append(session)
reinitialize = False reinitialize = False
session.init_outgoing(account, contact, contact_uri, streams, sibling=sibling, reinitialize=reinitialize) session.init_outgoing(account, contact, contact_uri, streams, sibling=sibling, reinitialize=reinitialize)
...@@ -5248,7 +5241,6 @@ class SessionManager(object): ...@@ -5248,7 +5241,6 @@ class SessionManager(object):
self.send_file_directory = os.path.dirname(filename) self.send_file_directory = os.path.dirname(filename)
transfer = BlinkFileTransfer() transfer = BlinkFileTransfer()
self.file_transfers.append(transfer)
transfer.init_outgoing(account, contact, contact_uri, filename, transfer_id) transfer.init_outgoing(account, contact, contact_uri, filename, transfer_id)
transfer.connect() transfer.connect()
return transfer return transfer
...@@ -5369,7 +5361,6 @@ class SessionManager(object): ...@@ -5369,7 +5361,6 @@ class SessionManager(object):
reinitialize = True reinitialize = True
except StopIteration: except StopIteration:
blink_session = BlinkSession() blink_session = BlinkSession()
self.sessions.append(blink_session)
reinitialize = False reinitialize = False
blink_session.init_incoming(incoming_request.session, accepted_streams, incoming_request.contact, incoming_request.contact_uri, reinitialize=reinitialize) blink_session.init_incoming(incoming_request.session, accepted_streams, incoming_request.contact, incoming_request.contact_uri, reinitialize=reinitialize)
...@@ -5387,7 +5378,6 @@ class SessionManager(object): ...@@ -5387,7 +5378,6 @@ class SessionManager(object):
self.incoming_requests.remove(incoming_request) self.incoming_requests.remove(incoming_request)
self.update_ringtone() self.update_ringtone()
transfer = BlinkFileTransfer() transfer = BlinkFileTransfer()
self.file_transfers.append(transfer)
transfer.init_incoming(incoming_request.contact, incoming_request.contact_uri, incoming_request.session, incoming_request.stream) transfer.init_incoming(incoming_request.contact, incoming_request.contact_uri, incoming_request.session, incoming_request.stream)
def _SH_IncomingFileTransferRequestRejected(self, incoming_request, mode): def _SH_IncomingFileTransferRequestRejected(self, incoming_request, mode):
...@@ -5441,7 +5431,6 @@ class SessionManager(object): ...@@ -5441,7 +5431,6 @@ class SessionManager(object):
reinitialize = True reinitialize = True
except StopIteration: except StopIteration:
blink_session = BlinkSession() blink_session = BlinkSession()
self.sessions.append(blink_session)
reinitialize = False reinitialize = False
blink_session.init_incoming(session, [chat_stream], contact, contact_uri, reinitialize=reinitialize) blink_session.init_incoming(session, [chat_stream], contact, contact_uri, reinitialize=reinitialize)
return return
...@@ -5464,6 +5453,10 @@ class SessionManager(object): ...@@ -5464,6 +5453,10 @@ class SessionManager(object):
self.incoming_requests.remove(incoming_request) self.incoming_requests.remove(incoming_request)
self.update_ringtone() self.update_ringtone()
def _NH_BlinkSessionWasCreated(self, notification):
self.sessions.append(notification.sender)
notification.center.add_observer(self, sender=notification.sender)
def _NH_BlinkSessionDidChangeState(self, notification): def _NH_BlinkSessionDidChangeState(self, notification):
new_state = notification.data.new_state new_state = notification.data.new_state
if new_state == 'connected/received_proposal': if new_state == 'connected/received_proposal':
...@@ -5504,17 +5497,24 @@ class SessionManager(object): ...@@ -5504,17 +5497,24 @@ class SessionManager(object):
def _NH_BlinkSessionWasDeleted(self, notification): def _NH_BlinkSessionWasDeleted(self, notification):
self.sessions.remove(notification.sender) self.sessions.remove(notification.sender)
notification.center.remove_observer(self, sender=notification.sender)
def _NH_BlinkFileTransferWasCreated(self, notification):
self.file_transfers.append(notification.sender)
notification.center.add_observer(self, sender=notification.sender)
def _NH_BlinkFileTransferWillRetry(self, notification):
self.file_transfers.append(notification.sender)
notification.center.add_observer(self, sender=notification.sender)
def _NH_BlinkFileTransferDidChangeState(self, notification): def _NH_BlinkFileTransferDidChangeState(self, notification):
new_state = notification.data.new_state new_state = notification.data.new_state
if new_state in ('connecting/ringing', 'connected', 'ending'): if new_state in ('connecting/ringing', 'connected', 'ending'):
self.update_ringtone() self.update_ringtone()
def _NH_BlinkFileTransferWillRetry(self, notification):
self.file_transfers.append(notification.sender)
def _NH_BlinkFileTransferDidEnd(self, notification): def _NH_BlinkFileTransferDidEnd(self, notification):
self.file_transfers.remove(notification.sender) self.file_transfers.remove(notification.sender)
notification.center.remove_observer(self, sender=notification.sender)
if not notification.data.error and not self._filetransfer_tone_timer.isActive(): if not notification.data.error and not self._filetransfer_tone_timer.isActive():
self._filetransfer_tone_timer.start() self._filetransfer_tone_timer.start()
player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/file_transfer.wav'), volume=30) player = WavePlayer(SIPApplication.voice_audio_bridge.mixer, Resources.get('sounds/file_transfer.wav'), volume=30)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment