// SPDX-FileCopyrightText: 2022 Jonah BrĂ¼chert // // SPDX-License-Identifier: LGPL-2.1-or-later #ifndef QXMPPFILESHARINGMANAGER_H #define QXMPPFILESHARINGMANAGER_H #include "QXmppClientExtension.h" #include "QXmppFileShare.h" #include "QXmppFileSharingProvider.h" #include "QXmppGlobal.h" #include #include #include #include #include #include #include #include #include class QIODevice; class QXmppFileMetadata; class QXMPP_EXPORT QXmppFileSharingManager : public QXmppClientExtension { public: struct MetadataThumbnail { uint32_t width; uint32_t height; QByteArray data; QMimeType mimeType; }; struct MetadataGeneratorResult { std::optional dimensions; std::optional length; QVector thumbnails; std::unique_ptr dataDevice; }; using MetadataGenerator = std::function>(std::unique_ptr)>; QXmppFileSharingManager(); void setMetadataGenerator(MetadataGenerator &&generator); /// /// \brief Register a provider for automatic downloads /// \param manager A shared_ptr to a QXmppFileSharingProvider subclass /// template void registerProivder(std::shared_ptr manager) { std::type_index index(typeid(typename ProviderType::SourceType)); internalRegisterProvider(index, manager); } std::shared_ptr sendFile(std::shared_ptr provider, const QString &filePath, const std::optional &description = {}); std::shared_ptr downloadFile(const QXmppFileShare &fileShare, std::unique_ptr &&output); private: void internalRegisterProvider(std::type_index, std::shared_ptr provider); MetadataGenerator m_metadataGenerator; std::unordered_map> m_providers; }; #endif // QXMPPFILESHARINGMANAGER_H