1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2015-06-21 7 * Description : a tool to export items to Google web services 8 * 9 * Copyright (C) 2015 by Shourya Singh Gupta <shouryasgupta at gmail dot com> 10 * Copyright (C) 2015-2020 by Caulier Gilles <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_GS_TALKER_BASE_H 26 #define DIGIKAM_GS_TALKER_BASE_H 27 28 // Qt includes 29 30 #include <QUrl> 31 #include <QString> 32 #include <QObject> 33 #include <QStringList> 34 #include <QNetworkReply> 35 #include <QNetworkAccessManager> 36 37 // O2 includes 38 39 #include "o2.h" 40 41 namespace DigikamGenericGoogleServicesPlugin 42 { 43 44 class GSTalkerBase : public QObject 45 { 46 Q_OBJECT 47 48 public: 49 50 explicit GSTalkerBase(QWidget* const parent, const QStringList& scope, const QString& serviceName); 51 ~GSTalkerBase() override; 52 53 public: 54 55 void link(); 56 void unlink(); 57 void doOAuth(); 58 bool authenticated() const; 59 60 Q_SIGNALS: 61 62 void signalBusy(bool val); 63 void signalLinkingSucceeded(); 64 void signalAccessTokenObtained(); 65 void signalAuthenticationRefused(); 66 67 private Q_SLOTS: 68 69 void slotLinkingFailed(); 70 void slotLinkingSucceeded(); 71 void slotOpenBrowser(const QUrl& url); 72 73 private: 74 75 void parseResponseGetLoggedInUser(const QByteArray& data); 76 77 protected: 78 79 QStringList m_scope; 80 QString m_accessToken; 81 82 QString m_bearerAccessToken; 83 84 QNetworkReply* m_reply; 85 QString m_serviceName; 86 87 private: 88 89 class Private; 90 Private* const d; 91 }; 92 93 } // namespace DigikamGenericGoogleServicesPlugin 94 95 #endif // DIGIKAM_GS_TALKER_BASE_H 96