Changeset View
Changeset View
Standalone View
Standalone View
src/drive/changefetchjob.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | using namespace KGAPI2; | 34 | using namespace KGAPI2; | ||
35 | using namespace KGAPI2::Drive; | 35 | using namespace KGAPI2::Drive; | ||
36 | 36 | | |||
37 | class Q_DECL_HIDDEN ChangeFetchJob::Private | 37 | class Q_DECL_HIDDEN ChangeFetchJob::Private | ||
38 | { | 38 | { | ||
39 | public: | 39 | public: | ||
40 | Private(ChangeFetchJob *parent); | 40 | Private(ChangeFetchJob *parent); | ||
41 | QNetworkRequest createRequest(const QUrl &url); | | |||
42 | 41 | | |||
43 | QString changeId; | 42 | QString changeId; | ||
44 | 43 | | |||
45 | bool includeDeleted; | 44 | bool includeDeleted; | ||
46 | bool includeSubscribed; | 45 | bool includeSubscribed; | ||
47 | int maxResults; | 46 | int maxResults; | ||
48 | qlonglong startChangeId; | 47 | qlonglong startChangeId; | ||
49 | bool includeItemsFromAllDrives; | 48 | bool includeItemsFromAllDrives; | ||
Show All 9 Lines | 55 | ChangeFetchJob::Private::Private(ChangeFetchJob *parent): | |||
59 | maxResults(0), | 58 | maxResults(0), | ||
60 | startChangeId(0), | 59 | startChangeId(0), | ||
61 | includeItemsFromAllDrives(true), | 60 | includeItemsFromAllDrives(true), | ||
62 | supportsAllDrives(true), | 61 | supportsAllDrives(true), | ||
63 | q(parent) | 62 | q(parent) | ||
64 | { | 63 | { | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | QNetworkRequest ChangeFetchJob::Private::createRequest(const QUrl &url) | | |||
68 | { | | |||
69 | QNetworkRequest request; | | |||
70 | request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); | | |||
71 | request.setUrl(url); | | |||
72 | | ||||
73 | return request; | | |||
74 | } | | |||
75 | | ||||
76 | | ||||
77 | ChangeFetchJob::ChangeFetchJob(const QString &changeId, | 66 | ChangeFetchJob::ChangeFetchJob(const QString &changeId, | ||
78 | const AccountPtr &account, | 67 | const AccountPtr &account, | ||
79 | QObject *parent): | 68 | QObject *parent): | ||
80 | FetchJob(account, parent), | 69 | FetchJob(account, parent), | ||
81 | d(new Private(this)) | 70 | d(new Private(this)) | ||
82 | { | 71 | { | ||
83 | d->changeId = changeId; | 72 | d->changeId = changeId; | ||
84 | } | 73 | } | ||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 166 | { | |||
192 | } else { | 181 | } else { | ||
193 | url = DriveService::fetchChangeUrl(d->changeId); | 182 | url = DriveService::fetchChangeUrl(d->changeId); | ||
194 | } | 183 | } | ||
195 | 184 | | |||
196 | QUrlQuery query(url); | 185 | QUrlQuery query(url); | ||
197 | query.addQueryItem(QStringLiteral("supportsAllDrives"), d->supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); | 186 | query.addQueryItem(QStringLiteral("supportsAllDrives"), d->supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); | ||
198 | url.setQuery(query); | 187 | url.setQuery(query); | ||
199 | 188 | | |||
200 | const QNetworkRequest request = d->createRequest(url); | 189 | QNetworkRequest request(url); | ||
201 | enqueueRequest(request); | 190 | enqueueRequest(request); | ||
202 | } | 191 | } | ||
203 | 192 | | |||
204 | 193 | | |||
205 | ObjectsList ChangeFetchJob::handleReplyWithItems(const QNetworkReply *reply, | 194 | ObjectsList ChangeFetchJob::handleReplyWithItems(const QNetworkReply *reply, | ||
206 | const QByteArray &rawData) | 195 | const QByteArray &rawData) | ||
207 | { | 196 | { | ||
208 | FeedData feedData; | 197 | FeedData feedData; | ||
Show All 13 Lines | |||||
222 | } else { | 211 | } else { | ||
223 | setError(KGAPI2::InvalidResponse); | 212 | setError(KGAPI2::InvalidResponse); | ||
224 | setErrorString(tr("Invalid response content type")); | 213 | setErrorString(tr("Invalid response content type")); | ||
225 | emitFinished(); | 214 | emitFinished(); | ||
226 | return items; | 215 | return items; | ||
227 | } | 216 | } | ||
228 | 217 | | |||
229 | if (feedData.nextPageUrl.isValid()) { | 218 | if (feedData.nextPageUrl.isValid()) { | ||
230 | const QNetworkRequest request = d->createRequest(feedData.nextPageUrl); | 219 | QNetworkRequest request(feedData.nextPageUrl); | ||
231 | enqueueRequest(request); | 220 | enqueueRequest(request); | ||
232 | } | 221 | } | ||
233 | 222 | | |||
234 | return items; | 223 | return items; | ||
235 | } | 224 | } | ||
236 | 225 | | |||
237 | 226 | |