plugin file sharing management: added a fileSharingDelete method

This commit is contained in:
Goffi 2020-06-19 15:39:32 +02:00
commit c68eb151ec

View file

@ -73,6 +73,14 @@ class FileSharingManagement(object):
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 @@ class FileSharingManagement(object):
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