File indexing completed on 2025-01-05 03:53:29
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-16-07 0007 * Description : a tool to export items to Google web services 0008 * 0009 * SPDX-FileCopyrightText: 2007-2008 by Vardhman Jain <vardhman at gmail dot com> 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_GP_TALKER_H 0018 #define DIGIKAM_GP_TALKER_H 0019 0020 // Qt includes 0021 0022 #include <QUrl> 0023 #include <QMap> 0024 #include <QHash> 0025 #include <QObject> 0026 #include <QPointer> 0027 0028 // Local includes 0029 0030 #include "gsitem.h" 0031 #include "gstalkerbase.h" 0032 0033 namespace DigikamGenericGoogleServicesPlugin 0034 { 0035 0036 class GPTalker : public GSTalkerBase 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 0042 explicit GPTalker(QWidget* const parent); 0043 ~GPTalker() override; 0044 0045 public: 0046 0047 void getLoggedInUser(); 0048 0049 void listAlbums(const QString& nextPageToken = QString()); 0050 void listPhotos(const QString& albumId, 0051 const QString& nextPageToken = QString()); 0052 0053 void createAlbum(const GSFolder& newAlbum); 0054 0055 bool addPhoto(const QString& photoPath, 0056 GSPhoto& info, 0057 const QString& albumId, 0058 bool original, 0059 bool rescale, 0060 int maxDim, 0061 int imageQuality); 0062 bool updatePhoto(const QString& photoPath, 0063 GSPhoto& info, 0064 bool rescale, 0065 int maxDim, 0066 int imageQuality); 0067 0068 void getPhoto(const QString& imgPath); 0069 0070 QStringList getUploadTokenList(); 0071 0072 void cancel(); 0073 0074 Q_SIGNALS: 0075 0076 void signalSetUserName(const QString& msg); 0077 void signalError(const QString& msg); 0078 void signalListAlbumsDone(int, const QString&, const QList <GSFolder>&); 0079 void signalListPhotosDone(int, const QString&, const QList <GSPhoto>&); 0080 void signalCreateAlbumDone(int, const QString&, const QString&); 0081 void signalAddPhotoDone(int, const QString&); 0082 void signalUploadPhotoDone(int, const QString&, const QStringList&); 0083 void signalGetPhotoDone(int errCode, const QString& errMsg, 0084 const QByteArray& photoData, const QString& fileName); 0085 void signalReadyToUpload(); 0086 0087 private: 0088 0089 void parseResponseGetLoggedInUser(const QByteArray& data); 0090 void parseResponseListAlbums(const QByteArray& data); 0091 void parseResponseListPhotos(const QByteArray& data); 0092 void parseResponseCreateAlbum(const QByteArray& data); 0093 void parseResponseAddPhoto(const QByteArray& data); 0094 void parseResponseUploadPhoto(const QByteArray& data); 0095 0096 private Q_SLOTS: 0097 0098 void slotError(const QString& msg); 0099 void slotFinished(QNetworkReply* reply); 0100 void slotUploadPhoto(); 0101 0102 private: 0103 0104 class Private; 0105 Private* const d; 0106 }; 0107 0108 } // namespace DigikamGenericGoogleServicesPlugin 0109 0110 #endif // DIGIKAM_GP_TALKER_H