File indexing completed on 2025-01-19 03:53:09
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2018-05-20 0007 * Description : a tool to export images to Onedrive web service 0008 * 0009 * SPDX-FileCopyrightText: 2018 by Tarek Talaat <tarektalaat93 at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_OD_TALKER_H 0016 #define DIGIKAM_OD_TALKER_H 0017 0018 // Qt includes 0019 0020 #include <QList> 0021 #include <QPair> 0022 #include <QString> 0023 #include <QNetworkReply> 0024 0025 // Local includes 0026 0027 #include "oditem.h" 0028 #include "dmetadata.h" 0029 0030 using namespace Digikam; 0031 0032 namespace DigikamGenericOneDrivePlugin 0033 { 0034 0035 class ODTalker : public QObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 0041 explicit ODTalker(QWidget* const parent); 0042 ~ODTalker() override; 0043 0044 public: 0045 0046 void link(); 0047 void unLink(); 0048 void getUserName(); 0049 bool authenticated(); 0050 void cancel(); 0051 bool addPhoto(const QString& imgPath, const QString& uploadFolder, bool rescale, int maxDim, int imageQuality); 0052 void listFolders(const QString& folder = QString()); 0053 void createFolder(QString& path); 0054 void setAccessToken(const QString& token); 0055 void readSettings(); 0056 void writeSettings(); 0057 0058 Q_SIGNALS: 0059 0060 void signalBusy(bool val); 0061 void signalTransferCancel(); 0062 void signalLinkingSucceeded(); 0063 void signalLinkingFailed(); 0064 void signalSetUserName(const QString& msg); 0065 void signalListAlbumsFailed(const QString& msg); 0066 void signalListAlbumsDone(const QList<QPair<QString, QString> >& list); 0067 void signalCreateFolderFailed(const QString& msg); 0068 void signalCreateFolderSucceeded(); 0069 void signalAddPhotoFailed(const QString& msg); 0070 void signalAddPhotoSucceeded(); 0071 void oneDriveLinkingSucceeded(); 0072 void oneDriveLinkingFailed(); 0073 0074 private Q_SLOTS: 0075 0076 void slotLinkingFailed(); 0077 void slotLinkingSucceeded(); 0078 void slotCatchUrl(const QUrl& url); 0079 void slotFinished(QNetworkReply* reply); 0080 0081 private: 0082 0083 void parseResponseUserName(const QByteArray& data); 0084 void parseResponseListFolders(const QByteArray& data); 0085 void parseResponseCreateFolder(const QByteArray& data); 0086 void parseResponseAddPhoto(const QByteArray& data); 0087 0088 private: 0089 0090 class Private; 0091 Private* const d; 0092 }; 0093 0094 } // namespace DigikamGenericOneDrivePlugin 0095 0096 #endif // DIGIKAM_OD_TALKER_H