예제 #1
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()
예제 #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()
예제 #3
0
 def cleanupIcons(self):
     save = False
     configuration_manager = ConfigurationManager()
     try:
         contacts = configuration_manager.get(['Addressbook', 'Contacts'])
     except Exception:
         return
     for data in contacts.itervalues():
         if 'icon' in data:
             del data['icon']
             save = True
     if save:
         configuration_manager.save()
예제 #4
0
 def cleanupIcons(self):
     save = False
     configuration_manager = ConfigurationManager()
     try:
         contacts = configuration_manager.get(['Addressbook', 'Contacts'])
     except Exception:
         return
     for data in contacts.values():
         if 'icon' in data:
             del data['icon']
             save = True
     if save:
         configuration_manager.save()
예제 #5
0
 def load(self):
     """
     Load all accounts from the configuration. The accounts will not be
     started until the start method is called.
     """
     configuration = ConfigurationManager()
     bonjour_account = BonjourAccount()
     names = configuration.get_names([Account.__group__])
     [Account(id) for id in names if id != bonjour_account.id]
     default_account = self.default_account
     if default_account is None or not default_account.enabled:
         try:
             self.default_account = (account for account in self.accounts.itervalues() if account.enabled).next()
         except StopIteration:
             self.default_account = None
예제 #6
0
    def delete(self):
        """Remove the group from the persistent storage."""
        if self.__state__ == 'deleted':
            return
        self.__state__ = 'deleted'

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        configuration.delete(self.__key__)
        notification_center.post_notification('VirtualGroupWasDeleted', sender=self)
        try:
            configuration.save()
        except Exception, e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed', sender=configuration, data=NotificationData(object=self, operation='delete', exception=e))
예제 #7
0
 def load(self):
     """
     Load all accounts from the configuration. The accounts will not be
     started until the start method is called.
     """
     configuration = ConfigurationManager()
     bonjour_account = BonjourAccount()
     names = configuration.get_names([Account.__group__])
     [Account(id) for id in names if id != bonjour_account.id]
     default_account = self.default_account
     if default_account is None or not default_account.enabled:
         try:
             self.default_account = next(
                 (account for account in list(self.accounts.values())
                  if account.enabled))
         except StopIteration:
             self.default_account = None
예제 #8
0
    def run(self):
        account_manager = AccountManager()
        configuration = ConfigurationManager()
        engine = Engine()

        # start output thread
        self.output.start()

        # startup configuration
        Account.register_extension(AccountExtension)
        SIPSimpleSettings.register_extension(SIPSimpleSettingsExtension)
        SIPApplication.storage = FileStorage(config_directory)
        try:
            configuration.start()
        except ConfigurationError, e:
            raise RuntimeError(
                "failed to load sipclient's configuration: %s\nIf an old configuration file is in place, delete it or move it and recreate the configuration using the sip_settings script."
                % str(e))
예제 #9
0
 def __new__(cls, id=None):
     with VirtualGroupsManager.load.lock:
         if not VirtualGroupsManager.load.called:
             raise RuntimeError("cannot instantiate %s before calling VirtualGroupsManager.load" % cls.__name__)
     if id is None:
         id = unique_id()
     elif not isinstance(id, basestring):
         raise TypeError("id needs to be a string or unicode object")
     instance = SettingsState.__new__(cls)
     instance.__id__ = id
     instance.__state__ = 'new'
     configuration = ConfigurationManager()
     try:
         data = configuration.get(instance.__key__)
     except ObjectNotFoundError:
         pass
     else:
         instance.__setstate__(data)
         instance.__state__ = 'loaded'
     return instance
예제 #10
0
 def __new__(cls, id=None):
     #        with VirtualGroupsManager.load.lock:
     #            if not VirtualGroupsManager.load.called:
     #                raise RuntimeError("cannot instantiate %s before calling VirtualGroupsManager.load" % cls.__name__)
     if id is None:
         id = unique_id()
     elif not isinstance(id, str):
         raise TypeError("id needs to be a string or unicode object")
     instance = SettingsState.__new__(cls)
     instance.__id__ = id
     instance.__state__ = 'new'
     configuration = ConfigurationManager()
     try:
         data = configuration.get(instance.__key__)
     except ObjectNotFoundError:
         pass
     else:
         instance.__setstate__(data)
         instance.__state__ = 'loaded'
     return instance
예제 #11
0
 def load(self):
     """
     Load all accounts from the configuration. The accounts will not be
     started until the start method is called.
     """
     notification_center = NotificationCenter()
     configuration = ConfigurationManager()
     bonjour_account = BonjourAccount()
     names = configuration.get_names([Account.__group__])
     [Account(id) for id in names if id != bonjour_account.id]
     default_account = self.default_account
     notification_center.post_notification(
         'SIPAccountManagerDidLoad',
         sender=self,
         data=NotificationData(accounts=names,
                               default_account=default_account))
     if default_account is None or not default_account.enabled:
         try:
             self.default_account = next(
                 (account for account in list(self.accounts.values())
                  if account.enabled))
         except StopIteration:
             self.default_account = None
예제 #12
0
    def start(self, storage):
        if not ISIPSimpleStorage.providedBy(storage):
            raise TypeError(
                "storage must implement the ISIPSimpleStorage interface")

        with self._lock:
            if self.state is not None:
                raise RuntimeError(
                    "SIPApplication cannot be started from '%s' state" %
                    self.state)
            self.state = 'starting'

        self.engine = Engine()
        self.storage = storage

        thread_manager = ThreadManager()
        thread_manager.start()

        configuration_manager = ConfigurationManager()
        addressbook_manager = AddressbookManager()
        account_manager = AccountManager()

        # load configuration and initialize core
        try:
            configuration_manager.start()
            SIPSimpleSettings()
            account_manager.load()
            addressbook_manager.load()
        except:
            self.engine = None
            self.state = None
            self.storage = None
            raise

        # run the reactor thread
        self.thread = Thread(name='Reactor Thread', target=self._run_reactor)
        self.thread.start()
예제 #13
0
    def save(self):
        """
        Store the group into persistent storage (local).

        This method will post the VirtualGroupWasCreated and
        VirtualGroupWasActivated notifications on the first save or a
        VirtualGroupDidChange notification on subsequent saves.
        A CFGManagerSaveFailed notification is posted if saving to the
        persistent configuration storage fails.
        """
        if self.__state__ == 'deleted':
            return

        modified_settings = self.get_modified()
        if not modified_settings and self.__state__ != 'new':
            return

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        if self.__state__ == 'new':
            configuration.update(self.__key__, self.__getstate__())
            self.__state__ = 'active'
            modified_data = None
            notification_center.post_notification('VirtualGroupWasActivated',
                                                  sender=self)
            notification_center.post_notification('VirtualGroupWasCreated',
                                                  sender=self)
        else:
            configuration.update(self.__key__, self.__getstate__())
            notification_center.post_notification(
                'VirtualGroupDidChange',
                sender=self,
                data=NotificationData(modified=modified_settings))
            modified_data = modified_settings

        try:
            configuration.save()
        except Exception as e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed',
                                                  sender=configuration,
                                                  data=NotificationData(
                                                      object=self,
                                                      operation='save',
                                                      modified=modified_data,
                                                      exception=e))
예제 #14
0
    def save(self):
        """
        Store the group into persistent storage (local).

        This method will post the VirtualGroupWasCreated and
        VirtualGroupWasActivated notifications on the first save or a
        VirtualGroupDidChange notification on subsequent saves.
        A CFGManagerSaveFailed notification is posted if saving to the
        persistent configuration storage fails.
        """
        if self.__state__ == 'deleted':
            return

        modified_settings = self.get_modified()
        if not modified_settings and self.__state__ != 'new':
            return

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        if self.__state__ == 'new':
            configuration.update(self.__key__, self.__getstate__())
            self.__state__ = 'active'
            modified_data = None
            notification_center.post_notification('VirtualGroupWasActivated', sender=self)
            notification_center.post_notification('VirtualGroupWasCreated', sender=self)
        else:
            configuration.update(self.__key__, self.__getstate__())
            notification_center.post_notification('VirtualGroupDidChange', sender=self, data=NotificationData(modified=modified_settings))
            modified_data = modified_settings

        try:
            configuration.save()
        except Exception, e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed', sender=configuration, data=NotificationData(object=self, operation='save', modified=modified_data, exception=e))
예제 #15
0
    def delete(self):
        """Remove the group from the persistent storage."""
        if self.__state__ == 'deleted':
            return
        self.__state__ = 'deleted'

        configuration = ConfigurationManager()
        notification_center = NotificationCenter()

        configuration.delete(self.__key__)
        notification_center.post_notification('VirtualGroupWasDeleted',
                                              sender=self)
        try:
            configuration.save()
        except Exception as e:
            log.err()
            notification_center.post_notification('CFGManagerSaveFailed',
                                                  sender=configuration,
                                                  data=NotificationData(
                                                      object=self,
                                                      operation='delete',
                                                      exception=e))
예제 #16
0
 def load(self):
     configuration = ConfigurationManager()
     [VirtualGroup(id=id) for id in configuration.get_names(VirtualGroup.__key__)]
예제 #17
0
 def load(self):
     configuration = ConfigurationManager()
     [
         VirtualGroup(id=id)
         for id in configuration.get_names(VirtualGroup.__key__)
     ]