comparison src/plugins/plugin_xep_0100.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents 1fe00f0c9a91
children c6d8fc63b1db
comparison
equal deleted inserted replaced
915:6f96ee4d8cc0 916:1a759096ccbd
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _, D_ 20 from sat.core.i18n import _, D_
21 from sat.core.constants import Const as C
21 from sat.core import exceptions 22 from sat.core import exceptions
22 from sat.tools import xml_tools 23 from sat.tools import xml_tools
23 from logging import debug, info, warning, error 24 from logging import debug, info, warning, error
24 from twisted.words.protocols.jabber import client as jabber_client, jid 25 from twisted.words.protocols.jabber import client as jabber_client, jid
25 from twisted.words.protocols.jabber import error as jab_error 26 from twisted.words.protocols.jabber import error as jab_error
135 """Called when in_band registration is ok, we must now follow the rest of procedure""" 136 """Called when in_band registration is ok, we must now follow the rest of procedure"""
136 debug(_("Registration successful, doing the rest")) 137 debug(_("Registration successful, doing the rest"))
137 self.host.addContact(jid_, profile_key=profile) 138 self.host.addContact(jid_, profile_key=profile)
138 self.host.setPresence(jid_, profile_key=profile) 139 self.host.setPresence(jid_, profile_key=profile)
139 140
140 def _gatewayRegister(self, target_jid_s, profile_key='@NONE@'): 141 def _gatewayRegister(self, target_jid_s, profile_key=C.PROF_KEY_NONE):
141 d = self.gatewayRegister(jid.JID(target_jid_s), profile_key) 142 d = self.gatewayRegister(jid.JID(target_jid_s), profile_key)
142 d.addCallback(lambda xmlui: xmlui.toXml()) 143 d.addCallback(lambda xmlui: xmlui.toXml())
143 return d 144 return d
144 145
145 def gatewayRegister(self, target_jid, profile_key='@NONE@'): 146 def gatewayRegister(self, target_jid, profile_key=C.PROF_KEY_NONE):
146 """Register gateway using in-band registration, then log-in to gateway""" 147 """Register gateway using in-band registration, then log-in to gateway"""
147 profile = self.host.memory.getProfileName(profile_key) 148 profile = self.host.memory.getProfileName(profile_key)
148 assert(profile) 149 assert(profile)
149 d = self.host.plugins["XEP-0077"].inBandRegister(target_jid, self._registrationSuccessful, profile) 150 d = self.host.plugins["XEP-0077"].inBandRegister(target_jid, self._registrationSuccessful, profile)
150 return d 151 return d