From 84cd3c6ea2380f8f5ddcb97cd91cac71049702ce Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 1 Dec 2009 06:07:20 +0100 Subject: [PATCH] better presentation for register new account - error message when no user, pass or server given - server is now automatically updated when jid change in connection category --- frontends/wix/main_window.py | 2 ++ frontends/wix/param.py | 21 ++++++++++++++++++--- sat.tac | 7 +++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontends/wix/main_window.py b/frontends/wix/main_window.py index c53982d2..71a9792b 100644 --- a/frontends/wix/main_window.py +++ b/frontends/wix/main_window.py @@ -306,6 +306,7 @@ class MainWindow(wx.Frame, QuickApp): if type == "SUPPRESS": self.current_action_ids.remove(id) elif type == "SUCCESS": + self.current_action_ids.remove(id) dlg = wx.MessageDialog(self, data["message"], 'Success', wx.OK | wx.ICON_INFORMATION @@ -313,6 +314,7 @@ class MainWindow(wx.Frame, QuickApp): dlg.ShowModal() dlg.Destroy() elif type == "ERROR": + self.current_action_ids.remove(id) dlg = wx.MessageDialog(self, data["message"], 'Error', wx.OK | wx.ICON_ERROR diff --git a/frontends/wix/param.py b/frontends/wix/param.py index c71ddf86..8ac66828 100644 --- a/frontends/wix/param.py +++ b/frontends/wix/param.py @@ -25,6 +25,7 @@ import wx import pdb from xml.dom import minidom from logging import debug, info, error +from tools.jid import JID class Param(wx.Frame): @@ -33,7 +34,8 @@ class Param(wx.Frame): self.host = host - self.modified={} # dict of modified data (i.e. what we have to save) + self.modified = {} # dict of modified data (i.e. what we have to save) + self.ctl_list = {} # usefull to access ctrl, key = (name, category) self.sizer = wx.BoxSizer(wx.VERTICAL) self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT) @@ -77,6 +79,7 @@ class Param(wx.Frame): raise NotImplementedError ctrl.param_id=(name, category) sizer.Add(ctrl, 1, flag=wx.EXPAND) + self.ctl_list[(name, category)] = ctrl panel.sizer.Add(sizer, flag=wx.EXPAND) if type=="string" or type=="password": @@ -92,10 +95,18 @@ class Param(wx.Frame): def onTextChanged(self, event): """Called when a paramated is modified""" self.modified[event.GetEventObject().param_id]=event.GetString() + + ### FIXME # Some hacks for better presentation, should be generic # FIXME ### + if event.GetEventObject().param_id == ('JabberID', 'Connection'): + domain = JID(event.GetString()).domain + self.ctl_list[('Server', 'Connection')].SetValue(domain) + self.modified[('Server', 'Connection')] = domain + event.Skip() def onButtonClicked(self, event): """Called when a paramated is modified""" + self.__save_parameters() print "Button Clicked (%s/%s)" % event.GetEventObject().param_id name, category = event.GetEventObject().param_id data = {"name":name, "category":category} @@ -104,12 +115,16 @@ class Param(wx.Frame): print "action id:",id event.Skip() + def __save_parameters(self): + for param in self.modified: + self.host.bridge.setParam(param[0], self.modified[param], param[1]) + self.modified.clear() + def onClose(self, event): """Close event: we have to save the params.""" debug("close") #now we save the modifier params - for param in self.modified: - self.host.bridge.setParam(param[0], self.modified[param], param[1]) + self.__save_parameters() self.MakeModal(False) event.Skip() diff --git a/sat.tac b/sat.tac index 28de247c..95ccc2d3 100644 --- a/sat.tac +++ b/sat.tac @@ -384,8 +384,15 @@ class SAT(service.Service): def registerNewAccountCB(self, id, data): user = jid.parse(self.memory.getParamA("JabberID", "Connection"))[0] + password = self.memory.getParamA("Password", "Connection") server = self.memory.getParamA("Server", "Connection") + if not user or not password or not server: + info ('No user or server given') + #TODO: a proper error message must be sent to frontend + self.actionResult(id, "ERROR", {'message':"No user, password or server given, can't register new account."}) + return + confirm_id = sat_next_id() self.__private_data[confirm_id]=id