core (memory): asyncDeleteProfile can force the deletion of a profile, even if it's connected (when called from the backend only)
This commit is contained in:
parent
d158589881
commit
88baf0791b
1 changed files with 11 additions and 5 deletions
|
|
@ -228,15 +228,17 @@ class Params(object):
|
|||
return defer.fail(Failure(exceptions.CancelError))
|
||||
return self.storage.createProfile(profile)
|
||||
|
||||
def asyncDeleteProfile(self, profile):
|
||||
def asyncDeleteProfile(self, profile, force=False):
|
||||
"""Delete an existing profile
|
||||
@param profile: name of the profile
|
||||
@param force: force the deletion even if the profile is connected.
|
||||
To be used for direct calls only (not through the bridge).
|
||||
@return: a Deferred instance
|
||||
"""
|
||||
if not self.storage.hasProfile(profile):
|
||||
info(_('Trying to delete an unknown profile'))
|
||||
return defer.fail(Failure(exceptions.ProfileUnknownError))
|
||||
if self.host.isConnected(profile):
|
||||
if not force and self.host.isConnected(profile):
|
||||
info(_("Trying to delete a connected profile"))
|
||||
return defer.fail(Failure(exceptions.ConnectedProfileError))
|
||||
return self.storage.deleteProfile(profile)
|
||||
|
|
@ -882,10 +884,14 @@ class Memory(object):
|
|||
"""
|
||||
return self.params.asyncCreateProfile(name)
|
||||
|
||||
def asyncDeleteProfile(self, name):
|
||||
def asyncDeleteProfile(self, name, force=False):
|
||||
"""Delete an existing profile
|
||||
@param name: Name of the profile"""
|
||||
return self.params.asyncDeleteProfile(name)
|
||||
@param name: Name of the profile
|
||||
@param force: force the deletion even if the profile is connected.
|
||||
To be used for direct calls only (not through the bridge).
|
||||
@return: a Deferred instance
|
||||
"""
|
||||
return self.params.asyncDeleteProfile(name, force)
|
||||
|
||||
def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile="@NONE@"):
|
||||
assert profile != "@NONE@"
|
||||
|
|
|
|||
Loading…
Reference in a new issue