core, frontends: add method asyncDeleteProfile, remove synchronous methods createProfile and deleteProfile
This commit is contained in:
parent
528ceb5f8b
commit
d158589881
4 changed files with 47 additions and 82 deletions
|
|
@ -104,6 +104,9 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def asyncCreateProfile(self, profile, callback=None, errback=None):
|
||||
return self.db_core_iface.asyncCreateProfile(profile, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]))
|
||||
|
||||
def asyncDeleteProfile(self, profile, callback=None, errback=None):
|
||||
return self.db_core_iface.asyncDeleteProfile(profile, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]))
|
||||
|
||||
def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])))
|
||||
|
||||
|
|
@ -113,15 +116,9 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def connect(self, profile_key="@DEFAULT@"):
|
||||
return self.db_core_iface.connect(profile_key)
|
||||
|
||||
def createProfile(self, profile):
|
||||
return self.db_core_iface.createProfile(profile)
|
||||
|
||||
def delContact(self, entity_jid, profile_key="@DEFAULT@"):
|
||||
return self.db_core_iface.delContact(entity_jid, profile_key)
|
||||
|
||||
def deleteProfile(self, profile):
|
||||
return self.db_core_iface.deleteProfile(profile)
|
||||
|
||||
def disconnect(self, profile_key="@DEFAULT@"):
|
||||
return self.db_core_iface.disconnect(profile_key)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ProfileDelete(base.CommandBase):
|
|||
if self.args.profile not in self.host.bridge.getProfilesList():
|
||||
error("Profile %s doesn't exist." % self.args.profile)
|
||||
self.host.quit(1)
|
||||
self.host.bridge.deleteProfile(self.args.profile)
|
||||
self.host.bridge.asyncDeleteProfile(self.args.profile, callback=lambda dummy: None)
|
||||
|
||||
|
||||
class ProfileInfo(base.CommandBase):
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
def deleteProfile(self, button):
|
||||
profile_name = self.list_profile.getSelectedValue()
|
||||
if profile_name:
|
||||
self.host.bridge.deleteProfile(profile_name)
|
||||
self.__refillProfiles()
|
||||
self.host.bridge.asyncDeleteProfile(profile_name, callback=self.__refillProfiles)
|
||||
self.host.removePopUp()
|
||||
|
||||
def onNewProfile(self, e):
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
import wx
|
||||
import pdb
|
||||
from logging import debug, info, error
|
||||
from sat.tools.jid import JID
|
||||
import pdb
|
||||
|
||||
|
||||
class ProfileManager(wx.Panel):
|
||||
|
|
@ -99,9 +97,10 @@ class ProfileManager(wx.Panel):
|
|||
if name[0]=='@':
|
||||
wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal()
|
||||
else:
|
||||
profile = self.host.bridge.createProfile(name)
|
||||
self.__refillProfiles()
|
||||
self.profile_name.SetValue(name)
|
||||
def cb():
|
||||
self.__refillProfiles()
|
||||
self.profile_name.SetValue(name)
|
||||
self.host.bridge.asyncCreateProfile(name, callback=cb)
|
||||
dlg.Destroy()
|
||||
|
||||
def onDeleteProfile(self, event):
|
||||
|
|
@ -110,9 +109,10 @@ class ProfileManager(wx.Panel):
|
|||
return
|
||||
dlg = wx.MessageDialog(self, _("Are you sure to delete the profile [%s]") % name, _("Confirmation"), wx.ICON_QUESTION | wx.YES_NO)
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
self.host.bridge.deleteProfile(name)
|
||||
self.__refillProfiles()
|
||||
self.__setDefault()
|
||||
def cb():
|
||||
self.__refillProfiles()
|
||||
self.__setDefault()
|
||||
self.host.bridge.asyncDeleteProfile(name, callback=cb)
|
||||
dlg.Destroy()
|
||||
|
||||
def onProfileChange(self, event):
|
||||
|
|
|
|||
Loading…
Reference in a new issue