finish supporting jabber:iq:gateway. Fixes #6054
This commit is contained in:
parent
c3fdfc3a4b
commit
0c2d703f25
|
@ -1953,11 +1953,18 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.entity_time_ids.append(id_)
|
||||
self.connection.send(iq)
|
||||
|
||||
def request_gateway_prompt(self, jid):
|
||||
def request_gateway_prompt(self, jid, prompt=None):
|
||||
def _on_prompt_result(resp):
|
||||
gajim.nec.push_incoming_event(GatewayPromptReceivedEvent(None,
|
||||
conn=self, stanza=resp))
|
||||
iq = common.xmpp.Iq(typ='get', queryNS=common.xmpp.NS_GATEWAY, to=jid)
|
||||
if prompt:
|
||||
typ_ = 'set'
|
||||
else:
|
||||
typ_ = 'get'
|
||||
iq = common.xmpp.Iq(typ=typ_, to=jid)
|
||||
query = iq.addChild(name='query', namespace=common.xmpp.NS_GATEWAY)
|
||||
if prompt:
|
||||
query.setTagData('prompt', prompt)
|
||||
self.connection.SendAndCallForResponse(iq, _on_prompt_result)
|
||||
|
||||
def get_settings(self):
|
||||
|
|
|
@ -1820,6 +1820,12 @@ class GatewayPromptReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
def generate(self):
|
||||
self.get_jid_resource()
|
||||
query = self.stanza.getTag('query')
|
||||
if query:
|
||||
self.desc = query.getTagData('desc')
|
||||
self.prompt = query.getTagData('prompt')
|
||||
self.prompt_jid = query.getTagData('jid')
|
||||
else:
|
||||
self.desc = None
|
||||
self.prompt = None
|
||||
self.prompt_jid = None
|
||||
return True
|
||||
|
|
|
@ -844,6 +844,7 @@ class AddNewContactWindow:
|
|||
|
||||
def __init__(self, account=None, jid=None, user_nick=None, group=None):
|
||||
self.account = account
|
||||
self.adding_jid = False
|
||||
if account is None:
|
||||
# fill accounts with active accounts
|
||||
accounts = []
|
||||
|
@ -1054,8 +1055,17 @@ class AddNewContactWindow:
|
|||
if type_ != 'jabber':
|
||||
transport = self.protocol_jid_combobox.get_active_text().decode(
|
||||
'utf-8')
|
||||
if self.account:
|
||||
self.adding_jid = (jid, transport)
|
||||
gajim.connections[self.account].request_gateway_prompt(
|
||||
transport, jid)
|
||||
else:
|
||||
jid = jid.replace('@', '%') + '@' + transport
|
||||
self._add_jid(jid)
|
||||
else:
|
||||
self._add_jid(jid)
|
||||
|
||||
def _add_jid(self, jid):
|
||||
# check if jid is conform to RFC and stringprep it
|
||||
try:
|
||||
jid = helpers.parse_jid(jid)
|
||||
|
@ -1119,6 +1129,8 @@ class AddNewContactWindow:
|
|||
def on_protocol_jid_combobox_changed(self, widget):
|
||||
model = widget.get_model()
|
||||
iter_ = widget.get_active_iter()
|
||||
if not iter_:
|
||||
return
|
||||
jid_ = model[iter_][0]
|
||||
model = self.protocol_combobox.get_model()
|
||||
iter_ = self.protocol_combobox.get_active_iter()
|
||||
|
@ -1226,7 +1238,14 @@ class AddNewContactWindow:
|
|||
self.transport_signed_out(obj.jid)
|
||||
|
||||
def _nec_gateway_prompt_received(self, obj):
|
||||
if obj.jid in self.gateway_prompt:
|
||||
if self.adding_jid:
|
||||
if obj.prompt_jid:
|
||||
self._add_jid(obj.prompt_jid)
|
||||
else:
|
||||
jid, transport = self.adding_jid
|
||||
jid = jid.replace('@', '%') + '@' + transport
|
||||
self._add_jid(jid)
|
||||
elif obj.jid in self.gateway_prompt:
|
||||
if obj.desc:
|
||||
self.gateway_prompt[obj.jid]['desc'] = obj.desc
|
||||
if obj.prompt:
|
||||
|
|
Loading…
Reference in New Issue