Kgapi

locationdeletejob.cpp
1/*
2 * This file is part of LibKGAPI library
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#include "locationdeletejob.h"
10#include "latitudeservice.h"
11#include "location.h"
12
13#include <QNetworkRequest>
14
15using namespace KGAPI2;
16
17class Q_DECL_HIDDEN LocationDeleteJob::Private
18{
19public:
20 Private();
21
22 qulonglong locationId = 0;
23 bool finished = false;
24};
25
26LocationDeleteJob::Private::Private()
27{
28}
29
35
36LocationDeleteJob::LocationDeleteJob(const LocationPtr &location, const AccountPtr &account, QObject *parent)
37 : DeleteJob(account, parent)
38 , d(new Private)
39{
40 d->locationId = location->timestamp();
41}
42
43LocationDeleteJob::LocationDeleteJob(qulonglong timestamp, const AccountPtr &account, QObject *parent)
44 : DeleteJob(account, parent)
45 , d(new Private)
46{
47 d->locationId = timestamp;
48}
49
54
56{
57 if (d->finished) {
59 return;
60 }
61
62 QUrl url;
63 if (d->locationId > 0) {
64 url = LatitudeService::deleteLocationUrl(d->locationId);
65 } else {
67 }
68
69 QNetworkRequest request(url);
70 request.setRawHeader("GData-Version", LatitudeService::APIVersion().toLatin1());
71
72 QStringList headers;
73 const auto rawHeaderList = request.rawHeaderList();
74 headers.reserve(rawHeaderList.size());
75 for (const QByteArray &str : std::as_const(rawHeaderList)) {
76 headers << QLatin1StringView(str) + QLatin1StringView(": ") + QLatin1StringView(request.rawHeader(str));
77 }
78
79 enqueueRequest(request);
80 d->finished = true;
81}
82
83#include "moc_locationdeletejob.cpp"
Abstract superclass for all jobs that delete resources from Google.
Definition deletejob.h:25
AccountPtr account() const
Returns account used to authenticate requests.
Definition job.cpp:436
virtual void emitFinished()
Emits Job::finished() signal.
Definition job.cpp:493
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
Definition job.cpp:513
A job to delete one or more location from user's account on Google Latitude service.
~LocationDeleteJob() override
Destructor.
void start() override
KGAPI2::Job::start implementation.
LocationDeleteJob(const AccountPtr &account, QObject *parent)
Constructs a job that will delete user's current location from his/her Google Latitude account.
QString APIVersion()
Supported version of API.
QUrl deleteLocationUrl(const qlonglong id)
Returns URL to delete a specific location.
QUrl deleteCurrentLocationUrl()
Returns URL for deleting user's current location.
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
void reserve(qsizetype size)
QByteArray rawHeader(const QByteArray &headerName) const const
QList< QByteArray > rawHeaderList() const const
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:11:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.