Remove discovery of generic pubsub support

We use PubSub only on our account jid, this use case is what PEP
was made for. If PEP is discovered we know that certain PubSub
features are supported, see: https://xmpp.org/extensions/xep-0163.html#defaults

The current check for <feature var='http://jabber.org/protocol/pubsub'/>
is pretty useless, as it just tells us that there is a PubSub implementation
but not much about the features. Only `publish` and `subscribe` are MUST
in XEP-0060 which is not enough for our needs.

If there is ever need to discover a generic PubSub implementation
that is not PEP we should check for all the PubSub features we need
instead of only for <feature var='http://jabber.org/protocol/pubsub'/>
This commit is contained in:
Philipp Hörist 2017-10-15 01:56:52 +02:00
parent 64d3bf63cf
commit 2e9de7702f
3 changed files with 5 additions and 11 deletions

View File

@ -670,7 +670,6 @@ class Connection(CommonConnection, ConnectionHandlers):
self.music_track_info = 0 self.music_track_info = 0
self.location_info = {} self.location_info = {}
self.pubsub_supported = False
self.register_supported = False self.register_supported = False
self.pubsub_publish_options_supported = False self.pubsub_publish_options_supported = False
# Do we auto accept insecure connection # Do we auto accept insecure connection
@ -1933,8 +1932,6 @@ class Connection(CommonConnection, ConnectionHandlers):
get_action(self.name + '-profile').set_enabled(True) get_action(self.name + '-profile').set_enabled(True)
if nbxmpp.NS_REGISTER in obj.features: if nbxmpp.NS_REGISTER in obj.features:
self.register_supported = True self.register_supported = True
if nbxmpp.NS_PUBSUB in obj.features:
self.pubsub_supported = True
if nbxmpp.NS_BLOCKING in obj.features: if nbxmpp.NS_BLOCKING in obj.features:
self.blocking_supported = True self.blocking_supported = True
if nbxmpp.NS_ADDRESS in obj.features: if nbxmpp.NS_ADDRESS in obj.features:
@ -2363,8 +2360,7 @@ class Connection(CommonConnection, ConnectionHandlers):
return return
if storage_type != 'xml': if storage_type != 'xml':
pubsub = self.pubsub_supported or self.pep_supported if self.pep_supported and self.pubsub_publish_options_supported:
if pubsub and self.pubsub_publish_options_supported:
self.send_pb_retrieve('', 'storage:bookmarks') self.send_pb_retrieve('', 'storage:bookmarks')
app.log('bookmarks').info('Request Bookmarks (PubSub)') app.log('bookmarks').info('Request Bookmarks (PubSub)')
# some server (ejabberd) are so slow to answer that we # some server (ejabberd) are so slow to answer that we
@ -2422,8 +2418,7 @@ class Connection(CommonConnection, ConnectionHandlers):
storage_node = self.get_bookmarks_storage_node() storage_node = self.get_bookmarks_storage_node()
if storage_type != 'xml': if storage_type != 'xml':
pubsub = self.pubsub_supported or self.pep_supported if self.pep_supported and self.pubsub_publish_options_supported:
if pubsub and self.pubsub_publish_options_supported:
self.send_pb_publish( self.send_pb_publish(
'', 'storage:bookmarks', storage_node, 'current', '', 'storage:bookmarks', storage_node, 'current',
options=self.get_bookmark_publish_options()) options=self.get_bookmark_publish_options())

View File

@ -354,7 +354,7 @@ class GroupchatControl(ChatControlBase):
img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU) img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU)
widget.set_sensitive( widget.set_sensitive(
app.connections[self.account].private_storage_supported or \ app.connections[self.account].private_storage_supported or \
(app.connections[self.account].pubsub_supported and \ (app.connections[self.account].pep_supported and \
app.connections[self.account].pubsub_publish_options_supported)) app.connections[self.account].pubsub_publish_options_supported))
widget.show() widget.show()
@ -971,7 +971,7 @@ class GroupchatControl(ChatControlBase):
notify_menuitem.set_active(app.config.get_per('rooms', self.contact.jid, notify_menuitem.set_active(app.config.get_per('rooms', self.contact.jid,
'notify_on_all_messages')) 'notify_on_all_messages'))
conn = app.connections[self.account] conn = app.connections[self.account]
if not conn.private_storage_supported and (not conn.pubsub_supported or \ if not conn.private_storage_supported and (not conn.pep_supported or \
not conn.pubsub_publish_options_supported): not conn.pubsub_publish_options_supported):
bookmark_room_menuitem.set_sensitive(False) bookmark_room_menuitem.set_sensitive(False)
if app.gc_connected[self.account][self.room_jid]: if app.gc_connected[self.account][self.room_jid]:

View File

@ -118,9 +118,8 @@ class ServerInfoDialog(Gtk.Dialog):
Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, None), Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, None),
Feature('XEP-0045: Multi-User Chat', con.muc_jid, None), Feature('XEP-0045: Multi-User Chat', con.muc_jid, None),
Feature('XEP-0054: vcard-temp', con.vcard_supported, None), Feature('XEP-0054: vcard-temp', con.vcard_supported, None),
Feature('XEP-0060: PubSub', con.pubsub_supported, None),
Feature('XEP-0060: Publish Options', con.pubsub_publish_options_supported, None),
Feature('XEP-0163: Personal Eventing Protocol', con.pep_supported, None), Feature('XEP-0163: Personal Eventing Protocol', con.pep_supported, None),
Feature('XEP-0163: #publish-options', con.pubsub_publish_options_supported, None),
Feature('XEP-0191: Blocking Command', con.blocking_supported, nbxmpp.NS_BLOCKING), Feature('XEP-0191: Blocking Command', con.blocking_supported, nbxmpp.NS_BLOCKING),
Feature('XEP-0198: Stream Management', con.sm.enabled, nbxmpp.NS_STREAM_MGMT), Feature('XEP-0198: Stream Management', con.sm.enabled, nbxmpp.NS_STREAM_MGMT),
Feature('XEP-0280: Message Carbons', con.carbons_enabled, nbxmpp.NS_CARBONS), Feature('XEP-0280: Message Carbons', con.carbons_enabled, nbxmpp.NS_CARBONS),