digiKam
twittertalker.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-06-29
7  * Description : a tool to export images to Twitter social network
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_TWITTER_TALKER_H
24 #define DIGIKAM_TWITTER_TALKER_H
25 
26 // Qt includes
27 
28 #include <QList>
29 #include <QPair>
30 #include <QString>
31 #include <QNetworkReply>
32 
33 // OAuth2 library includes
34 
35 #if defined(Q_CC_CLANG)
36 # pragma clang diagnostic push
37 # pragma clang diagnostic ignored "-Wextra-semi"
38 #endif
39 
40 #include "o2.h"
41 #include "o0globals.h"
42 #include "o1twitter.h"
43 
44 #if defined(Q_CC_CLANG)
45 # pragma clang diagnostic pop
46 #endif
47 
48 // Local includes
49 
50 #include "twitteritem.h"
51 #include "dmetadata.h"
52 
53 using namespace Digikam;
54 
56 {
57 
58 class TwTalker : public QObject
59 {
60  Q_OBJECT
61 
62 public:
63 
64  explicit TwTalker(QWidget* const parent);
65  ~TwTalker() override;
66 
67 public:
68 
69  void link();
70  void unLink();
71  void getUserName();
72  bool authenticated();
73  void cancel();
74  bool addPhoto(const QString& imgPath, const QString& uploadFolder, bool rescale, int maxDim, int imageQuality);
75  void listFolders(const QString& path = QString());
76  void createFolder(QString& path);
77  void setAccessToken(const QString& token);
78  QMap<QString, QString> ParseUrlParameters(const QString& url);
79  void createTweet(const QString& mediaId);
80 
81  bool addPhotoSingleUpload(const QString& imgPath);
82 
83  bool addPhotoInit(const QString& imgPath);
84  bool addPhotoAppend(const QString& mediaId, int segmentIndex=0);
85  bool addPhotoFinalize(const QString& mediaId);
86 
87 Q_SIGNALS:
88 
89  void signalBusy(bool val);
92  void signalSetUserName(const QString& msg);
93  void signalListAlbumsFailed(const QString& msg);
94  void signalListAlbumsDone(const QList<QPair<QString, QString> >& list);
95  void signalCreateFolderFailed(const QString& msg);
97  void signalAddPhotoFailed(const QString& msg);
101 
102 private Q_SLOTS:
103 
104  void slotLinkingFailed();
105  void slotLinkingSucceeded();
106  void slotOpenBrowser(const QUrl& url);
107  void slotFinished(QNetworkReply* reply);
108 
109  void slotCheckUploadStatus();
110 
111 private:
112 
113  void parseResponseUserName(const QByteArray& data);
114  void parseResponseListFolders(const QByteArray& data);
115  void parseResponseCreateFolder(const QByteArray& data);
116  void parseResponseAddPhoto(const QByteArray& data);
117  void parseResponseAddPhotoInit(const QByteArray& data);
118  void parseResponseAddPhotoAppend(const QByteArray& data, int segmentIndex);
119  void parseResponseAddPhotoFinalize(const QByteArray& data);
120  void parseResponseCreateTweet(const QByteArray& data);
121  void parseCheckUploadStatus(const QByteArray& data);
122 
123 private:
124 
125  class Private;
126  Private* const d;
127 };
128 
129 } // namespace DigikamGenericTwitterPlugin
130 
131 #endif // DIGIKAM_TWITTER_TALKER_H
Definition: twittertalker.h:59
void signalAddPhotoFailed(const QString &msg)
void signalListAlbumsFailed(const QString &msg)
void listFolders(const QString &path=QString())
void signalSetUserName(const QString &msg)
void signalCreateFolderFailed(const QString &msg)
void setAccessToken(const QString &token)
void signalListAlbumsDone(const QList< QPair< QString, QString > > &list)
Definition: piwigotalker.h:48
Definition: twitteritem.h:31
Definition: datefolderview.cpp:43