Mercurial > libervia-backend
comparison sat.tac @ 135:7452ac3818e7
Core, wix: added profile management for RegisterNewAccount method, and LaunchAction
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 16 Jul 2010 20:16:13 +0800 |
parents | ded2431cea5a |
children | 61f1e509e684 |
comparison
equal
deleted
inserted
replaced
134:7201851d9aed | 135:7452ac3818e7 |
---|---|
241 class SatFallbackHandler(generic.FallbackHandler): | 241 class SatFallbackHandler(generic.FallbackHandler): |
242 def __init__(self, host): | 242 def __init__(self, host): |
243 generic.FallbackHandler.__init__(self) | 243 generic.FallbackHandler.__init__(self) |
244 | 244 |
245 def iqFallback(self, iq): | 245 def iqFallback(self, iq): |
246 #pdb.set_trace() | |
247 print "iqFallback: xml = [%s], handled=%s" % (iq.toXml(), "True" if iq.handled else "False") | 246 print "iqFallback: xml = [%s], handled=%s" % (iq.toXml(), "True" if iq.handled else "False") |
248 generic.FallbackHandler.iqFallback(self, iq) | 247 generic.FallbackHandler.iqFallback(self, iq) |
249 | 248 |
250 class RegisteringAuthenticator(xmlstream.ConnectAuthenticator): | 249 class RegisteringAuthenticator(xmlstream.ConnectAuthenticator): |
251 | 250 |
476 serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect() | 475 serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect() |
477 | 476 |
478 return next_id | 477 return next_id |
479 | 478 |
480 def registerNewAccountCB(self, id, data, profile): | 479 def registerNewAccountCB(self, id, data, profile): |
481 #FIXME: gof: profile not managed here ! | 480 user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0] |
482 user = jid.parse(self.memory.getParamA("JabberID", "Connection"))[0] | 481 password = self.memory.getParamA("Password", "Connection", profile_key=profile) |
483 password = self.memory.getParamA("Password", "Connection") | 482 server = self.memory.getParamA("Server", "Connection", profile_key=profile) |
484 server = self.memory.getParamA("Server", "Connection") | |
485 | 483 |
486 if not user or not password or not server: | 484 if not user or not password or not server: |
487 info (_('No user or server given')) | 485 info (_('No user or server given')) |
488 #TODO: a proper error message must be sent to frontend | 486 #TODO: a proper error message must be sent to frontend |
489 self.actionResult(id, "ERROR", {'message':_("No user, password or server given, can't register new account.")}) | 487 self.actionResult(id, "ERROR", {'message':_("No user, password or server given, can't register new account.")}) |
490 return | 488 return |
491 | 489 |
492 confirm_id = sat_next_id() | 490 confirm_id = sat_next_id() |
493 self.__private_data[confirm_id]=id | 491 self.__private_data[confirm_id]=(id,profile) |
494 | 492 |
495 self.askConfirmation(confirm_id, "YES/NO", | 493 self.askConfirmation(confirm_id, "YES/NO", |
496 {"message":_("Are you sure to register new account [%(user)s] to server %(server)s ?") % {'user':user, 'server':server}}, | 494 {"message":_("Are you sure to register new account [%(user)s] to server %(server)s ?") % {'user':user, 'server':server, 'profile':profile}}, |
497 self.regisConfirmCB) | 495 self.regisConfirmCB) |
498 print ("===============+++++++++++ REGISTER NEW ACCOUNT++++++++++++++============") | 496 print ("===============+++++++++++ REGISTER NEW ACCOUNT++++++++++++++============") |
499 print "id=",id | 497 print "id=",id |
500 print "data=",data | 498 print "data=",data |
501 | 499 |
502 def regisConfirmCB(self, id, accepted, data): | 500 def regisConfirmCB(self, id, accepted, data): |
503 #FIXME: gof: profile not managed here ! | |
504 print _("register Confirmation CB ! (%s)") % str(accepted) | 501 print _("register Confirmation CB ! (%s)") % str(accepted) |
505 action_id = self.__private_data[id] | 502 action_id,profile = self.__private_data[id] |
506 del self.__private_data[id] | 503 del self.__private_data[id] |
507 user = jid.parse(self.memory.getParamA("JabberID", "Connection"))[0] | |
508 password = self.memory.getParamA("Password", "Connection") | |
509 server = self.memory.getParamA("Server", "Connection") | |
510 if accepted: | 504 if accepted: |
505 user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0] | |
506 password = self.memory.getParamA("Password", "Connection", profile_key=profile) | |
507 server = self.memory.getParamA("Server", "Connection", profile_key=profile) | |
511 self.registerNewAccount(user, password, server, id=action_id) | 508 self.registerNewAccount(user, password, server, id=action_id) |
512 else: | 509 else: |
513 self.actionResult(action_id, "SUPPRESS", {}) | 510 self.actionResult(action_id, "SUPPRESS", {}) |
514 | 511 |
515 def submitForm(self, action, target, fields, profile_key='@DEFAULT@'): | 512 def submitForm(self, action, target, fields, profile_key='@DEFAULT@'): |
643 profile = self.memory.getProfileName(profile_key) | 640 profile = self.memory.getProfileName(profile_key) |
644 assert(profile) | 641 assert(profile) |
645 to_jid=jid.JID(to) | 642 to_jid=jid.JID(to) |
646 self.profiles[profile].roster.removeItem(to_jid) | 643 self.profiles[profile].roster.removeItem(to_jid) |
647 self.profiles[profile].presence.unsubscribe(to_jid) | 644 self.profiles[profile].presence.unsubscribe(to_jid) |
648 self.host.bridge.contactDeleted(to, profile) | 645 self.bridge.contactDeleted(to, profile) |
649 | 646 |
650 | 647 |
651 ## callbacks ## | 648 ## callbacks ## |
652 | 649 |
653 def serverDisco(self, disco): | 650 def serverDisco(self, disco): |