# HG changeset patch # User Goffi # Date 1306421303 -7200 # Node ID b0b773f432e5a5385d0bcdfefa003b9f736b26c5 # Parent 6dcdc4cf862256b6351bed5491b4a27d6fbec192 plugin XEP-00277: setMicroblogAccess is now asynchronous diff -r 6dcdc4cf8622 -r b0b773f432e5 src/plugins/plugin_xep_0277.py --- a/src/plugins/plugin_xep_0277.py Thu May 26 16:47:39 2011 +0200 +++ b/src/plugins/plugin_xep_0277.py Thu May 26 16:48:23 2011 +0200 @@ -48,6 +48,9 @@ "description": _("""Implementation of microblogging Protocol""") } +class NodeAccessChangeException(Exception): + pass + class XEP_0277(): def __init__(self, host): @@ -66,6 +69,7 @@ }) host.bridge.addMethod("setMicroblogAccess", ".communication", in_sign='ss', out_sign='', method=self.setMicroblogAccess, + async = True, doc = { }) @@ -152,7 +156,7 @@ 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) - def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@'): + def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@', callback=None, errback=None): """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 @@ -166,10 +170,12 @@ 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()) def err_cb(s_error): #If the node already exists, the condition is "conflict",