plugin XEP-00277: setMicroblogAccess is now asynchronous

This commit is contained in:
Goffi 2011-05-26 16:48:23 +02:00
commit cb8dd04e0c

View file

@ -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",