comparison src/plugins/plugin_xep_0277.py @ 1513:955221487a3e

plugin XEP-0277, quick_frontend: rename mbGetLast to mbGet and add it the parameter "item_ids"
author souliane <souliane@mailoo.org>
date Thu, 10 Sep 2015 07:39:09 +0200
parents 83f71763e1a7
children afa0894dcc71
comparison
equal deleted inserted replaced
1512:fcfec24c87f3 1513:955221487a3e
76 async=True) 76 async=True)
77 host.bridge.addMethod("mbRetract", ".plugin", 77 host.bridge.addMethod("mbRetract", ".plugin",
78 in_sign='ssss', out_sign='', 78 in_sign='ssss', out_sign='',
79 method=self._mbRetract, 79 method=self._mbRetract,
80 async=True) 80 async=True)
81 host.bridge.addMethod("mbGetLast", ".plugin", 81 host.bridge.addMethod("mbGet", ".plugin",
82 in_sign='ssia{ss}s', out_sign='(aa{ss}a{ss})', 82 in_sign='ssiasa{ss}s', out_sign='(aa{ss}a{ss})',
83 method=self._mbGetLast, 83 method=self._mbGet,
84 async=True) 84 async=True)
85 host.bridge.addMethod("mbSetAccess", ".plugin", in_sign='ss', out_sign='', 85 host.bridge.addMethod("mbSetAccess", ".plugin", in_sign='ss', out_sign='',
86 method=self.mbSetAccess, 86 method=self.mbSetAccess,
87 async=True) 87 async=True)
88 host.bridge.addMethod("mbSetAccess", ".plugin", in_sign='ss', out_sign='', 88 host.bridge.addMethod("mbSetAccess", ".plugin", in_sign='ss', out_sign='',
485 """Call self._p._retractItem, but use default node if node is empty""" 485 """Call self._p._retractItem, but use default node if node is empty"""
486 return self._p._retractItem(service_jid_s, nodeIdentifier or NS_MICROBLOG, itemIdentifier, True, profile_key) 486 return self._p._retractItem(service_jid_s, nodeIdentifier or NS_MICROBLOG, itemIdentifier, True, profile_key)
487 487
488 ## get ## 488 ## get ##
489 489
490 def _mbGetLast(self, service_jid_s, node="", max_items=10, extra_dict=None, profile_key=C.PROF_KEY_NONE): 490 def _mbGet(self, service_jid_s, node="", max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE):
491 """ 491 """
492 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 492 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
493 @param item_ids (list[unicode]): list of item IDs
493 """ 494 """
494 max_items = None if max_items == C.NO_LIMIT else max_items 495 max_items = None if max_items == C.NO_LIMIT else max_items
495 extra = self._p.parseExtra(extra_dict) 496 extra = self._p.parseExtra(extra_dict)
496 return self.mbGetLast(jid.JID(service_jid_s), node or None, max_items, extra.rsm_request, extra.extra, profile_key) 497 return self.mbGet(jid.JID(service_jid_s), node or None, max_items, item_ids, extra.rsm_request, extra.extra, profile_key)
497 498
498 @defer.inlineCallbacks 499 @defer.inlineCallbacks
499 def mbGetLast(self, service_jid, node=None, max_items=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE): 500 def mbGet(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
500 """Get the last published microblogs 501 """Get the last published microblogs
501 502
502 @param service_jid(jid.JID): jid of the publisher 503 @param service_jid(jid.JID): jid of the publisher
503 @param node(unicode, None): node to get (or microblog node if None) 504 @param node(unicode, None): node to get (or microblog node if None)
504 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit 505 @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
506 @param item_ids (list[unicode]): list of item IDs
505 @param rsm_request (rsm.RSMRequest): RSM request data 507 @param rsm_request (rsm.RSMRequest): RSM request data
506 @param profile_key: profile key 508 @param profile_key: profile key
507 509
508 @return: a deferred couple with the list of items and metadatas. 510 @return: a deferred couple with the list of items and metadatas.
509 """ 511 """
510 if node is None: 512 if node is None:
511 node = NS_MICROBLOG 513 node = NS_MICROBLOG
512 items_data = yield self._p.getItems(service_jid, node, max_items=max_items, rsm_request=rsm_request, extra=extra, profile_key=profile_key) 514 items_data = yield self._p.getItems(service_jid, node, max_items=max_items, item_ids=item_ids, rsm_request=rsm_request, extra=extra, profile_key=profile_key)
513 serialised = yield self._p.serItemsDataD(items_data, self.item2mbdata) 515 serialised = yield self._p.serItemsDataD(items_data, self.item2mbdata)
514 defer.returnValue(serialised) 516 defer.returnValue(serialised)
515 517
516 def parseCommentUrl(self, node_url): 518 def parseCommentUrl(self, node_url):
517 """Parse a XMPP URI 519 """Parse a XMPP URI
654 - remaining is the number of still expected results 656 - remaining is the number of still expected results
655 - results is a list of tuple with 657 - results is a list of tuple with
656 - service (unicode): pubsub service 658 - service (unicode): pubsub service
657 - node (unicode): pubsub node 659 - node (unicode): pubsub node
658 - failure (unicode): empty string in case of success, error message else 660 - failure (unicode): empty string in case of success, error message else
659 - items_data(list): data as returned by [mbGetLast] 661 - items_data(list): data as returned by [mbGet]
660 - items_metadata(dict): metadata as returned by [mbGetLast] 662 - items_metadata(dict): metadata as returned by [mbGet]
661 @param profile_key: %(doc_profile_key)s 663 @param profile_key: %(doc_profile_key)s
662 """ 664 """
663 def onSuccess(items_data): 665 def onSuccess(items_data):
664 """convert items elements to list of microblog data in items_data""" 666 """convert items elements to list of microblog data in items_data"""
665 d = self._p.serItemsDataD(items_data, self.item2mbdata) 667 d = self._p.serItemsDataD(items_data, self.item2mbdata)