Example #1
0
 def _NH_CFGSettingsObjectDidChange(self, notification):
     if notification.sender is BlinkSettings():
         account_manager = AccountManager()
         if 'presence.offline_note' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if account.xcap.discovered):
                 state = BlinkPresenceState(account).offline_state
                 account.xcap_manager.set_offline_status(OfflineStatus(state) if state is not None else None)
         if 'presence.icon' in notification.data.modified:
             icon = IconManager().get('avatar')
             status_icon = Icon(icon.content, icon.content_type) if icon is not None else None
             for account in (account for account in account_manager.get_accounts() if account.xcap.discovered):
                 account.xcap_manager.set_status_icon(status_icon)
         if 'presence.current_state' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if account.enabled and account.presence.enabled):
                 account.presence_state = BlinkPresenceState(account).online_state
     else:
         account = notification.sender
         if {'xcap.enabled', 'xcap.xcap_root'}.intersection(notification.data.modified):
             account.xcap.icon = None
             account.save()
         elif {'presence.enabled', 'display_name', 'xcap.icon'}.intersection(notification.data.modified) and account.presence.enabled:
             account.presence_state = BlinkPresenceState(account).online_state
             if account.xcap.discovered and (set(notification.data.modified) != {'xcap.icon'} or account.id in self._should_set_offline_status):
                 state = BlinkPresenceState(account).offline_state
                 account.xcap_manager.set_offline_status(OfflineStatus(state) if state is not None else None)
             if account.id in self._should_set_offline_status:  # do not use set.discard() here to avoid race conditions. it should only be removed if present.
                 self._should_set_offline_status.remove(account.id)
Example #2
0
 def _NH_CFGSettingsObjectDidChange(self, notification):
     if notification.sender is BlinkSettings():
         account_manager = AccountManager()
         if 'presence.offline_note' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if account.xcap.discovered):
                 state = BlinkPresenceState(account).offline_state
                 account.xcap_manager.set_offline_status(OfflineStatus(state) if state is not None else None)
         if 'presence.icon' in notification.data.modified:
             icon = IconManager().get('avatar')
             status_icon = Icon(icon.content, icon.content_type) if icon is not None else None
             for account in (account for account in account_manager.get_accounts() if account.xcap.discovered):
                 account.xcap_manager.set_status_icon(status_icon)
         if 'presence.current_state' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if account.enabled and account.presence.enabled):
                 account.presence_state = BlinkPresenceState(account).online_state
     else:
         account = notification.sender
         if {'xcap.enabled', 'xcap.xcap_root'}.intersection(notification.data.modified):
             account.xcap.icon = None
             account.save()
         elif {'presence.enabled', 'display_name', 'xcap.icon'}.intersection(notification.data.modified) and account.presence.enabled:
             account.presence_state = BlinkPresenceState(account).online_state
             if account.xcap.discovered and (set(notification.data.modified) != {'xcap.icon'} or account.id in self._should_set_offline_status):
                 state = BlinkPresenceState(account).offline_state
                 account.xcap_manager.set_offline_status(OfflineStatus(state) if state is not None else None)
             if account.id in self._should_set_offline_status:  # do not use set.discard() here to avoid race conditions. it should only be removed if present.
                 self._should_set_offline_status.remove(account.id)
Example #3
0
    def init_configurations(self):
        account_manager = AccountManager()
        settings = SIPSimpleSettings()

        self.notification_center.add_observer(self, sender=settings)

        # fixup default account
        self._selected_account = account_manager.default_account
        if self._selected_account is None:
            self._selected_account = account_manager.get_accounts()[0]

        default_ca = open(Resources.get('ca.crt'), "r").read().strip()
        self.set_default_certificate_authority(default_ca)
Example #4
0
    def init_configurations(self):
        account_manager = AccountManager()
        settings = SIPSimpleSettings()

        self.notification_center.add_observer(self, sender=settings)

        # fixup default account
        self._selected_account = account_manager.default_account
        if self._selected_account is None:
            self._selected_account = account_manager.get_accounts()[0]

        default_ca = open(Resources.get('ca.crt'), "r").read().strip()
        self.set_default_certificate_authority(default_ca)
Example #5
0
 def _NH_CFGSettingsObjectDidChange(self, notification):
     if notification.sender is BlinkSettings():
         account_manager = AccountManager()
         if 'presence.offline_note' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 state = BlinkPresenceState(account).offline_state
                 account.xcap_manager.set_offline_status(OfflineStatus(state) if state is not None else None)
         if 'presence.icon' in notification.data.modified:
             icon_data = IconManager().get_image('avatar')
             icon = Icon(icon_data, 'image/png') if icon_data is not None else None
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 account.xcap_manager.set_status_icon(icon)
         if 'presence.current_state' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if account.enabled and account.presence.enabled):
                 account.presence_state = BlinkPresenceState(account).online_state
     else:
         account = notification.sender
         if set(['xcap.enabled', 'xcap.xcap_root']).intersection(notification.data.modified):
             account.xcap.icon = None
             account.save()
         elif set(['presence.enabled', 'display_name', 'xcap.icon']).intersection(notification.data.modified) and account.presence.enabled:
             account.presence_state = BlinkPresenceState(account).online_state
 def _NH_CFGSettingsObjectDidChange(self, notification):
     if isinstance(notification.sender, Account):
         account = notification.sender
         if set(['xcap.enabled', 'xcap.xcap_root']).intersection(notification.data.modified):
             account.xcap.icon = None
             account.save()
         elif set(['display_name', 'presence.enabled', 'presence.disable_location', 'presence.disable_timezone', 'presence.homepage', 'xcap.icon']).intersection(notification.data.modified):
             account.presence_state = self.build_pidf(account)
             if 'presence.disable_location' in notification.data.modified and not account.presence.disable_location:
                 self.get_location([account])
     elif notification.sender is SIPSimpleSettings():
         account_manager = AccountManager()
         if set(['chat.disabled', 'video.device', 'screen_sharing_server.disabled', 'file_transfer.disabled', 'presence_state.icon', 'presence_state.status', 'presence_state.note']).intersection(notification.data.modified):
             self.publish()
         if 'presence_state.offline_note' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 offline_pidf = self.build_offline_pidf(account)
                 offline_status = OfflineStatus(offline_pidf) if offline_pidf is not None else None
                 account.xcap_manager.set_offline_status(offline_status)
         if 'presence_state.icon' in notification.data.modified:
             status_icon = self.build_status_icon()
             icon = Icon(status_icon, 'image/png') if status_icon is not None else None
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 account.xcap_manager.set_status_icon(icon)
 def _NH_CFGSettingsObjectDidChange(self, notification):
     if isinstance(notification.sender, Account):
         account = notification.sender
         if set(['xcap.enabled', 'xcap.xcap_root']).intersection(notification.data.modified):
             account.xcap.icon = None
             account.save()
         elif set(['display_name', 'presence.enabled', 'presence.disable_location', 'presence.disable_timezone', 'presence.homepage', 'xcap.icon']).intersection(notification.data.modified):
             account.presence_state = self.build_pidf(account)
             if 'presence.disable_location' in notification.data.modified and not account.presence.disable_location:
                 self.get_location([account])
     elif notification.sender is SIPSimpleSettings():
         account_manager = AccountManager()
         if set(['chat.disabled', 'video.device', 'screen_sharing_server.disabled', 'file_transfer.disabled', 'presence_state.icon', 'presence_state.status', 'presence_state.note']).intersection(notification.data.modified):
             self.publish()
         if 'presence_state.offline_note' in notification.data.modified:
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 offline_pidf = self.build_offline_pidf(account)
                 offline_status = OfflineStatus(offline_pidf) if offline_pidf is not None else None
                 account.xcap_manager.set_offline_status(offline_status)
         if 'presence_state.icon' in notification.data.modified:
             status_icon = self.build_status_icon()
             icon = Icon(status_icon, 'image/png') if status_icon is not None else None
             for account in (account for account in account_manager.get_accounts() if hasattr(account, 'xcap') and account.enabled and account.xcap.enabled and account.xcap.discovered):
                 account.xcap_manager.set_status_icon(icon)
Example #8
0
    def init_configurations(self):
        account_manager = AccountManager()
        settings = SIPSimpleSettings()

        # fixup default account
        self._selected_account = account_manager.default_account
        if self._selected_account is None:
            self._selected_account = account_manager.get_accounts()[0]

        # save default ca if needed
        ca = open(Resources.get('ca.crt'), "r").read().strip()
        try:
            X509Certificate(ca)
        except GNUTLSError, e:
            BlinkLogger().log_error(u"Invalid Certificate Authority: %s" % e)
            return
Example #9
0
    def init_configurations(self):
        account_manager = AccountManager()
        settings = SIPSimpleSettings()

        # fixup default account
        self._selected_account = account_manager.default_account
        if self._selected_account is None:
            self._selected_account = account_manager.get_accounts()[0]

        # save default ca if needed
        ca = open(Resources.get('ca.crt'), "r").read().strip()
        try:
            X509Certificate(ca)
        except GNUTLSError as e:
            BlinkLogger().log_error("Invalid Certificate Authority: %s" % e)
            return

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

        try:
            existing_cas = open(ca_path, "r").read().strip()
        except Exception:
            existing_cas = None

        if ca == existing_cas:
            return

        with open(ca_path, "wb") as f:
            os.chmod(ca_path, 0o600)
            f.write(ca.encode())

        BlinkLogger().log_debug("Added default Certificate Authority to %s" % ca_path)
        settings.tls.ca_list = ca_path
        settings.save()