File indexing completed on 2023-09-24 08:19:51
0001 /* ============================================================ 0002 * 0003 * This file is a part of KDE project 0004 * 0005 * 0006 * Date : 2005-07-07 0007 * Description : a kipi plugin to export images to Flickr web service 0008 * 0009 * Copyright (C) 2005-2009 by Vardhman Jain <vardhman at gmail dot com> 0010 * Copyright (C) 2009-2018 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * Copyright (C) 2017 by Maik Qualmann <metzpinguin at gmail dot com> 0012 * 0013 * This program is free software; you can redistribute it 0014 * and/or modify it under the terms of the GNU General 0015 * Public License as published by the Free Software Foundation; 0016 * either version 2, or (at your option) any later version. 0017 * 0018 * This program is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * ============================================================ */ 0024 0025 #ifndef FLICKRTALKER_H 0026 #define FLICKRTALKER_H 0027 0028 // Qt includes 0029 0030 #include <QUrl> 0031 #include <QList> 0032 #include <QPair> 0033 #include <QString> 0034 #include <QObject> 0035 #include <QNetworkReply> 0036 #include <QNetworkAccessManager> 0037 0038 // Libkipi includes 0039 0040 #include <KIPI/Interface> 0041 0042 // Local includes 0043 0044 #include "flickritem.h" 0045 #include "o1.h" 0046 #include "o0globals.h" 0047 #include "o1requestor.h" 0048 #include "o0settingsstore.h" 0049 0050 class QProgressDialog; 0051 0052 using namespace KIPI; 0053 0054 namespace KIPIFlickrPlugin 0055 { 0056 0057 class GAlbum; 0058 class GPhoto; 0059 class FPhotoInfo; 0060 class FPhotoSet; 0061 0062 class FlickrTalker : public QObject 0063 { 0064 Q_OBJECT 0065 0066 public: 0067 0068 enum State 0069 { 0070 FE_LOGOUT = -1, 0071 FE_LOGIN = 0, 0072 FE_LISTPHOTOSETS, 0073 FE_LISTPHOTOS, 0074 FE_GETPHOTOPROPERTY, 0075 FE_ADDPHOTO, 0076 FE_CREATEPHOTOSET, 0077 FE_ADDPHOTOTOPHOTOSET, 0078 FE_GETMAXSIZE 0079 }; 0080 0081 public: 0082 0083 FlickrTalker(QWidget* const parent, const QString& serviceName); 0084 ~FlickrTalker(); 0085 0086 void link(const QString& userName); 0087 void unLink(); 0088 void removeUserName(const QString& userName); 0089 QString getUserName() const; 0090 QString getUserId() const; 0091 void maxAllowedFileSize(); 0092 QString getMaxAllowedFileSize(); 0093 void getPhotoProperty(const QString& method, const QStringList& argList); 0094 void cancel(); 0095 0096 void listPhotoSets(); 0097 void listPhotos(const QString& albumName); 0098 void createPhotoSet(const QString& name, 0099 const QString& title, 0100 const QString& desc, 0101 const QString& primaryPhotoId); 0102 0103 void addPhotoToPhotoSet(const QString& photoId, const QString& photoSetId); 0104 bool addPhoto(const QString& photoPath, const FPhotoInfo& info, 0105 bool original = false, bool rescale = false, 0106 int maxDim = 600, int imageQuality = 85); 0107 0108 public: 0109 0110 QProgressDialog* m_authProgressDlg; 0111 QLinkedList <FPhotoSet>* m_photoSetsList; 0112 FPhotoSet m_selectedPhotoSet; 0113 0114 Q_SIGNALS: 0115 0116 void signalError(const QString& msg); 0117 void signalBusy(bool val); 0118 void signalAddPhotoSucceeded(); 0119 void signalAddPhotoSetSucceeded(); 0120 void signalListPhotoSetsSucceeded(); 0121 void signalListPhotoSetsFailed(QString& msg); 0122 void signalAddPhotoFailed(const QString& msg); 0123 void signalListPhotoSetsFailed(const QString& msg); 0124 void signalLinkingSucceeded(); 0125 0126 private: 0127 0128 // void parseResponseLogin(const QByteArray& data); 0129 void parseResponseMaxSize(const QByteArray& data); 0130 void parseResponseListPhotoSets(const QByteArray& data); 0131 void parseResponseListPhotos(const QByteArray& data); 0132 void parseResponseCreateAlbum(const QByteArray& data); 0133 void parseResponseAddPhoto(const QByteArray& data); 0134 void parseResponsePhotoProperty(const QByteArray& data); 0135 void parseResponseCreatePhotoSet(const QByteArray& data); 0136 void parseResponseAddPhotoToPhotoSet(const QByteArray& data); 0137 0138 private Q_SLOTS: 0139 0140 void slotLinkingFailed(); 0141 void slotLinkingSucceeded(); 0142 void slotOpenBrowser(const QUrl& url); 0143 void slotError(const QString& msg); 0144 void slotFinished(QNetworkReply* reply); 0145 0146 private: 0147 0148 QWidget* m_parent; 0149 QByteArray m_buffer; 0150 0151 QString m_serviceName; 0152 QString m_apiUrl; 0153 QString m_authUrl; 0154 QString m_tokenUrl; 0155 QString m_accessUrl; 0156 QString m_uploadUrl; 0157 QString m_apikey; 0158 QString m_secret; 0159 QString m_maxSize; 0160 QString m_username; 0161 QString m_userId; 0162 QString m_lastTmpFile; 0163 0164 QNetworkAccessManager* m_netMngr; 0165 QNetworkReply* m_reply; 0166 0167 QSettings* m_settings; 0168 0169 State m_state; 0170 0171 Interface* m_iface; 0172 0173 O1* m_o1; 0174 O0SettingsStore* m_store; 0175 O1Requestor* m_requestor; 0176 }; 0177 0178 } // namespace KIPIFlickrPlugin 0179 0180 #endif /* FLICKRTALKER_H */