comparison src/plugins/plugin_xep_0060.py @ 1829:6079752ffeae

plugin XEP-0060, XEP-0277: added getNodeURI method
author Goffi <goffi@goffi.org>
date Sat, 23 Jan 2016 19:53:16 +0100
parents 442303b62a16
children 3c0bb714a80b
comparison
equal deleted inserted replaced
1828:cb4be663a4a7 1829:6079752ffeae
29 from twisted.internet import defer 29 from twisted.internet import defer
30 from wokkel import disco 30 from wokkel import disco
31 from wokkel import data_form 31 from wokkel import data_form
32 from zope.interface import implements 32 from zope.interface import implements
33 from collections import namedtuple 33 from collections import namedtuple
34 import urllib
34 import datetime 35 import datetime
35 from dateutil import tz 36 from dateutil import tz
36 # XXX: tmp.wokkel.pubsub is actually use instead of wokkel version 37 # XXX: tmp.wokkel.pubsub is actually use instead of wokkel version
37 # mam and rsm come from tmp.wokkel too 38 # mam and rsm come from tmp.wokkel too
38 from wokkel import pubsub 39 from wokkel import pubsub
398 399
399 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE): 400 def subscriptions(self, service, nodeIdentifier='', profile_key=C.PROF_KEY_NONE):
400 client = self.host.getClient(profile_key) 401 client = self.host.getClient(profile_key)
401 return client.pubsub_client.subscriptions(service, nodeIdentifier) 402 return client.pubsub_client.subscriptions(service, nodeIdentifier)
402 403
404 ## misc tools ##
405
406 def getNodeURI(self, service, node, item=None):
407 """Return XMPP URI of a PubSub node
408
409 @param service(jid.JID, None): PubSub service,
410 @param node(unicode): node
411 @return (unicode): URI of the node
412 """
413 query_data = [('node', node.encode('utf-8'))]
414 if item is not None:
415 query_data.append(('item', item.encode('utf-8')))
416 return "xmpp:{service}?{query}".format(
417 service=service.userhost(),
418 query=urllib.urlencode(query_data)
419 ).decode('utf-8')
420
403 ## methods to manage several stanzas/jids at once ## 421 ## methods to manage several stanzas/jids at once ##
404 422
405 # generic # 423 # generic #
406 424
407 def getRTResults(self, session_id, on_success=None, on_error=None, profile=C.PROF_KEY_NONE): 425 def getRTResults(self, session_id, on_success=None, on_error=None, profile=C.PROF_KEY_NONE):