Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0096.py @ 3449:893582c2d983
plugin XEP-0096: fix plugin following changes in `plugin_misc_file`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 Dec 2020 17:48:19 +0100 |
parents | 559a625a236b |
children | be6d91572633 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0096.py Thu Dec 10 14:11:45 2020 +0100 +++ b/sat/plugins/plugin_xep_0096.py Fri Dec 11 17:48:19 2020 +0100 @@ -50,6 +50,8 @@ class XEP_0096(object): # TODO: call self._f.unregister when unloading order will be managing (i.e. when depenencies will be unloaded at the end) + name = PLUGIN_INFO[C.PI_NAME] + human_name = D_("Stream Initiation") def __init__(self, host): log.info(_("Plugin XEP_0096 initialization")) @@ -59,15 +61,16 @@ self.host.plugins["XEP-0047"].NAMESPACE, ] # Stream methods managed self._f = self.host.plugins["FILE"] - self._f.register( - NS_SI_FT, self.sendFile, priority=0, method_name="Stream Initiation" - ) + self._f.register(self) self._si = self.host.plugins["XEP-0095"] self._si.registerSIProfile(SI_PROFILE_NAME, self._transferRequest) host.bridge.addMethod( - "siSendFile", ".plugin", in_sign="sssss", out_sign="s", method=self._sendFile + "siSendFile", ".plugin", in_sign="sssss", out_sign="s", method=self._fileSend ) + async def canHandleFileSend(self, client, peer_jid, filepath): + return await self.host.hasFeature(client, NS_SI_FT, peer_jid) + def unload(self): self._si.unregisterSIProfile(SI_PROFILE_NAME) @@ -279,13 +282,13 @@ ) data["stream_object"].close() - def _sendFile(self, peer_jid_s, filepath, name, desc, profile=C.PROF_KEY_NONE): + def _fileSend(self, peer_jid_s, filepath, name, desc, profile=C.PROF_KEY_NONE): client = self.host.getClient(profile) - return self.sendFile( + return self.fileSend( client, jid.JID(peer_jid_s), filepath, name or None, desc or None ) - def sendFile(self, client, peer_jid, filepath, name=None, desc=None, extra=None): + def fileSend(self, client, peer_jid, filepath, name=None, desc=None, extra=None): """Send a file using XEP-0096 @param peer_jid(jid.JID): recipient