comparison frontends/src/jp/cmd_pubsub.py @ 2195:d65275ac39b3

plugin XEP-0060: renamed psGet bridge method to psItemGet
author Goffi <goffi@goffi.org>
date Mon, 13 Mar 2017 23:17:13 +0100
parents a1a8233f89e8
children e0e06391ce91
comparison
equal deleted inserted replaced
2194:322948499db0 2195:d65275ac39b3
26 26
27 27
28 class Get(base.CommandBase): 28 class Get(base.CommandBase):
29 29
30 def __init__(self, host): 30 def __init__(self, host):
31 base.CommandBase.__init__(self, host, 'get', use_verbose=True, use_output=C.OUTPUT_LIST_XML, help=_(u'get pubsub item(s)')) 31 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_LIST_XML, help=_(u'get pubsub item(s)'))
32 self.need_loop=True 32 self.need_loop=True
33 33
34 def add_parser_options(self): 34 def add_parser_options(self):
35 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, action='append', default=[], dest='items', 35 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, action='append', default=[], dest='items',
36 help=_(u"item(s) id(s) to get (default: request all items)")) 36 help=_(u"item(s) id(s) to get (default: request all items)"))
42 self.parser.add_argument("service", type=base.unicode_decoder, nargs='?', default=u'', 42 self.parser.add_argument("service", type=base.unicode_decoder, nargs='?', default=u'',
43 help=_(u"JID of the PubSub service (default: request profile own pubsub)")) 43 help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
44 # TODO: add MAM filters 44 # TODO: add MAM filters
45 45
46 46
47 def psGetCb(self, ps_result): 47 def psItemGetCb(self, ps_result):
48 self.output(ps_result[0]) 48 self.output(ps_result[0])
49 self.host.quit(C.EXIT_OK) 49 self.host.quit(C.EXIT_OK)
50 50
51 def psGetEb(self, failure_): 51 def psItemGetEb(self, failure_):
52 self.disp(u"can't get pubsub items: {reason}".format( 52 self.disp(u"can't get pubsub items: {reason}".format(
53 reason=failure_), error=True) 53 reason=failure_), error=True)
54 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 54 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
55 55
56 def start(self): 56 def start(self):
57 self.host.bridge.psGet( 57 self.host.bridge.psItemGet(
58 self.args.service, 58 self.args.service,
59 self.args.node, 59 self.args.node,
60 self.args.max, 60 self.args.max,
61 self.args.items, 61 self.args.items,
62 self.args.sub_id, 62 self.args.sub_id,
63 {}, 63 {},
64 self.profile, 64 self.profile,
65 callback=self.psGetCb, 65 callback=self.psItemGetCb,
66 errback=self.psGetEb) 66 errback=self.psItemGetEb)
67 67
68 68
69 class Pubsub(base.CommandBase): 69 class Pubsub(base.CommandBase):
70 subcommands = (Get,) 70 subcommands = (Get,)
71 71