QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppFileSharingProvider.h
1// SPDX-FileCopyrightText: 2022 Jonah BrĂ¼chert <jbb@kaidan.im>
2// SPDX-FileCopyrightText: 2022 Linus Jahn <lnj@kaidan.im>
3//
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
6#ifndef QXMPPFILESHARINGPROVIDER_H
7#define QXMPPFILESHARINGPROVIDER_H
8
9#include "QXmppError.h"
10#include "QXmppGlobal.h"
11
12#include <any>
13#include <functional>
14#include <memory>
15#include <variant>
16
17class QIODevice;
19class QXmppUpload;
20class QXmppDownload;
21
31class QXMPP_EXPORT QXmppFileSharingProvider
32{
33public:
36 using DownloadResult = std::variant<QXmpp::Success, QXmpp::Cancelled, QXmppError>;
37
40 using UploadResult = std::variant<std::any /* source */, QXmpp::Cancelled, QXmppError>;
41
44 {
45 public:
46 virtual ~Download() = default;
48 virtual void cancel() = 0;
49 };
50
52 class Upload
53 {
54 public:
55 virtual ~Upload() = default;
57 virtual void cancel() = 0;
58 };
59
61 virtual ~QXmppFileSharingProvider() = default;
63
72 virtual auto downloadFile(const std::any &source,
73 std::unique_ptr<QIODevice> target,
74 std::function<void(quint64, quint64)> reportProgress,
75 std::function<void(DownloadResult)> reportFinished) -> std::shared_ptr<Download> = 0;
76
84 virtual auto uploadFile(std::unique_ptr<QIODevice> source,
85 const QXmppFileMetadata &info,
86 std::function<void(quint64, quint64)> reportProgress,
87 std::function<void(UploadResult)> reportFinished) -> std::shared_ptr<Upload> = 0;
88};
89
90#endif // QXMPPFILESHARINGPROVIDER_H
Definition QXmppFileMetadata.h:24
Used to control ongoing downloads.
Definition QXmppFileSharingProvider.h:44
virtual void cancel()=0
Cancels the download.
Used to control ongoing uploads.
Definition QXmppFileSharingProvider.h:53
virtual void cancel()=0
Cancels the upload.
The interface of a provider for the QXmppFileSharingManager.
Definition QXmppFileSharingProvider.h:32
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.
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.
std::variant< QXmpp::Success, QXmpp::Cancelled, QXmppError > DownloadResult
Definition QXmppFileSharingProvider.h:36
std::variant< std::any, QXmpp::Cancelled, QXmppError > UploadResult
Definition QXmppFileSharingProvider.h:40
Definition QXmppError.h:18
Definition QXmppGlobal.h:181