Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 2196:d3e48c9a255e
plugin XEP-0060: added getConfiguration ad psNodeConfigurationGet bridge method
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 13 Mar 2017 23:18:00 +0100 |
parents | d65275ac39b3 |
children | 44f12990e275 |
comparison
equal
deleted
inserted
replaced
2195:d65275ac39b3 | 2196:d3e48c9a255e |
---|---|
83 log.info(_(u"PubSub plugin initialization")) | 83 log.info(_(u"PubSub plugin initialization")) |
84 self.host = host | 84 self.host = host |
85 self._mam = host.plugins.get('XEP-0313') | 85 self._mam = host.plugins.get('XEP-0313') |
86 self._node_cb = {} # dictionnary of callbacks for node (key: node, value: list of callbacks) | 86 self._node_cb = {} # dictionnary of callbacks for node (key: node, value: list of callbacks) |
87 self.rt_sessions = sat_defer.RTDeferredSessions() | 87 self.rt_sessions = sat_defer.RTDeferredSessions() |
88 host.bridge.addMethod("psNodeConfigurationGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeConfiguration, async=True) | |
88 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) | 89 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) |
89 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) | 90 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) |
90 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) | 91 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) |
91 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) | 92 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) |
92 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany) | 93 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany) |
389 | 390 |
390 def createNode(self, service, nodeIdentifier, options, profile_key=C.PROF_KEY_NONE): | 391 def createNode(self, service, nodeIdentifier, options, profile_key=C.PROF_KEY_NONE): |
391 client = self.host.getClient(profile_key) | 392 client = self.host.getClient(profile_key) |
392 return client.pubsub_client.createNode(service, nodeIdentifier, options) | 393 return client.pubsub_client.createNode(service, nodeIdentifier, options) |
393 | 394 |
395 def _getNodeConfiguration(self, service_s, nodeIdentifier, profile_key): | |
396 client = self.host.getClient(profile_key) | |
397 d = self.getConfiguration(client, jid.JID(service_s) if service_s else None, nodeIdentifier) | |
398 def serialize(form): | |
399 # FIXME: better more generic dataform serialisation should be available in SàT | |
400 return {f.var: unicode(f.value) for f in form.fields.values()} | |
401 d.addCallback(serialize) | |
402 return d | |
403 | |
404 def getConfiguration(self, client, service, nodeIdentifier): | |
405 request = pubsub.PubSubRequest('configureGet') | |
406 request.recipient = service | |
407 request.nodeIdentifier = nodeIdentifier | |
408 | |
409 def cb(iq): | |
410 form = data_form.findForm(iq.pubsub.configure, | |
411 pubsub.NS_PUBSUB_NODE_CONFIG) | |
412 form.typeCheck() | |
413 return form | |
414 | |
415 d = request.send(client.xmlstream) | |
416 d.addCallback(cb) | |
417 return d | |
418 | |
394 def _deleteNode(self, service_s, nodeIdentifier, profile_key): | 419 def _deleteNode(self, service_s, nodeIdentifier, profile_key): |
395 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key) | 420 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key) |
396 | 421 |
397 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE): | 422 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE): |
398 client = self.host.getClient(profile_key) | 423 client = self.host.getClient(profile_key) |