delete bookmarks from pubsub if server doesn't support publish-options. Fixes #5787

This commit is contained in:
Yann Leboulanger 2010-06-21 19:15:46 +02:00
parent 4ab308d855
commit 77a6a02dc3
3 changed files with 24 additions and 23 deletions

View File

@ -354,6 +354,11 @@ class ConnectionDisco:
self.pubsub_supported = True
if features.__contains__(common.xmpp.NS_PUBSUB_PUBLISH_OPTIONS):
self.pubsub_publish_options_supported = True
else:
# Remove stored bookmarks accessible to everyone.
our_jid = gajim.get_jid_from_account(self.name)
self.send_pb_purge(our_jid, 'storage:bookmarks')
self.send_pb_delete(our_jid, 'storage:bookmarks')
if features.__contains__(common.xmpp.NS_BYTESTREAM):
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) +\
'/' + self.server_resource)

View File

@ -109,22 +109,34 @@ class ConnectionPubSub:
self.connection.send(query)
def send_pb_delete(self, jid, node):
def send_pb_purge(self, jid, node):
"""
Purge node: Remove all items
"""
if not self.connection or self.connected < 2:
return
query = xmpp.Iq('set', to=jid)
d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB_OWNER)
d = d.addChild('purge', {'node': node})
self.connection.send(query)
def send_pb_delete(self, jid, node, on_ok=None, on_fail=None):
"""
Delete node
"""
if not self.connection or self.connected < 2:
return
query = xmpp.Iq('set', to=jid)
d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB)
d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB_OWNER)
d = d.addChild('delete', {'node': node})
def response(con, resp, jid, node):
if resp.getType() == 'result':
self.dispatch('PUBSUB_NODE_REMOVED', (jid, node))
else:
if resp.getType() == 'result' and on_ok:
on_ok(jid, node)
elif on_fail:
msg = resp.getErrorMsg()
self.dispatch('PUBSUB_NODE_NOT_REMOVED', (jid, node, msg))
on_fail(jid, node, msg)
self.connection.SendAndCallForResponse(query, response, {'jid': jid,
'node': node})

View File

@ -2064,19 +2064,6 @@ class Interface:
checktext2, on_response_ok=on_ok, on_response_cancel=on_cancel,
is_modal=False)
def handle_event_pubsub_node_removed(self, account, data):
# ('PUBSUB_NODE_REMOVED', account, (jid, node))
if 'pep_services' in self.instances[account]:
if data[0] == gajim.get_jid_from_account(account):
self.instances[account]['pep_services'].node_removed(data[1])
def handle_event_pubsub_node_not_removed(self, account, data):
# ('PUBSUB_NODE_NOT_REMOVED', account, (jid, node, msg))
if data[0] == gajim.get_jid_from_account(account):
dialogs.WarningDialog(_('PEP node was not removed'),
_('PEP node %(node)s was not removed: %(message)s') % {
'node': data[1], 'message': data[2]})
def handle_event_pep_received(self, account, data):
# ('PEP_RECEIVED', account, (jid, pep_type))
jid = data[0]
@ -2188,9 +2175,6 @@ class Interface:
'INSECURE_SSL_CONNECTION': \
[self.handle_event_insecure_ssl_connection],
'INSECURE_PASSWORD': [self.handle_event_insecure_password],
'PUBSUB_NODE_REMOVED': [self.handle_event_pubsub_node_removed],
'PUBSUB_NODE_NOT_REMOVED': \
[self.handle_event_pubsub_node_not_removed],
'JINGLE_INCOMING': [self.handle_event_jingle_incoming],
'JINGLE_CONNECTED': [self.handle_event_jingle_connected],
'JINGLE_DISCONNECTED': [self.handle_event_jingle_disconnected],