File indexing completed on 2025-01-05 03:53:24

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2013-11-18
0007  * Description : a tool to export images to Dropbox web service
0008  *
0009  * SPDX-FileCopyrightText: 2013 by Pankaj Kumar <me at panks dot me>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DB_TALKER_H
0016 #define DIGIKAM_DB_TALKER_H
0017 
0018 // Qt includes
0019 
0020 #include <QList>
0021 #include <QPair>
0022 #include <QString>
0023 #include <QNetworkReply>
0024 
0025 namespace DigikamGenericDropBoxPlugin
0026 {
0027 
0028 class DBTalker : public QObject
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033 
0034     explicit DBTalker(QWidget* const parent);
0035     ~DBTalker() override;
0036 
0037 public:
0038 
0039     void link();
0040     void unLink();
0041     bool authenticated();
0042     void reauthenticate();
0043     void getUserName();
0044     void cancel();
0045     void listFolders(const QString& cursor = QString());
0046     bool addPhoto(const QString& imgPath, const QString& uploadFolder,
0047                   bool original, bool rescale, int maxDim, int imageQuality);
0048     void createFolder(const QString& path);
0049 
0050 Q_SIGNALS:
0051 
0052     void signalBusy(bool val);
0053     void signalLinkingSucceeded();
0054     void signalLinkingFailed();
0055     void signalSetUserName(const QString& msg);
0056     void signalListAlbumsFailed(const QString& msg);
0057     void signalListAlbumsDone(const QList<QPair<QString, QString> >& list);
0058     void signalCreateFolderFailed(const QString& msg);
0059     void signalCreateFolderSucceeded();
0060     void signalAddPhotoFailed(const QString& msg);
0061     void signalAddPhotoSucceeded();
0062 
0063 private Q_SLOTS:
0064 
0065     void slotLinkingFailed();
0066     void slotLinkingSucceeded();
0067     void slotOpenBrowser(const QUrl& url);
0068     void slotFinished(QNetworkReply* reply);
0069 
0070 private:
0071 
0072     void parseResponseUserName(const QByteArray& data);
0073     void parseResponseListFolders(const QByteArray& data);
0074     void parseResponseCreateFolder(const QByteArray& data);
0075     void parseResponseAddPhoto(const QByteArray& data);
0076 
0077 private:
0078 
0079     class Private;
0080     Private* const d;
0081 };
0082 
0083 } // namespace DigikamGenericDropBoxPlugin
0084 
0085 #endif // DIGIKAM_DB_TALKER_H