9#include "changefetchjob.h"
12#include "driveservice.h"
15#include <QNetworkReply>
16#include <QNetworkRequest>
20using namespace KGAPI2::Drive;
22class Q_DECL_HIDDEN ChangeFetchJob::Private
25 Private(ChangeFetchJob *parent);
29 bool includeDeleted =
true;
30 bool includeSubscribed =
true;
32 qlonglong startChangeId = 0;
33 bool includeItemsFromAllDrives =
true;
34 bool supportsAllDrives =
true;
37 ChangeFetchJob *
const q;
40ChangeFetchJob::Private::Private(ChangeFetchJob *parent)
47 , d(new Private(this))
49 d->changeId = changeId;
54 , d(new Private(this))
58ChangeFetchJob::~ChangeFetchJob()
63void ChangeFetchJob::setIncludeDeleted(
bool includeDeleted)
66 qCWarning(KGAPIDebug) <<
"Can't modify includeDeleted property when job is running";
70 d->includeDeleted = includeDeleted;
73bool ChangeFetchJob::includeDeleted()
const
75 return d->includeDeleted;
78void ChangeFetchJob::setIncludeSubscribed(
bool includeSubscribed)
81 qCWarning(KGAPIDebug) <<
"Can't modify includeSubscribed property when job is running";
85 d->includeSubscribed = includeSubscribed;
88bool ChangeFetchJob::includeSubscribed()
const
90 return d->includeSubscribed;
93void ChangeFetchJob::setMaxResults(
int maxResults)
96 qCWarning(KGAPIDebug) <<
"Can't modify maxResults property when job is running";
100 d->maxResults = maxResults;
103int ChangeFetchJob::maxResults()
const
105 return d->maxResults;
108void ChangeFetchJob::setStartChangeId(qlonglong startChangeId)
111 qCWarning(KGAPIDebug) <<
"Can't modify startChangeId property when job is running";
114 d->startChangeId = startChangeId;
117qlonglong ChangeFetchJob::startChangeId()
const
119 return d->startChangeId;
122bool ChangeFetchJob::includeItemsFromAllDrives()
const
124 return d->includeItemsFromAllDrives;
127void ChangeFetchJob::setIncludeItemsFromAllDrives(
bool includeItemsFromAllDrives)
129 d->includeItemsFromAllDrives = includeItemsFromAllDrives;
132bool ChangeFetchJob::supportsAllDrives()
const
134 return d->supportsAllDrives;
137void ChangeFetchJob::setSupportsAllDrives(
bool supportsAllDrives)
139 d->supportsAllDrives = supportsAllDrives;
142void ChangeFetchJob::start()
146 url = DriveService::fetchChangesUrl();
148 query.addQueryItem(QStringLiteral(
"includeDeleted"), Utils::bool2Str(d->includeDeleted));
149 query.addQueryItem(QStringLiteral(
"includeSubscribed"), Utils::bool2Str(d->includeSubscribed));
150 if (d->maxResults > 0) {
153 if (d->startChangeId > 0) {
156 query.addQueryItem(QStringLiteral(
"includeItemsFromAllDrives"), Utils::bool2Str(d->includeItemsFromAllDrives));
159 url = DriveService::fetchChangeUrl(d->changeId);
163 query.addQueryItem(QStringLiteral(
"supportsAllDrives"), Utils::bool2Str(d->supportsAllDrives));
178 ContentType ct = Utils::stringToContentType(contentType);
179 if (ct == KGAPI2::JSON) {
181 items << Change::fromJSONFeed(rawData, feedData);
183 items << Change::fromJSON(rawData);
200#include "moc_changefetchjob.cpp"
Structure to store additional information about a feed.
QUrl requestUrl
Original URL of the request.
QUrl nextPageUrl
Link to next page of feed.
Abstract superclass for all jobs that fetch resources from Google.
virtual ObjectsList items() const
Returns all items fetched by this job.
void setErrorString(const QString &errorString)
Set job error description to errorString.
virtual void emitFinished()
Emits Job::finished() signal.
void setError(KGAPI2::Error error)
Set job error to error.
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
bool isRunning
Whether the job is running.
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
@ InvalidResponse
LibKGAPI error - Google returned invalid response.
QString tr(const char *sourceText, const char *disambiguation, int n)
bool isEmpty() const const
QString number(double n, char format, int precision)
bool isValid() const const
void setQuery(const QString &query, ParsingMode mode)
QString toString() const const