Mercurial > libervia-backend
comparison frontends/src/primitivus/profile_manager.py @ 413:dd4caab17008
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 01 Nov 2011 20:39:22 +0100 |
parents | b1794cbb88e5 |
children | 28e4299d4553 |
comparison
equal
deleted
inserted
replaced
412:62b17854254e | 413:dd4caab17008 |
---|---|
89 def onDeleteProfile(self, e): | 89 def onDeleteProfile(self, e): |
90 pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getSelectedValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile) | 90 pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getSelectedValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile) |
91 self.host.showPopUp(pop_up_widget) | 91 self.host.showPopUp(pop_up_widget) |
92 | 92 |
93 def onProfileChange(self, list_wid): | 93 def onProfileChange(self, list_wid): |
94 def setJID(jabberID): | |
95 self.login_wid.set_edit_text(jabberID) | |
96 def setPassword(password): | |
97 self.pass_wid.set_edit_text(password) | |
98 | |
94 profile_name = list_wid.getSelectedValue() | 99 profile_name = list_wid.getSelectedValue() |
95 if profile_name: | 100 if profile_name: |
96 jabberID = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile_name) | 101 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile_name, callback=setJID, errback=self.getParamError) |
97 password = self.host.bridge.getParamA("Password", "Connection", profile_key=profile_name) | 102 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile_name, callback=setPassword, errback=self.getParamError) |
98 self.login_wid.set_edit_text(jabberID) | |
99 self.pass_wid.set_edit_text(password) | |
100 | 103 |
101 def onConnectProfile(self, button): | 104 def onConnectProfile(self, button): |
102 profile_name = self.list_profile.getSelectedValue() | 105 profile_name = self.list_profile.getSelectedValue() |
103 if not profile_name: | 106 if not profile_name: |
104 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog) | 107 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog) |
108 self.host.showPopUp(pop_up_widget) | 111 self.host.showPopUp(pop_up_widget) |
109 else: | 112 else: |
110 profile = self.host.bridge.getProfileName(profile_name) | 113 profile = self.host.bridge.getProfileName(profile_name) |
111 assert(profile) | 114 assert(profile) |
112 #TODO: move this to quick_app | 115 #TODO: move this to quick_app |
113 old_jid = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile) | 116 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile, |
114 old_pass = self.host.bridge.getParamA("Password", "Connection", profile_key=profile) | 117 callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError) |
115 new_jid = self.login_wid.get_edit_text() | |
116 new_pass = self.pass_wid.get_edit_text() | |
117 | 118 |
118 if old_jid != new_jid: | 119 def __old_jidReceived(self, old_jid, profile): |
119 self.host.bridge.setParam("JabberID", new_jid, "Connection", profile) | 120 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, |
120 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile) | 121 callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError) |
121 if old_pass != new_pass: | 122 |
122 self.host.bridge.setParam("Password", new_pass, "Connection", profile) | 123 def __old_passReceived(self, old_jid, old_pass, profile): |
123 self.host.plug_profile(profile) | 124 """Check if we have new jid/pass, save them if it is the case, and plug profile""" |
125 new_jid = self.login_wid.get_edit_text() | |
126 new_pass = self.pass_wid.get_edit_text() | |
127 | |
128 if old_jid != new_jid: | |
129 self.host.bridge.setParam("JabberID", new_jid, "Connection", profile) | |
130 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile) | |
131 if old_pass != new_pass: | |
132 self.host.bridge.setParam("Password", new_pass, "Connection", profile) | |
133 self.host.plug_profile(profile) | |
124 | 134 |
135 def getParamError(self): | |
136 error(_("Can't get profile parameter")) |