diff src/plugins/plugin_xep_0277.py @ 468:c97640c90a94

D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
author Goffi <goffi@goffi.org>
date Fri, 30 Mar 2012 09:23:23 +0200
parents 78e67a59d51d
children 2a072735e459
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py	Thu Mar 29 00:04:31 2012 +0200
+++ b/src/plugins/plugin_xep_0277.py	Fri Mar 30 09:23:23 2012 +0200
@@ -146,7 +146,7 @@
         self.host.plugins["XEP-0060"].publish(None, NS_MICROBLOG, [item], profile_key = profile)
         return 0
 
-    def getLastMicroblogs(self, pub_jid, max_items=10, profile_key='@DEFAULT@', callback=None, errback=None):
+    def getLastMicroblogs(self, pub_jid, max_items=10, profile_key='@DEFAULT@'):
         """Get the last published microblogs
         @param pub_jid: jid of the publisher
         @param max_items: how many microblogs we want to get
@@ -156,9 +156,9 @@
         """
         assert(callback)
         d = self.host.plugins["XEP-0060"].getItems(jid.JID(pub_jid), NS_MICROBLOG, max_items=max_items, profile_key=profile_key)
-        d.addCallbacks(lambda items: callback(map(self.item2mbdata, items)), errback)
+        d.addCallback(lambda items: map(self.item2mbdata, items))
         
-    def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@', callback=None, errback=None):
+    def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@'):
         """Create a microblog node on PEP with given access
         If the node already exists, it change options
         @param access: Node access model, according to xep-0060 #4.5
@@ -173,12 +173,11 @@
         def cb(result):
             #Node is created with right permission
             debug(_("Microblog node has now access %s") % access)
-            callback()
 
         def fatal_err(s_error):
             #Something went wrong
             error(_("Can't set microblog access"))
-            errback(NodeAccessChangeException())
+            raise NodeAccessChangeException()
 
         def err_cb(s_error):
             #If the node already exists, the condition is "conflict",