Skip to content
Snippets Groups Projects
Commit 9dc44a6f authored by Philipp Hörist's avatar Philipp Hörist
Browse files

PubSub: Remove unused methods

parent f4e4596d
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,12 @@ ...@@ -30,6 +30,12 @@
class PubSub(BaseModule): class PubSub(BaseModule):
_nbxmpp_extends = 'PubSub'
_nbxmpp_methods = [
'publish',
]
def __init__(self, con): def __init__(self, con):
BaseModule.__init__(self, con) BaseModule.__init__(self, con)
...@@ -71,86 +77,6 @@ def send_pb_unsubscribe(self, jid, node, cb, **kwargs): ...@@ -71,86 +77,6 @@ def send_pb_unsubscribe(self, jid, node, cb, **kwargs):
self._con.connection.SendAndCallForResponse(query, 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): def send_pb_delete(self, jid, node, on_ok=None, on_fail=None):
""" """
Delete node Delete node
...@@ -171,23 +97,6 @@ def response(_nbxmpp_client, resp, jid, node): ...@@ -171,23 +97,6 @@ def response(_nbxmpp_client, resp, jid, node):
self._con.connection.SendAndCallForResponse( self._con.connection.SendAndCallForResponse(
query, response, {'jid': jid, 'node': node}) 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): def send_pb_configure(self, jid, node, form, cb=None, **kwargs):
if not app.account_is_available(self._account): if not app.account_is_available(self._account):
return return
......
...@@ -2190,8 +2190,9 @@ def _on_send_button_clicked(self, w): ...@@ -2190,8 +2190,9 @@ def _on_send_button_clicked(self, w):
# Publish it to node # Publish it to node
con = app.connections[self.account] con = app.connections[self.account]
con.get_module('PubSub').send_pb_publish( con.get_module('PubSub').publish(self.groupid,
self.servicejid, self.groupid, item, str(uuid.uuid4())) item,
jid=self.servicejid)
# Close the window # Close the window
self.window.destroy() self.window.destroy()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment