Kgapi

locationdeletejob.cpp
1 /*
2  * This file is part of LibKGAPI library
3  *
4  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <[email protected]>
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 "account.h"
12 #include "../debug.h"
13 #include "location.h"
14 #include "utils.h"
15 
16 #include <QNetworkRequest>
17 
18 using namespace KGAPI2;
19 
20 class Q_DECL_HIDDEN LocationDeleteJob::Private
21 {
22  public:
23  Private();
24 
25  qulonglong locationId = 0;
26  bool finished = false;
27 };
28 
29 LocationDeleteJob::Private::Private()
30 {
31 }
32 
34  DeleteJob(account, parent),
35  d(new Private)
36 {
37 }
38 
40  const AccountPtr& account, QObject* parent):
41  DeleteJob(account, parent),
42  d(new Private)
43 {
44  d->locationId = location->timestamp();
45 }
46 
48  const AccountPtr &account,
49  QObject *parent):
50  DeleteJob(account, parent),
51  d(new Private)
52 {
53  d->locationId = timestamp;
54 }
55 
57 {
58  delete d;
59 }
60 
62 {
63  if (d->finished) {
64  emitFinished();
65  return;
66  }
67 
68  QUrl url;
69  if (d->locationId > 0) {
70  url = LatitudeService::deleteLocationUrl(d->locationId);
71  } else {
73  }
74 
75  QNetworkRequest request(url);
76  request.setRawHeader("GData-Version", LatitudeService::APIVersion().toLatin1());
77 
78  QStringList headers;
79  const auto rawHeaderList = request.rawHeaderList();
80  headers.reserve(rawHeaderList.size());
81  for (const QByteArray &str : qAsConst(rawHeaderList)) {
82  headers << QLatin1String(str) + QLatin1String(": ") + QLatin1String(request.rawHeader(str));
83  }
84 
85  enqueueRequest(request);
86  d->finished = true;
87 }
88 
89 
AccountPtr account() const
Returns account used to authenticate requests.
Definition: job.cpp:425
QList< QByteArray > rawHeaderList() const const
void reserve(int alloc)
QByteArray rawHeader(const QByteArray &headerName) const const
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
Definition: job.cpp:497
QUrl deleteCurrentLocationUrl()
Returns URL for deleting user&#39;s current location.
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:16
A job to delete one or more location from user&#39;s account on Google Latitude service.
Abstract superclass for all jobs that delete resources from Google.
Definition: deletejob.h:24
QString APIVersion()
Supported version of API.
QUrl deleteLocationUrl(const qlonglong id)
Returns URL to delete a specific location.
virtual void emitFinished()
Emits Job::finished() signal.
Definition: job.cpp:479
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
void start() override
KGAPI2::Job::start implementation.
~LocationDeleteJob() override
Destructor.
LocationDeleteJob(const AccountPtr &account, QObject *parent)
Constructs a job that will delete user&#39;s current location from his/her Google Latitude account...
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Sep 19 2020 23:09:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.