File indexing completed on 2025-01-19 03:52:58
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2005-07-07 0007 * Description : a tool to export images to Flickr web service 0008 * 0009 * SPDX-FileCopyrightText: 2005-2009 by Vardhman Jain <vardhman at gmail dot com> 0010 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2017-2019 by Maik Qualmann <metzpinguin at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_FLICKR_TALKER_H 0018 #define DIGIKAM_FLICKR_TALKER_H 0019 0020 // Qt includes 0021 0022 #include <QUrl> 0023 #include <QList> 0024 #include <QPair> 0025 #include <QString> 0026 #include <QObject> 0027 #include <QNetworkReply> 0028 0029 // Local includes 0030 0031 #include "dinfointerface.h" 0032 #include "flickritem.h" 0033 0034 class QProgressDialog; 0035 0036 using namespace Digikam; 0037 0038 namespace DigikamGenericFlickrPlugin 0039 { 0040 0041 class FPhotoInfo; 0042 class FPhotoSet; 0043 0044 class FlickrTalker : public QObject 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 0050 enum State 0051 { 0052 FE_LOGOUT = -1, 0053 FE_LOGIN = 0, 0054 FE_LISTPHOTOSETS, 0055 FE_LISTPHOTOS, 0056 FE_GETPHOTOPROPERTY, 0057 FE_ADDPHOTO, 0058 FE_CREATEPHOTOSET, 0059 FE_ADDPHOTOTOPHOTOSET, 0060 FE_GETMAXSIZE, 0061 FE_SETGEO 0062 }; 0063 0064 public: 0065 0066 explicit FlickrTalker(QWidget* const parent, const QString& serviceName, 0067 DInfoInterface* const iface); 0068 ~FlickrTalker() override; 0069 0070 void link(const QString& userName); 0071 void unLink(); 0072 void removeUserName(const QString& userName); 0073 QString getUserName() const; 0074 QString getUserId() const; 0075 void maxAllowedFileSize(); 0076 QString getMaxAllowedFileSize(); 0077 void getPhotoProperty(const QString& method, const QStringList& argList); 0078 void cancel(); 0079 0080 void listPhotoSets(); 0081 void listPhotos(const QString& albumName); 0082 void createPhotoSet(const QString& name, 0083 const QString& title, 0084 const QString& desc, 0085 const QString& primaryPhotoId); 0086 0087 void addPhotoToPhotoSet(const QString& photoId, const QString& photoSetId); 0088 bool addPhoto(const QString& photoPath, const FPhotoInfo& info, 0089 bool original = false, bool rescale = false, 0090 int maxDim = 600, int imageQuality = 85); 0091 void setGeoLocation(const QString& photoId, const QString& lat, const QString& lon); 0092 0093 public: 0094 0095 QProgressDialog* m_authProgressDlg; 0096 QList<FPhotoSet>* m_photoSetsList; 0097 FPhotoSet m_selectedPhotoSet; 0098 0099 Q_SIGNALS: 0100 0101 void signalError(const QString& msg); 0102 void signalBusy(bool val); 0103 void signalAddPhotoSucceeded(const QString&); 0104 void signalAddPhotoSetSucceeded(); 0105 void signalListPhotoSetsSucceeded(); 0106 void signalListPhotoSetsFailed(QString& msg); 0107 void signalAddPhotoFailed(const QString& msg); 0108 void signalListPhotoSetsFailed(const QString& msg); 0109 void signalLinkingSucceeded(); 0110 0111 private: 0112 0113 /* 0114 void parseResponseLogin(const QByteArray& data); 0115 */ 0116 void parseResponseMaxSize(const QByteArray& data); 0117 void parseResponseListPhotoSets(const QByteArray& data); 0118 void parseResponseListPhotos(const QByteArray& data); 0119 void parseResponseCreateAlbum(const QByteArray& data); 0120 void parseResponseAddPhoto(const QByteArray& data); 0121 void parseResponsePhotoProperty(const QByteArray& data); 0122 void parseResponseCreatePhotoSet(const QByteArray& data); 0123 void parseResponseAddPhotoToPhotoSet(const QByteArray& data); 0124 void parseResponseSetGeoLocation(const QByteArray& data); 0125 0126 private Q_SLOTS: 0127 0128 void slotLinkingFailed(); 0129 void slotLinkingSucceeded(); 0130 void slotCatchUrl(const QUrl& url); 0131 void slotOpenBrowser(const QUrl& url); 0132 void slotError(const QString& msg); 0133 void slotFinished(QNetworkReply* reply); 0134 0135 private: 0136 0137 class Private; 0138 Private* const d; 0139 }; 0140 0141 } // namespace DigikamGenericFlickrPlugin 0142 0143 #endif // DIGIKAM_FLICKR_TALKER_H