comparison sat/plugins/plugin_comp_file_sharing_management.py @ 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 d0e8b0a3ef9c
children 15612c0fb421
comparison
equal deleted inserted replaced
3304:9a174abafdee 3305:04a7d77ed86f
71 log.info(_("File Sharing Management plugin initialization")) 71 log.info(_("File Sharing Management plugin initialization"))
72 self.host = host 72 self.host = host
73 self._c = host.plugins["XEP-0050"] 73 self._c = host.plugins["XEP-0050"]
74 self._t = host.plugins["XEP-0264"] 74 self._t = host.plugins["XEP-0264"]
75 self.files_path = host.getLocalPath(None, C.FILES_DIR, profile=False) 75 self.files_path = host.getLocalPath(None, C.FILES_DIR, profile=False)
76 host.bridge.addMethod(
77 "fileSharingDelete",
78 ".plugin",
79 in_sign="ssss",
80 out_sign="",
81 method=self._delete,
82 async_=True,
83 )
76 84
77 def profileConnected(self, client): 85 def profileConnected(self, client):
78 self._c.addAdHocCommand( 86 self._c.addAdHocCommand(
79 client, self._onChangeFile, "Change Permissions of File(s)", 87 client, self._onChangeFile, "Change Permissions of File(s)",
80 node=NS_FILE_MANAGEMENT_PERM, 88 node=NS_FILE_MANAGEMENT_PERM,
88 self._c.addAdHocCommand( 96 self._c.addAdHocCommand(
89 client, self._onGenThumbnails, "Generate Thumbnails", 97 client, self._onGenThumbnails, "Generate Thumbnails",
90 node=NS_FILE_MANAGEMENT_THUMB, 98 node=NS_FILE_MANAGEMENT_THUMB,
91 allowed_magics=C.ENTITY_ALL, 99 allowed_magics=C.ENTITY_ALL,
92 ) 100 )
101
102 def _delete(self, service_jid_s, path, namespace, profile):
103 client = self.host.getClient(profile)
104 service_jid = jid.JID(service_jid_s) if service_jid_s else None
105 return defer.ensureDeferred(self._c.sequence(
106 client,
107 [{"path": path, "namespace": namespace}, {"confirm": True}],
108 NS_FILE_MANAGEMENT_DELETE,
109 service_jid,
110 ))
93 111
94 def _err(self, reason): 112 def _err(self, reason):
95 """Helper method to get argument to return for error 113 """Helper method to get argument to return for error
96 114
97 workflow will be interrupted with an error note 115 workflow will be interrupted with an error note