예제 #1
0
 def _set_default_account(self, account):
     if account is not None and not account.enabled:
         raise ValueError("account %s is not enabled" % account.id)
     notification_center = NotificationCenter()
     settings = SIPSimpleSettings()
     with self._lock:
         old_account = self.accounts.get(settings.default_account, None)
         if account is old_account:
             return
         if account is None:
             settings.default_account = None
         else:
             settings.default_account = account.id
         settings.save()
         # we need to post the notification in the file-io thread in order to have it serialized after the
         # SIPAccountManagerDidAddAccount notification that is triggered when the account is saved the first
         # time, because save is executed in the file-io thread while this runs in the current thread. -Dan
         call_in_thread('file-io', notification_center.post_notification, 'SIPAccountManagerDidChangeDefaultAccount', sender=self, data=NotificationData(old_account=old_account, account=account))
예제 #2
0
 def default_account(self, account):
     if account is not None and not account.enabled:
         raise ValueError("account %s is not enabled" % account.id)
     notification_center = NotificationCenter()
     settings = SIPSimpleSettings()
     with self._lock:
         old_account = self.accounts.get(settings.default_account, None)
         if account is old_account:
             return
         if account is None:
             settings.default_account = None
         else:
             settings.default_account = account.id
         settings.save()
         # we need to post the notification in the file-io thread in order to have it serialized after the
         # SIPAccountManagerDidAddAccount notification that is triggered when the account is saved the first
         # time, because save is executed in the file-io thread while this runs in the current thread. -Dan
         call_in_thread('file-io',
                        notification_center.post_notification,
                        'SIPAccountManagerDidChangeDefaultAccount',
                        sender=self,
                        data=NotificationData(old_account=old_account,
                                              account=account))