def _NH_DNSLookupDidSucceed(self, sender, data): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=sender) if self.interrupted: notification_center.post_notification("BlinkFileTransferDidFail", sender=self) return self.session.connect(ToHeader(self.target_uri), data.result, [self.stream])
def stop(self): self._deactivate() notification_center = NotificationCenter() notification_center.remove_observer(self, name='NetworkConditionsDidChange') self._select_proc.kill() self._command_channel.send_exception(api.GreenletExit)
def end(self): if self.ended: return if self._sip_session_timer is not None and self._sip_session_timer.active( ): self._sip_session_timer.cancel() self._sip_session_timer = None notification_center = NotificationCenter() if self.sip_session is not None: notification_center.remove_observer(self, sender=self.sip_session) notification_center.remove_observer(self, sender=self.msrp_stream) self.sip_session.end() self.sip_session = None self.msrp_stream = None if self.xmpp_session is not None: notification_center.remove_observer(self, sender=self.xmpp_session) self.xmpp_session.end() self.xmpp_session = None self.ended = True if self.started: notification_center.post_notification('ChatSessionDidEnd', sender=self) else: notification_center.post_notification( 'ChatSessionDidFail', sender=self, data=NotificationData(reason='Ended before actually started'))
def _CH_unregister(self, command): # Cancel any timer which would restart the registration process if self._registration_timer is not None and self._registration_timer.active(): self._registration_timer.cancel() self._registration_timer = None registered = self.registered self.registered = False if self._registration is not None: notification_center = NotificationCenter() if registered: self._registration.end(timeout=2) try: while True: notification = self._data_channel.wait() if notification.name == 'SIPRegistrationDidEnd': break except (SIPRegistrationDidFail, SIPRegistrationDidNotEnd), e: notification_center.post_notification('SIPAccountRegistrationDidNotEnd', sender=self.account, data=NotificationData(code=e.data.code, reason=e.data.reason, registration=self._registration)) else: notification_center.post_notification('SIPAccountRegistrationDidEnd', sender=self.account, data=NotificationData(registration=self._registration)) notification_center.remove_observer(self, sender=self._registration) self._registration = None self.account.contact.public_gruu = None self.account.contact.temporary_gruu = None
def stop(self): # stop the thread processing the notifications self._event_queue.stop() self._event_queue.join() # close sip trace file if self._siptrace_file is not None: self._siptrace_file.close() self._siptrace_file = None # close msrp trace file if self._msrptrace_file is not None: self._msrptrace_file.close() self._msrptrace_file = None # close pjsip trace file if self._pjsiptrace_file is not None: self._pjsiptrace_file.close() self._pjsiptrace_file = None # close notifications trace file if self._notifications_file is not None: self._notifications_file.close() self._notifications_file = None # unregister from receiving notifications notification_center = NotificationCenter() notification_center.remove_observer(self)
def _NH_SIPSessionDidEnd(self, notification): log.msg('Session ended') session = notification.sender chat_stream = session.streams[0] notification_center = NotificationCenter() notification_center.remove_observer(self, sender=chat_stream) notification_center.remove_observer(self, sender=session)
def _CH_unpublish(self, command): # Cancel any timer which would restart the publication process if self._publication_timer is not None and self._publication_timer.active( ): self._publication_timer.cancel() self._publication_timer = None publishing = self.publishing self.publishing = False if self._publication is not None: notification_center = NotificationCenter() if publishing: self._publication.end(timeout=2) try: while True: notification = self._data_channel.wait() if notification.name == 'SIPPublicationDidEnd': break except (SIPPublicationDidFail, SIPPublicationDidNotEnd): notification_center.post_notification( self.__nickname__ + 'PublicationDidNotEnd', sender=self) else: notification_center.post_notification(self.__nickname__ + 'PublicationDidEnd', sender=self) notification_center.remove_observer(self, sender=self._publication) self._publication = None command.signal()
def _NH_SIPSessionDidEnd(self, notification): log.msg('Session ended') session = notification.sender chat_stream = session.streams[0] notification_center = NotificationCenter() notification_center.remove_observer(self, sender=chat_stream) notification_center.remove_observer(self, sender=session)
def stop(self): self._deactivate() notification_center = NotificationCenter() notification_center.remove_observer(self, name='SystemIPAddressDidChange') notification_center.remove_observer(self, name='SystemDidWakeUpFromSleep') self._select_proc.kill() self._command_channel.send_exception(api.GreenletExit)
def end(self): if self.ended: return notification_center = NotificationCenter() if self.sip_session is not None: notification_center.remove_observer(self, sender=self.sip_session) if self.sip_session.direction == 'incoming' and not self.started: self.sip_session.reject() else: self.sip_session.end() self.sip_session = None if self.jingle_session is not None: notification_center.remove_observer(self, sender=self.jingle_session) if self.jingle_session.direction == 'incoming' and not self.started: self.jingle_session.reject() else: self.jingle_session.end() self.jingle_session = None self.ended = True if self.started: notification_center.post_notification('MediaSessionHandlerDidEnd', sender=self) else: notification_center.post_notification('MediaSessionHandlerDidFail', sender=self)
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self, name='SIPAccountWillActivate') notification_center.remove_observer(self, name='SIPAccountWillDeactivate') notification_center.remove_observer(self, name='SIPAccountDidDiscoverXCAPSupport') notification_center.remove_observer(self, name='XCAPManagerDidReloadData') notification_center.remove_observer(self, sender=BlinkSettings(), name='CFGSettingsObjectDidChange')
def stop(self): # stop the thread processing the notifications self._event_queue.stop() self._event_queue.join() # close sip trace file if self._siptrace_file is not None: self._siptrace_file.close() self._siptrace_file = None # close msrp trace file if self._msrptrace_file is not None: self._msrptrace_file.close() self._msrptrace_file = None # close pjsip trace file if self._pjsiptrace_file is not None: self._pjsiptrace_file.close() self._pjsiptrace_file = None # close notifications trace file if self._notifications_file is not None: self._notifications_file.close() self._notifications_file = None # unregister from receiving notifications notification_center = NotificationCenter() notification_center.remove_observer(self)
def end(self): if self.ended: return notification_center = NotificationCenter() if self._xmpp_muc_session is not None: notification_center.remove_observer(self, sender=self._xmpp_muc_session) # Send indication that the user has been kicked from the room sender = Identity( FrozenURI(self.sip_identity.uri.user, self.sip_identity.uri.host, self.nickname)) stanza = MUCAvailabilityPresence(sender, self.xmpp_identity, available=False) stanza.jid = self.xmpp_identity stanza.muc_statuses.append('307') xmpp_manager = XMPPManager() xmpp_manager.send_muc_stanza(stanza) self._xmpp_muc_session.end() self._xmpp_muc_session = None if self._sip_session is not None: notification_center.remove_observer(self, sender=self._sip_session) self._sip_session.end() self._sip_session = None self.ended = True notification_center.post_notification('X2SMucHandlerDidEnd', sender=self)
def _CH_unregister(self, command): # Cancel any timer which would restart the registration process if self._registration_timer is not None and self._registration_timer.active( ): self._registration_timer.cancel() self._registration_timer = None registered = self.registered self.registered = False if self._registration is not None: notification_center = NotificationCenter() if registered: self._registration.end(timeout=2) try: while True: notification = self._data_channel.wait() if notification.name == 'SIPRegistrationDidEnd': break except (SIPRegistrationDidFail, SIPRegistrationDidNotEnd) as e: notification_center.post_notification( 'SIPAccountRegistrationDidNotEnd', sender=self.account, data=NotificationData(code=e.data.code, reason=e.data.reason, registration=self._registration)) else: notification_center.post_notification( 'SIPAccountRegistrationDidEnd', sender=self.account, data=NotificationData(registration=self._registration)) notification_center.remove_observer(self, sender=self._registration) self._registration = None self.account.contact.public_gruu = None self.account.contact.temporary_gruu = None command.signal()
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self, name='SIPAccountWillActivate') notification_center.remove_observer(self, name='SIPAccountWillDeactivate') notification_center.remove_observer(self, name='SIPAccountDidDiscoverXCAPSupport') notification_center.remove_observer(self, name='XCAPManagerDidReloadData') notification_center.remove_observer(self, sender=BlinkSettings(), name='CFGSettingsObjectDidChange')
def _make_and_send_request(self, contact_header, route_header, timeout, do_register): notification_center = NotificationCenter() prev_request = self._current_request or self._last_request if prev_request is not None: call_id = prev_request.call_id cseq = prev_request.cseq + 1 else: call_id = None cseq = 1 extra_headers = [] extra_headers.append(Header("Expires", str(int(self.duration) if do_register else 0))) extra_headers.extend(self.extra_headers) request = Request("REGISTER", SIPURI(self.from_header.uri.host), self.from_header, ToHeader.new(self.from_header), route_header, credentials=self.credentials, contact_header=contact_header, call_id=call_id, cseq=cseq, extra_headers=extra_headers) notification_center.add_observer(self, sender=request) if self._current_request is not None: # we are trying to send something already, cancel whatever it is self._current_request.end() self._current_request = None try: request.send(timeout=timeout) except: notification_center.remove_observer(self, sender=request) raise self._unregistering = not do_register self._current_request = request
def _make_and_send_request(self, body, route_header, timeout, do_publish): notification_center = NotificationCenter() extra_headers = [] extra_headers.append(Header("Event", self.event)) extra_headers.append( Header("Expires", str(int(self.duration) if do_publish else 0))) if self._last_etag is not None: extra_headers.append(Header("SIP-If-Match", self._last_etag)) extra_headers.extend(self.extra_headers) content_type = (self.content_type if body is not None else None) request = Request("PUBLISH", self.from_header.uri, self.from_header, ToHeader.new(self.from_header), route_header, credentials=self.credentials, cseq=1, extra_headers=extra_headers, content_type=content_type, body=body) notification_center.add_observer(self, sender=request) if self._current_request is not None: # we are trying to send something already, cancel whatever it is self._current_request.end() self._current_request = None try: request.send(timeout=timeout) except: notification_center.remove_observer(self, sender=request) raise self._unpublishing = not do_publish self._current_request = request
def _NH_SIPOptionsDidFail(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=notification.sender) if not self._routes: notification_center.post_notification('SIPOptionsRequestDidFail', sender=self, data=TimestampedNotificationData(code=notification.data.code, reason=notification.data.reason)) return self._send_options()
def send(self, timeout=None): notification_center = NotificationCenter() with self._lock: notification_center.add_observer(self, sender=self._request) try: self._request.send(timeout) except: notification_center.remove_observer(self, sender=self._request)
def _NH_DNSLookupDidFail(self, sender, data): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=sender) self.log_info("DNS Lookup for SIP routes failed: '%s'" % data.error) self.fail_reason = "DNS Lookup failed" self.status = self.fail_reason self.ft_info.status = "failed" notification_center.post_notification("BlinkFileTransferDidFail", sender=self)
def _NH_MediaStreamWillEnd(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=self.beep) self.beep.stop() self.beep = None if self.unavailable_message: notification_center.remove_observer(self, sender=self.unavailable_message) self.unavailable_message.stop() self.unavailable_message = None
def _NH_MediaStreamWillEnd(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=self.beep) self.beep.stop() self.beep = None if self.unavailable_message: notification_center.remove_observer(self, sender=self.unavailable_message) self.unavailable_message.stop() self.unavailable_message = None
def master(self, master): old_master = self.__dict__['master'] if old_master is master: return notification_center = NotificationCenter() if old_master is not None: notification_center.remove_observer(self, sender=old_master) if master is not None: notification_center.add_observer(self, sender=master) self.__dict__['master'] = master
def send(self, timeout=None): notification_center = NotificationCenter() with self._lock: if self.is_sent: raise RuntimeError("This MESSAGE was already sent") notification_center.add_observer(self, sender=self._request) try: self._request.send(timeout) except: notification_center.remove_observer(self, sender=self._request)
def send(self, timeout=None): notification_center = NotificationCenter() with self._lock: if self.is_sent: raise RuntimeError("This MESSAGE was already sent") notification_center.add_observer(self, sender=self._request) try: self._request.send(timeout) except: notification_center.remove_observer(self, sender=self._request)
def stop(self): if not self.started: return notification_center = NotificationCenter() notification_center.remove_observer(self, name="BlinkFileTransferDidEnd") notification_center.remove_observer(self, name="AudioStreamDidChangeHoldState") notification_center.remove_observer(self, name="CFGSettingsObjectDidChange") notification_center.remove_observer(self, name="ChatViewControllerDidDisplayMessage") notification_center.remove_observer(self, name="ConferenceHasAddedAudio") notification_center.remove_observer(self, name="BlinkWillCancelProposal")
def _set_master(self, master): old_master = self.__dict__['master'] if old_master is master: return notification_center = NotificationCenter() if old_master is not None: notification_center.remove_observer(self, sender=old_master) if master is not None: notification_center.add_observer(self, sender=master) self.__dict__['master'] = master
def protocol(self, value): old_protocol = self.__dict__.get('protocol', None) new_protocol = self.__dict__['protocol'] = value if new_protocol is old_protocol: return notification_center = NotificationCenter() if old_protocol is not None: notification_center.remove_observer(self, sender=old_protocol) if new_protocol is not None: notification_center.add_observer(self, sender=new_protocol)
def start(self, welcome_prompt=True): notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.session) self.proc = proc.spawn(self.play_audio_welcome, welcome_prompt) self.proc.wait() notification_center.remove_observer(self, sender=self.session) self.session = None self.room = None self.proc = None
def stop(self): if not self._started: return self._started = False self._deactivate() self._bonjour_services.stop() notification_center = NotificationCenter() notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=self) notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings())
def _NH_DNSLookupDidSucceed(self, sender, data): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=sender) if self.interrupted: notification_center.post_notification( "BlinkFileTransferDidFail", sender=self, data=TimestampedNotificationData()) return self.session.connect(ToHeader(self.target_uri), data.result, [self.stream])
def start(self): if self.started: return self.started = True notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) notification_center.post_notification(self.__class__.__name__ + 'WillStart', sender=self) notification_center.add_observer(self, name='NetworkConditionsDidChange') self._command_proc = proc.spawn(self._run) notification_center.post_notification(self.__class__.__name__ + 'DidStart', sender=self) notification_center.remove_observer(self, sender=self)
def start(self): if self.started: return self.started = True notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) notification_center.post_notification(self.__class__.__name__ + 'WillStart', sender=self) notification_center.add_observer(self, name='NetworkConditionsDidChange') self._command_proc = proc.spawn(self._run) notification_center.post_notification(self.__class__.__name__ + 'DidStart', sender=self) notification_center.remove_observer(self, sender=self)
def stop(self): # deactivate command = Command('stop') self._command_channel.send(command) command.wait() self._stopped = True notification_center = NotificationCenter() notification_center.remove_observer(self, name='SystemIPAddressDidChange') notification_center.remove_observer(self, name='SystemDidWakeUpFromSleep') self._select_proc.kill() self._command_channel.send_exception(api.GreenletExit)
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self) self.event_queue.stop() self.event_queue.join() self.event_queue = Null self.siptrace_file = Null self.msrptrace_file = Null self.pjsiptrace_file = Null self.notifications_file = Null
def _NH_DNSLookupDidFail(self, sender, data): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=sender) self.log_info("DNS Lookup for SIP routes failed: '%s'" % data.error) self.fail_reason = "DNS Lookup failed" self.status = self.fail_reason self.ft_info.status = "failed" notification_center.post_notification( "BlinkFileTransferDidFail", sender=self, data=TimestampedNotificationData())
def _NH_DNSLookupDidSucceed(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=notification.sender) account = DefaultAccount() conference_application = ConferenceApplication() try: room = conference_application.get_room(self.room_uri) except RoomNotFoundError: log.info('Room %s - failed to add %s' % (self.room_uri_str, self.refer_to_uri)) self._refer_request.end(500) return active_media = set(room.active_media).intersection(('audio', 'chat')) if not active_media: log.info('Room %s - failed to add %s' % (self.room_uri_str, self.refer_to_uri)) self._refer_request.end(500) return for stream_type in active_media: self.streams.append(MediaStreamRegistry.get(stream_type)()) self.session = Session(account) notification_center.add_observer(self, sender=self.session) original_from_header = self._refer_headers.get('From') if original_from_header.display_name: original_identity = "%s <%s@%s>" % ( original_from_header.display_name, original_from_header.uri.user, original_from_header.uri.host) else: original_identity = "%s@%s" % (original_from_header.uri.user, original_from_header.uri.host) from_header = FromHeader(SIPURI.new(self.room_uri), u'Conference Call') to_header = ToHeader(self.refer_to_uri) extra_headers = [] if self._refer_headers.get('Referred-By', None) is not None: extra_headers.append( Header.new(self._refer_headers.get('Referred-By'))) else: extra_headers.append( Header('Referred-By', str(original_from_header.uri))) if ThorNodeConfig.enabled: extra_headers.append(Header('Thor-Scope', 'conference-invitation')) extra_headers.append( Header('X-Originator-From', str(original_from_header.uri))) extra_headers.append( SubjectHeader(u'Join conference request from %s' % original_identity)) route = notification.data.result[0] self.session.connect(from_header, to_header, route=route, streams=self.streams, is_focus=True, extra_headers=extra_headers)
def end(self): if self.ended: return notification_center = NotificationCenter() if self._xmpp_subscription is not None: notification_center.remove_observer(self, sender=self._xmpp_subscription) self._xmpp_subscription.end() self._xmpp_subscription = None if self._sip_subscription: self._unsubscribe_sip() self.ended = True notification_center.post_notification("X2SPresenceHandlerDidEnd", sender=self)
def end(self): if self.ended: return notification_center = NotificationCenter() if self._xmpp_subscription is not None: notification_center.remove_observer(self, sender=self._xmpp_subscription) self._xmpp_subscription.end() self._xmpp_subscription = None if self._sip_subscription: self._unsubscribe_sip() self.ended = True notification_center.post_notification('X2SPresenceHandlerDidEnd', sender=self)
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self) self.event_queue.stop() self.event_queue.join() self.event_queue = Null self.siptrace_file = Null self.msrptrace_file = Null self.pjsiptrace_file = Null self.notifications_file = Null
def stop(self): self.stopped = True self._s2s_listener.stopListening() self.jingle_session_manager.stop() self.subscription_manager.stop() self.muc_session_manager.stop() self.chat_session_manager.stop() self._internal_component.stopService() self._muc_component.stopService() notification_center = NotificationCenter() notification_center.remove_observer(self, sender=self._internal_component) notification_center.remove_observer(self, sender=self._muc_component)
def stop(self): self.stopped = True self._s2s_listener.stopListening() self.jingle_session_manager.stop() self.subscription_manager.stop() self.muc_session_manager.stop() self.chat_session_manager.stop() self._internal_component.stopService() self._muc_component.stopService() notification_center = NotificationCenter() notification_center.remove_observer(self, sender=self._internal_component) notification_center.remove_observer(self, sender=self._muc_component) xmpp_logger.stop()
def _NH_SIPRequestDidEnd(self, notification): notification_center = NotificationCenter() with self._lock: notification_center.remove_observer(self, sender=notification.sender) if notification.sender is not self._last_request: return self._last_request = None if self._current_request is not None: self._current_request.end() self._current_request = None self._last_etag = None notification_center.post_notification("SIPPublicationDidEnd", sender=self, data=TimestampedNotificationData(expired=True))
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self, name='SIPSessionNewIncoming') notification_center.remove_observer(self, name='SIPSessionGotProposal') notification_center.remove_observer(self, name='SIPSessionDidFail') notification_center.remove_observer(self, name='SIPSessionGotRejectProposal') notification_center.remove_observer(self, name='SIPSessionDidRenegotiateStreams')
def _NH_SIPSubscriptionDidEnd(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=notification.sender) route = Route( notification.sender.route_header.uri.host, notification.sender.route_header.uri.port, notification.sender.route_header.uri.parameters.get( 'transport', 'udp')) if (route.uri.user): self.statusdict.pop(str( route.uri.user)) # removes them from the status list self.output.put('Unsubscribed from %s:%d;transport=%s' % (route.address, route.port, route.transport)) self.stop()
def stop(self): if not self.started: return self.started = False self.active = False notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) notification_center.post_notification(self.__class__.__name__ + 'WillEnd', sender=self) notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=self.account) notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings()) notification_center.remove_observer(self, name='NetworkConditionsDidChange') command = Command('terminate') self._command_channel.send(command) command.wait() self._command_proc = None notification_center.post_notification(self.__class__.__name__ + 'DidDeactivate', sender=self) notification_center.post_notification(self.__class__.__name__ + 'DidEnd', sender=self) notification_center.remove_observer(self, sender=self)
def _NH_SIPRequestDidEnd(self, notification): request = notification.sender notification_center = NotificationCenter() with self._lock: notification_center.remove_observer(self, sender=request) if request is not self._last_request: return self._last_request = None if self._current_request is not None: self._current_request.end() self._current_request = None notification_center.post_notification( "SIPRegistrationDidEnd", sender=self, data=TimestampedNotificationData(expired=True))
def _set_account(self, account): notification_center = NotificationCenter() old_account = self.__dict__.get('account', Null) if account is old_account: return self.__dict__['account'] = account self.authenticated = False if old_account: notification_center.remove_observer(self, sender=old_account) if account: notification_center.add_observer(self, sender=account) self.access_manager.authenticationRequired.disconnect(self._SH_AuthenticationRequired) self.access_manager = QNetworkAccessManager(self) self.access_manager.authenticationRequired.connect(self._SH_AuthenticationRequired) self.page().setNetworkAccessManager(self.access_manager)
def stop(self): log.msg('Falcon HAL backend stopped') notification_center = NotificationCenter() notification_center.remove_observer(self, name='IncomingRequestReceived') notification_center.remove_observer(self, name='IncomingRequestAccepted') notification_center.remove_observer(self, name='IncomingRequestRejected') notification_center.remove_observer(self, name='SessionItemNewIncoming') notification_center.remove_observer(self, name='SessionItemNewOutgoing') notification_center.remove_observer(self, name='SessionItemDidChange') notification_center.remove_observer(self, name='SessionItemDidEnd') # Cleanup hardware stuff GPIO.cleanup() self._lcd.clear() self._lcd_gpio.cleanup()
def stop(self): notification_center = NotificationCenter() notification_center.remove_observer(self, name='JingleSessionNewIncoming') notification_center.remove_observer(self, name='JingleSessionNewOutgoing') notification_center.remove_observer(self, name='JingleSessionDidFail') notification_center.remove_observer(self, name='JingleSessionDidEnd')
def stop(self): if not self._started: return self._started = False self._deactivate() self._bonjour_services.stop() notification_center = NotificationCenter() notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=self) notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings())
def stop(self): if not self.started: return self.started = False self.active = False notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) notification_center.post_notification(self.__class__.__name__ + 'WillEnd', sender=self) notification_center.remove_observer(self, name='NetworkConditionsDidChange') command = Command('terminate') self._command_channel.send(command) command.wait() self._command_proc = None notification_center.post_notification(self.__class__.__name__ + 'DidDeactivate', sender=self) notification_center.post_notification(self.__class__.__name__ + 'DidEnd', sender=self) notification_center.remove_observer(self, sender=self)
def end(self): if self.ended: return notification_center = NotificationCenter() if self._xmpp_subscription is not None: notification_center.remove_observer(self, sender=self._xmpp_subscription) self._xmpp_subscription.end() self._xmpp_subscription = None while self._sip_subscriptions: subscription = self._sip_subscriptions.pop() notification_center.remove_observer(self, sender=subscription) try: subscription.end() except SIPCoreError: pass self.ended = True notification_center.post_notification("S2XPresenceHandlerDidEnd", sender=self)
def _cleanup(self): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=self.session) self.session = None if self.audio_stream is not None: notification_center.discard_observer(self, sender=self.audio_stream) self.audio_stream = None if self.chat_stream is not None: notification_center.discard_observer(self, sender=self.chat_stream) self.chat_stream = None if self.end_timer is not None and self.end_timer.active(): self.end_timer.cancel() self.end_timer = None
def _NH_DNSLookupDidSucceed(self, notification): notification_center = NotificationCenter() notification_center.remove_observer(self, sender=notification.sender) account = DefaultAccount() conference_application = ConferenceApplication() try: room = conference_application.get_room(self.room_uri) except RoomNotFoundError: log.msg("Room %s - failed to add %s" % (self.room_uri_str, self.refer_to_uri)) self._refer_request.end(500) return active_media = set(room.active_media).intersection(("audio", "chat")) if not active_media: log.msg("Room %s - failed to add %s" % (self.room_uri_str, self.refer_to_uri)) self._refer_request.end(500) return registry = MediaStreamRegistry() for stream_type in active_media: self.streams.append(registry.get(stream_type)()) self.session = Session(account) notification_center.add_observer(self, sender=self.session) original_from_header = self._refer_headers.get("From") if original_from_header.display_name: original_identity = "%s <%s@%s>" % ( original_from_header.display_name, original_from_header.uri.user, original_from_header.uri.host, ) else: original_identity = "%s@%s" % (original_from_header.uri.user, original_from_header.uri.host) from_header = FromHeader(SIPURI.new(self.room_uri), u"Conference Call") to_header = ToHeader(self.refer_to_uri) extra_headers = [] if self._refer_headers.get("Referred-By", None) is not None: extra_headers.append(Header.new(self._refer_headers.get("Referred-By"))) else: extra_headers.append(Header("Referred-By", str(original_from_header.uri))) if ThorNodeConfig.enabled: extra_headers.append(Header("Thor-Scope", "conference-invitation")) extra_headers.append(Header("X-Originator-From", str(original_from_header.uri))) extra_headers.append(SubjectHeader(u"Join conference request from %s" % original_identity)) route = notification.data.result[0] self.session.connect( from_header, to_header, route=route, streams=self.streams, is_focus=True, extra_headers=extra_headers )
def stop(self): self.authorization_handler.stop() notification_center = NotificationCenter() notification_center.remove_observer(self, name='SIPSessionNewIncoming') notification_center.remove_observer(self, name='SIPIncomingSubscriptionGotSubscribe') notification_center.remove_observer(self, name='SIPIncomingReferralGotRefer') notification_center.remove_observer(self, name='SIPIncomingRequestGotRequest') for app in ApplicationRegistry(): try: app().stop() except Exception, e: log.warning('Error stopping application: %s' % e) log.err()