comparison src/plugins/plugin_xep_0077.py @ 941:c6d8fc63b1db

core, plugins: host.getClient now raise an exception instead of returning None when no profile is found, plugins have been adapted consequently and a bit cleaned
author Goffi <goffi@goffi.org>
date Fri, 28 Mar 2014 18:07:02 +0100
parents 1a759096ccbd
children 301b342c697a
comparison
equal deleted inserted replaced
940:92e41e7c7e00 941:c6d8fc63b1db
22 from sat.core import exceptions 22 from sat.core import exceptions
23 from logging import debug, info, warning, error 23 from logging import debug, info, warning, error
24 from twisted.words.protocols.jabber import jid 24 from twisted.words.protocols.jabber import jid
25 from twisted.words.protocols.jabber.xmlstream import IQ 25 from twisted.words.protocols.jabber.xmlstream import IQ
26 from sat.tools import xml_tools 26 from sat.tools import xml_tools
27 from sat.memory import memory
28 27
29 from wokkel import data_form, compat 28 from wokkel import data_form, compat
30 29
31 NS_REG = 'jabber:iq:register' 30 NS_REG = 'jabber:iq:register'
32 31
103 return self.inBandRegister, jid.JID(to_jid_s, profile_key) 102 return self.inBandRegister, jid.JID(to_jid_s, profile_key)
104 103
105 def inBandRegister(self, to_jid, post_treat_cb=None, profile_key=C.PROF_KEY_NONE): 104 def inBandRegister(self, to_jid, post_treat_cb=None, profile_key=C.PROF_KEY_NONE):
106 """register to a target JID""" 105 """register to a target JID"""
107 client = self.host.getClient(profile_key) 106 client = self.host.getClient(profile_key)
108 if not client:
109 raise exceptions.ProfileUnknownError
110 debug(_("Asking registration for [%s]") % to_jid.full()) 107 debug(_("Asking registration for [%s]") % to_jid.full())
111 reg_request = IQ(client.xmlstream, 'get') 108 reg_request = IQ(client.xmlstream, 'get')
112 reg_request["from"] = client.jid.full() 109 reg_request["from"] = client.jid.full()
113 reg_request["to"] = to_jid.full() 110 reg_request["to"] = to_jid.full()
114 reg_request.addElement('query', NS_REG) 111 reg_request.addElement('query', NS_REG)