From cb8dd04e0cea617f6283ec5febf1152dd576284a Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 26 May 2011 16:48:23 +0200 Subject: [PATCH] plugin XEP-00277: setMicroblogAccess is now asynchronous --- src/plugins/plugin_xep_0277.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py index 90b7725c..b2c075a4 100755 --- a/src/plugins/plugin_xep_0277.py +++ b/src/plugins/plugin_xep_0277.py @@ -48,6 +48,9 @@ PLUGIN_INFO = { "description": _("""Implementation of microblogging Protocol""") } +class NodeAccessChangeException(Exception): + pass + class XEP_0277(): def __init__(self, host): @@ -66,6 +69,7 @@ class XEP_0277(): }) host.bridge.addMethod("setMicroblogAccess", ".communication", in_sign='ss', out_sign='', method=self.setMicroblogAccess, + async = True, doc = { }) @@ -152,7 +156,7 @@ class XEP_0277(): 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 @@ class XEP_0277(): 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",