add publish-options to bookmark storage if server supports it
This commit is contained in:
parent
4a0e5bc2b3
commit
5b62a6fbbd
|
@ -163,6 +163,7 @@ class Connection(ConnectionHandlers):
|
|||
self.blocked_all = False
|
||||
self.music_track_info = 0
|
||||
self.pubsub_supported = False
|
||||
self.pubsub_publish_options_supported = False
|
||||
self.pep_supported = False
|
||||
self.mood = {}
|
||||
self.tune = {}
|
||||
|
@ -1624,7 +1625,20 @@ class Connection(ConnectionHandlers):
|
|||
iq2.setTagData('print_status', bm['print_status'])
|
||||
|
||||
if self.pubsub_supported:
|
||||
self.send_pb_publish('', 'storage:bookmarks', iq, 'current')
|
||||
if self.pubsub_publish_options_supported:
|
||||
options = common.xmpp.Node(common.xmpp.NS_DATA + ' x',
|
||||
attrs={'type': 'submit'})
|
||||
f = options.addChild('field', attrs={'var': 'FORM_TYPE',
|
||||
'type': 'hidden'})
|
||||
f.setTagData('value', common.xmpp.NS_PUBSUB_PUBLISH_OPTIONS)
|
||||
f = options.addChild('field', attrs={'var': 'pubsub#persist_items'})
|
||||
f.setTagData('value', 'true')
|
||||
f = options.addChild('field', attrs={'var': 'pubsub#access_model'})
|
||||
f.setTagData('value', 'whitelist')
|
||||
else:
|
||||
options = None
|
||||
self.send_pb_publish('', 'storage:bookmarks', iq, 'current',
|
||||
options=options)
|
||||
else:
|
||||
iqA = common.xmpp.Iq(typ='set')
|
||||
iqB = iqA.addChild(name='query', namespace=common.xmpp.NS_PRIVATE)
|
||||
|
|
|
@ -899,6 +899,8 @@ class ConnectionDisco:
|
|||
break
|
||||
if features.__contains__(common.xmpp.NS_PUBSUB):
|
||||
self.pubsub_supported = True
|
||||
if features.__contains__(common.xmpp.NS_PUBSUB_PUBLISH_OPTIONS):
|
||||
self.pubsub_publish_options_supported = True
|
||||
if features.__contains__(common.xmpp.NS_BYTESTREAM):
|
||||
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) +\
|
||||
'/' + self.server_resource)
|
||||
|
|
|
@ -64,14 +64,17 @@ class ConnectionPubSub:
|
|||
|
||||
self.__callbacks[id_]=(cb, args, kwargs)
|
||||
|
||||
def send_pb_publish(self, jid, node, item, id_):
|
||||
def send_pb_publish(self, jid, node, item, id_, options=None):
|
||||
'''Publish item to a node.'''
|
||||
if not self.connection or self.connected < 2:
|
||||
return
|
||||
query = xmpp.Iq('set', to=jid)
|
||||
e = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB)
|
||||
e = e.addChild('publish', {'node': node})
|
||||
e = e.addChild('item', {'id': id_}, [item])
|
||||
p = e.addChild('publish', {'node': node})
|
||||
p.addChild('item', {'id': id_}, [item])
|
||||
if options:
|
||||
p = e.addChild('publish-options')
|
||||
p.addChild(node=options)
|
||||
|
||||
self.connection.send(query)
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ NS_PRIVACY ='jabber:iq:privacy'
|
|||
NS_PRIVATE ='jabber:iq:private'
|
||||
NS_PROFILE ='http://jabber.org/protocol/profile' # XEP-0154
|
||||
NS_PUBSUB ='http://jabber.org/protocol/pubsub' # XEP-0060
|
||||
NS_PUBSUB_PUBLISH_OPTIONS = NS_PUBSUB + '#publish-options' # XEP-0060
|
||||
NS_PUBSUB_OWNER ='http://jabber.org/protocol/pubsub#owner' # JEP-0060
|
||||
NS_REGISTER ='jabber:iq:register'
|
||||
NS_ROSTER ='jabber:iq:roster'
|
||||
|
|
Loading…
Reference in New Issue