def removeSelectedAccount(self):
        account_info = self.selectedAccount()
        if account_info:
            account = account_info.account
            text = "Permanently remove account %s?" % account_info.name
            text = re.sub("%", "%%", text)
            # http://stackoverflow.com/questions/4498709/problem-in-displaying-in-nsrunalertpanel
            if NSRunAlertPanel("Remove Account", text, "Remove", "Cancel",
                               None) != NSAlertDefaultReturn:
                return

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

            account_manager = AccountManager()
            if account_manager.default_account is account:
                try:
                    account_manager.default_account = (
                        acc for acc in account_manager.iter_accounts()
                        if acc is not account and acc.enabled).next()
                except StopIteration:
                    account_manager.default_account = None

            account.delete()
Example #2
0
    def migratePasswordsToKeychain(self):
        if NSApp.delegate().applicationName == 'SIP2SIP':
            return

        account_manager = AccountManager()
        configuration_manager = ConfigurationManager()
        bonjour_account = BonjourAccount()
        for account in (account for account in account_manager.iter_accounts() if account is not bonjour_account):
            try:
                stored_auth_password = configuration_manager.get(account.__key__ + ['auth', 'password'])
            except ObjectNotFoundError:
                stored_auth_password = None
            try:
                stored_ldap_password = configuration_manager.get(account.__key__ + ['ldap', 'password'])
            except ObjectNotFoundError:
                stored_ldap_password = None
            try:
                stored_web_password = configuration_manager.get(account.__key__ + ['server', 'web_password'])
            except ObjectNotFoundError:
                stored_web_password = None
            if (stored_auth_password, stored_ldap_password, stored_web_password) != ('keychain', 'keychain', 'keychain'):
                Account.auth.password.dirty[account.auth] = True
                Account.ldap.password.dirty[account.ldap] = True
                Account.server.web_password.dirty[account.server] = True
                account.save()
Example #3
0
 def migratePasswordsToKeychain(self):
     account_manager = AccountManager()
     configuration_manager = ConfigurationManager()
     bonjour_account = BonjourAccount()
     for account in (account for account in account_manager.iter_accounts()
                     if account is not bonjour_account):
         try:
             stored_auth_password = configuration_manager.get(
                 account.__key__ + ['auth', 'password'])
         except ObjectNotFoundError:
             stored_auth_password = None
         try:
             stored_ldap_password = configuration_manager.get(
                 account.__key__ + ['ldap', 'password'])
         except ObjectNotFoundError:
             stored_ldap_password = None
         try:
             stored_web_password = configuration_manager.get(
                 account.__key__ + ['server', 'web_password'])
         except ObjectNotFoundError:
             stored_web_password = None
         if (stored_auth_password, stored_ldap_password,
                 stored_web_password) != ('keychain', 'keychain',
                                          'keychain'):
             Account.auth.password.dirty[account.auth] = True
             Account.ldap.password.dirty[account.ldap] = True
             Account.server.web_password.dirty[account.server] = True
             account.save()
Example #4
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()
Example #5
0
    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()
Example #6
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()
Example #7
0
 def _NH_SIPApplicationWillStart(self, notification):
     account_manager = AccountManager()
     settings = SIPSimpleSettings()
     self.silent_action.setChecked(settings.audio.silent)
     self.silent_button.setChecked(settings.audio.silent)
     self.answering_machine_action.setChecked(settings.answering_machine.enabled)
     self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
     self.received_messages_sound_action.setChecked(settings.sounds.play_message_alerts)
     if settings.google_contacts.enabled:
         self.google_contacts_action.setText('Disable &Google Contacts')
     else:
         self.google_contacts_action.setText('Enable &Google Contacts...')
     if not any(account.enabled for account in account_manager.iter_accounts()):
         self.display_name.setEnabled(False)
         self.activity_note.setEnabled(False)
         self.account_state.setEnabled(False)
Example #8
0
 def _NH_SIPApplicationWillStart(self, notification):
     account_manager = AccountManager()
     settings = SIPSimpleSettings()
     self.silent_action.setChecked(settings.audio.silent)
     self.silent_button.setChecked(settings.audio.silent)
     self.answering_machine_action.setChecked(settings.answering_machine.enabled)
     self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
     self.received_messages_sound_action.setChecked(settings.sounds.play_message_alerts)
     if settings.google_contacts.authorization_token is None:
         self.google_contacts_action.setText(u'Enable &Google Contacts...')
     else:
         self.google_contacts_action.setText(u'Disable &Google Contacts')
     self.google_contacts_action.triggered.connect(self._AH_GoogleContactsActionTriggered)
     if not any(account.enabled for account in account_manager.iter_accounts()):
         self.display_name.setEnabled(False)
         self.activity_note.setEnabled(False)
         self.account_state.setEnabled(False)
Example #9
0
 def _NH_SIPApplicationWillStart(self, notification):
     account_manager = AccountManager()
     settings = SIPSimpleSettings()
     self.silent_action.setChecked(settings.audio.silent)
     self.silent_button.setChecked(settings.audio.silent)
     self.answering_machine_action.setChecked(settings.answering_machine.enabled)
     self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
     self.auto_accept_files_action.setChecked(settings.file_transfer.auto_accept)
     if settings.google_contacts.authorization_token is None:
         self.google_contacts_action.setText(u'Enable Google Contacts')
     else:
         self.google_contacts_action.setText(u'Disable Google Contacts')
     self.google_contacts_action.triggered.connect(self._AH_GoogleContactsActionTriggered)
     if not any(account.enabled for account in account_manager.iter_accounts()):
         self.display_name.setEnabled(False)
         self.activity_note.setEnabled(False)
         self.status.setEnabled(False)
         self.status.setCurrentIndex(self.status.findText(u'Offline'))
    def removeSelectedAccount(self):
        account_info = self.selectedAccount()
        if account_info:
            account = account_info.account
            text = "Permanently remove account %s?" % account_info.name
            text = re.sub("%", "%%", text)
            # http://stackoverflow.com/questions/4498709/problem-in-displaying-in-nsrunalertpanel
            if NSRunAlertPanel("Remove Account", text, "Remove", "Cancel", None) != NSAlertDefaultReturn:
                return

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

            account_manager = AccountManager()
            if account_manager.default_account is account:
                try:
                    account_manager.default_account = (acc for acc in account_manager.iter_accounts() if acc is not account and acc.enabled).next()
                except StopIteration:
                    account_manager.default_account = None

            account.delete()
Example #11
0
    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_info(u"SIP User Agent: %s" % settings.user_agent)

        self.migratePasswordsToKeychain()
        self.cleanupIcons()

        # Set audio settings compatible with AEC and Noise Supressor
        settings.audio.sample_rate = 32000 if settings.audio.echo_canceller.enabled else 48000
        if NSApp.delegate().applicationName == 'SIP2SIP':
            settings.service_provider.help_url  = 'http://wiki.sip2sip.info'
            settings.service_provider.name = 'SIP2SIP'
        settings.save()
        BlinkLogger().log_info(u"Audio engine sampling rate %dKHz covering 0-%dKHz spectrum" % (settings.audio.sample_rate/1000, settings.audio.sample_rate/1000/2))
        BlinkLogger().log_info(u"Acoustic Echo Canceller is %s" % ('enabled' if settings.audio.echo_canceller.enabled 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 must_save:
                account.save()

        logger = FileLogger()
        logger.start()
        self.ip_address_monitor.start()