File indexing completed on 2025-01-05 03:53:25
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-12-26 0007 * Description : a tool to export items to Facebook web service 0008 * 0009 * SPDX-FileCopyrightText: 2008-2009 by Luka Renko <lure at kubuntu dot org> 0010 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2018 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_FB_TALKER_WIZARD_H 0018 #define DIGIKAM_FB_TALKER_WIZARD_H 0019 0020 // Qt includes 0021 0022 #include <QList> 0023 #include <QString> 0024 #include <QTime> 0025 #include <QObject> 0026 #include <QUrl> 0027 #include <QNetworkReply> 0028 #include <QMap> 0029 #include <QSettings> 0030 0031 // Local includes 0032 0033 #include "fbitem.h" 0034 #include "wsnewalbumdialog.h" 0035 #include "wstalker.h" 0036 #include "wsitem.h" 0037 0038 // O2 include 0039 0040 #include "o2.h" 0041 #include "o0globals.h" 0042 0043 class QDomElement; 0044 0045 using namespace Digikam; 0046 0047 namespace DigikamGenericFaceBookPlugin 0048 { 0049 0050 class FbTalker : public WSTalker 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 0056 explicit FbTalker(QWidget* const parent, WSNewAlbumDialog* albumDlg=0); 0057 ~FbTalker(); 0058 0059 void link(); 0060 void unlink(); 0061 bool linked() const; 0062 0063 void resetTalker(const QString& expire, const QString& accessToken, const QString& refreshToken); 0064 0065 FbUser getUser() const; 0066 0067 void authenticate(); 0068 void logout(); 0069 0070 void listAlbums(long long userID = 0); 0071 0072 void createNewAlbum(); 0073 void createAlbum(const FbAlbum& album); 0074 0075 void addPhoto(const QString& imgPath, const QString& albumID, 0076 const QString& caption); 0077 0078 Q_SIGNALS: 0079 0080 void signalLoginProgress(int step, int maxStep = 0, const QString& label = QString()); 0081 void signalLoginDone(int errCode, const QString& errMsg); 0082 0083 private: 0084 0085 //QString getApiSig(const QMap<QString, QString>& args); 0086 void authenticationDone(int errCode, const QString& errMsg); 0087 void getLoggedInUser(); 0088 0089 QString errorToText(int errCode, const QString& errMsg); 0090 int parseErrorResponse(const QDomElement& e, QString& errMsg); 0091 void parseResponseGetLoggedInUser(const QByteArray& data); 0092 void parseResponseAddPhoto(const QByteArray& data); 0093 void parseResponseCreateAlbum(const QByteArray& data); 0094 void parseResponseListAlbums(const QByteArray& data); 0095 0096 private Q_SLOTS: 0097 0098 void slotResponseTokenReceived(const QMap<QString, QString>& rep); 0099 0100 private: 0101 0102 class Private; 0103 Private* const d; 0104 }; 0105 0106 } // namespace DigikamGenericFaceBookPlugin 0107 0108 #endif // DIGIKAM_FB_TALKER_WIZARD_H