digiKam
imageshacktalker.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2012-02-02
7  * Description : a tool to export items to ImageShack web service
8  *
9  * Copyright (C) 2012 by Dodon Victor <dodonvictor at gmail dot com>
10  * Copyright (C) 2013-2018 by Caulier Gilles <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_IMAGE_SHACK_TALKER_H
25 #define DIGIKAM_IMAGE_SHACK_TALKER_H
26 
27 // Qt includes
28 
29 #include <QObject>
30 #include <QString>
31 #include <QMap>
32 #include <QNetworkReply>
33 #include <QNetworkAccessManager>
34 
35 class QDomElement;
36 class QByteArray;
37 
39 {
40 
41 class ImageShackSession;
42 
43 class ImageShackTalker : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit ImageShackTalker(ImageShackSession* const session);
50  ~ImageShackTalker() override;
51 
52 public:
53 
54  void authenticate();
55  void cancelLogIn();
56  void cancel();
57  void getGalleries();
58 
59  void uploadItem(const QString& path, const QMap<QString, QString>& opts);
60  void uploadItemToGallery(const QString& path,
61  const QString& gallery,
62  const QMap<QString, QString>& opts);
63 
64 Q_SIGNALS:
65 
66  void signalBusy(bool busy);
67  void signalJobInProgress(int step,
68  int maxStep = 0,
69  const QString& label = QString());
70  void signalLoginDone(int errCode, const QString& errMsg);
71  void signalGetGalleriesDone(int errCode, const QString& errMsg);
72 
73  void signalAddPhotoDone(int errCode, const QString& errMsg);
74  void signalUpdateGalleries(const QStringList& gTexts,
75  const QStringList& gNames);
76 
77 private Q_SLOTS:
78 
79  void slotFinished(QNetworkReply* reply);
80 
81 private:
82 
83  QString getCallString(QMap<QString, QString>& args) const;
84  void checkRegistrationCodeDone(int errCode, const QString& errMsg);
85  void parseAccessToken(const QByteArray& data);
86  void parseGetGalleries(const QByteArray& data);
87  void authenticationDone(int errCode, const QString& errMsg);
88 
89  void logOut();
90 
91  int parseErrorResponse(const QDomElement& elem, QString& errMsg) const;
92 
93  void parseUploadPhotoDone(const QByteArray& data);
94  void parseAddPhotoToGalleryDone(const QByteArray& data);
95 
96  QString mimeType(const QString& path) const;
97 
98 private:
99 
100  // Disable
101  explicit ImageShackTalker(QObject*) = delete;
102 
103 private:
104 
105  class Private;
106  Private* const d;
107 };
108 
109 } // namespace DigikamGenericImageShackPlugin
110 
111 #endif // DIGIKAM_IMAGE_SHACK_TALKER_H
Definition: imageshacksession.h:35
Definition: imageshacktalker.h:44
ImageShackTalker(ImageShackSession *const session)
Definition: imageshacktalker.cpp:111
void signalLoginDone(int errCode, const QString &errMsg)
void authenticate()
Definition: imageshacktalker.cpp:223
void signalGetGalleriesDone(int errCode, const QString &errMsg)
void cancelLogIn()
Definition: imageshacktalker.cpp:369
~ImageShackTalker() override
Definition: imageshacktalker.cpp:121
void signalAddPhotoDone(int errCode, const QString &errMsg)
void uploadItem(const QString &path, const QMap< QString, QString > &opts)
Definition: imageshacktalker.cpp:383
void uploadItemToGallery(const QString &path, const QString &gallery, const QMap< QString, QString > &opts)
Definition: imageshacktalker.cpp:432
void signalJobInProgress(int step, int maxStep=0, const QString &label=QString())
void getGalleries()
Definition: imageshacktalker.cpp:248
void cancel()
Definition: imageshacktalker.cpp:131
void signalUpdateGalleries(const QStringList &gTexts, const QStringList &gNames)
Definition: imageshackitem.h:32