Kgapi

authjob.h
1/*
2 * This file is part of LibKGAPI
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#pragma once
10
11#include "job.h"
12#include "kgapicore_export.h"
13
14class QWidget;
15
16namespace KGAPI2
17{
18
19/**
20 * @headerfile authjob.h
21 * @brief A job to authenticate against Google and fetch tokens
22 *
23 * This job can be either used to refresh expired tokens (this is usually done
24 * automatically by Job implementation), or to request tokens for a new account.
25 *
26 * In the latter case, the AuthJob will automatically open a browser window
27 * where user has to provide Google account credentials and grant access to all
28 * requested scopes (@see Account::scopes).
29 *
30 * @author Daniel Vrátil <dvratil@redhat.com>
31 * @since 2.0
32 */
33class KGAPICORE_EXPORT AuthJob : public KGAPI2::Job
34{
35 Q_OBJECT
36
37public:
38 /**
39 * @brief Creates a new authentication job
40 *
41 * When constructed without a parent, or with a non-QWidget parent, the
42 * job might pop up the authentication dialog.
43 *
44 * @param account Account to authenticate.
45 * @param apiKey Application API key
46 * @param secretKey Application secret API key
47 * @param parent
48 */
49 explicit AuthJob(const AccountPtr &account, const QString &apiKey, const QString &secretKey, QObject *parent = nullptr);
50
51 /**
52 * @brief Destructor
53 */
54 ~AuthJob() override;
55
56 /**
57 * @brief Returns reauthenticated account.
58 *
59 * @returns An account pointer passed to the AuthJob() constructor with
60 * all fields filled and validated. When the job fails, the account
61 * is unchanged.
62 */
63 AccountPtr account() const;
64
65 /**
66 * Sets the username that will be used when authenticate is called
67 *
68 * @param username username to use
69 */
70 void setUsername(const QString &username);
71
72 /**
73 * Sets the password that will be used when authenticate is called
74 *
75 * @param password password to use
76 * @deprecated
77 */
78 QT_DEPRECATED_X("It's no longer possible to prefill password")
79 void setPassword(const QString &password);
80
81protected:
82 /**
83 * @brief KGAPI2::Job::handleReply implementation
84 *
85 * @param reply
86 * @param rawData
87 */
88 void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override;
89
90 /**
91 * @brief KGAPI2::Job::displayRequest implementation
92 *
93 * @param accessManager
94 * @param request
95 * @param data
96 * @param contentType
97 */
98 void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override;
99
100 /**
101 * @brief KGAPI2::Job::start implementation
102 */
103 void start() override;
104
105private:
106 class Private;
107 QScopedPointer<Private> const d;
108 friend class Private;
109};
110
111} // namespace KGAPI2
A job to authenticate against Google and fetch tokens.
Definition authjob.h:34
~AuthJob() override
Destructor.
Abstract base class for all jobs in LibKGAPI.
Definition job.h:41
Q_SCRIPTABLE Q_NOREPLY void start()
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.