File indexing completed on 2024-12-08 10:25:56

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "libruqolacore_export.h"
0009 #include "uploadfilejob.h"
0010 #include <QMap>
0011 #include <QObject>
0012 #include <QPointer>
0013 class RocketChatAccount;
0014 class LIBRUQOLACORE_EXPORT UploadFileManager : public QObject
0015 {
0016     Q_OBJECT
0017 public:
0018     explicit UploadFileManager(RocketChatAccount *account, QObject *parent = nullptr);
0019     ~UploadFileManager() override;
0020 
0021     [[nodiscard]] int addUpload(const RocketChatRestApi::UploadFileJob::UploadFileInfo &info);
0022 
0023     void cancelJob(int identifier);
0024 Q_SIGNALS:
0025     void uploadProgress(const RocketChatRestApi::UploadFileJob::UploadStatusInfo &info, int identifier, const QString &accountName);
0026 
0027 private:
0028     LIBRUQOLACORE_NO_EXPORT void removeFile(const RocketChatRestApi::UploadFileJob::UploadFileInfo &info);
0029     RocketChatAccount *const mRocketChatAccount;
0030     QMap<int, QPointer<RocketChatRestApi::UploadFileJob>> mUploadMap;
0031     static int uploadIdentifier;
0032 };