plugin xep-0060: added getEntry method
This commit is contained in:
parent
3baae43808
commit
124b2d0f4f
1 changed files with 25 additions and 1 deletions
|
|
@ -47,6 +47,17 @@ class XEP_0060():
|
|||
self.host = host
|
||||
self.managedNodes=[]
|
||||
self.clients={}
|
||||
"""host.bridge.addMethod("getItems", ".communication", in_sign='ssa{ss}s', out_sign='as', method=self.getItems,
|
||||
async = True,
|
||||
doc = { 'summary':'retrieve items',
|
||||
'param_0':'service: pubsub service',
|
||||
'param_1':'node: node identifier',
|
||||
'param_2':'\n'.join(['options: can be:',
|
||||
'- max_items: see XEP-0060 #6.5.7',
|
||||
'- sub_id: subscription identifier, see XEP-0060 #7.2.2.2']),
|
||||
'param_3':'%(doc_profile)s',
|
||||
'return':'array of raw XML (content of the items)'
|
||||
})"""
|
||||
|
||||
def getHandler(self, profile):
|
||||
self.clients[profile] = SatPubSubClient(self.host, self)
|
||||
|
|
@ -73,7 +84,20 @@ class XEP_0060():
|
|||
raise Exception(err_mess)
|
||||
client.publish(service, nodeIdentifier, items, client.parent.jid)
|
||||
|
||||
|
||||
def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'):
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
if not profile:
|
||||
err_mess = _('Trying to get items with an unknown profile key [%s]') % profile_key
|
||||
error(err_mess)
|
||||
raise Exception(err_mess)
|
||||
try:
|
||||
client = self.clients[profile]
|
||||
except KeyError:
|
||||
err_mess = _('INTERNAL ERROR: no handler for required profile')
|
||||
error(err_mess)
|
||||
raise Exception(err_mess)
|
||||
return client.items(service, node, max_items, sub_id, client.parent.jid)
|
||||
|
||||
class SatPubSubClient(pubsub.PubSubClient):
|
||||
implements(disco.IDisco)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue