comparison src/plugins/plugin_xep_0077.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 65bf1bc70f6b
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 _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C
21 from sat.core import exceptions 22 from sat.core import exceptions
22 from logging import debug, info, warning, error 23 from logging import debug, info, warning, error
23 from twisted.words.protocols.jabber import jid 24 from twisted.words.protocols.jabber import jid
24 from twisted.words.protocols.jabber.xmlstream import IQ 25 from twisted.words.protocols.jabber.xmlstream import IQ
25 from sat.tools import xml_tools 26 from sat.tools import xml_tools
96 info(_("Registration failure: %s") % str(failure.value)) 97 info(_("Registration failure: %s") % str(failure.value))
97 if failure.value.condition == 'conflict': 98 if failure.value.condition == 'conflict':
98 raise exceptions.ConflictError( _("Username already exists, please choose an other one")) 99 raise exceptions.ConflictError( _("Username already exists, please choose an other one"))
99 raise failure 100 raise failure
100 101
101 def _inBandRegister(self, to_jid_s, profile_key='@NONE@'): 102 def _inBandRegister(self, to_jid_s, profile_key=C.PROF_KEY_NONE):
102 return self.inBandRegister, jid.JID(to_jid_s, profile_key) 103 return self.inBandRegister, jid.JID(to_jid_s, profile_key)
103 104
104 def inBandRegister(self, to_jid, post_treat_cb=None, profile_key='@NONE@'): 105 def inBandRegister(self, to_jid, post_treat_cb=None, profile_key=C.PROF_KEY_NONE):
105 """register to a target JID""" 106 """register to a target JID"""
106 client = self.host.getClient(profile_key) 107 client = self.host.getClient(profile_key)
107 if not client: 108 if not client:
108 raise exceptions.ProfileUnknownError 109 raise exceptions.ProfileUnknownError
109 debug(_("Asking registration for [%s]") % to_jid.full()) 110 debug(_("Asking registration for [%s]") % to_jid.full())