digiKam
fbtalker.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 : 2008-12-26
7  * Description : a tool to export items to Facebook web service
8  *
9  * Copyright (C) 2008-2009 by Luka Renko <lure at kubuntu dot org>
10  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2018 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_FB_TALKER_H
26 #define DIGIKAM_FB_TALKER_H
27 
28 // Qt includes
29 
30 #include <QList>
31 #include <QString>
32 #include <QTime>
33 #include <QObject>
34 #include <QUrl>
35 #include <QNetworkReply>
36 #include <QMap>
37 
38 // Local includes
39 
40 #include "fbitem.h"
41 
42 class QDomElement;
43 
45 {
46 
47 class FbTalker : public QObject
48 {
49  Q_OBJECT
50 
51 public:
52 
53  explicit FbTalker(QWidget* const parent);
54  ~FbTalker();
55 
56  void link();
57  void unlink();
58  bool linked();
59  void cancel();
60 
61  FbUser getUser() const;
62 
63  void logout();
64 
65  void listAlbums(long long userID = 0);
66 
67  void createAlbum(const FbAlbum& album);
68 
69  void addPhoto(const QString& imgPath, const QString& albumID,
70  const QString& caption);
71 
72  void readSettings();
73  void writeSettings();
74 
75 Q_SIGNALS:
76 
77  void signalBusy(bool val);
78  void signalListAlbumsDone(int errCode, const QString& errMsg, const QList <FbAlbum>& albumsList);
79  void signalCreateAlbumDone(int errCode, const QString& errMsg, const QString& newAlbumId);
80  void signalAddPhotoDone(int errCode, const QString& errMsg);
81  void signalLoginProgress(int step, int maxStep = 0, const QString& label = QString());
82  void signalLoginDone(int errCode, const QString& errMsg);
84 
85 private:
86 
87  void getLoggedInUser();
88 
89  QString errorToText(int errCode, const QString& errMsg);
90  int parseErrorResponse(const QDomElement& e, QString& errMsg);
91  void parseResponseGetLoggedInUser(const QByteArray& data);
92  void parseResponseAddPhoto(const QByteArray& data);
93  void parseResponseCreateAlbum(const QByteArray& data);
94  void parseResponseListAlbums(const QByteArray& data);
95  void parseResponseLogoutUser();
96 
97 private Q_SLOTS:
98 
99  void slotLinkingSucceeded();
100  void slotCatchUrl(const QUrl& url);
101  void slotFinished(QNetworkReply* reply);
102 
103 private:
104 
105  class Private;
106  Private* const d;
107 };
108 
109 } // namespace DigikamGenericFaceBookPlugin
110 
111 #endif // DIGIKAM_FB_TALKER_H
void signalLoginProgress(int step, int maxStep=0, const QString &label=QString())
void signalAddPhotoDone(int errCode, const QString &errMsg)
void writeSettings()
Definition: fbtalker.cpp:793
void createAlbum(const FbAlbum &album)
Definition: fbtalker.cpp:382
FbTalker(QWidget *const parent)
Definition: fbtalker.cpp:149
void link()
Definition: fbtalker.cpp:175
void addPhoto(const QString &imgPath, const QString &albumID, const QString &caption)
Definition: fbtalker.cpp:440
bool linked()
Definition: fbtalker.cpp:273
~FbTalker()
Definition: fbtalker.cpp:163
void listAlbums(long long userID=0)
Definition: fbtalker.cpp:337
void signalCreateAlbumDone(int errCode, const QString &errMsg, const QString &newAlbumId)
FbUser getUser() const
Definition: fbtalker.cpp:268
void readSettings()
Definition: fbtalker.cpp:801
void signalListAlbumsDone(int errCode, const QString &errMsg, const QList< FbAlbum > &albumsList)
void cancel()
Definition: fbtalker.cpp:213
void unlink()
Definition: fbtalker.cpp:201
void signalLoginDone(int errCode, const QString &errMsg)
void logout()
Definition: fbtalker.cpp:308
Definition: piwigotalker.h:48
Definition: fbitem.h:38