def _NH_SIPAccountDidActivate(self, account, data):
     BlinkLogger().log_info("Account %s activated" % account.id)
     # Activate BonjourConferenceServer discovery
     if account is BonjourAccount():
         call_in_green_thread(self.bonjour_conference_services.start)
     else:
         BlinkLogger().log_info("Account %s loaded %d CAs from %s" % (account.id, len(account.tls_credentials._trusted), account.ca_list))
 def _NH_NetworkConditionsDidChange(self, notification):
     self.ip_change_timestamp = int(time.time())
     BlinkLogger().log_info("Network conditions changed")
     if host.default_ip is None:
         BlinkLogger().log_info("No IP address")
     else:
         BlinkLogger().log_info("IP address changed to %s" % host.default_ip)
 def _NH_SystemDidWakeUpFromSleep(self, sender, data):
     BlinkLogger().log_info("Computer wake up from sleep")
     bonjour_account = BonjourAccount()
     if not bonjour_account.enabled and self.bonjour_disabled_on_sleep:
         BlinkLogger().log_debug("Enabling Bonjour discovery after wakeup from sleep")
         bonjour_account.enabled=True
         self.bonjour_disabled_on_sleep=False
    def save_certificates(self, response):
        passport = response["passport"]
        address = response["sip_address"]

        tls_folder = ApplicationData.get('tls')
        if not os.path.exists(tls_folder):
            os.mkdir(tls_folder, 0o700)

        ca = passport["ca"].strip() + os.linesep
        self.add_certificate_authority(ca)

        crt = passport["crt"].strip() + os.linesep
        try:
            X509Certificate(crt)
        except GNUTLSError as e:
            BlinkLogger().log_error("Invalid TLS certificate: %s" % e)
            return None

        key = passport["key"].strip() + os.linesep
        try:
            X509PrivateKey(key)
        except GNUTLSError as e:
            BlinkLogger().log_error("Invalid Private Key: %s" % e)
            return None

        crt_path = os.path.join(tls_folder, address + ".crt")
        f = open(crt_path, "w")
        os.chmod(crt_path, 0o600)
        f.write(crt)
        f.write(key)
        f.close()
        BlinkLogger().log_info("Saved new TLS Certificate and Private Key to %s" % crt_path)

        return crt_path
 def _NH_SystemWillSleep(self, sender, data):
     bonjour_account = BonjourAccount()
     if bonjour_account.enabled:
         BlinkLogger().log_info("Computer will go to sleep")
         BlinkLogger().log_debug("Disabling Bonjour discovery during sleep")
         bonjour_account.enabled=False
         self.bonjour_disabled_on_sleep=True
    def _NH_CFGSettingsObjectDidChange(self, account, data):
        if isinstance(account, Account):
            if 'message_summary.enabled' in data.modified:
                if not account.message_summary.enabled:
                    MWIData.remove(account)

        if 'audio.echo_canceller.enabled' in data.modified:
            settings = SIPSimpleSettings()
            settings.audio.sample_rate = 32000 if settings.audio.echo_canceller.enabled and settings.audio.sample_rate not in ('16000', '32000') else 48000
            spectrum = settings.audio.sample_rate/1000/2 if settings.audio.sample_rate/1000/2 < 20 else 20
            BlinkLogger().log_info("Audio sample rate is set to %dkHz covering 0-%dkHz spectrum" % (settings.audio.sample_rate/1000, spectrum))
            BlinkLogger().log_debug("Acoustic Echo Canceller is %s" % ('enabled' if settings.audio.echo_canceller.enabled else 'disabled'))
            if spectrum >=20:
                BlinkLogger().log_debug("For studio quality disable the option 'Use ambient noise reduction' in System Preferences > Sound > Input section.")
            settings.save()
        elif 'audio.sample_rate' in data.modified:
            settings = SIPSimpleSettings()
            spectrum = settings.audio.sample_rate/1000/2 if settings.audio.sample_rate/1000/2 < 20 else 20
            if settings.audio.sample_rate == 48000:
                settings.audio.echo_canceller.enabled = False
                settings.audio.enable_aec = False
                settings.save()
            else:
                settings.audio.echo_canceller.enabled = True
                settings.audio.enable_aec = True
                settings.save()
Beispiel #7
0
    def _NH_SIPApplicationWillStart(self, sender, data):
        settings = SIPSimpleSettings()
        settings.user_agent = "%s %s (MacOSX)" % (
            NSApp.delegate().applicationName, self._version)
        BlinkLogger().log_info(u"Initializing SIP SIMPLE Client SDK %s" %
                               sdk_version)

        build = str(NSBundle.mainBundle().infoDictionary().objectForKey_(
            "CFBundleVersion"))
        date = str(NSBundle.mainBundle().infoDictionary().objectForKey_(
            "BlinkVersionDate"))
        BlinkLogger().log_info(u"Build %s from %s" % (build, date))

        self.migratePasswordsToKeychain()

        # Set audio settings compatible with AEC and Noise Supressor
        settings.audio.sample_rate = 16000
        settings.audio.tail_length = 15 if settings.audio.enable_aec else 0
        settings.save()
        BlinkLogger().log_info(
            u"Acoustic Echo Canceller is %s" %
            ('enabled' if settings.audio.enable_aec else 'disabled'))

        # Although this setting is set at enrollment time, people who have downloaded previous versions will not have it
        account_manager = AccountManager()
        for account in account_manager.iter_accounts():
            must_save = False
            if account is not BonjourAccount(
            ) and account.sip.primary_proxy is None and account.sip.outbound_proxy and not account.sip.selected_proxy:
                account.sip.primary_proxy = account.sip.outbound_proxy
                must_save = True

            if account is not BonjourAccount(
            ) and settings.tls.verify_server != account.tls.verify_server:
                account.tls.verify_server = settings.tls.verify_server
                must_save = True

            if account.tls.certificate and os.path.basename(
                    account.tls.certificate.normalized) != 'default.crt':
                account.tls.certificate = DefaultValue
                must_save = True

            if account.id.domain == "sip2sip.info":
                if account.server.settings_url is None:
                    account.server.settings_url = "https://blink.sipthor.net/settings.phtml"
                    must_save = True
                if not account.ldap.hostname:
                    account.ldap.hostname = "ldap.sipthor.net"
                    account.ldap.dn = "ou=addressbook, dc=sip2sip, dc=info"
                    account.ldap.enabled = True
                    must_save = True

            if must_save:
                account.save()

        logger = FileLogger()
        logger.start()
        self.ip_address_monitor.start()
 def _NH_XCAPManagerDidDiscoverServerCapabilities(self, sender, data):
     account = sender.account
     xcap_root = sender.xcap_root
     if xcap_root is None:
         # The XCAP manager might be stopped because this notification is processed in a different
         # thread from which it was posted
         return
     BlinkLogger().log_debug("Using XCAP root %s for account %s" % (xcap_root, account.id))
     BlinkLogger().log_debug("XCAP server capabilities: %s" % ", ".join(data.auids))
    def _NH_SIPApplicationWillStart(self, sender, data):
        settings = SIPSimpleSettings()
        _version = str(NSBundle.mainBundle().infoDictionary().objectForKey_("CFBundleShortVersionString"))
        settings.user_agent = "%s %s (MacOSX)" % (NSApp.delegate().applicationName, _version)
        BlinkLogger().log_debug("SIP User Agent: %s" % settings.user_agent)
        settings.save()

        self.migratePasswordsToKeychain()
        self.cleanupIcons()

        # Set audio settings compatible with AEC and Noise Suppression
        settings.audio.sample_rate = 32000 if settings.audio.echo_canceller.enabled else 48000
        if NSApp.delegate().service_provider_help_url and settings.service_provider.help_url != NSApp.delegate().service_provider_help_url:
            settings.service_provider.help_url = NSApp.delegate().service_provider_help_url
            settings.save()

        if NSApp.delegate().service_provider_name and settings.service_provider.name != NSApp.delegate().service_provider_name:
            settings.service_provider.name = NSApp.delegate().service_provider_name
            settings.save()

        BlinkLogger().log_debug("Audio engine sampling rate %dKHz covering 0-%dKHz spectrum" % (settings.audio.sample_rate/1000, settings.audio.sample_rate/1000/2))
        BlinkLogger().log_debug("Acoustic Echo Canceller is %s" % ('enabled' if settings.audio.echo_canceller.enabled else 'disabled'))

        account_manager = AccountManager()
        for account in account_manager.iter_accounts():
            must_save = False
            if account is not BonjourAccount() and account.sip.primary_proxy is None and account.sip.outbound_proxy and not account.sip.selected_proxy:
                account.sip.primary_proxy = account.sip.outbound_proxy

            if account is not BonjourAccount() and settings.tls.verify_server != account.tls.verify_server:
                account.tls.verify_server = settings.tls.verify_server

            if account.tls.certificate and os.path.basename(account.tls.certificate.normalized) != 'default.crt':
                account.tls.certificate = DefaultValue

            if account.rtp.encryption_type == '':
                account.rtp.encryption.enabled = False
            elif account.rtp.encryption_type == 'opportunistic':
                account.rtp.encryption.enabled = True
                account.rtp.encryption.key_negotiation = 'opportunistic'
            elif account.rtp.encryption_type == 'sdes_optional':
                account.rtp.encryption.enabled = True
                account.rtp.encryption.key_negotiation = 'sdes_optional'
            elif account.rtp.encryption_type == 'sdes_mandatory':
                account.rtp.encryption.enabled = True
                account.rtp.encryption.key_negotiation = 'sdes_mandatory'
            elif account.rtp.encryption_type == 'zrtp':
                account.rtp.encryption.enabled = True
                account.rtp.encryption.key_negotiation = 'zrtp'
            account.save()

        logger = FileLogger()
        logger.start()
        self.ip_address_monitor.start()
 def download_decideDestinationWithSuggestedFilename_(
         self, download, filename):
     panel = NSSavePanel.savePanel()
     panel.setTitle_(NSLocalizedString("Download File", "Window title"))
     if panel.runModalForDirectory_file_(
             "", filename) == NSFileHandlingPanelOKButton:
         download.setDestination_allowOverwrite_(panel.filename(), True)
         BlinkLogger().log_info("Downloading file to %s" % panel.filename())
     else:
         download.cancel()
         BlinkLogger().log_info("Download cancelled")
Beispiel #11
0
    def _NH_SIPEngineTransportDidDisconnect(self, notification):
        self.transport_lost_timestamp = int(time.time())

        transport = '%s:%s' % (notification.data.transport,
                               notification.data.remote_address)
        try:
            self.active_transports.remove(transport)
        except KeyError:
            return

        for account_info in self.contactsWindowController.accounts:
            account = account_info.account

            if account is BonjourAccount():
                continue

            if not account.enabled:
                continue

            if account_info.registrar != transport:
                continue

            account_info.register_state = 'failed'

            if host is None or host.default_ip is None:
                account_info.register_failure_reason = NSLocalizedString(
                    "No Internet connection", "Label")
            else:
                account_info.register_failure_reason = NSLocalizedString(
                    "Connection failed", "Label")

            self.contactsWindowController.refreshAccountList()
            BlinkLogger().log_info('Reconnecting account %s' % account.id)

            account.reregister()
            account.resubscribe()
            presence_state = account.presence_state
            account.presence_state = None
            account.presence_state = presence_state

        if notification.data.reason != 'Success':
            BlinkLogger().log_info(
                "%s connection %s <-> %s lost" %
                (notification.data.transport, notification.data.local_address,
                 notification.data.remote_address))
            #nc_title = NSLocalizedString("Connection failed", "Label")
            #nc_body = NSLocalizedString("Remote Address", "Label") + " %s:%s" % (notification.data.transport, notification.data.remote_address)
            #self.gui_notify(nc_title, nc_body)

        else:
            NotificationCenter().post_notification(
                "BlinkTransportFailed",
                data=NotificationData(transport=transport))
Beispiel #12
0
    def _NH_SIPSessionGotConferenceInfo(self, notification):
        BlinkLogger().log_info(u"Received conference-info update in web view")
        screen_sharing_urls = list(unquote(user.screen_image_url.value) for user in notification.data.conference_info.users if user.screen_image_url is not None)

        if self.screensharing_url not in screen_sharing_urls and self.loading:
            BlinkLogger().log_info(u"%s stopped sharing her screen" % self.display_name)
            #self.stopLoading()   # unfortunately stop loading does not prevent the view to refresh based on html refresh meta tag
            self.closed_by_user = False
            self.window.performClose_(None)
        elif self.screensharing_url in screen_sharing_urls and not self.loading:
            BlinkLogger().log_info(u"%s re-started sharing her screen" % self.display_name)
            self.startLoading()
    def _NH_SIPApplicationDidStart(self, sender, data):
        settings = SIPSimpleSettings()
        settings.audio.enable_aec = settings.audio.echo_canceller.enabled
        settings.audio.sound_card_delay = settings.audio.echo_canceller.tail_length
        #self._app.engine.enable_colorbar_device = True

        BlinkLogger().log_debug("SDK loaded")
        BlinkLogger().log_debug("SIP device ID: %s" % settings.instance_id)
        codecs_print = []
        for codec in settings.rtp.audio_codec_list:
            codecs_print.append(beautify_audio_codec(codec))
        BlinkLogger().log_info("Enabled audio codecs: %s" % ", ".join(codecs_print))

        if settings.audio.input_device is None:
            BlinkLogger().log_info("Switching audio input device to system default")
            settings.audio.input_device = 'system_default'
        if settings.audio.output_device is None:
            BlinkLogger().log_info("Switching audio output device to system default")
            settings.audio.output_device = 'system_default'
        if settings.audio.alert_device is None:
            BlinkLogger().log_info("Switching audio alert device to system default")
            settings.audio.alert_device = 'system_default'

        try:
            from VideoController import VideoController
        except ImportError:
            pass
        else:
            if settings.video.max_bitrate is not None and settings.video.max_bitrate > 10000:
                settings.video.max_bitrate = 4.0
            codecs_print = []
            for codec in settings.rtp.video_codec_list:
                codecs_print.append(beautify_video_codec(codec))
            #BlinkLogger().log_info(u"Enabled video codecs: %s" % ", ".join(codecs_print))
            #BlinkLogger().log_debug(u"Available video cameras: %s" % ", ".join((camera for camera in self._app.engine.video_devices)))
            if settings.video.device != "system_default" and settings.video.device != self._app.video_device.real_name and self._app.video_device.real_name != None:
                settings.video.device = self._app.video_device.real_name
                #BlinkLogger().log_info(u"Using video camera %s" % self._app.video_device.real_name)
            elif settings.video.device is None:
                devices = list(device for device in self._app.engine.video_devices if device not in ('system_default', None))
                if devices:
                    BlinkLogger().log_info("Switching video camera to %s" % devices[0])
                    settings.video.device = devices[0]
            else:
                BlinkLogger().log_debug("Using video camera %s" % self._app.video_device.real_name)
        settings.save()

        bonjour_account = BonjourAccount()
        if bonjour_account.enabled:
            for transport in settings.sip.transport_list:
                try:
                    BlinkLogger().log_debug('Bonjour Account listens on %s' % bonjour_account.contact[transport])
                except KeyError:
                    pass

        self.init_configurations()
Beispiel #14
0
 def rejectAllSessions(self):
     for s in self.sessions.keys():
         is_proposal = self.proposals.has_key(s)
         try:
             if is_proposal:
                 BlinkLogger().log_info(u"Rejecting %s proposal from %s"%([stream.type for stream in s.proposed_streams], format_identity_to_string(s.remote_identity)))
                 try:
                     self.rejectProposal(s)
                 except Exception, exc:
                     BlinkLogger().log_info(u"Error rejecting proposal: %s" % exc)
                     self.removeSession(s)
             else:
                 BlinkLogger().log_info(u"Rejecting session from %s with Busy Everywhere" % format_identity_to_string(s.remote_identity))
                 self.rejectSession(s, 603, "Busy Everywhere")
Beispiel #15
0
    def _NH_SIPApplicationDidStart(self, sender, data):

        settings = SIPSimpleSettings()
        BlinkLogger().log_info(u"SIP User Agent %s" % settings.user_agent)
        BlinkLogger().log_info(u"SIP Device ID %s" % settings.instance_id)

        bonjour_account = BonjourAccount()
        if bonjour_account.enabled:
            for transport in settings.sip.transport_list:
                try:
                    BlinkLogger().log_info(u'Bonjour Account listens on %s' %
                                           bonjour_account.contact[transport])
                except KeyError:
                    pass
    def __init__(self):
        if self:
            BlinkLogger().log_debug('Starting History Viewer')
            NSBundle.loadNibNamed_owner_("HistoryViewer", self)

            self.all_contacts = BlinkHistoryViewerContact('Any Address', name='All Contacts')
            self.bonjour_contact = BlinkHistoryViewerContact('bonjour.local', name='Bonjour Neighbours', icon=NSImage.imageNamed_("NSBonjour"))

            self.notification_center = NotificationCenter()
            self.notification_center.add_observer(self, name='ChatViewControllerDidDisplayMessage')
            self.notification_center.add_observer(self, name='AudioCallLoggedToHistory')
            self.notification_center.add_observer(self, name='BlinkContactsHaveChanged')
            self.notification_center.add_observer(self, name='BlinkTableViewSelectionChaged')
            self.notification_center.add_observer(self, name='BlinkConferenceContactPresenceHasChanged')
            self.notification_center.add_observer(self, name='BlinkShouldTerminate')

            self.searchText.cell().setSendsSearchStringImmediately_(True)
            self.searchText.cell().setPlaceholderString_(NSLocalizedString("Type text and press Enter", "Placeholder text"))

            self.chatViewController.setContentFile_(NSBundle.mainBundle().pathForResource_ofType_("ChatView", "html"))
            self.chatViewController.setHandleScrolling_(False)
            self.entriesView.setShouldCloseWithWindow_(False)

            for c in ('remote_uri', 'local_uri', 'date', 'type'):
                col = self.indexTable.tableColumnWithIdentifier_(c)
                descriptor = NSSortDescriptor.alloc().initWithKey_ascending_(c, True)
                col.setSortDescriptorPrototype_(descriptor)

            self.chat_history = ChatHistory()
            self.session_history = SessionHistory()
            self.setPeriod(1)

            self.selectedTableView = self.contactTable
Beispiel #17
0
    def _sendMessage(self, msgid, text, content_type="text/plain"):

        utf8_encode = content_type not in ('application/im-iscomposing+xml',
                                           'message/cpim')
        message_request = Message(
            FromHeader(self.account.uri, self.account.display_name),
            ToHeader(self.target_uri),
            RouteHeader(self.routes[0].get_uri()),
            content_type,
            text.encode('utf-8') if utf8_encode else text,
            credentials=self.account.credentials)
        self.notification_center.add_observer(self, sender=message_request)
        message_request.send(
            15 if content_type != "application/im-iscomposing+xml" else 5)

        id = str(message_request)
        if content_type != "application/im-iscomposing+xml":
            BlinkLogger().log_info(u"Sent %s SMS message to %s" %
                                   (content_type, self.target_uri))
            self.enableIsComposing = True
            message = self.messages.pop(msgid)
            message.status = 'sent'
        else:
            message = MessageInfo(id, content_type=content_type)

        self.messages[id] = message
        return message
    def __init__(self):
        BlinkLogger().log_info("Using SIP SIMPLE client SDK version %s" % sdk_version)

        self._app = SIPApplication()
        self._delegate = None
        self._selected_account = None
        self.ip_address_monitor = IPAddressMonitor()
        self.bonjour_disabled_on_sleep = False
        self.bonjour_conference_services = BonjourConferenceServices()
        self.notification_center = NotificationCenter()
        self.notification_center.add_observer(self, sender=self._app)
        self.notification_center.add_observer(self, sender=self._app.engine)
        self.notification_center.add_observer(self, name='CFGSettingsObjectDidChange')
        self.notification_center.add_observer(self, name='SIPAccountDidActivate')
        self.notification_center.add_observer(self, name='SIPAccountDidDeactivate')
        self.notification_center.add_observer(self, name='SIPAccountRegistrationDidSucceed')
        self.notification_center.add_observer(self, name='SIPAccountRegistrationDidEnd')
        self.notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        self.notification_center.add_observer(self, name='XCAPManagerDidDiscoverServerCapabilities')
        self.notification_center.add_observer(self, name='XCAPManagerClientError')
        self.notification_center.add_observer(self, name='SystemWillSleep')
        self.notification_center.add_observer(self, name='SystemDidWakeUpFromSleep')
        self.notification_center.add_observer(self, name='SIPEngineGotException')

        self.registrar_addresses = {}
        self.contact_addresses = {}
    def getURL_withReplyEvent_(self, event, replyEvent):
        participants = set()
        media_type = set()
        url = event.descriptorForKeyword_(fourcharToInt('----')).stringValue()
        url = self.normalizeExternalURL(url)

        BlinkLogger().log_info("Will start outgoing session from external link: %s" % url)

        url = urllib.parse.unquote(url).replace(" ", "")
        _split = url.split(';')
        _url = []
        for item in _split[:]:
            if item.startswith("participant="):
                puri = item.split("=")[1]
                participants.add(puri)
            elif item.startswith("media_type="):
                m = item.split("=")[1]
                media_type.add(m)
            else:
                _url.append(item)
                _split.remove(item)

        url = ";".join(_url)

        if not self.ready:
            self.urisToOpen.append((str(url), list(media_type), list(participants)))
        else:
            self.contactsWindowController.joinConference(str(url), list(media_type), list(participants))
Beispiel #20
0
    def show(self):
        BlinkLogger().log_debug('Show %s' % self)
        aspect_ratio = self.videoView.aspect_ratio
        self.visible = True
        self.videoView.show()

        if self.close_timer is not None and self.close_timer.isValid():
            self.close_timer.invalidate()
            self.close_timer = None

        self.window().setAlphaValue_(ALPHA)
        userdef = NSUserDefaults.standardUserDefaults()
        savedFrame = userdef.stringForKey_(self.window().frameAutosaveName())

        if savedFrame:
            x, y, w, h = str(savedFrame).split()[:4]
            frame = NSMakeRect(int(x), int(y), int(w), int(h))
            self.window().setFrame_display_(frame, True)

        frame = self.window().frame()
        currentSize = frame.size
        scaledSize = currentSize

        if aspect_ratio is not None:
            scaledSize.height = scaledSize.width / aspect_ratio
            frame.size = scaledSize
            self.window().setFrame_display_animate_(frame, True, False)
        self.window().orderFront_(None)
Beispiel #21
0
 def decideForProposalRequest(self, action, session, streams):
     if action == ACCEPT:
         try:
             self.acceptProposedStreams(session)
         except Exception, exc:
             BlinkLogger().log_warning(u"Error accepting proposal: %s" % exc)
             self.removeSession(session)
Beispiel #22
0
 def add_certificate_authority(self, ca):
     # not used anymore, let users add CAs in keychain instead
     try:
         X509Certificate(ca)
     except GNUTLSError, e:
         BlinkLogger().log_error(u"Invalid Certificate Authority: %s" % e)
         return False
Beispiel #23
0
 def _NH_SIPAccountRegistrationDidSucceed(self, account, data):
     message = u'%s registered contact "%s" at %s:%d;transport=%s for %d seconds' % (
         account, data.contact_header.uri, data.registrar.address,
         data.registrar.port, data.registrar.transport, data.expires)
     #contact_header_list = data.contact_header_list
     #if len(contact_header_list) > 1:
     #    message += u'Other registered Contact Addresses:\n%s\n' % '\n'.join('  %s (expires in %s seconds)' % (other_contact_header.uri, other_contact_header.expires) for other_contact_header in contact_header_list if other_contact_header.uri!=data.contact_header.uri)
     BlinkLogger().log_info(message)
     if account.contact.public_gruu is not None:
         message = u'%s public GRUU %s' % (account,
                                           account.contact.public_gruu)
         BlinkLogger().log_info(message)
     if account.contact.temporary_gruu is not None:
         message = u'%s temporary GRUU %s' % (
             account, account.contact.temporary_gruu)
         BlinkLogger().log_info(message)
Beispiel #24
0
 def send_global_pause_notification(self):
     if self.itunes_paused and self.spotify_paused and self.vlc_paused:
         self.notification_center.post_notification('MusicPauseDidExecute', sender=self, data=TimestampedNotificationData())
         self.itunes_paused = False
         self.spotify_paused = False
         self.vlc_paused = False
         BlinkLogger().log_info(u"Playback of music applications stopped")
 def close(self):
     BlinkLogger().log_debug('Close %s' % self)
     self.videoView.close()
     self.videoView = None
     self.notification_center.remove_observer(self, name="VideoDeviceDidChangeCamera")
     self.notification_center = None
     self.window().close()
    def start(self, restart=False):
        self.ft_info = FileTransferInfo(
            transfer_id=self.transfer_id,
            direction='outgoing',
            file_size=self.file_size,
            local_uri=format_identity_to_string(self.account)
            if self.account is not BonjourAccount() else 'bonjour',
            remote_uri=self.remote_identity,
            file_path=self.file_path)
        self.ft_info.status = "pending"
        self.status = "Pending"

        notification_center = NotificationCenter()
        if restart:
            notification_center.post_notification(
                "BlinkFileTransferRestarting",
                self,
                data=TimestampedNotificationData())
        else:
            notification_center.post_notification(
                "BlinkFileTransferInitializing",
                self,
                data=TimestampedNotificationData())

        BlinkLogger().log_info(u"Computing checksum for file %s" %
                               os.path.basename(self.file_path))

        self.stop_event.clear()
        self.initiate_file_transfer()
    def runModal(self):
        BlinkLogger().log_info('Starting Enrollment')
        self.newDisplayNameText.setStringValue_(NSFullUserName() or "")
        self.displayNameText.setStringValue_(NSFullUserName() or "")

        self.window.center()
        NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
Beispiel #28
0
 def decideForSessionRequest(self, action, session):
     if action == ACCEPT:
         NSApp.activateIgnoringOtherApps_(True)
         try:
             self.acceptStreams(session)
         except Exception, exc:
             BlinkLogger().log_warning(u"Error accepting session: %s" % exc)
             self.removeSession(session)
    def _NH_BlinkFileTransferDidComputeHash(self, sender, data):
        notification_center = NotificationCenter()
        settings = SIPSimpleSettings()

        self.stream = FileTransferStream(self.account, self.file_selector,
                                         'sendonly')
        self.session = Session(self.account)

        notification_center.add_observer(self, sender=self.session)
        notification_center.add_observer(self, sender=self.stream)

        self.status = "Offering File..."
        self.ft_info.status = "proposing"

        BlinkLogger().log_info(u"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
                         })
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %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)
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %s (through account %s proxy)"
                % (self.target_uri, self.account.id))
        else:
            uri = self.target_uri
            BlinkLogger().log_info(
                u"Initiating DNS Lookup for SIP routes of %s" %
                self.target_uri)
        notification_center.post_notification(
            "BlinkFileTransferInitiated",
            self,
            data=TimestampedNotificationData())
        lookup.lookup_sip_proxy(uri, settings.sip.transport_list)
 def initWithOwner_stream_(self, scontroller, stream):
     self = super(DesktopSharingController, self).initWithOwner_stream_(scontroller, stream)
     BlinkLogger().log_debug(u"Creating %s" % self)
     self.stream = stream
     self.direction = stream.handler.type
     self.vncViewerTask = None
     self.close_timer = None
     return self