File indexing completed on 2025-01-05 03:53:30
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2015-06-21 0007 * Description : a tool to export items to Google web services 0008 * 0009 * SPDX-FileCopyrightText: 2015 by Shourya Singh Gupta <shouryasgupta at gmail dot com> 0010 * SPDX-FileCopyrightText: 2015-2020 by Caulier Gilles <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_GS_TALKER_BASE_H 0018 #define DIGIKAM_GS_TALKER_BASE_H 0019 0020 // Qt includes 0021 0022 #include <QUrl> 0023 #include <QString> 0024 #include <QObject> 0025 #include <QStringList> 0026 #include <QNetworkReply> 0027 #include <QOAuth2AuthorizationCodeFlow> 0028 0029 namespace DigikamGenericGoogleServicesPlugin 0030 { 0031 0032 class GSTalkerBase : public QObject 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 0038 explicit GSTalkerBase(QObject* const parent, const QStringList& scope, const QString& serviceName); 0039 ~GSTalkerBase() override; 0040 0041 public: 0042 0043 void link(); 0044 void unlink(); 0045 void doOAuth(); 0046 bool authenticated() const; 0047 0048 Q_SIGNALS: 0049 0050 void signalBusy(bool val); 0051 void signalLinkingSucceeded(); 0052 void signalAccessTokenObtained(); 0053 void signalAuthenticationRefused(); 0054 0055 private Q_SLOTS: 0056 0057 void slotLinkingFailed(); 0058 void slotLinkingSucceeded(); 0059 void slotOpenBrowser(const QUrl& url); 0060 void slotTokenChanged(const QString& token); 0061 0062 private: 0063 0064 void parseResponseGetLoggedInUser(const QByteArray& data); 0065 0066 protected: 0067 0068 QStringList m_scope; 0069 QString m_accessToken; 0070 QString m_bearerAccessToken; 0071 0072 QString m_serviceName; 0073 0074 QNetworkReply* m_reply; 0075 QOAuth2AuthorizationCodeFlow* m_service; 0076 0077 private: 0078 0079 class Private; 0080 Private* const d; 0081 }; 0082 0083 } // namespace DigikamGenericGoogleServicesPlugin 0084 0085 #endif // DIGIKAM_GS_TALKER_BASE_H