Debian Codegraph @

src/backend/uploader/imgur/ImgurUploader.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
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 //KSNIP_IMGURUPLOADER_H