core: - individual parameters managed through sqlite
- new asyncGetParamA method, which allow to get parameter for a not connected profile ==> individual parameters are cached in memory when the profile is connected, but must be accessed though sqlite else, and that must be done asynchronously primitivus: - profile manager updated to use asyncGetParamA /!\ still broken, need more work before being able to run again
This commit is contained in:
parent
1982eb79d8
commit
554299aa91
2 changed files with 135 additions and 29 deletions
|
|
@ -62,6 +62,9 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
return self.db_core_iface.asyncConnect(profile_key, reply_handler=callback, error_handler=errback)
|
||||
|
||||
def asyncGetParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
return unicode(self.db_core_iface.asyncGetParamA(name, category, attribute, profile_key, reply_handler=callback, error_handler=errback))
|
||||
|
||||
def callMenu(self, category, name, menu_type, profile_key):
|
||||
return unicode(self.db_core_iface.callMenu(category, name, menu_type, profile_key))
|
||||
|
||||
|
|
|
|||
|
|
@ -91,12 +91,15 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
self.host.showPopUp(pop_up_widget)
|
||||
|
||||
def onProfileChange(self, list_wid):
|
||||
def setJID(jabberID):
|
||||
self.login_wid.set_edit_text(jabberID)
|
||||
def setPassword(password):
|
||||
self.pass_wid.set_edit_text(password)
|
||||
|
||||
profile_name = list_wid.getSelectedValue()
|
||||
if profile_name:
|
||||
jabberID = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile_name)
|
||||
password = self.host.bridge.getParamA("Password", "Connection", profile_key=profile_name)
|
||||
self.login_wid.set_edit_text(jabberID)
|
||||
self.pass_wid.set_edit_text(password)
|
||||
self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile_name, callback=setJID, errback=self.getParamError)
|
||||
self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile_name, callback=setPassword, errback=self.getParamError)
|
||||
|
||||
def onConnectProfile(self, button):
|
||||
profile_name = self.list_profile.getSelectedValue()
|
||||
|
|
@ -110,15 +113,24 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
profile = self.host.bridge.getProfileName(profile_name)
|
||||
assert(profile)
|
||||
#TODO: move this to quick_app
|
||||
old_jid = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile)
|
||||
old_pass = self.host.bridge.getParamA("Password", "Connection", profile_key=profile)
|
||||
new_jid = self.login_wid.get_edit_text()
|
||||
new_pass = self.pass_wid.get_edit_text()
|
||||
self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile,
|
||||
callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError)
|
||||
|
||||
if old_jid != new_jid:
|
||||
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile)
|
||||
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile)
|
||||
if old_pass != new_pass:
|
||||
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
|
||||
self.host.plug_profile(profile)
|
||||
def __old_jidReceived(self, old_jid, profile):
|
||||
self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile,
|
||||
callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError)
|
||||
|
||||
def __old_passReceived(self, old_jid, old_pass, profile):
|
||||
"""Check if we have new jid/pass, save them if it is the case, and plug profile"""
|
||||
new_jid = self.login_wid.get_edit_text()
|
||||
new_pass = self.pass_wid.get_edit_text()
|
||||
|
||||
if old_jid != new_jid:
|
||||
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile)
|
||||
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile)
|
||||
if old_pass != new_pass:
|
||||
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
|
||||
self.host.plug_profile(profile)
|
||||
|
||||
def getParamError(self):
|
||||
error(_("Can't get profile parameter"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue