changeset 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 e0e06391ce91
children ea0d0a4e2ad8
files src/plugins/plugin_xep_0060.py src/tmp/wokkel/pubsub.py
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py	Mon Mar 13 23:18:57 2017 +0100
+++ b/src/plugins/plugin_xep_0060.py	Tue Mar 14 00:18:02 2017 +0100
@@ -86,6 +86,7 @@
         self._node_cb = {} # dictionnary of callbacks for node (key: node, value: list of callbacks)
         self.rt_sessions = sat_defer.RTDeferredSessions()
         host.bridge.addMethod("psNodeConfigurationGet", ".plugin", in_sign='sss', out_sign='a{ss}', method=self._getNodeConfiguration, async=True)
+        host.bridge.addMethod("psNodeConfigurationSet", ".plugin", in_sign='ssa{ss}s', out_sign='', method=self._setNodeConfiguration, async=True)
         host.bridge.addMethod("psDeleteNode", ".plugin", in_sign='sss', out_sign='', method=self._deleteNode, async=True)
         host.bridge.addMethod("psItemGet", ".plugin", in_sign='ssiassa{ss}s', out_sign='(asa{ss})', method=self._getItems, async=True)
         host.bridge.addMethod("psRetractItem", ".plugin", in_sign='sssbs', out_sign='', method=self._retractItem, async=True)
@@ -416,6 +417,24 @@
         d.addCallback(cb)
         return d
 
+    def _setNodeConfiguration(self, service_s, nodeIdentifier, options, profile_key):
+        client = self.host.getClient(profile_key)
+        d = self.setConfiguration(client, jid.JID(service_s) if service_s else None, nodeIdentifier, options)
+        return d
+
+    def setConfiguration(self, client, service, nodeIdentifier, options):
+        request = pubsub.PubSubRequest('configureSet')
+        request.recipient = service
+        request.nodeIdentifier = nodeIdentifier
+
+        form = data_form.Form(formType='submit',
+                              formNamespace=pubsub.NS_PUBSUB_NODE_CONFIG)
+        form.makeFields(options)
+        request.options = form
+
+        d = request.send(client.xmlstream)
+        return d
+
     def _deleteNode(self, service_s, nodeIdentifier, profile_key):
         return self.deleteNode(jid.JID(service_s) if service_s else None, nodeIdentifier, profile_key)
 
--- a/src/tmp/wokkel/pubsub.py	Mon Mar 13 23:18:57 2017 +0100
+++ b/src/tmp/wokkel/pubsub.py	Tue Mar 14 00:18:02 2017 +0100
@@ -338,7 +338,7 @@
         'create': ['nodeOrNone', 'configureOrNone'],
         'default': ['default'],
         'configureGet': ['nodeOrEmpty'],
-        'configureSet': ['nodeOrEmpty', 'configure'],
+        'configureSet': ['nodeOrEmpty', 'configureOrNone'],
         'items': ['node', 'maxItems', 'itemIdentifiers', 'subidOrNone'],
         'retract': ['node', 'notify', 'itemIdentifiers'],
         'purge': ['node'],