digiKam
smugtalker.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 : 2008-12-01
7  * Description : a tool to export images to Smugmug web service
8  *
9  * Copyright (C) 2008-2009 by Luka Renko <lure at kubuntu dot org>
10  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2018 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_SMUG_TALKER_H
26 #define DIGIKAM_SMUG_TALKER_H
27 
28 // Qt includes
29 
30 #include <QList>
31 #include <QString>
32 #include <QObject>
33 
34 // local includes
35 
36 #include "smugitem.h"
37 #include "dinfointerface.h"
38 
39 // OAuth2 library includes
40 
41 #if defined(Q_CC_CLANG)
42 # pragma clang diagnostic push
43 # pragma clang diagnostic ignored "-Wextra-semi"
44 #endif
45 
46 #include "o0globals.h"
47 #include "o1smugmug.h"
48 #include "o1requestor.h"
49 
50 #if defined(Q_CC_CLANG)
51 # pragma clang diagnostic pop
52 #endif
53 
54 class QNetworkReply;
55 
56 using namespace Digikam;
57 
59 {
60 
61 class SmugTalker : public QObject
62 {
63  Q_OBJECT
64 
65 public:
66 
67  explicit SmugTalker(DInfoInterface* const iface, QWidget* const parent);
68  ~SmugTalker() override;
69 
70 public:
71 
72  SmugUser getUser() const;
73 
74  bool loggedIn() const;
75  void cancel();
76 
77  void link();
78  void unlink();
79  void removeUserAccount(const QString& userName);
80  void login();
81  void getLoginedUser();
82  void logout();
83 
84  void listAlbums(const QString& nickName = QString());
85  void listPhotos(qint64 albumID,
86  const QString& albumKey,
87  const QString& albumPassword = QString(),
88  const QString& sitePassword = QString());
89  void listAlbumTmpl();
90 
91 /* Categories are deprecated in API v2
92  void listCategories();
93  void listSubCategories(qint64 categoryID);
94 */
95 
96  void createAlbum(const SmugAlbum& album);
97 
98  bool addPhoto(const QString& imgPath,
99  qint64 albumID,
100  const QString& albumKey,
101  const QString& caption);
102 
103  void getPhoto(const QString& imgPath);
104 
105  QString createAlbumName(const QString& word);
106 
107  QString createAlbumUrl(const QString& name);
108 
109 Q_SIGNALS:
110 
111  void signalBusy(bool val);
113  void signalLoginProgress(int step,
114  int maxStep = 0,
115  const QString& label = QString());
116  void signalLoginDone(int errCode, const QString& errMsg);
117 
118  void signalAddPhotoDone(int errCode, const QString& errMsg);
119 
120  void signalGetPhotoDone(int errCode, const QString& errMsg,
121  const QByteArray& photoData);
122  void signalCreateAlbumDone(int errCode, const QString& errMsg, qint64 newAlbumID,
123  const QString& newAlbumKey);
124  void signalListAlbumsDone(int errCode, const QString& errMsg,
125  const QList <SmugAlbum>& albumsList);
126  void signalListPhotosDone(int errCode, const QString& errMsg,
127  const QList <SmugPhoto>& photosList);
128  void signalListAlbumTmplDone(int errCode, const QString& errMsg,
129  const QList <SmugAlbumTmpl>& albumTList);
130 
131 /* Categories deprecated in API v2
132 
133  void signalListCategoriesDone(int errCode, const QString& errMsg,
134  const QList <SmugCategory>& categoriesList);
135  void signalListSubCategoriesDone(int errCode, const QString& errMsg,
136  const QList <SmugCategory>& categoriesList);
137 */
138 
139 private:
140 
141  QString htmlToText(const QString& htmlText) const;
142  QString errorToText(int errCode, const QString& errMsg) const;
143  void parseResponseLogin(const QByteArray& data);
144 
145 // void parseResponseLogout(const QByteArray& data);
146 
147  void parseResponseAddPhoto(const QByteArray& data);
148  void parseResponseCreateAlbum(const QByteArray& data);
149  void parseResponseListAlbums(const QByteArray& data);
150  void parseResponseListPhotos(const QByteArray& data);
151  void parseResponseListAlbumTmpl(const QByteArray& data);
152 
153 /* Categories deprecated in API v2
154 
155  void parseResponseListCategories(const QByteArray& data);
156  void parseResponseListSubCategories(const QByteArray& data);
157 */
158 
159 private Q_SLOTS:
160 
161  void slotFinished(QNetworkReply* reply);
162  void slotLinkingFailed();
163  void slotLinkingSucceeded();
164  void slotOpenBrowser(const QUrl& url);
165  void slotCloseBrowser();
166 
167 private:
168 
169  class Private;
170  Private* const d;
171 };
172 
173 } // namespace DigikamGenericSmugPlugin
174 
175 #endif // DIGIKAM_SMUG_TALKER_H
Definition: smugitem.h:72
Definition: smugtalker.h:62
void signalListAlbumsDone(int errCode, const QString &errMsg, const QList< SmugAlbum > &albumsList)
void signalGetPhotoDone(int errCode, const QString &errMsg, const QByteArray &photoData)
void signalListAlbumTmplDone(int errCode, const QString &errMsg, const QList< SmugAlbumTmpl > &albumTList)
void signalListPhotosDone(int errCode, const QString &errMsg, const QList< SmugPhoto > &photosList)
void signalLoginProgress(int step, int maxStep=0, const QString &label=QString())
void signalAddPhotoDone(int errCode, const QString &errMsg)
void signalLoginDone(int errCode, const QString &errMsg)
void signalCreateAlbumDone(int errCode, const QString &errMsg, qint64 newAlbumID, const QString &newAlbumKey)
Definition: smugitem.h:36
Definition: dinfointerface.h:56
Definition: piwigotalker.h:48
Definition: smugitem.h:33
Definition: datefolderview.cpp:43