def start(self): notification_center = NotificationCenter() notification_center.add_observer(self, name='NetworkConditionsDidChange') proc.spawn(self._run) notification_center.post_notification( 'X2SMucInvitationHandlerDidStart', sender=self)
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 __init__(self, parent=None): super(FileTransferWindow, self).__init__(parent) with Resources.directory: self.setupUi(self) self.model = FileTransferModel(self) self.listview.setModel(self.model) self.listview.setItemDelegate(FileTransferDelegate(self.listview)) self.listview.customContextMenuRequested.connect(self._SH_ContextMenuRequested) self.context_menu = QMenu(self.listview) self.actions = ContextMenuActions() self.actions.open_file = QAction("Open", self, triggered=self._AH_OpenFile) self.actions.open_file_folder = QAction("Open File Folder", self, triggered=self._AH_OpenFileFolder) self.actions.cancel_transfer = QAction("Cancel", self, triggered=self._AH_CancelTransfer) self.actions.retry_transfer = QAction("Retry", self, triggered=self._AH_RetryTransfer) self.actions.remove_entry = QAction("Remove From List", self, triggered=self._AH_RemoveEntry) self.actions.open_downloads_folder = QAction("Open Transfers Folder", self, triggered=self._AH_OpenTransfersFolder) self.actions.clear_list = QAction("Clear List", self, triggered=self._AH_ClearList) self.model.itemAdded.connect(self.update_status) self.model.itemRemoved.connect(self.update_status) self.model.modelReset.connect(self.update_status) notification_center = NotificationCenter() notification_center.add_observer(self, name='BlinkFileTransferWillRetry') notification_center.add_observer(self, name='BlinkFileTransferDidEnd')
def _NH_SIPApplicationDidStart(self, notification): account_manager = AccountManager() self.xcap_manager = XCAPManager(account_manager.default_account) notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.xcap_manager) self.xcap_manager.load(os.path.realpath('xcap-cache')) self.xcap_manager.start()
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 _start_incoming_sip_session(self, session): self.sip_session = session self.msrp_stream = next(stream for stream in session.proposed_streams if stream.type=='chat') notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.sip_session) notification_center.add_observer(self, sender=self.msrp_stream) self.sip_session.accept([self.msrp_stream])
def start(self): settings = SIPSimpleSettings() notification_center = NotificationCenter() notification_center.add_observer(self) if settings.logs.trace_sip: self.siptrace_file = LogFile( os.path.join(ApplicationData.directory, 'logs', 'sip_trace.txt')) if settings.logs.trace_msrp: self.msrptrace_file = LogFile( os.path.join(ApplicationData.directory, 'logs', 'msrp_trace.txt')) if settings.logs.trace_pjsip: self.pjsiptrace_file = LogFile( os.path.join(ApplicationData.directory, 'logs', 'pjsip_trace.txt')) if settings.logs.trace_notifications: self.notifications_file = LogFile( os.path.join(ApplicationData.directory, 'logs', 'notifications_trace.txt')) self._siptrace_start_time = datetime.now() self._siptrace_packet_count = 0 self.event_queue = EventQueue(handler=self._process_notification, name='Blink LogManager') self.event_queue.start() while settings.logs.trace_notifications and self.notification_queue and self.notification_queue.notifications: notification = self.notification_queue.notifications.popleft() self.handle_notification(notification) self.notification_queue = None
def _start_outgoing_sip_session(self, target_uri): notification_center = NotificationCenter() # self.xmpp_identity is our local identity from_uri = self.xmpp_identity.uri.as_sip_uri() del from_uri.parameters['gr'] # no GRUU in From header contact_uri = self.xmpp_identity.uri.as_sip_uri() contact_uri.parameters['gr'] = encode_resource(contact_uri.parameters['gr'].decode('utf-8')) to_uri = target_uri.as_sip_uri() lookup = DNSLookup() settings = SIPSimpleSettings() account = DefaultAccount() if account.sip.outbound_proxy is not None: uri = SIPURI(host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = to_uri try: routes = lookup.lookup_sip_proxy(uri, settings.sip.transport_list).wait() except DNSLookupError: log.warning('DNS lookup error while looking for %s proxy' % uri) notification_center.post_notification('ChatSessionDidFail', sender=self, data=NotificationData(reason='DNS lookup error')) return self.msrp_stream = MediaStreamRegistry.get('chat')() route = routes.pop(0) from_header = FromHeader(from_uri) to_header = ToHeader(to_uri) contact_header = ContactHeader(contact_uri) self.sip_session = Session(account) notification_center.add_observer(self, sender=self.sip_session) notification_center.add_observer(self, sender=self.msrp_stream) self.sip_session.connect(from_header, to_header, contact_header=contact_header, route=route, streams=[self.msrp_stream])
def _start_outgoing_sip_session(self, streams): notification_center = NotificationCenter() # self.xmpp_identity is our local identity on the SIP side from_uri = self.xmpp_identity.uri.as_sip_uri() from_uri.parameters.pop('gr', None) # no GRUU in From header to_uri = self.sip_identity.uri.as_sip_uri() to_uri.parameters.pop('gr', None) # no GRUU in To header # TODO: need to fix GRUU in the proxy #contact_uri = self.xmpp_identity.uri.as_sip_uri() #contact_uri.parameters['gr'] = encode_resource(contact_uri.parameters['gr'].decode('utf-8')) lookup = DNSLookup() settings = SIPSimpleSettings() account = DefaultAccount() if account.sip.outbound_proxy is not None: uri = SIPURI(host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = to_uri try: routes = lookup.lookup_sip_proxy(uri, settings.sip.transport_list).wait() except DNSLookupError: log.warning('DNS lookup error while looking for %s proxy' % uri) notification_center.post_notification('MedialSessionHandlerDidFail', sender=self, data=NotificationData(reason='DNS lookup error')) return route = routes.pop(0) from_header = FromHeader(from_uri) to_header = ToHeader(to_uri) self.sip_session = Session(account) notification_center.add_observer(self, sender=self.sip_session) self.sip_session.connect(from_header, to_header, route=route, streams=streams)
def __init__(self, owner): BlinkLogger().log_debug('Starting Ringtone Manager') notification_center = NotificationCenter() notification_center.add_observer(self, name="SIPApplicationDidStart") self.owner = owner self.started = False self.cleanupTimer = None
def start(self): if not self.refer_to_uri.startswith(('sip:', 'sips:')): self.refer_to_uri = 'sip:%s' % self.refer_to_uri try: self.refer_to_uri = SIPURI.parse(self.refer_to_uri) except SIPCoreError: log.msg('Room %s - failed to add %s' % (self.room_uri_str, self.refer_to_uri)) self._refer_request.reject(488) return notification_center = NotificationCenter() notification_center.add_observer(self, sender=self._refer_request) if self.method == 'INVITE': self._refer_request.accept() settings = SIPSimpleSettings() account = DefaultAccount() if account.sip.outbound_proxy is not None: uri = SIPURI(host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = self.refer_to_uri lookup = DNSLookup() notification_center.add_observer(self, sender=lookup) lookup.lookup_sip_proxy(uri, settings.sip.transport_list) elif self.method == 'BYE': log.msg('Room %s - %s removed %s from the room' % (self.room_uri_str, self._refer_headers.get('From').uri, self.refer_to_uri)) self._refer_request.accept() conference_application = ConferenceApplication() conference_application.remove_participant(self.refer_to_uri, self.room_uri) self._refer_request.end(200) else: self._refer_request.reject(488)
def initiate_file_transfer(self): notification_center = NotificationCenter() notification_center.add_observer(self, sender=self) try: self.file_selector = FileSelector.for_file(self.file_path.encode('utf-8'), hash=None) except IOError: notification_center.post_notification('BlinkFileTransferDidNotComputeHash', sender=self, data=NotificationData(reason='Cannot open file')) return self.ft_info.file_size = self.file_size # compute the file hash first self.ft_info.status = "preparing" self.status = "Computing checksum..." hash = hashlib.sha1() pos = progress = 0 chunk_size = limit(self.file_selector.size/100, min=65536, max=1048576) notification_center.post_notification('BlinkFileTransferHashUpdate', sender=self, data=NotificationData(progress=0)) while not self.stop_event.isSet(): content = self.file_selector.fd.read(chunk_size) if not content: break hash.update(content) pos += len(content) old_progress, progress = progress, int(float(pos)/self.file_selector.size*100) if old_progress != progress: notification_center.post_notification('BlinkFileTransferHashUpdate', sender=self, data=NotificationData(progress=progress)) else: self.file_selector.fd.close() notification_center.post_notification('BlinkFileTransferDidNotComputeHash', sender=self, data=NotificationData(reason='Cancelled computing checksum')) return self.file_selector.fd.seek(0) self.file_selector.hash = hash notification_center.post_notification('BlinkFileTransferDidComputeHash', sender=self)
def start(self): notification_center = NotificationCenter() notification_center.add_observer(self, name='SystemIPAddressDidChange') notification_center.add_observer(self, name='SystemDidWakeUpFromSleep') self._select_proc = proc.spawn(self._process_files) proc.spawn(self._handle_commands) self._activate()
def _start_outgoing_sip_session(self, target_uri): notification_center = NotificationCenter() # self.xmpp_identity is our local identity from_uri = self.xmpp_identity.uri.as_sip_uri() del from_uri.parameters['gr'] # no GRUU in From header contact_uri = self.xmpp_identity.uri.as_sip_uri() contact_uri.parameters['gr'] = encode_resource(contact_uri.parameters['gr'].decode('utf-8')) to_uri = target_uri.as_sip_uri() lookup = DNSLookup() settings = SIPSimpleSettings() account = DefaultAccount() if account.sip.outbound_proxy is not None: uri = SIPURI(host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = to_uri try: routes = lookup.lookup_sip_proxy(uri, settings.sip.transport_list).wait() except DNSLookupError: log.warning('DNS lookup error while looking for %s proxy' % uri) notification_center.post_notification('ChatSessionDidFail', sender=self, data=NotificationData(reason='DNS lookup error')) return self.msrp_stream = MediaStreamRegistry().get('chat')() route = routes.pop(0) from_header = FromHeader(from_uri) to_header = ToHeader(to_uri) contact_header = ContactHeader(contact_uri) self.sip_session = Session(account) notification_center.add_observer(self, sender=self.sip_session) notification_center.add_observer(self, sender=self.msrp_stream) self.sip_session.connect(from_header, to_header, contact_header=contact_header, route=route, streams=[self.msrp_stream])
def start(self): notification_center = NotificationCenter() self.greenlet = api.getcurrent() settings = SIPSimpleSettings() account = AccountManager().sylkserver_account if account.sip.outbound_proxy is not None: uri = SIPURI(host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = self.destination_uri lookup = DNSLookup() try: routes = lookup.lookup_sip_proxy(uri, settings.sip.transport_list).wait() except DNSLookupError: notification_center.post_notification('OutgoingFileTransferHandlerDidFail', sender=self) return self.session = Session(account) self.stream = FileTransferStream(self.file_selector, 'sendonly') notification_center.add_observer(self, sender=self.session) notification_center.add_observer(self, sender=self.stream) from_header = FromHeader(self.sender_uri, u'SIPStache File Transfer') to_header = ToHeader(self.destination_uri) transport = routes[0].transport parameters = {} if transport=='udp' else {'transport': transport} contact_header = ContactHeader(SIPURI(user=self.sender_uri.user, host=SIPConfig.local_ip.normalized, port=getattr(Engine(), '%s_port' % transport), parameters=parameters)) extra_headers = [] if ThorNodeConfig.enabled: extra_headers.append(Header('Thor-Scope', 'sipstache-file')) extra_headers.append(Header('X-Originator-From', str(self.destination_uri))) self.session.connect(from_header, to_header, contact_header=contact_header, routes=routes, streams=[self.stream], is_focus=False, extra_headers=extra_headers) notification_center.post_notification('OutgoingFileTransferHandlerDidStart', sender=self)
def start(self): notification_center = NotificationCenter() notification_center.add_observer(self, name='SIPAccountWillActivate') notification_center.add_observer(self, name='SIPAccountWillDeactivate') notification_center.add_observer(self, name='SIPAccountDidDiscoverXCAPSupport') notification_center.add_observer(self, name='XCAPManagerDidReloadData') notification_center.add_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 _CH_register(self, command): notification_center = NotificationCenter() settings = SIPSimpleSettings() if self._registration_timer is not None and self._registration_timer.active(): self._registration_timer.cancel() self._registration_timer = None # Initialize the registration if self._registration is None: duration = command.refresh_interval or self.account.sip.register_interval self._registration = Registration(FromHeader(self.account.uri, self.account.display_name), credentials=self.account.credentials, duration=duration, extra_headers=[Header('Supported', 'gruu')]) notification_center.add_observer(self, sender=self._registration) notification_center.post_notification('SIPAccountWillRegister', sender=self.account) else: notification_center.post_notification('SIPAccountRegistrationWillRefresh', sender=self.account) try: # Lookup routes if self.account.sip.outbound_proxy is not None and self.account.sip.outbound_proxy.transport in settings.sip.transport_list: uri = SIPURI(host=self.account.sip.outbound_proxy.host, port=self.account.sip.outbound_proxy.port, parameters={'transport': self.account.sip.outbound_proxy.transport}) else: uri = SIPURI(host=self.account.id.domain) lookup = DNSLookup() try: routes = lookup.lookup_sip_proxy(uri, settings.sip.transport_list).wait() except DNSLookupError, e: retry_after = random.uniform(self._dns_wait, 2*self._dns_wait) self._dns_wait = limit(2*self._dns_wait, max=30) raise RegistrationError('DNS lookup failed: %s' % e, retry_after=retry_after) else:
def _NH_DNSLookupDidSucceed(self, notification): # create subscriptions for everyone in the queue and register to get notifications from it self._subscription_routes = deque(notification.data.result) route = self._subscription_routes[0] route_header = RouteHeader(route.uri) for waitingsubscription in self.subscriptionqueue: # Creates a subscription for the waiting subscription newsubscription = Subscription( waitingsubscription.uri, FromHeader(self.account.uri, self.account.display_name), waitingsubscription, ContactHeader(self.account.contact[route]), "presence", route_header, credentials=self.account.credentials, refresh=self.account.sip.subscribe_interval) # Sets up an event listener for this new subscription notification_center = NotificationCenter() notification_center.add_observer(self, sender=newsubscription) # Starts the subscribe newsubscription.subscribe(timeout=5) # Adds this subscription to the active subscriptions list self.subscriptions.append(newsubscription) # Debug stuff self.output.put("Started new subscription with " + waitingsubscription.uri.user) # Clears all of the waiting subscriptions self.subscriptionqueue = []
def start(self): notification_center = NotificationCenter() notification_center.add_observer(self, name='NetworkConditionsDidChange') self._select_proc = proc.spawn(self._process_files) proc.spawn(self._handle_commands) self._activate()
def _initialize_core(self): notification_center = NotificationCenter() settings = SIPSimpleSettings() # initialize core options = dict( # general user_agent=settings.user_agent, # SIP detect_sip_loops=True, udp_port=settings.sip.udp_port if 'udp' in settings.sip.transport_list else None, tcp_port=settings.sip.tcp_port if 'tcp' in settings.sip.transport_list else None, tls_port=None, # TLS tls_verify_server=False, tls_ca_file=None, tls_cert_file=None, tls_privkey_file=None, # rtp rtp_port_range=(settings.rtp.port_range.start, settings.rtp.port_range.end), # audio codecs=list(settings.rtp.audio_codec_list), # video video_codecs=list(settings.rtp.video_codec_list), # logging log_level=settings.logs.pjsip_level if settings.logs.trace_pjsip else 0, trace_sip=settings.logs.trace_sip) notification_center.add_observer(self, sender=self.engine) self.engine.start(**options)
def init(self): self = super(DebugWindow, self).init() NSBundle.loadNibNamed_owner_("DebugWindow", self) for textView in [self.activityTextView, self.sipTextView, self.rtpTextView, self.msrpTextView, self.xcapTextView, self.pjsipTextView]: textView.setString_("") for label in [self.activityInfoLabel, self.sipInfoLabel, self.rtpInfoLabel, self.msrpInfoLabel, self.xcapInfoLabel, self.notificationsInfoLabel, self.pjsipInfoLabel]: label.setStringValue_('') BlinkLogger().set_gui_logger(self.renderActivity) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "userDefaultsDidChange:", "NSUserDefaultsDidChangeNotification", NSUserDefaults.standardUserDefaults()) notification_center = NotificationCenter() notification_center.add_observer(self, name="SIPSessionDidStart") notification_center.add_observer(self, name="SIPSessionDidRenegotiateStreams") userdef = NSUserDefaults.standardUserDefaults() self.sipRadio.selectCellWithTag_(userdef.integerForKey_("SIPTrace") or Disabled) self.msrpRadio.selectCellWithTag_(userdef.integerForKey_("MSRPTrace") or Disabled) self.xcapRadio.selectCellWithTag_(userdef.integerForKey_("XCAPTrace") or Disabled) self.pjsipCheckBox.setState_(NSOnState if userdef.boolForKey_("EnablePJSIPTrace") else NSOffState) self.userDefaultsDidChange_(None) return self
def __init__(self, mixer): self.mixer = mixer self.ports = set() self._lock = RLock() notification_center = NotificationCenter() notification_center.add_observer(ObserverWeakrefProxy(self), name='AudioPortDidChangeSlots')
def start(self): notification_center = NotificationCenter() self._xmpp_subscription = XMPPIncomingSubscription(local_identity=self.sip_identity, remote_identity=self.xmpp_identity) notification_center.add_observer(self, sender=self._xmpp_subscription) self._xmpp_subscription.start() self._command_proc = proc.spawn(self._run) self._subscribe_sip() notification_center.post_notification('X2SPresenceHandlerDidStart', sender=self)
def __init__(self): self.application = SIPApplication() self.xcap_manager = None self.quit_event = Event() notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.application)
def __init__(self, stream): self.stream = stream self.otr_cache = OTRCache() self.otr_session = OTRSession(self.otr_cache.private_key, self.stream, supported_versions={3}) # we need at least OTR-v3 for question based SMP notification_center = NotificationCenter() notification_center.add_observer(self, sender=stream) notification_center.add_observer(self, sender=self.otr_session)
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 __init__(self, parent=None): super(AccountSelector, self).__init__(parent) notification_center = NotificationCenter() notification_center.add_observer( self, name="SIPAccountManagerDidChangeDefaultAccount") notification_center.add_observer(self, name="SIPAccountManagerDidStart")
def __init__(self): self._lock = Lock() self.accounts = {} notification_center = NotificationCenter() notification_center.add_observer(self, name='CFGSettingsObjectWasActivated') notification_center.add_observer(self, name='CFGSettingsObjectWasCreated')
def _CH_publish(self, command): if command.state is None or self._publication is None and command.state is SameState: command.signal() return notification_center = NotificationCenter() settings = SIPSimpleSettings() if self._publication_timer is not None and self._publication_timer.active( ): self._publication_timer.cancel() self._publication_timer = None if self._publication is None: duration = command.refresh_interval or self.account.sip.publish_interval from_header = FromHeader(self.account.uri, self.account.display_name) self._publication = Publication( from_header, self.event, self.payload_type.content_type, credentials=self.account.credentials, duration=duration, extra_headers=self.extra_headers) notification_center.add_observer(self, sender=self._publication) notification_center.post_notification( self.__class__.__name__ + 'WillPublish', sender=self, data=NotificationData(state=command.state, duration=duration)) else: notification_center.post_notification( self.__class__.__name__ + 'WillRefresh', sender=self, data=NotificationData(state=command.state)) try: # Lookup routes valid_transports = self.__transports__.intersection( settings.sip.transport_list) if self.account.sip.outbound_proxy is not None and self.account.sip.outbound_proxy.transport in valid_transports: uri = SIPURI(host=self.account.sip.outbound_proxy.host, port=self.account.sip.outbound_proxy.port, parameters={ 'transport': self.account.sip.outbound_proxy.transport }) else: uri = SIPURI(host=self.account.id.domain) lookup = DNSLookup() try: routes = lookup.lookup_sip_proxy(uri, valid_transports).wait() except DNSLookupError, e: retry_after = random.uniform(self._dns_wait, 2 * self._dns_wait) self._dns_wait = limit(2 * self._dns_wait, max=30) raise PublicationError('DNS lookup failed: %s' % e, retry_after=retry_after) else:
def start(self, restart=False): notification_center = NotificationCenter() file_path = self._file_selector.name.decode() if isinstance( self._file_selector.name, bytes) else self._file_selector.name self.ft_info = FileTransferInfo( transfer_id=str(uuid.uuid4()), direction='outgoing', file_size=self._file_selector.size, local_uri=format_identity_to_string(self.account) if self.account is not BonjourAccount() else 'bonjour.local', remote_uri=self.remote_identity, file_path=file_path) self.status = NSLocalizedString("Offering File...", "Label") self.ft_info.status = "proposing" self.log_info("Initiating DNS Lookup of %s to %s" % (self.account, self.target_uri)) lookup = DNSLookup() notification_center.add_observer(self, sender=lookup) if isinstance(self.account, Account) and self.account.sip.outbound_proxy is not None: uri = SIPURI(host=self.account.sip.outbound_proxy.host, port=self.account.sip.outbound_proxy.port, parameters={ 'transport': self.account.sip.outbound_proxy.transport }) self.log_info("Initiating DNS Lookup for %s (through proxy %s)" % (self.target_uri, uri)) elif isinstance(self.account, Account) and self.account.sip.always_use_my_proxy: uri = SIPURI(host=self.account.id.domain) self.log_info( "Initiating DNS Lookup for %s (through account %s proxy)" % (self.target_uri, self.account.id)) else: uri = self.target_uri self.log_info("Initiating DNS Lookup for %s" % self.target_uri) settings = SIPSimpleSettings() tls_name = None if isinstance(self.account, Account): tls_name = self.account.sip.tls_name or self.account.id.domain lookup.lookup_sip_proxy(uri, settings.sip.transport_list, tls_name=tls_name) if restart: notification_center.post_notification( "BlinkFileTransferWillRestart", self) else: notification_center.post_notification( "BlinkFileTransferNewOutgoing", sender=self)
def start(self): notification_center = NotificationCenter() notification_center.add_observer(self, name='SystemIPAddressDidChange') notification_center.add_observer(self, name='SystemDidWakeUpFromSleep') self._select_proc = proc.spawn(self._process_files) proc.spawn(self._handle_commands) # activate self._stopped = False self._command_channel.send(Command('discover'))
def __init__(self): super(Blink, self).__init__(sys.argv) self.setAttribute(Qt.AA_DontShowIconsInMenus, False) self.sip_application = SIPApplication() self.first_run = False self.setOrganizationDomain("ag-projects.com") self.setOrganizationName("AG Projects") self.setApplicationName("Blink") self.setApplicationVersion(__version__) self.main_window = MainWindow() self.chat_window = ChatWindow() self.main_window.__closed__ = True self.chat_window.__closed__ = True self.main_window.installEventFilter(self) self.chat_window.installEventFilter(self) self.main_window.addAction(self.chat_window.control_button.actions.main_window) self.chat_window.addAction(self.main_window.quit_action) self.chat_window.addAction(self.main_window.help_action) self.chat_window.addAction(self.main_window.redial_action) self.chat_window.addAction(self.main_window.join_conference_action) self.chat_window.addAction(self.main_window.mute_action) self.chat_window.addAction(self.main_window.silent_action) self.chat_window.addAction(self.main_window.preferences_action) self.chat_window.addAction(self.main_window.transfers_window_action) self.chat_window.addAction(self.main_window.logs_window_action) self.chat_window.addAction(self.main_window.received_files_window_action) self.chat_window.addAction(self.main_window.screenshots_window_action) self.ip_address_monitor = IPAddressMonitor() self.log_manager = LogManager() self.presence_manager = PresenceManager() self.session_manager = SessionManager() self.update_manager = UpdateManager() # Prevent application from exiting after last window is closed if system tray was initialized if self.main_window.system_tray_icon: self.setQuitOnLastWindowClosed(False) self.main_window.check_for_updates_action.triggered.connect(self.update_manager.check_for_updates) self.main_window.check_for_updates_action.setVisible(self.update_manager != Null) if getattr(sys, 'frozen', False): XMLDocument.schema_path = Resources.get('xml-schemas') Account.register_extension(AccountExtension) BonjourAccount.register_extension(BonjourAccountExtension) Contact.register_extension(ContactExtension) Group.register_extension(GroupExtension) SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension) notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.sip_application) branding.setup(self)
def __init__(self, parent=None): super(AccountSelector, self).__init__(parent) self.currentIndexChanged[int].connect(self._SH_SelectionChanged) self.model().dataChanged.connect(self._SH_DataChanged) self.view().setItemDelegate(AccountDelegate(self.view())) notification_center = NotificationCenter() notification_center.add_observer(self, name="SIPAccountManagerDidChangeDefaultAccount") notification_center.add_observer(self, name="SIPAccountManagerDidStart")
def run(self): notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.session) self.session.send_ring_indication() stream_types = {'audio'} if self.config.enable_video: stream_types.add('video') streams = [stream for stream in self.session.proposed_streams if stream.type in stream_types] reactor.callLater(self.config.answer_delay, self._accept_session, self.session, streams)
def start(self): self.account_model.start() self.hal.start() self.history_manager.start() self.session_manager.start() notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.application) self.application.start(FileStorage(ApplicationData.directory))
def __init__(self, stream): self._stream = stream self._rtp_transport = None self.__dict__['type'] = None self.__dict__['zrtp'] = None notification_center = NotificationCenter() notification_center.add_observer(self, sender=stream)
def start(self): notification_center = NotificationCenter() self._xmpp_subscription = XMPPSubscription( local_identity=self.sip_identity, remote_identity=self.xmpp_identity) notification_center.add_observer(self, sender=self._xmpp_subscription) self._xmpp_subscription.start() notification_center.post_notification('S2XPresenceHandlerDidStart', sender=self)
def __init__(self): super(Blink, self).__init__(sys.argv) self.setAttribute(Qt.AA_DontShowIconsInMenus, False) self.sip_application = SIPApplication() self.first_run = False self.setOrganizationDomain("ag-projects.com") self.setOrganizationName("AG Projects") self.setApplicationName("Blink") self.setApplicationVersion(__version__) self.main_window = MainWindow() self.chat_window = ChatWindow() self.main_window.__closed__ = True self.chat_window.__closed__ = True self.main_window.installEventFilter(self) self.chat_window.installEventFilter(self) self.main_window.addAction(self.chat_window.control_button.actions.main_window) self.chat_window.addAction(self.main_window.quit_action) self.chat_window.addAction(self.main_window.help_action) self.chat_window.addAction(self.main_window.redial_action) self.chat_window.addAction(self.main_window.join_conference_action) self.chat_window.addAction(self.main_window.mute_action) self.chat_window.addAction(self.main_window.silent_action) self.chat_window.addAction(self.main_window.preferences_action) self.chat_window.addAction(self.main_window.transfers_window_action) self.chat_window.addAction(self.main_window.logs_window_action) self.chat_window.addAction(self.main_window.received_files_window_action) self.chat_window.addAction(self.main_window.screenshots_window_action) self.ip_address_monitor = IPAddressMonitor() self.log_manager = LogManager() self.presence_manager = PresenceManager() self.session_manager = SessionManager() self.update_manager = UpdateManager() # Prevent application from exiting after last window is closed if system tray was initialized if self.main_window.system_tray_icon: self.setQuitOnLastWindowClosed(False) self.main_window.check_for_updates_action.triggered.connect(self.update_manager.check_for_updates) self.main_window.check_for_updates_action.setVisible(self.update_manager != Null) if getattr(sys, "frozen", False): XMLDocument.schema_path = Resources.get("xml-schemas") Account.register_extension(AccountExtension) BonjourAccount.register_extension(BonjourAccountExtension) Contact.register_extension(ContactExtension) Group.register_extension(GroupExtension) SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension) notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.sip_application) branding.setup(self)
def send(self): lookup = DNSLookup() settings = SIPSimpleSettings() account = DefaultAccount() if account.sip.outbound_proxy is not None: uri = SIPURI( host=account.sip.outbound_proxy.host, port=account.sip.outbound_proxy.port, parameters={'transport': account.sip.outbound_proxy.transport}) else: uri = self.to_uri try: routes = lookup.lookup_sip_proxy( uri, settings.sip.transport_list).wait() except DNSLookupError: msg = 'DNS lookup error while looking for %s proxy' % uri log.warning(msg) raise SIPMessageError(0, msg) else: route = routes.pop(0) from_header = FromHeader(self.from_uri) to_header = ToHeader(self.to_uri) route_header = RouteHeader(route.uri) notification_center = NotificationCenter() for chunk in chunks(self.body, 1000): if self.use_cpim: additional_headers = [] payload = CPIMPayload( self.body.encode('utf-8'), self.content_type, charset='utf-8', sender=ChatIdentity(self.from_uri, None), recipients=[ChatIdentity(self.to_uri, None)], additional_headers=additional_headers) payload, content_type = payload.encode() else: content_type = self.content_type payload = self.body.encode('utf-8') request = SIPMessageRequest(from_header, to_header, route_header, content_type, payload) notification_center.add_observer(self, sender=request) self._requests.add(request) request.send() error = None count = len(self._requests) while count > 0: notification = self._channel.wait() if notification.name == 'SIPMessageDidFail': error = (notification.data.code, notification.data.reason) count -= 1 self._requests.clear() if error is not None: raise SIPMessageError(*error)
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 __init__(self, mixer): self._lock = RLock() self.ports = set() self.mixer = mixer self.multiplexer = MixerPort(mixer) self.demultiplexer = MixerPort(mixer) self.multiplexer.start() self.demultiplexer.start() notification_center = NotificationCenter() notification_center.add_observer(ObserverWeakrefProxy(self), name='AudioPortDidChangeSlots')
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): notification_center = NotificationCenter() notification_center.add_observer(self, name="BlinkFileTransferDidEnd") notification_center.add_observer(self, name="AudioStreamDidChangeHoldState") notification_center.add_observer(self, name="CFGSettingsObjectDidChange") notification_center.add_observer(self, name="ChatViewControllerDidDisplayMessage") notification_center.add_observer(self, name="ConferenceHasAddedAudio") notification_center.add_observer(self, name="BlinkWillCancelProposal") self.started = True
def run(self): notification_center = NotificationCenter() notification_center.add_observer(self, sender=self.session) streams = [] if self.audio_stream is not None: streams.append(self.audio_stream) if self.chat_stream is not None: streams.append(self.chat_stream) reactor.callLater(2 if self.audio_stream is not None else 0, self._accept_session, self.session, streams)
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