digiKam
ptalker.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 : 2018-05-20
7  * Description : a tool to export images to Pinterest web service
8  *
9  * Copyright (C) 2018 by Tarek Talaat <tarektalaat93 at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef DIGIKAM_P_TALKER_H
24 #define DIGIKAM_P_TALKER_H
25 
26 // Qt includes
27 
28 #include <QList>
29 #include <QPair>
30 #include <QString>
31 #include <QNetworkReply>
32 
33 // Local includes
34 
35 #include "pitem.h"
36 #include "dmetadata.h"
37 
38 using namespace Digikam;
39 
41 {
42 
43 class PTalker : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit PTalker(QWidget* const parent);
50  ~PTalker() override;
51 
52 public:
53 
54  void link();
55  void unLink();
56  void getUserName();
57  bool authenticated();
58  void cancel();
59  bool addPin(const QString& imgPath, const QString& uploadFolder, bool rescale, int maxDim, int imageQuality);
60  void listBoards(const QString& path = QString());
61  void createBoard(QString& boardName);
62  void setAccessToken(const QString& token);
63  QMap<QString, QString> ParseUrlParameters(const QString& url);
64  void getToken(const QString& code);
65  void readSettings();
66  void writeSettings();
67 
68 Q_SIGNALS:
69 
70  void signalBusy(bool val);
73  void signalSetUserName(const QString& msg);
74  void signalListBoardsFailed(const QString& msg);
75  void signalListBoardsDone(const QList<QPair<QString, QString> >& list);
76  void signalCreateBoardFailed(const QString& msg);
78  void signalAddPinFailed(const QString& msg);
82 
83 private Q_SLOTS:
84 
85  void slotLinkingFailed();
86  void slotLinkingSucceeded();
87  void slotCatchUrl(const QUrl& url);
88  void slotFinished(QNetworkReply* reply);
89 
90 private:
91 
92  void parseResponseUserName(const QByteArray& data);
93  void parseResponseListBoards(const QByteArray& data);
94  void parseResponseCreateBoard(const QByteArray& data);
95  void parseResponseAddPin(const QByteArray& data);
96  void parseResponseAccessToken(const QByteArray& data);
97 
98 private:
99 
100  class Private;
101  Private* const d;
102 };
103 
104 } // namespace DigikamGenericPinterestPlugin
105 
106 #endif // DIGIKAM_P_TALKER_H
void signalCreateBoardFailed(const QString &msg)
void signalListBoardsDone(const QList< QPair< QString, QString > > &list)
void signalSetUserName(const QString &msg)
void signalAddPinFailed(const QString &msg)
void signalListBoardsFailed(const QString &msg)
void setAccessToken(const QString &token)
Definition: piwigotalker.h:48
Definition: pitem.h:31
Definition: datefolderview.cpp:43