changeset 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 fcfec24c87f3
children bad2e0e3fe70
files frontends/src/quick_frontend/quick_app.py frontends/src/quick_frontend/quick_blog.py src/plugins/plugin_xep_0277.py
diffstat 3 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Thu Sep 10 07:37:14 2015 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Thu Sep 10 07:39:09 2015 +0200
@@ -638,7 +638,7 @@
                 except KeyError:
                     pass
                 else:
-                    self.bridge.mbGetLast(comments_service, comments_node, C.NO_LIMIT, {"subscribe":C.BOOL_TRUE}, profile=profile)
+                    self.bridge.mbGet(comments_service, comments_node, C.NO_LIMIT, [], {"subscribe":C.BOOL_TRUE}, profile=profile)
             elif event_type == C.PS_RETRACT:
                 for wid in self.widgets.getWidgets(quick_blog.QuickBlog):
                     wid.deleteEntryIfPresent(service_s, node, data['id'], profile)
--- a/frontends/src/quick_frontend/quick_blog.py	Thu Sep 10 07:37:14 2015 +0200
+++ b/frontends/src/quick_frontend/quick_blog.py	Thu Sep 10 07:39:09 2015 +0200
@@ -122,7 +122,7 @@
         """Add Microblog items to this panel
         update is NOT called after addition
 
-        @param items_tuple(tuple): (items_data,items_metadata) tuple as returned by mbGetLast
+        @param items_tuple(tuple): (items_data,items_metadata) tuple as returned by mbGet
         """
         items, metadata = items_tuple
         for item in items:
@@ -132,7 +132,7 @@
         """Add Microblog items to this panel
         update is NOT called after addition
 
-        @param items_tuple(tuple): (items_data,items_metadata) tuple as returned by mbGetLast
+        @param items_tuple(tuple): (items_data,items_metadata) tuple as returned by mbGet
         """
         items, metadata = items_tuple
         for item, comments in items:
--- a/src/plugins/plugin_xep_0277.py	Thu Sep 10 07:37:14 2015 +0200
+++ b/src/plugins/plugin_xep_0277.py	Thu Sep 10 07:39:09 2015 +0200
@@ -78,9 +78,9 @@
                               in_sign='ssss', out_sign='',
                               method=self._mbRetract,
                               async=True)
-        host.bridge.addMethod("mbGetLast", ".plugin",
-                              in_sign='ssia{ss}s', out_sign='(aa{ss}a{ss})',
-                              method=self._mbGetLast,
+        host.bridge.addMethod("mbGet", ".plugin",
+                              in_sign='ssiasa{ss}s', out_sign='(aa{ss}a{ss})',
+                              method=self._mbGet,
                               async=True)
         host.bridge.addMethod("mbSetAccess", ".plugin", in_sign='ss', out_sign='',
                               method=self.mbSetAccess,
@@ -487,21 +487,23 @@
 
     ## get ##
 
-    def _mbGetLast(self, service_jid_s, node="", max_items=10, extra_dict=None, profile_key=C.PROF_KEY_NONE):
+    def _mbGet(self, service_jid_s, node="", max_items=10, item_ids=None, extra_dict=None, profile_key=C.PROF_KEY_NONE):
         """
         @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
+        @param item_ids (list[unicode]): list of item IDs
         """
         max_items = None if max_items == C.NO_LIMIT else max_items
         extra = self._p.parseExtra(extra_dict)
-        return self.mbGetLast(jid.JID(service_jid_s), node or None, max_items, extra.rsm_request, extra.extra, profile_key)
+        return self.mbGet(jid.JID(service_jid_s), node or None, max_items, item_ids, extra.rsm_request, extra.extra, profile_key)
 
     @defer.inlineCallbacks
-    def mbGetLast(self, service_jid, node=None, max_items=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
+    def mbGet(self, service_jid, node=None, max_items=None, item_ids=None, rsm_request=None, extra=None, profile_key=C.PROF_KEY_NONE):
         """Get the last published microblogs
 
         @param service_jid(jid.JID): jid of the publisher
         @param node(unicode, None): node to get (or microblog node if None)
         @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
+        @param item_ids (list[unicode]): list of item IDs
         @param rsm_request (rsm.RSMRequest): RSM request data
         @param profile_key: profile key
 
@@ -509,7 +511,7 @@
         """
         if node is None:
             node = NS_MICROBLOG
-        items_data = yield self._p.getItems(service_jid, node, max_items=max_items, rsm_request=rsm_request, extra=extra, profile_key=profile_key)
+        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)
         serialised = yield self._p.serItemsDataD(items_data, self.item2mbdata)
         defer.returnValue(serialised)
 
@@ -656,8 +658,8 @@
                 - service (unicode): pubsub service
                 - node (unicode): pubsub node
                 - failure (unicode): empty string in case of success, error message else
-                - items_data(list): data as returned by [mbGetLast]
-                - items_metadata(dict): metadata as returned by [mbGetLast]
+                - items_data(list): data as returned by [mbGet]
+                - items_metadata(dict): metadata as returned by [mbGet]
         @param profile_key: %(doc_profile_key)s
         """
         def onSuccess(items_data):