Mercurial > libervia-backend
comparison plugins/plugin_xep_0100.py @ 169:06985b6ad23a
SàT: plugin 0077 & 0100: fixed profile management
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Aug 2010 12:30:36 +0800 |
parents | 94011f553cd0 |
children | fbae69247b15 |
comparison
equal
deleted
inserted
replaced
168:a2655a0a4eac | 169:06985b6ad23a |
---|---|
42 def __init__(self, host): | 42 def __init__(self, host): |
43 info(_("Gateways plugin initialization")) | 43 info(_("Gateways plugin initialization")) |
44 self.host = host | 44 self.host = host |
45 self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid | 45 self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid |
46 host.bridge.addMethod("findGateways", ".communication", in_sign='ss', out_sign='s', method=self.findGateways) | 46 host.bridge.addMethod("findGateways", ".communication", in_sign='ss', out_sign='s', method=self.findGateways) |
47 host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)', out_sign='s', method=self.gatewayRegister) | 47 host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)s', out_sign='s', method=self.gatewayRegister) |
48 | 48 |
49 def __inc_handled_items(self, request_id): | 49 def __inc_handled_items(self, request_id): |
50 self.__gateways[request_id]['__handled_items']+=1 | 50 self.__gateways[request_id]['__handled_items']+=1 |
51 | 51 |
52 if self.__gateways[request_id]['__total_items'] == self.__gateways[request_id]['__handled_items']: | 52 if self.__gateways[request_id]['__total_items'] == self.__gateways[request_id]['__handled_items']: |
95 error(_("Error when discovering [%(target)s]: %(condition)s") % {'target':target.full(), 'condition':unicode(failure.value)}) | 95 error(_("Error when discovering [%(target)s]: %(condition)s") % {'target':target.full(), 'condition':unicode(failure.value)}) |
96 message_data={"reason": "connection error", "message":_(u"Error while trying to discover %(target)s gateways: %(error_mess)s") % {'target':target.full(), 'error_mess':unicode(failure.value)}} | 96 message_data={"reason": "connection error", "message":_(u"Error while trying to discover %(target)s gateways: %(error_mess)s") % {'target':target.full(), 'error_mess':unicode(failure.value)}} |
97 self.host.bridge.actionResult("ERROR", request_id, message_data) | 97 self.host.bridge.actionResult("ERROR", request_id, message_data) |
98 | 98 |
99 | 99 |
100 def registrationSuccessful(self, target): | 100 def registrationSuccessful(self, target, profile): |
101 """Called when in_band registration is ok, we must now follow the rest of procedure""" | 101 """Called when in_band registration is ok, we must now follow the rest of procedure""" |
102 debug (_("Registration successful, doing the rest")) | 102 debug (_("Registration successful, doing the rest")) |
103 self.host.addContact(target) | 103 self.host.addContact(target, profile) |
104 self.host.setPresence(target) | 104 self.host.setPresence(target, profile) |
105 | 105 |
106 def gatewayRegister(self, action, target, fields): | 106 def gatewayRegister(self, action, target, fields, profile_key='@DEFAULT@'): |
107 """Register gateway using in-band registration, then log-in to gateway""" | 107 """Register gateway using in-band registration, then log-in to gateway""" |
108 profile = self.host.memory.getProfileName(profile_key) | |
109 assert(profile) #FIXME: return an error here | |
108 if action == 'SUBMIT': | 110 if action == 'SUBMIT': |
109 self.host.plugins["XEP_0077"].addTrigger(target, self.registrationSuccessful) | 111 self.host.plugins["XEP_0077"].addTrigger(target, self.registrationSuccessful, profile) |
110 return self.host.plugins["XEP_0077"].in_band_submit(action, target, fields) | 112 return self.host.plugins["XEP_0077"].in_band_submit(action, target, fields, profile) |
111 | 113 |
112 def findGateways(self, target, profile_key='@DEFAULT@'): | 114 def findGateways(self, target, profile_key='@DEFAULT@'): |
113 """Find gateways in the target JID, using discovery protocol | 115 """Find gateways in the target JID, using discovery protocol |
114 Return an id used for retrieving the list of gateways | 116 Return an id used for retrieving the list of gateways |
115 """ | 117 """ |