Mercurial > libervia-backend
comparison frontends/src/primitivus/profile_manager.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | 84a6e83157c2 |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
29 def __init__(self, host): | 29 def __init__(self, host): |
30 self.host = host | 30 self.host = host |
31 #profiles list | 31 #profiles list |
32 profiles = self.host.bridge.getProfilesList() | 32 profiles = self.host.bridge.getProfilesList() |
33 profiles.sort() | 33 profiles.sort() |
34 | 34 |
35 #login & password box must be created before list because of onProfileChange | 35 #login & password box must be created before list because of onProfileChange |
36 self.login_wid = AdvancedEdit(_('Login:'),align='center') | 36 self.login_wid = AdvancedEdit(_('Login:'),align='center') |
37 self.pass_wid = Password(_('Password:'),align='center') | 37 self.pass_wid = Password(_('Password:'),align='center') |
38 | 38 |
39 self.list_profile = List(profiles, style=['single'], align='center', on_change=self.onProfileChange) | 39 self.list_profile = List(profiles, style=['single'], align='center', on_change=self.onProfileChange) |
40 | 40 |
41 #new & delete buttons | 41 #new & delete buttons |
42 buttons = [urwid.Button(_("New"), self.onNewProfile), | 42 buttons = [urwid.Button(_("New"), self.onNewProfile), |
43 urwid.Button(_("Delete"), self.onDeleteProfile)] | 43 urwid.Button(_("Delete"), self.onDeleteProfile)] |
94 profile_name = self.list_profile.getSelectedValue() | 94 profile_name = self.list_profile.getSelectedValue() |
95 if profile_name: | 95 if profile_name: |
96 self.host.bridge.deleteProfile(profile_name) | 96 self.host.bridge.deleteProfile(profile_name) |
97 self.__refillProfiles() | 97 self.__refillProfiles() |
98 self.host.removePopUp() | 98 self.host.removePopUp() |
99 | 99 |
100 def onNewProfile(self, e): | 100 def onNewProfile(self, e): |
101 pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile) | 101 pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile) |
102 self.host.showPopUp(pop_up_widget) | 102 self.host.showPopUp(pop_up_widget) |
103 | 103 |
104 def onDeleteProfile(self, e): | 104 def onDeleteProfile(self, e): |
115 | 115 |
116 profile_name = list_wid.getSelectedValue() | 116 profile_name = list_wid.getSelectedValue() |
117 if profile_name: | 117 if profile_name: |
118 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile_name, callback=setJID, errback=self.getParamError) | 118 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile_name, callback=setJID, errback=self.getParamError) |
119 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile_name, callback=setPassword, errback=self.getParamError) | 119 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile_name, callback=setPassword, errback=self.getParamError) |
120 | 120 |
121 def onConnectProfile(self, button): | 121 def onConnectProfile(self, button): |
122 profile_name = self.list_profile.getSelectedValue() | 122 profile_name = self.list_profile.getSelectedValue() |
123 if not profile_name: | 123 if not profile_name: |
124 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog) | 124 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog) |
125 self.host.showPopUp(pop_up_widget) | 125 self.host.showPopUp(pop_up_widget) |
134 callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError) | 134 callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError) |
135 | 135 |
136 def __old_jidReceived(self, old_jid, profile): | 136 def __old_jidReceived(self, old_jid, profile): |
137 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, | 137 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, |
138 callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError) | 138 callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError) |
139 | 139 |
140 def __old_passReceived(self, old_jid, old_pass, profile): | 140 def __old_passReceived(self, old_jid, old_pass, profile): |
141 """Check if we have new jid/pass, save them if it is the case, and plug profile""" | 141 """Check if we have new jid/pass, save them if it is the case, and plug profile""" |
142 new_jid = self.login_wid.get_edit_text() | 142 new_jid = self.login_wid.get_edit_text() |
143 new_pass = self.pass_wid.get_edit_text() | 143 new_pass = self.pass_wid.get_edit_text() |
144 | 144 |
146 self.host.bridge.setParam("JabberID", new_jid, "Connection", profile) | 146 self.host.bridge.setParam("JabberID", new_jid, "Connection", profile) |
147 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile) | 147 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile) |
148 if old_pass != new_pass: | 148 if old_pass != new_pass: |
149 self.host.bridge.setParam("Password", new_pass, "Connection", profile) | 149 self.host.bridge.setParam("Password", new_pass, "Connection", profile) |
150 self.host.plug_profile(profile) | 150 self.host.plug_profile(profile) |
151 | 151 |
152 def getParamError(self, ignore): | 152 def getParamError(self, ignore): |
153 popup = Alert("Error", _("Can't get profile parameter"), ok_cb=self.host.removePopUp) | 153 popup = Alert("Error", _("Can't get profile parameter"), ok_cb=self.host.removePopUp) |
154 self.host.showPopUp(popup) | 154 self.host.showPopUp(popup) |