From 68f167995e7ba71a6f2e556a7a0eab3d234e2d1a Mon Sep 17 00:00:00 2001 From: Jonah BrĂ¼chert Date: Fri, 9 Sep 2022 23:15:10 +0200 Subject: Implement XEP-0448: Stateless File Sharing This adds a file sharing manager that is capable of using multiple back ends. Currently implemented are a normal HTTP File Upload backend and an encrypted HTTP File Upload. Jingle File Transfer could be implemented later. Co-authored-by: Linus Jahn --- src/client/QXmppFileSharingProvider.h | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/client/QXmppFileSharingProvider.h (limited to 'src/client/QXmppFileSharingProvider.h') diff --git a/src/client/QXmppFileSharingProvider.h b/src/client/QXmppFileSharingProvider.h new file mode 100644 index 00000000..cde719db --- /dev/null +++ b/src/client/QXmppFileSharingProvider.h @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: 2022 Jonah BrĂ¼chert +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +#ifndef QXMPPFILESHARINGPROVIDER_H +#define QXMPPFILESHARINGPROVIDER_H + +#include "QXmppGlobal.h" + +#include +#include + +class QIODevice; +class QXmppFileMetadata; +class QXmppUpload; +class QXmppDownload; + +/// +/// \brief The interface of a provider for the FileSharingManager +/// +/// To use it, implement all the pure virtual functions, +/// and add a using declaration for the type of source you want to handle. +/// ``` +/// using SourceType = QXmppHttpFileSource; +/// ``` +/// +class QXMPP_EXPORT QXmppFileSharingProvider +{ +public: + /// \cond + virtual ~QXmppFileSharingProvider() = default; + /// \endcond + + /// + /// \brief Handles the download of files for this provider + /// \param source A type-erased source object. The provider will only ever have to handle its own sources, + /// so this can be safely casted to a concrete type. + /// \param target QIODevice into which the received data should be written + /// \return A subclass of QXmppDownload + /// + virtual auto downloadFile(const std::any &source, std::unique_ptr &&target) -> std::shared_ptr = 0; + + /// + /// \brief Handles the upload of a file for this provider + /// \param source A QIODevice from which data for uploading should be read. + /// \param info Metadata of the file + /// \return A subclass of QXmppUpload + /// + virtual auto uploadFile(std::unique_ptr source, const QXmppFileMetadata &info) -> std::shared_ptr = 0; +}; + +#endif // QXMPPFILESHARINGPROVIDER_H -- cgit v1.2.3