Kgapi

eventdeletejob.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 "eventdeletejob.h"
10#include "calendarservice.h"
11#include "event.h"
12#include "private/queuehelper_p.h"
13
14#include <QNetworkRequest>
15
16using namespace KGAPI2;
17
18class Q_DECL_HIDDEN EventDeleteJob::Private
19{
20public:
21 QueueHelper<QString> eventsIds;
22 QString calendarId;
23};
24
25EventDeleteJob::EventDeleteJob(const EventPtr &event, const QString &calendarId, const AccountPtr &account, QObject *parent)
26 : DeleteJob(account, parent)
27 , d(new Private)
28{
29 d->eventsIds << event->id();
30 d->calendarId = calendarId;
31}
32
33EventDeleteJob::EventDeleteJob(const EventsList &events, const QString &calendarId, const AccountPtr &account, QObject *parent)
34 : DeleteJob(account, parent)
35 , d(new Private)
36{
37 for (const EventPtr &event : events) {
38 d->eventsIds << event->id();
39 }
40 d->calendarId = calendarId;
41}
42
43EventDeleteJob::EventDeleteJob(const QString &eventId, const QString &calendarId, const AccountPtr &account, QObject *parent)
44 : DeleteJob(account, parent)
45 , d(new Private)
46{
47 d->eventsIds << eventId;
48 d->calendarId = calendarId;
49}
50
51EventDeleteJob::EventDeleteJob(const QStringList &eventIds, const QString &calendarId, const AccountPtr &account, QObject *parent)
52 : DeleteJob(account, parent)
53 , d(new Private)
54{
55 d->eventsIds = eventIds;
56 d->calendarId = calendarId;
57}
58
60
62{
63 if (d->eventsIds.atEnd()) {
65 return;
66 }
67
68 const QString eventId = d->eventsIds.current();
69 const auto request = CalendarService::prepareRequest(CalendarService::removeEventUrl(d->calendarId, eventId));
70
71 enqueueRequest(request);
72}
73
74void EventDeleteJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
75{
76 d->eventsIds.currentProcessed();
77
78 KGAPI2::DeleteJob::handleReply(reply, rawData);
79}
Abstract superclass for all jobs that delete resources from Google.
Definition deletejob.h:25
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
Definition deletejob.cpp:58
A job to delete one or more events from calendar in user's Google Calendar account.
void start() override
KGAPI2::Job::start implementation.
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
EventDeleteJob(const EventPtr &event, const QString &calendarId, const AccountPtr &account, QObject *parent)
Constructs a new job that will delete given event from a calendar with given calendarId.
~EventDeleteJob() override
Destructor.
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
QNetworkRequest prepareRequest(const QUrl &url)
Preparse a QNetworkRequest for given URL.
QUrl removeEventUrl(const QString &calendarID, const QString &eventID)
Returns URL for removing events.
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
virtual bool event(QEvent *e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:11 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.