File indexing completed on 2025-01-19 03:53:10
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 Pinterest 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_P_TALKER_H 0016 #define DIGIKAM_P_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 "pitem.h" 0028 #include "dmetadata.h" 0029 0030 using namespace Digikam; 0031 0032 namespace DigikamGenericPinterestPlugin 0033 { 0034 0035 class PTalker : public QObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 0041 explicit PTalker(QWidget* const parent); 0042 ~PTalker() override; 0043 0044 public: 0045 0046 void link(); 0047 void unLink(); 0048 void getUserName(); 0049 bool authenticated(); 0050 void cancel(); 0051 bool addPin(const QString& imgPath, 0052 const QString& boradID, 0053 bool rescale, int maxDim, int imageQuality); 0054 void listBoards(const QString& path = QString()); 0055 void createBoard(QString& boardName); 0056 void setAccessToken(const QString& token); 0057 QMap<QString, QString> ParseUrlParameters(const QString& url); 0058 void getToken(const QString& code); 0059 void readSettings(); 0060 void writeSettings(); 0061 0062 Q_SIGNALS: 0063 0064 void signalBusy(bool val); 0065 void signalLinkingSucceeded(); 0066 void signalLinkingFailed(); 0067 void signalNetworkError(); 0068 void signalSetUserName(const QString& msg); 0069 void signalListBoardsFailed(const QString& msg); 0070 void signalListBoardsDone(const QList<QPair<QString, QString> >& list); 0071 void signalCreateBoardFailed(const QString& msg); 0072 void signalCreateBoardSucceeded(); 0073 void signalAddPinFailed(const QString& msg); 0074 void signalAddPinSucceeded(); 0075 void pinterestLinkingSucceeded(); 0076 void pinterestLinkingFailed(); 0077 0078 private Q_SLOTS: 0079 0080 void slotLinkingFailed(); 0081 void slotLinkingSucceeded(); 0082 void slotCatchUrl(const QUrl& url); 0083 void slotFinished(QNetworkReply* reply); 0084 0085 private: 0086 0087 void parseResponseUserName(const QByteArray& data); 0088 void parseResponseListBoards(const QByteArray& data); 0089 void parseResponseCreateBoard(const QByteArray& data); 0090 void parseResponseAddPin(const QByteArray& data); 0091 void parseResponseAccessToken(const QByteArray& data); 0092 0093 private: 0094 0095 class Private; 0096 Private* const d; 0097 }; 0098 0099 } // namespace DigikamGenericPinterestPlugin 0100 0101 #endif // DIGIKAM_P_TALKER_H