From 9dc44a6fefe803f9c1b35ce71366675a0e8fc490 Mon Sep 17 00:00:00 2001 From: lovetox <philipp@hoerist.com> Date: Thu, 26 Nov 2020 22:00:06 +0100 Subject: [PATCH] PubSub: Remove unused methods --- gajim/common/modules/pubsub.py | 103 ++------------------------------- gajim/gtk/discovery.py | 5 +- 2 files changed, 9 insertions(+), 99 deletions(-) diff --git a/gajim/common/modules/pubsub.py b/gajim/common/modules/pubsub.py index c8c60e7561..d9352832d2 100644 --- a/gajim/common/modules/pubsub.py +++ b/gajim/common/modules/pubsub.py @@ -30,6 +30,12 @@ class PubSub(BaseModule): + + _nbxmpp_extends = 'PubSub' + _nbxmpp_methods = [ + 'publish', + ] + def __init__(self, con): BaseModule.__init__(self, con) @@ -71,86 +77,6 @@ def send_pb_unsubscribe(self, jid, node, cb, **kwargs): self._con.connection.SendAndCallForResponse(query, cb, kwargs) - def send_pb_publish(self, jid, node, item, - id_=None, options=None, cb=None, **kwargs): - if not app.account_is_available(self._account): - return - - if cb is None: - cb = self._default_callback - - query = nbxmpp.Iq('set', to=jid) - pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) - publish = pubsub.addChild('publish', {'node': node}) - attrs = {} - if id_: - attrs = {'id': id_} - publish.addChild('item', attrs, [item]) - if options: - publish = pubsub.addChild('publish-options') - publish.addChild(node=options) - - self._con.connection.SendAndCallForResponse(query, cb, kwargs) - - @staticmethod - def get_pb_retrieve_iq(jid, node, item_id=None): - """ - Get IQ to query items from a node - """ - query = nbxmpp.Iq('get', to=jid) - pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) - items = pubsub.addChild('items', {'node': node}) - if item_id is not None: - items.addChild('item', {'id': item_id}) - return query - - def send_pb_retrieve(self, jid, node, item_id=None, cb=None, **kwargs): - """ - Get items from a node - """ - if not app.account_is_available(self._account): - return - - if cb is None: - cb = self._default_callback - - query = self.get_pb_retrieve_iq(jid, node, item_id) - - self._con.connection.SendAndCallForResponse(query, cb, kwargs) - - def send_pb_retract(self, jid, node, id_, cb=None, **kwargs): - """ - Delete item from a node - """ - if not app.account_is_available(self._account): - return - - if cb is None: - cb = self._default_callback - - query = nbxmpp.Iq('set', to=jid) - pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) - retract = pubsub.addChild('retract', {'node': node, 'notify': '1'}) - retract.addChild('item', {'id': id_}) - - self._con.connection.SendAndCallForResponse(query, cb, kwargs) - - def send_pb_purge(self, jid, node, cb=None, **kwargs): - """ - Purge node: Remove all items - """ - if not app.account_is_available(self._account): - return - - if cb is None: - cb = self._default_callback - - query = nbxmpp.Iq('set', to=jid) - pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB_OWNER) - pubsub.addChild('purge', {'node': node}) - - self._con.connection.SendAndCallForResponse(query, cb, kwargs) - def send_pb_delete(self, jid, node, on_ok=None, on_fail=None): """ Delete node @@ -171,23 +97,6 @@ def response(_nbxmpp_client, resp, jid, node): self._con.connection.SendAndCallForResponse( query, response, {'jid': jid, 'node': node}) - def send_pb_create(self, jid, node, cb, - configure=False, configure_form=None): - """ - Create a new node - """ - if not app.account_is_available(self._account): - return - query = nbxmpp.Iq('set', to=jid) - pubsub = query.addChild('pubsub', namespace=Namespace.PUBSUB) - create = pubsub.addChild('create', {'node': node}) - if configure: - conf = create.addChild('configure') - if configure_form is not None: - conf.addChild(node=configure_form) - - self._con.connection.SendAndCallForResponse(query, cb) - def send_pb_configure(self, jid, node, form, cb=None, **kwargs): if not app.account_is_available(self._account): return diff --git a/gajim/gtk/discovery.py b/gajim/gtk/discovery.py index c4c409ae4e..e348f35bc2 100644 --- a/gajim/gtk/discovery.py +++ b/gajim/gtk/discovery.py @@ -2190,8 +2190,9 @@ def _on_send_button_clicked(self, w): # Publish it to node con = app.connections[self.account] - con.get_module('PubSub').send_pb_publish( - self.servicejid, self.groupid, item, str(uuid.uuid4())) + con.get_module('PubSub').publish(self.groupid, + item, + jid=self.servicejid) # Close the window self.window.destroy() -- GitLab