Philipp Hörist pushed to branch master at gajim / gajim

Commits:
64d3bf63 by Philipp Hörist at 2017-10-15T00:52:34+02:00
Discover PEP on the account jid

see: https://xmpp.org/extensions/xep-0163.html#support

- - - - -
2e9de770 by Philipp Hörist at 2017-10-15T01:56:52+02:00
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'/>

- - - - -


3 changed files:

- gajim/common/connection.py
- gajim/groupchat_control.py
- gajim/server_info.py


Changes:

=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -670,7 +670,6 @@ class Connection(CommonConnection, ConnectionHandlers):
 
         self.music_track_info = 0
         self.location_info = {}
-        self.pubsub_supported = False
         self.register_supported = False
         self.pubsub_publish_options_supported = False
         # Do we auto accept insecure connection
@@ -1914,28 +1913,25 @@ class Connection(CommonConnection, ConnectionHandlers):
                     self.archiving_supported = True
                     self.archiving_313_supported = True
                     get_action(self.name + '-archive').set_enabled(True)
+                for identity in obj.identities:
+                    if identity['category'] == 'pubsub':
+                        self.pep_supported = identity.get('type') == 'pep'
+                        break
+                if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
+                    self.pubsub_publish_options_supported = True
+                else:
+                    # Remove stored bookmarks accessible to everyone.
+                    self.send_pb_purge(our_jid, 'storage:bookmarks')
+                    self.send_pb_delete(our_jid, 'storage:bookmarks')
 
             if obj.fjid == hostname:
                 if nbxmpp.NS_SECLABEL in obj.features:
                     self.seclabel_supported = True
-                for identity in obj.identities:
-                    if identity['category'] == 'pubsub' and identity.get(
-                    'type') == 'pep':
-                        self.pep_supported = True
-                        break
                 if nbxmpp.NS_VCARD in obj.features:
                     self.vcard_supported = True
                     get_action(self.name + '-profile').set_enabled(True)
                 if nbxmpp.NS_REGISTER in obj.features:
                     self.register_supported = True
-                if nbxmpp.NS_PUBSUB in obj.features:
-                    self.pubsub_supported = True
-                if nbxmpp.NS_PUBSUB_PUBLISH_OPTIONS in obj.features:
-                    self.pubsub_publish_options_supported = True
-                else:
-                    # Remove stored bookmarks accessible to everyone.
-                    self.send_pb_purge(our_jid, 'storage:bookmarks')
-                    self.send_pb_delete(our_jid, 'storage:bookmarks')
                 if nbxmpp.NS_BLOCKING in obj.features:
                     self.blocking_supported = True
                 if nbxmpp.NS_ADDRESS in obj.features:
@@ -2364,8 +2360,7 @@ class Connection(CommonConnection, ConnectionHandlers):
             return
 
         if storage_type != 'xml':
-            pubsub = self.pubsub_supported or self.pep_supported
-            if pubsub and self.pubsub_publish_options_supported:
+            if self.pep_supported and self.pubsub_publish_options_supported:
                 self.send_pb_retrieve('', 'storage:bookmarks')
                 app.log('bookmarks').info('Request Bookmarks (PubSub)')
                 # some server (ejabberd) are so slow to answer that we
@@ -2423,8 +2418,7 @@ class Connection(CommonConnection, ConnectionHandlers):
         storage_node = self.get_bookmarks_storage_node()
 
         if storage_type != 'xml':
-            pubsub = self.pubsub_supported or self.pep_supported
-            if pubsub and self.pubsub_publish_options_supported:
+            if self.pep_supported and self.pubsub_publish_options_supported:
                 self.send_pb_publish(
                     '', 'storage:bookmarks', storage_node, 'current',
                     options=self.get_bookmark_publish_options())


=====================================
gajim/groupchat_control.py
=====================================
--- a/gajim/groupchat_control.py
+++ b/gajim/groupchat_control.py
@@ -354,7 +354,7 @@ class GroupchatControl(ChatControlBase):
                 img.set_from_icon_name('bookmark-new', Gtk.IconSize.MENU)
             widget.set_sensitive(
                 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))
             widget.show()
 
@@ -971,7 +971,7 @@ class GroupchatControl(ChatControlBase):
         notify_menuitem.set_active(app.config.get_per('rooms', 
self.contact.jid,
             'notify_on_all_messages'))
         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):
             bookmark_room_menuitem.set_sensitive(False)
         if app.gc_connected[self.account][self.room_jid]:


=====================================
gajim/server_info.py
=====================================
--- a/gajim/server_info.py
+++ b/gajim/server_info.py
@@ -118,9 +118,8 @@ class ServerInfoDialog(Gtk.Dialog):
             Feature('XEP-0016: Privacy Lists', con.privacy_rules_supported, 
None),
             Feature('XEP-0045: Multi-User Chat', con.muc_jid, 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: #publish-options', 
con.pubsub_publish_options_supported, None),
             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-0280: Message Carbons', con.carbons_enabled, 
nbxmpp.NS_CARBONS),



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/16ad6080663e575be1367bcc35d446d519bb9b5e...2e9de7702f913cddf0571e1a2ed0094b49ceb425

---
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/16ad6080663e575be1367bcc35d446d519bb9b5e...2e9de7702f913cddf0571e1a2ed0094b49ceb425
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to