| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef KSNIP_IMGURUPLOADER_H |
| 21 |
#define KSNIP_IMGURUPLOADER_H |
| 22 |
|
| 23 |
#include <QImage> |
| 24 |
|
| 25 |
#include "IImgurUploader.h" |
| 26 |
#include "ImgurWrapper.h" |
| 27 |
#include "ImgurResponseLogger.h" |
| 28 |
#include "src/backend/uploader/IUploader.h" |
| 29 |
#include "src/backend/uploader/UploadResult.h" |
| 30 |
#include "src/backend/config/IConfig.h" |
| 31 |
#include "src/common/constants/DefaultValues.h" |
| 32 |
|
| 33 |
class ImgurUploader : public IImgurUploader |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
public: |
| 37 |
explicit ImgurUploader(const QSharedPointer<IConfig> &config); |
| 38 |
~ImgurUploader() override; |
| 39 |
|
| 40 |
void upload(const QImage &image) override; |
| 41 |
UploaderType type() const override; |
| 42 |
|
| 43 |
private: |
| 44 |
QSharedPointer<IConfig> mConfig; |
| 45 |
ImgurWrapper *mImgurWrapper; |
| 46 |
ImgurResponseLogger *mImgurResponseLogger; |
| 47 |
QImage mImage; |
| 48 |
|
| 49 |
static UploadStatus mapErrorTypeToStatus(QNetworkReply::NetworkError errorType); |
| 50 |
|
| 51 |
private slots: |
| 52 |
void imgurUploadFinished(const ImgurResponse &response); |
| 53 |
void imgurError(QNetworkReply::NetworkError networkError, const QString &message); |
| 54 |
void imgurTokenUpdated(const QString &accessToken, const QString &refreshToken, const QString &username); |
| 55 |
void imgurTokenRefresh(); |
| 56 |
QString formatResponseUrl(const ImgurResponse &response) const; |
| 57 |
}; |
| 58 |
|
| 59 |
#endif |