#pragma once #include "common/Singleton.hpp" #include #include #include #include #include namespace chatterino { class ResizingTextEdit; class Channel; class NetworkResult; using ChannelPtr = std::shared_ptr; struct RawImageData { QByteArray data; QString format; QString filePath; }; class ImageUploader final : public Singleton { public: void save() override; void upload(const QMimeData *source, ChannelPtr channel, QPointer outputTextEdit); private: void sendImageUploadRequest(RawImageData imageData, ChannelPtr channel, QPointer textEdit); // This is called from the onSuccess handler of the NetworkRequest in sendImageUploadRequest void handleSuccessfulUpload(const NetworkResult &result, QString originalFilePath, ChannelPtr channel, QPointer textEdit); void handleFailedUpload(const NetworkResult &result, ChannelPtr channel); void logToFile(const QString &originalFilePath, const QString &imageLink, const QString &deletionLink, ChannelPtr channel); // These variables are only used from the main thread. QMutex uploadMutex_; std::queue uploadQueue_; }; } // namespace chatterino