# HG changeset patch # User Goffi # Date 1298248612 -3600 # Node ID e33b3a777f10d8205fd236df970517ef6c033d75 # Parent 233e6fce0b4998627457373c0886d55f38081be0 plugin xep-0060: added getEntry method diff -r 233e6fce0b49 -r e33b3a777f10 src/plugins/plugin_xep_0060.py --- a/src/plugins/plugin_xep_0060.py Mon Feb 21 01:35:39 2011 +0100 +++ b/src/plugins/plugin_xep_0060.py Mon Feb 21 01:36:52 2011 +0100 @@ -47,6 +47,17 @@ 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 @@ 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)