Mercurial > libervia-backend
comparison src/memory/memory.py @ 894:57c32d8ec847
core (memory): asyncDeleteProfile can force the deletion of a profile, even if it's connected (when called from the backend only)
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 03 Mar 2014 15:37:49 +0100 |
parents | 308a96bc7c1b |
children | fab49a1d5ea2 |
comparison
equal
deleted
inserted
replaced
893:308a96bc7c1b | 894:57c32d8ec847 |
---|---|
226 return defer.fail(Failure(exceptions.ConflictError)) | 226 return defer.fail(Failure(exceptions.ConflictError)) |
227 if not self.host.trigger.point("ProfileCreation", profile): | 227 if not self.host.trigger.point("ProfileCreation", profile): |
228 return defer.fail(Failure(exceptions.CancelError)) | 228 return defer.fail(Failure(exceptions.CancelError)) |
229 return self.storage.createProfile(profile) | 229 return self.storage.createProfile(profile) |
230 | 230 |
231 def asyncDeleteProfile(self, profile): | 231 def asyncDeleteProfile(self, profile, force=False): |
232 """Delete an existing profile | 232 """Delete an existing profile |
233 @param profile: name of the profile | 233 @param profile: name of the profile |
234 @param force: force the deletion even if the profile is connected. | |
235 To be used for direct calls only (not through the bridge). | |
234 @return: a Deferred instance | 236 @return: a Deferred instance |
235 """ | 237 """ |
236 if not self.storage.hasProfile(profile): | 238 if not self.storage.hasProfile(profile): |
237 info(_('Trying to delete an unknown profile')) | 239 info(_('Trying to delete an unknown profile')) |
238 return defer.fail(Failure(exceptions.ProfileUnknownError)) | 240 return defer.fail(Failure(exceptions.ProfileUnknownError)) |
239 if self.host.isConnected(profile): | 241 if not force and self.host.isConnected(profile): |
240 info(_("Trying to delete a connected profile")) | 242 info(_("Trying to delete a connected profile")) |
241 return defer.fail(Failure(exceptions.ConnectedProfileError)) | 243 return defer.fail(Failure(exceptions.ConnectedProfileError)) |
242 return self.storage.deleteProfile(profile) | 244 return self.storage.deleteProfile(profile) |
243 | 245 |
244 def getProfileName(self, profile_key, return_profile_keys = False): | 246 def getProfileName(self, profile_key, return_profile_keys = False): |
880 """Create a new profile | 882 """Create a new profile |
881 @param name: Profile name | 883 @param name: Profile name |
882 """ | 884 """ |
883 return self.params.asyncCreateProfile(name) | 885 return self.params.asyncCreateProfile(name) |
884 | 886 |
885 def asyncDeleteProfile(self, name): | 887 def asyncDeleteProfile(self, name, force=False): |
886 """Delete an existing profile | 888 """Delete an existing profile |
887 @param name: Name of the profile""" | 889 @param name: Name of the profile |
888 return self.params.asyncDeleteProfile(name) | 890 @param force: force the deletion even if the profile is connected. |
891 To be used for direct calls only (not through the bridge). | |
892 @return: a Deferred instance | |
893 """ | |
894 return self.params.asyncDeleteProfile(name, force) | |
889 | 895 |
890 def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile="@NONE@"): | 896 def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile="@NONE@"): |
891 assert profile != "@NONE@" | 897 assert profile != "@NONE@" |
892 if extra is None: | 898 if extra is None: |
893 extra = {} | 899 extra = {} |