Changeset View
Changeset View
Standalone View
Standalone View
src/core/job.cpp
Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Line(s) | 317 | { | |||
---|---|---|---|---|---|
325 | 325 | | |||
326 | QNetworkRequest authorizedRequest = r.request; | 326 | QNetworkRequest authorizedRequest = r.request; | ||
327 | if (account) { | 327 | if (account) { | ||
328 | authorizedRequest.setRawHeader("Authorization", "Bearer " + account->accessToken().toLatin1()); | 328 | authorizedRequest.setRawHeader("Authorization", "Bearer " + account->accessToken().toLatin1()); | ||
329 | } | 329 | } | ||
330 | 330 | | |||
331 | QUrl url = authorizedRequest.url(); | 331 | QUrl url = authorizedRequest.url(); | ||
332 | QUrlQuery standardParamQuery(url); | 332 | QUrlQuery standardParamQuery(url); | ||
333 | if (!fields.isEmpty()) { | ||||
334 | standardParamQuery.addQueryItem(Job::StandardParams::Fields, fields.join(QStringLiteral(","))); | ||||
335 | } | ||||
333 | 336 | | |||
334 | if (!standardParamQuery.hasQueryItem(Job::StandardParams::PrettyPrint)) { | 337 | if (!standardParamQuery.hasQueryItem(Job::StandardParams::PrettyPrint)) { | ||
335 | standardParamQuery.addQueryItem(Job::StandardParams::PrettyPrint, prettyPrint ? QStringLiteral("true") : QStringLiteral("false")); | 338 | standardParamQuery.addQueryItem(Job::StandardParams::PrettyPrint, prettyPrint ? QStringLiteral("true") : QStringLiteral("false")); | ||
336 | } | 339 | } | ||
337 | 340 | | |||
338 | url.setQuery(standardParamQuery); | 341 | url.setQuery(standardParamQuery); | ||
339 | authorizedRequest.setUrl(url); | 342 | authorizedRequest.setUrl(url); | ||
340 | 343 | | |||
341 | qCDebug(KGAPIDebug) << q << "Dispatching request to" << r.request.url(); | 344 | qCDebug(KGAPIDebug) << q << "Dispatching request to" << r.request.url(); | ||
342 | FileLogger::self()->logRequest(authorizedRequest, r.rawData); | 345 | FileLogger::self()->logRequest(authorizedRequest, r.rawData); | ||
343 | 346 | | |||
344 | q->dispatchRequest(accessManager, authorizedRequest, r.rawData, r.contentType); | 347 | q->dispatchRequest(accessManager, authorizedRequest, r.rawData, r.contentType); | ||
345 | 348 | | |||
346 | if (requestQueue.isEmpty()) { | 349 | if (requestQueue.isEmpty()) { | ||
347 | dispatchTimer->stop(); | 350 | dispatchTimer->stop(); | ||
348 | } | 351 | } | ||
349 | } | 352 | } | ||
350 | 353 | | |||
351 | /************************* PUBLIC **********************/ | 354 | /************************* PUBLIC **********************/ | ||
352 | 355 | | |||
353 | const QString Job::StandardParams::PrettyPrint = QStringLiteral("prettyPrint"); | 356 | const QString Job::StandardParams::PrettyPrint = QStringLiteral("prettyPrint"); | ||
357 | const QString Job::StandardParams::Fields = QStringLiteral("fields"); | ||||
354 | 358 | | |||
355 | Job::Job(QObject* parent): | 359 | Job::Job(QObject* parent): | ||
356 | QObject(parent), | 360 | QObject(parent), | ||
357 | d(new Private(this)) | 361 | d(new Private(this)) | ||
358 | { | 362 | { | ||
359 | d->init(); | 363 | d->init(); | ||
360 | } | 364 | } | ||
361 | 365 | | |||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
448 | { | 452 | { | ||
449 | if (d->isRunning) { | 453 | if (d->isRunning) { | ||
450 | qCWarning(KGAPIDebug) << "Called setPrettyPrint() on running job. Ignoring."; | 454 | qCWarning(KGAPIDebug) << "Called setPrettyPrint() on running job. Ignoring."; | ||
451 | return; | 455 | return; | ||
452 | } | 456 | } | ||
453 | 457 | | |||
454 | d->prettyPrint = prettyPrint; | 458 | d->prettyPrint = prettyPrint; | ||
455 | } | 459 | } | ||
460 | | ||||
461 | QStringList Job::fields() const | ||||
462 | { | ||||
463 | return d->fields; | ||||
464 | } | ||||
465 | | ||||
466 | void Job::setFields(const QStringList &fields) | ||||
467 | { | ||||
468 | d->fields = fields; | ||||
469 | } | ||||
470 | | ||||
471 | QString Job::buildSubfields(const QString &field, const QStringList &fields) { | ||||
472 | return QStringLiteral("%1(%2)").arg(field).arg(fields.join(QStringLiteral(","))); | ||||
473 | } | ||||
474 | | ||||
456 | void Job::restart() | 475 | void Job::restart() | ||
457 | { | 476 | { | ||
458 | if (d->isRunning) { | 477 | if (d->isRunning) { | ||
459 | qCWarning(KGAPIDebug) << "Running job cannot be restarted."; | 478 | qCWarning(KGAPIDebug) << "Running job cannot be restarted."; | ||
460 | return; | 479 | return; | ||
461 | } | 480 | } | ||
462 | 481 | | |||
463 | QTimer::singleShot(0, this, [this]() { d->_k_doStart();}); | 482 | QTimer::singleShot(0, this, [this]() { d->_k_doStart();}); | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |