changeset 3305:04a7d77ed86f

plugin file sharing management: added a fileSharingDelete method
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 15:39:32 +0200
parents 9a174abafdee
children 3af0909629a2
files sat/plugins/plugin_comp_file_sharing_management.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_file_sharing_management.py	Fri Jun 19 15:38:17 2020 +0200
+++ b/sat/plugins/plugin_comp_file_sharing_management.py	Fri Jun 19 15:39:32 2020 +0200
@@ -73,6 +73,14 @@
         self._c = host.plugins["XEP-0050"]
         self._t = host.plugins["XEP-0264"]
         self.files_path = host.getLocalPath(None, C.FILES_DIR, profile=False)
+        host.bridge.addMethod(
+            "fileSharingDelete",
+            ".plugin",
+            in_sign="ssss",
+            out_sign="",
+            method=self._delete,
+            async_=True,
+        )
 
     def profileConnected(self, client):
         self._c.addAdHocCommand(
@@ -91,6 +99,16 @@
             allowed_magics=C.ENTITY_ALL,
         )
 
+    def _delete(self, service_jid_s, path, namespace, profile):
+        client = self.host.getClient(profile)
+        service_jid = jid.JID(service_jid_s) if service_jid_s else None
+        return defer.ensureDeferred(self._c.sequence(
+            client,
+            [{"path": path, "namespace": namespace}, {"confirm": True}],
+            NS_FILE_MANAGEMENT_DELETE,
+            service_jid,
+        ))
+
     def _err(self, reason):
         """Helper method to get argument to return for error