# HG changeset patch # User souliane # Date 1393857469 -3600 # Node ID 57c32d8ec847062fe24e0bf1cc1e21e1d7914095 # Parent 308a96bc7c1b130932c2dde8417e7b69d1890202 core (memory): asyncDeleteProfile can force the deletion of a profile, even if it's connected (when called from the backend only) diff -r 308a96bc7c1b -r 57c32d8ec847 src/memory/memory.py --- a/src/memory/memory.py Mon Mar 03 09:59:10 2014 +0100 +++ b/src/memory/memory.py Mon Mar 03 15:37:49 2014 +0100 @@ -228,15 +228,17 @@ 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 @@ """ 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@"