def play_hangup(self): settings = SIPSimpleSettings() if settings.audio.silent: return if time.time( ) - self.last_hangup_tone_time > HANGUP_TONE_THROTLE_DELAY: hangup_tone = WavePlayer(SIPApplication.voice_audio_mixer, Resources.get('hangup_tone.wav'), volume=30) NotificationCenter().add_observer(self, sender=hangup_tone, name="WavePlayerDidEnd") SIPApplication.voice_audio_bridge.add(hangup_tone) hangup_tone.start() self.last_hangup_tone_time = time.time()
def notify(): if self.running: settings = SIPSimpleSettings() if 'tcp' in settings.sip.transport_list: self.engine.set_tcp_port(None) self.engine.set_tcp_port(settings.sip.tcp_port) if 'tls' in settings.sip.transport_list: self._initialize_tls() notification_center = NotificationCenter() _changed = [] if self.default_ip != Host.default_ip: _changed.append('ip') data = NotificationData(changed=_changed) notification_center.post_notification( 'NetworkConditionsDidChange', sender=self, data=data) self.default_ip = Host.default_ip self._timer = None
def _LH_DNSLookupTrace(self, notification): settings = SIPSimpleSettings() if not settings.logs.trace_sip or not settings.logs.trace_sip_to_file: return message = 'DNS lookup %(query_type)s %(query_name)s' % notification.data.__dict__ if notification.data.error is None: message += ' succeeded, ttl=%d: ' % notification.data.answer.ttl if notification.data.query_type == 'A': message += ", ".join(record.address for record in notification.data.answer) elif notification.data.query_type == 'SRV': message += ", ".join('%d %d %d %s' % (record.priority, record.weight, record.port, record.target) for record in notification.data.answer) elif notification.data.query_type == 'NAPTR': message += ", ".join( '%d %d "%s" "%s" "%s" %s' % (record.order, record.preference, record.flags, record.service, record.regexp, record.replacement) for record in notification.data.answer) else: import dns.resolver message_map = { dns.resolver.NXDOMAIN: 'DNS record does not exist', dns.resolver.NoAnswer: 'DNS response contains no answer', dns.resolver.NoNameservers: 'no DNS name servers could be reached', dns.resolver.Timeout: 'no DNS response received, the query has timed out' } message += ' failed: %s' % message_map.get( notification.data.error.__class__, '') try: self._init_log_file('siptrace') except Exception: pass else: self._siptrace_file.write( '%s [%s %d]: %s\n' % (notification.datetime, os.path.basename( sys.argv[0]).rstrip('.py'), os.getpid(), message)) self._siptrace_file.flush()
def _CH_update_registrations(self, command): notification_center = NotificationCenter() settings = SIPSimpleSettings() if self._update_timer is not None and self._update_timer.active(): self._update_timer.cancel() self._update_timer = None available_transports = settings.sip.transport_list old_files = [] for file in (f for f in self._files[:] if isinstance(f, BonjourRegistrationFile) and f.transport not in available_transports): old_files.append(file) self._files.remove(file) self._select_proc.kill(RestartSelect) for file in old_files: file.close() update_failure = False for file in (f for f in self._files if isinstance(f, BonjourRegistrationFile)): try: contact_uri = self.account.contact[file.transport] contact_uri.user = self.uri_user if self.is_focus: contact_uri.parameters['isfocus'] = None txtdata = dict(txtvers=1, name=self.name, contact="<%s>" % str(contact_uri), instance_id=self.id) state = self.presence_state if state is not None: txtdata['state'] = state.state txtdata['note'] = state.note.encode('utf-8') _bonjour.DNSServiceUpdateRecord( file.file, None, flags=0, rdata=_bonjour.TXTRecord(items=txtdata), ttl=0) except (_bonjour.BonjourError, KeyError), e: notification_center.post_notification( 'BonjourServiceRegistrationUpdateDidFail', sender=self, data=NotificationData(reason=str(e), transport=file.transport)) update_failure = True
def _CH_register(self, command): notification_center = NotificationCenter() settings = SIPSimpleSettings() if self._register_timer is not None and self._register_timer.active(): self._register_timer.cancel() self._register_timer = None supported_transports = set( transport for transport in settings.sip.transport_list if transport != 'tls' or self.account.tls.certificate is not None) registered_transports = set( file.transport for file in self._files if isinstance(file, BonjourRegistrationFile)) missing_transports = supported_transports - registered_transports added_transports = set() for transport in missing_transports: notification_center.post_notification( 'BonjourAccountWillRegister', sender=self.account, data=NotificationData(transport=transport)) try: contact = self.account.contact[NoGRUU, transport] instance_id = str(uuid.UUID(settings.instance_id)) txtdata = dict(txtvers=1, name=self.account.display_name.encode('utf-8'), contact="<%s>" % str(contact), instance_id=instance_id) state = self.account.presence_state if self.account.presence.enabled and state is not None: txtdata['state'] = state.state txtdata['note'] = state.note.encode('utf-8') file = _bonjour.DNSServiceRegister( name=str(contact), regtype="_sipuri._%s" % (transport if transport == 'udp' else 'tcp'), port=contact.port, callBack=self._register_cb, txtRecord=_bonjour.TXTRecord(items=txtdata)) except (_bonjour.BonjourError, KeyError), e: notification_center.post_notification( 'BonjourAccountRegistrationDidFail', sender=self.account, data=NotificationData(reason=str(e), transport=transport)) else: self._files.append(BonjourRegistrationFile(file, transport)) added_transports.add(transport)
def _LH_MSRPLibraryLog(self, notification): settings = SIPSimpleSettings() if not settings.logs.trace_msrp or not settings.logs.trace_msrp_to_file: return if notification.data.level < self.msrp_level: return message = '%s%s' % (notification.data.level.prefix, notification.data.message) try: self._init_log_file('msrptrace') except Exception: pass else: self._msrptrace_file.write( '%s [%s %d]: %s\n' % (notification.datetime, os.path.basename( sys.argv[0]).rstrip('.py'), os.getpid(), message)) self._msrptrace_file.flush()
def load_video_devices(self): settings = SIPSimpleSettings() action = QAction(u'System default', self.video_devices_group) action.setData(u'system_default') self.video_camera_menu.addAction(action) self.video_camera_menu.addSeparator() for device in SIPApplication.engine.video_devices: action = QAction(device, self.video_devices_group) action.setData(device) self.video_camera_menu.addAction(action) action = QAction(u'None', self.video_devices_group) action.setData(None) self.video_camera_menu.addAction(action) for action in self.video_devices_group.actions(): action.setCheckable(True) if settings.video.device == action.data(): action.setChecked(True)
def stop(self): if not self.started: return self.started = False self.active = False notification_center = NotificationCenter() 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
def start(self, local_sdp, remote_sdp, stream_index): with self._lock: if self.state != "INITIALIZED": raise RuntimeError( "AudioStream.start() may only be called in the INITIALIZED state" ) settings = SIPSimpleSettings() self._transport.start(local_sdp, remote_sdp, stream_index, timeout=settings.rtp.timeout) self._check_hold(self._transport.direction, True) if self._try_ice: self.state = 'WAIT_ICE' else: self.state = 'ESTABLISHED' self.notification_center.post_notification( 'MediaStreamDidStart', sender=self)
def stop(self): if not self._started: return self._started = False notification_center = NotificationCenter() notification_center.post_notification('BonjourAccountWillStop', sender=self) self._deactivate() self._bonjour_services.stop() notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=self) notification_center.remove_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings())
def start(self): if self._started: return self._started = True notification_center = NotificationCenter() notification_center.post_notification('BonjourAccountWillStart', sender=self) notification_center.add_observer(self, name='CFGSettingsObjectDidChange', sender=self) notification_center.add_observer(self, name='CFGSettingsObjectDidChange', sender=SIPSimpleSettings()) self._bonjour_services.start() if self.enabled: self._activate()
def start(self): notification_center = NotificationCenter() settings = SIPSimpleSettings() download_folder = unicodedata.normalize( 'NFC', NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, True)[0]) for name in self.filename_generator( os.path.join(download_folder, self.file_name)): if not os.path.exists(name) and not os.path.exists(name + ".download"): self.file_path = name + '.download' break self.ft_info = FileTransferInfo( transfer_id=self.transfer_id, direction='incoming', local_uri=format_identity_to_string(self.account) if self.account is not BonjourAccount() else 'bonjour', file_size=self.file_size, remote_uri=self.remote_identity, file_path=self.file_path) BlinkLogger().log_info(u"Will write file to %s" % self.file_path) self.file_selector.fd = open(self.file_path, "w+") self.ft_info.status = "preparing" self.status = "Accepting File Transfer..." notification_center.add_observer(self, sender=self) notification_center.add_observer(self, sender=self.session) notification_center.add_observer(self, sender=self.stream) BlinkLogger().log_info("Initiating Incoming File Transfer") notification_center.post_notification( "BlinkFileTransferInitializing", self, data=TimestampedNotificationData()) notification_center.post_notification( "BlinkFileTransferInitiated", self, data=TimestampedNotificationData())
def _NH_WavePlayerDidEnd(self, notification): if notification.sender is self.unavailable_message: # once message is played, beep self.stream.bridge.remove(self.unavailable_message) self.stream.bridge.add(self.beep) self.beep.start() elif notification.sender is self.beep: # start recording after the beep settings = SIPSimpleSettings() self.stream.bridge.remove(self.beep) direction = self.session.direction remote = "%s@%s" % (self.session.remote_identity.uri.user, self.session.remote_identity.uri.host) filename = "%s-%s-%s.wav" % (datetime.datetime.now().strftime( "%Y%m%d-%H%M%S"), remote, direction) path = os.path.join(settings.audio.directory.normalized, self.session.account.id) self.stream.start_recording(os.path.join(path, filename)) self.start_time = datetime.datetime.now()
def composeReplicationMessage(self, sent_message, response_code): if isinstance(self.account, Account): settings = SIPSimpleSettings() if settings.chat.sms_replication: contact = NSApp.delegate( ).contactsWindowController.getContactMatchingURI( self.target_uri) msg = CPIMMessage( sent_message.body.decode('utf-8'), sent_message.content_type, sender=CPIMIdentity(self.account.uri, self.account.display_name), recipients=[ CPIMIdentity(self.target_uri, contact.display_name if contact else None) ]) self.sendReplicationMessage(response_code, str(msg), content_type='message/cpim')
def updateBonjourPresenceState(self): bonjour_account = BonjourAccount() if not bonjour_account.enabled: return status = None settings = SIPSimpleSettings() note = settings.presence_state.note selected_item = self.owner.presenceActivityPopUp.selectedItem() if selected_item is not None: activity_object = selected_item.representedObject() if activity_object is not None: status = activity_object['extended_status'] if status in (None, 'offline'): bonjour_account.presence_state = None else: bonjour_account.presence_state = BonjourPresenceState(status, note) NotificationCenter().post_notification('BonjourAccountPresenceStateDidChange', sender=bonjour_account)
def _NH_RTPStreamDidChangeHoldState(self, notification): data = notification.data settings = SIPSimpleSettings() session = notification.sender.session if data.on_hold: self.on_hold_audio_sessions.add(session) else: self.on_hold_audio_sessions.discard(session) if not settings.audio.silent: if self.secondary_hold_tone: if len(self.on_hold_audio_sessions) == 1: self.secondary_hold_tone.start() elif len(self.on_hold_audio_sessions) == 0: self.secondary_hold_tone.stop() if data.on_hold and data.originator == 'remote' and self.initial_hold_tone and not self.initial_hold_tone.is_active: self.initial_hold_tone.start()
def updateBonjourServersPopupButton(self): settings = SIPSimpleSettings() account = AccountManager().default_account if isinstance(account, BonjourAccount): self.bonjour_server_combolist.removeAllItems() if SIPManager().bonjour_conference_services.servers: servers = set() servers_dict = {} for server in (server for server in SIPManager().bonjour_conference_services.servers if server.uri.transport in settings.sip.transport_list): servers_dict.setdefault( "%s@%s" % (server.uri.user, server.uri.host), []).append(server) for transport in (transport for transport in ('tls', 'tcp', 'udp') if transport in settings.sip.transport_list): for k, v in servers_dict.items(): try: server = next( (server for server in v if server.uri.transport == transport)) except StopIteration: pass else: servers.add(server) break for server in servers: self.bonjour_server_combolist.addItemWithTitle_( '%s (%s)' % (server.host, server.uri.host)) item = self.bonjour_server_combolist.lastItem() item.setRepresentedObject_(server) self.ok_button.setEnabled_(True) else: self.bonjour_server_combolist.addItemWithTitle_( NSLocalizedString( "No conference server in this neighbourhood", "Menu item")) self.bonjour_server_combolist.lastItem().setEnabled_(False) self.ok_button.setEnabled_(False) else: self.ok_button.setEnabled_(False)
def initialize(self, stream, session): super(IncomingFileTransferHandler, self).initialize(stream, session) try: directory = self.save_directory or SIPSimpleSettings( ).file_transfer.directory.normalized makedirs(directory) with self.metadata as metadata: try: prev_file = metadata.pop(stream.file_selector.hash.lower()) mtime = os.path.getmtime(prev_file.filename) if mtime != prev_file.mtime: raise ValueError('file was modified') filename = os.path.join( directory, os.path.basename(stream.file_selector.name)) try: os.link(prev_file.filename, filename) except (AttributeError, OSError): stream.file_selector.name = prev_file.filename else: stream.file_selector.name = filename unlink(prev_file.filename) stream.file_selector.fd = openfile( stream.file_selector.name, 'ab' ) # open doesn't seek to END in append mode on win32 until first write, but openfile does self.offset = stream.file_selector.fd.tell() self.hash = prev_file.partial_hash except (KeyError, EnvironmentError, ValueError): for name in UniqueFilenameGenerator.generate( os.path.join( directory, os.path.basename(stream.file_selector.name))): try: stream.file_selector.fd = openfile(name, 'xb') except FileExistsError: continue else: stream.file_selector.name = name break except Exception, e: NotificationCenter().post_notification( 'FileTransferHandlerDidNotInitialize', sender=self, data=NotificationData(reason=str(e)))
def _LH_SIPEngineSIPTrace(self, notification): settings = SIPSimpleSettings() if not settings.logs.trace_sip: return self._siptrace_packet_count += 1 if notification.data.received: direction = "RECEIVED" else: direction = "SENDING" buf = ["%s: Packet %d, +%s" % (direction, self._siptrace_packet_count, (notification.datetime - self._siptrace_start_time)), "%(source_ip)s:%(source_port)d -(SIP over %(transport)s)-> %(destination_ip)s:%(destination_port)d" % notification.data.__dict__, notification.data.data, '--'] message = '\n'.join(buf) try: self.siptrace_file.write('%s [%s %d]: %s\n' % (notification.datetime, self.name, self.pid, message)) self.siptrace_file.flush() except Exception: pass
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 _NH_RTPTransportDidInitialize(self, notification): settings = SIPSimpleSettings() rtp_transport = notification.sender with self._lock: if self.state == "ENDED": return del self._rtp_args del self._stun_servers try: if hasattr(self, "_incoming_remote_sdp"): try: audio_transport = AudioTransport( self.mixer, rtp_transport, self._incoming_remote_sdp, self._incoming_stream_index, codecs=list( self.session.account.rtp.audio_codec_list or settings.rtp.audio_codec_list)) finally: del self._incoming_remote_sdp del self._incoming_stream_index else: audio_transport = AudioTransport( self.mixer, rtp_transport, codecs=list(self.session.account.rtp.audio_codec_list or settings.rtp.audio_codec_list)) except SIPCoreError, e: self.state = "ENDED" self.notification_center.post_notification( 'MediaStreamDidNotInitialize', sender=self, data=NotificationData(reason=e.args[0])) return self._rtp_transport = rtp_transport self._transport = audio_transport self.notification_center.add_observer(self, sender=audio_transport) self._initialized = True self.state = "INITIALIZED" self.notification_center.post_notification( 'MediaStreamDidInitialize', sender=self)
def sendReplicationMessage(self, response_code, text, content_type="message/cpim", timestamp=None): timestamp = timestamp or datetime.datetime.now(tzlocal()) # Lookup routes if 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 }) else: uri = SIPURI(host=self.account.id.domain) lookup = DNSLookup() settings = SIPSimpleSettings() try: routes = lookup.lookup_sip_proxy( uri, settings.sip.transport_list).wait() except DNSLookupError: pass else: utf8_encode = content_type not in ( 'application/im-iscomposing+xml', 'message/cpim') extra_headers = [ Header("X-Offline-Storage", "no"), Header("X-Replication-Code", str(response_code)), Header("X-Replication-Timestamp", str(Timestamp(datetime.datetime.now()))) ] message_request = Message( FromHeader(self.account.uri, self.account.display_name), ToHeader(self.account.uri), RouteHeader(routes[0].get_uri()), content_type, text.encode('utf-8') if utf8_encode else text, credentials=self.account.credentials, extra_headers=extra_headers) message_request.send( 15 if content_type != "application/im-iscomposing+xml" else 5)
def _setup_new_subscriptions(self, urilist): # TODO: Add check to see active subscriptions so it doesn't subscribe twice # sets up a new subscription with the given list of URI's for uri in urilist: tempuri = uri if tempuri is None: tempuri = ToHeader( SIPURI(user=self.account.id.username, host=self.account.id.domain)) else: if '@' not in tempuri: tempuri = '%s@%s' % (tempuri, self.account.id.domain) if not uri.startswith('sip:') and not tempuri.startswith( 'sips:'): tempuri = 'sip:' + tempuri try: tempuri = ToHeader(SIPURI.parse(tempuri)) except SIPCoreError: self.output.put('Illegal SIP URI: %s' % tempuri) return 1 self.subscriptionqueue.append(tempuri) #reactor.callLater(0, self._subscribe) settings = SIPSimpleSettings() self._subscription_timeout = time() + 30 lookup = DNSLookup() notification_center = NotificationCenter() notification_center.add_observer(self, sender=lookup) proxyuri = None if self.account.sip.outbound_proxy is not None: proxyuri = SIPURI(host=self.account.sip.outbound_proxy.host, port=self.account.sip.outbound_proxy.port, parameters={ 'transport': self.account.sip.outbound_proxy.transport }) elif self.account.sip.always_use_my_proxy: proxyuri = SIPURI(host=self.account.id.domain) else: proxyuri = self.subscriptionqueue[0].uri lookup.lookup_sip_proxy(proxyuri, settings.sip.transport_list)
def _process_notification(self, notification): handler = getattr(self, '_NH_%s' % notification.name, Null) handler(notification) handler = getattr(self, '_LH_%s' % notification.name, Null) handler(notification) settings = SIPSimpleSettings() if notification.name not in ('SIPEngineLog', 'SIPEngineSIPTrace' ) and settings.logs.trace_notifications: message = 'Notification name=%s sender=%s data=%s' % ( notification.name, notification.sender, pformat(notification.data)) try: self.notifications_file.write( '%s [%s %d]: %s\n' % (datetime.now(), self.name, self.pid, message)) self.notifications_file.flush() except Exception: pass
def startOutgoing(self, is_update): if self.direction == "active": self.sessionController.log_info("Requesting remote screen...") else: self.sessionController.log_info("Offering local screen...") NSBundle.loadNibNamed_owner_("ScreenServerWindow", self) self.statusProgress.startAnimation_(None) self.statusWindow.setTitle_( NSLocalizedString("Screen Sharing with %s", "Window title") % self.sessionController.titleShort) settings = SIPSimpleSettings() if not settings.logs.trace_msrp: settings.logs.trace_msrp = True settings.save() self.must_reset_trace_msrp = True NotificationCenter().add_observer(self, name="MSRPTransportTrace") #self.statusItem.show(self) NotificationCenter().add_observer(self, sender=self.stream.handler) NotificationCenter().add_observer(self, sender=self.stream) self.changeStatus(STREAM_PROPOSING if is_update else STREAM_CONNECTING)
def new_from_sdp(cls, session, remote_sdp, stream_index): # TODO: actually validate the SDP settings = SIPSimpleSettings() remote_stream = remote_sdp.media[stream_index] if remote_stream.media != 'audio': raise UnknownStreamError if remote_stream.transport not in ('RTP/AVP', 'RTP/SAVP'): raise InvalidStreamError('expected RTP/AVP or RTP/SAVP transport in audio stream, got %s' % remote_stream.transport) local_encryption_policy = 'sdes_optional' if local_encryption_policy == 'sdes_mandatory' and not 'crypto' in remote_stream.attributes: raise InvalidStreamError("SRTP/SDES is locally mandatory but it's not remotely enabled") if remote_stream.transport == 'RTP/SAVP' and 'crypto' in remote_stream.attributes and local_encryption_policy not in ('opportunistic', 'sdes_optional', 'sdes_mandatory'): raise InvalidStreamError("SRTP/SDES is remotely mandatory but it's not locally enabled") supported_codecs = session.account.rtp.audio_codec_list or settings.rtp.audio_codec_list if not any(codec for codec in remote_stream.codec_list if codec in supported_codecs): raise InvalidStreamError('no compatible codecs found') stream = cls() stream._incoming_remote_sdp = remote_sdp stream._incoming_stream_index = stream_index return 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 showCollaborationEditor(self): self.editorVisible = True self.last_scrolling_label = self.lastMessagesLabel.stringValue() self.lastMessagesLabel.setStringValue_( NSLocalizedString( "Click on Editor toolbar button to switch back to the chat session", "Label")) self.searchMessagesBox.setHidden_(True) self.showRelatedMessagesButton.setHidden_(True) settings = SIPSimpleSettings() frame = self.inputView.frame() self.splitterHeight = frame.size.height frame.size.height = 0 self.inputView.setFrame_(frame) script = """showCollaborationEditor("%s", "%s")""" % ( self.delegate.sessionController.collaboration_form_id, settings.server.collaboration_url) self.executeJavaScript(script)
def _NH_DefaultAudioDeviceDidChange(self, notification): if None in (self.voice_audio_bridge, self.alert_audio_bridge): return settings = SIPSimpleSettings() current_input_device = self.voice_audio_bridge.mixer.input_device current_output_device = self.voice_audio_bridge.mixer.output_device current_alert_device = self.alert_audio_bridge.mixer.output_device ec_tail_length = self.voice_audio_bridge.mixer.ec_tail_length if notification.data.changed_input and 'system_default' in ( current_input_device, settings.audio.input_device): self.voice_audio_bridge.mixer.set_sound_devices( 'system_default', current_output_device, ec_tail_length) if notification.data.changed_output and 'system_default' in ( current_output_device, settings.audio.output_device): self.voice_audio_bridge.mixer.set_sound_devices( current_input_device, 'system_default', ec_tail_length) if notification.data.changed_output and 'system_default' in ( current_alert_device, settings.audio.alert_device): self.alert_audio_bridge.mixer.set_sound_devices( None, 'system_default', 0)
def build_offline_pidf(self, account): settings = SIPSimpleSettings() note = settings.presence_state.offline_note if not note: return None pidf_doc = pidf.PIDF(account.id) account_hash = hashlib.md5(account.id.encode()).hexdigest() person = pidf.Person("PID-%s" % account_hash) person.activities = rpid.Activities() person.activities.add('offline') person.notes.add(str(note)) pidf_doc.add(person) service = pidf.Service("SID-%s" % account_hash) service.status = pidf.Status(basic='closed') service.status.extended = 'offline' service.contact = pidf.Contact(str(account.uri)) service.capabilities = caps.ServiceCapabilities() service.notes.add(str(note)) pidf_doc.add(service) return pidf_doc