Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 2198:44f12990e275
plugin XEP-0060: added setConfiguration/psNodeConfigurationSet + fix in tmp.wokkel.pubsub
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 14 Mar 2017 00:18:02 +0100 |
parents | d3e48c9a255e |
children | 40dd9eb2692c |
comparison
equal
deleted
inserted
replaced
2197:e0e06391ce91 | 2198:44f12990e275 |
---|---|
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("psNodeConfigurationGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeConfiguration, async=True) |
89 host.bridge.addMethod("psNodeConfigurationSet", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._setNodeConfiguration, async=True) | |
89 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) | 90 host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True) |
90 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) | 91 host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True) |
91 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) | 92 host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True) |
92 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) | 93 host.bridge.addMethod("psRetractItems", ".plugin", in_sign='ssasbs', out_sign='', method=self._retractItems, async=True) |
93 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany) | 94 host.bridge.addMethod("psSubscribeToMany", ".plugin", in_sign='a(ss)sa{ss}s', out_sign='s', method=self._subscribeToMany) |
414 | 415 |
415 d = request.send(client.xmlstream) | 416 d = request.send(client.xmlstream) |
416 d.addCallback(cb) | 417 d.addCallback(cb) |
417 return d | 418 return d |
418 | 419 |
420 def _setNodeConfiguration(self, service_s, nodeIdentifier, options, profile_key): | |
421 client = self.host.getClient(profile_key) | |
422 d = self.setConfiguration(client, jid.JID(service_s) if service_s else None, nodeIdentifier, options) | |
423 return d | |
424 | |
425 def setConfiguration(self, client, service, nodeIdentifier, options): | |
426 request = pubsub.PubSubRequest('configureSet') | |
427 request.recipient = service | |
428 request.nodeIdentifier = nodeIdentifier | |
429 | |
430 form = data_form.Form(formType='submit', | |
431 formNamespace=pubsub.NS_PUBSUB_NODE_CONFIG) | |
432 form.makeFields(options) | |
433 request.options = form | |
434 | |
435 d = request.send(client.xmlstream) | |
436 return d | |
437 | |
419 def _deleteNode(self, service_s, nodeIdentifier, profile_key): | 438 def _deleteNode(self, service_s, nodeIdentifier, profile_key): |
420 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key) | 439 return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key) |
421 | 440 |
422 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE): | 441 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE): |
423 client = self.host.getClient(profile_key) | 442 client = self.host.getClient(profile_key) |