Commit 3a3b3224 authored by Philipp Hörist's avatar Philipp Hörist

Fix requesting pubsub node config

Regression from refactoring
parent 09aead3e
......@@ -39,7 +39,6 @@ from gajim.common import caps_cache as capscache
from gajim.common import helpers
from gajim.common import app
from gajim.common import dataforms
from gajim.common import jingle_xtls
from gajim.common.caps_cache import muc_caps_cache
from gajim.common.commands import ConnectionCommands
......@@ -64,7 +63,6 @@ METACONTACTS_ARRIVED = 'metacontacts_arrived'
ROSTER_ARRIVED = 'roster_arrived'
DELIMITER_ARRIVED = 'delimiter_arrived'
PRIVACY_ARRIVED = 'privacy_arrived'
PEP_CONFIG = 'pep_config'
class ConnectionDisco:
......@@ -933,21 +931,6 @@ ConnectionHandlersBase, ConnectionJingle, ConnectionIBBytestream):
# connection process, we don't take the risk
self.privacy_rules_supported = False
self._continue_connection_request_privacy()
elif self.awaiting_answers[id_][0] == PEP_CONFIG:
del self.awaiting_answers[id_]
if iq_obj.getType() == 'error':
return
if not iq_obj.getTag('pubsub'):
return
conf = iq_obj.getTag('pubsub').getTag('configure')
if not conf:
return
node = conf.getAttr('node')
form_tag = conf.getTag('x', namespace=nbxmpp.NS_DATA)
if form_tag:
form = dataforms.ExtendForm(node=form_tag)
app.nec.push_incoming_event(PEPConfigReceivedEvent(None,
conn=self, node=node, form=form))
def _nec_iq_error_received(self, obj):
if obj.conn.name != self.name:
......
......@@ -1822,10 +1822,6 @@ class UpdateRoomAvatarEvent(nec.NetworkIncomingEvent):
def generate(self):
return True
class PEPConfigReceivedEvent(nec.NetworkIncomingEvent):
name = 'pep-config-received'
base_network_events = []
class MetacontactsReceivedEvent(nec.NetworkIncomingEvent):
name = 'metacontacts-received'
base_network_events = []
......
......@@ -25,6 +25,8 @@ import logging
import nbxmpp
from gajim.common import app
from gajim.common import dataforms
from gajim.common.nec import NetworkIncomingEvent
log = logging.getLogger('gajim.c.m.pubsub')
......@@ -185,7 +187,7 @@ class PubSub:
self._con.connection.SendAndCallForResponse(query, cb)
def send_pb_configure(self, jid, node, form, cb=None):
def send_pb_configure(self, jid, node, form, cb=None, **kwargs):
if not app.account_is_connected(self._account):
return
......@@ -197,21 +199,58 @@ class PubSub:
c = c.addChild('configure', {'node': node})
c.addChild(node=form)
self._con.connection.SendAndCallForResponse(query, cb)
log.info('Send node config for %s', node)
self._con.connection.SendAndCallForResponse(query, cb, kwargs)
def request_pb_configuration(self, jid, node, cb=None):
def request_pb_configuration(self, jid, node):
if not app.account_is_connected(self._account):
return
if cb is None:
cb = self._default_callback
query = nbxmpp.Iq('get', to=jid)
e = query.addChild('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
e = e.addChild('configure', {'node': node})
self._con.connection.SendAndCallForResponse(query, cb)
log.info('Request node config for %s', node)
self._con.connection.SendAndCallForResponse(
query, self._received_pb_configuration, {'node': node})
def _received_pb_configuration(self, conn, stanza, node):
if not nbxmpp.isResultNode(stanza):
log.warning('Error: %s', stanza.getError())
return
pubsub = stanza.getTag('pubsub', namespace=nbxmpp.NS_PUBSUB_OWNER)
if pubsub is None:
log.warning('Malformed PubSub configure '
'stanza (no pubsub node): %s', stanza)
return
configure = pubsub.getTag('configure')
if configure is None:
log.warning('Malformed PubSub configure '
'stanza (no configure node): %s', stanza)
return
if configure.getAttr('node') != node:
log.warning('Malformed PubSub configure '
'stanza (wrong node): %s', stanza)
return
form = configure.getTag('x', namespace=nbxmpp.NS_DATA)
if form is None:
log.warning('Malformed PubSub configure '
'stanza (no form): %s', stanza)
return
app.nec.push_incoming_event(PubSubConfigReceivedEvent(
None, conn=self._con, node=node,
form=dataforms.ExtendForm(node=form)))
def _default_callback(self, conn, stanza, *args, **kwargs):
if not nbxmpp.isResultNode(stanza):
log.warning('Error: %s', stanza.getError())
class PubSubConfigReceivedEvent(NetworkIncomingEvent):
name = 'pubsub-config-received'
base_network_events = []
......@@ -2839,7 +2839,7 @@ class ManagePEPServicesWindow:
self.xml.get_object('services_treeview').get_selection().connect(
'changed', self.on_services_selection_changed)
app.ged.register_event_handler('pep-config-received', ged.GUI1,
app.ged.register_event_handler('pubsub-config-received', ged.GUI1,
self._nec_pep_config_received)
app.ged.register_event_handler('agent-items-received', ged.GUI1,
self._nec_agent_items_received)
......@@ -2849,7 +2849,7 @@ class ManagePEPServicesWindow:
def on_manage_pep_services_window_destroy(self, widget):
'''close window'''
del app.interface.instances[self.account]['pep_services']
app.ged.remove_event_handler('pep-config-received', ged.GUI1,
app.ged.remove_event_handler('pubsub-config-received', ged.GUI1,
self._nec_pep_config_received)
app.ged.remove_event_handler('agent-items-received', ged.GUI1,
self._nec_agent_items_received)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment