Loading...
Searching...
No Matches
QXmppFileSharingProvider.h
// SPDX-FileCopyrightText: 2022 Jonah Brüchert <jbb@kaidan.im>
// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPFILESHARINGPROVIDER_H
#define QXMPPFILESHARINGPROVIDER_H
#include "QXmppError.h"
#include "QXmppGlobal.h"
#include <any>
#include <functional>
#include <memory>
#include <variant>
class QIODevice;
class QXmppFileMetadata;
class QXmppUpload;
class QXmppDownload;
class QXMPP_EXPORT QXmppFileSharingProvider
{
public:
using DownloadResult = std::variant<QXmpp::Success, QXmpp::Cancelled, QXmppError>;
using UploadResult = std::variant<std::any /* source */, QXmpp::Cancelled, QXmppError>;
class Download
{
public:
virtual ~Download() = default;
virtual void cancel() = 0;
};
class Upload
{
public:
virtual ~Upload() = default;
virtual void cancel() = 0;
};
virtual ~QXmppFileSharingProvider() = default;
virtual auto downloadFile(const std::any &source,
std::unique_ptr<QIODevice> target,
std::function<void(quint64, quint64)> reportProgress,
std::function<void(DownloadResult)> reportFinished) -> std::shared_ptr<Download> = 0;
virtual auto uploadFile(std::unique_ptr<QIODevice> source,
const QXmppFileMetadata &info,
std::function<void(quint64, quint64)> reportProgress,
std::function<void(UploadResult)> reportFinished) -> std::shared_ptr<Upload> = 0;
};
#endif // QXMPPFILESHARINGPROVIDER_H
QXmppFileMetadata
Definition QXmppFileMetadata.h:24
QXmppFileSharingProvider::Download
Used to control ongoing downloads.
Definition QXmppFileSharingProvider.h:44
QXmppFileSharingProvider::Download::cancel
virtual void cancel()=0
Cancels the download.
QXmppFileSharingProvider::Upload
Used to control ongoing uploads.
Definition QXmppFileSharingProvider.h:53
QXmppFileSharingProvider::Upload::cancel
virtual void cancel()=0
Cancels the upload.
QXmppFileSharingProvider
The interface of a provider for the QXmppFileSharingManager.
Definition QXmppFileSharingProvider.h:32
QXmppFileSharingProvider::uploadFile
virtual auto uploadFile(std::unique_ptr< QIODevice > source, const QXmppFileMetadata &info, std::function< void(quint64, quint64)> reportProgress, std::function< void(UploadResult)> reportFinished) -> std::shared_ptr< Upload >=0
Handles the upload of a file for this provider.
QXmppFileSharingProvider::downloadFile
virtual auto downloadFile(const std::any &source, std::unique_ptr< QIODevice > target, std::function< void(quint64, quint64)> reportProgress, std::function< void(DownloadResult)> reportFinished) -> std::shared_ptr< Download >=0
Handles the download of files for this provider.
QXmppFileSharingProvider::DownloadResult
std::variant< QXmpp::Success, QXmpp::Cancelled, QXmppError > DownloadResult
Definition QXmppFileSharingProvider.h:36
QXmppFileSharingProvider::UploadResult
std::variant< std::any, QXmpp::Cancelled, QXmppError > UploadResult
Definition QXmppFileSharingProvider.h:40
QXmppError
Definition QXmppError.h:18
QXmpp::Cancelled
Definition QXmppGlobal.h:181