Changeset View
Changeset View
Standalone View
Standalone View
src/calendar/eventmodifyjob.cpp
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
| 53 | EventModifyJob::EventModifyJob(const EventsList& events, const QString& calendarId, const AccountPtr& account, QObject* parent): | 53 | EventModifyJob::EventModifyJob(const EventsList& events, const QString& calendarId, const AccountPtr& account, QObject* parent): | ||
| 54 | ModifyJob(account, parent), | 54 | ModifyJob(account, parent), | ||
| 55 | d(new Private) | 55 | d(new Private) | ||
| 56 | { | 56 | { | ||
| 57 | d->events = events; | 57 | d->events = events; | ||
| 58 | d->calendarId = calendarId; | 58 | d->calendarId = calendarId; | ||
| 59 | } | 59 | } | ||
| 60 | 60 | | |||
| 61 | EventModifyJob::~EventModifyJob() | 61 | EventModifyJob::~EventModifyJob() = default; | ||
| 62 | { | | |||
| 63 | delete d; | | |||
| 64 | } | | |||
| 65 | 62 | | |||
| 66 | void EventModifyJob::setSendUpdates(KGAPI2::SendUpdatesPolicy updatesPolicy) | 63 | void EventModifyJob::setSendUpdates(KGAPI2::SendUpdatesPolicy updatesPolicy) | ||
| 67 | { | 64 | { | ||
| 68 | if (d->updatesPolicy != updatesPolicy) { | 65 | if (d->updatesPolicy != updatesPolicy) { | ||
| 69 | d->updatesPolicy = updatesPolicy; | 66 | d->updatesPolicy = updatesPolicy; | ||
| 70 | Q_EMIT sendUpdatesChanged(d->updatesPolicy); | 67 | Q_EMIT sendUpdatesChanged(d->updatesPolicy); | ||
| 71 | } | 68 | } | ||
| 72 | } | 69 | } | ||
| 73 | 70 | | |||
| 74 | SendUpdatesPolicy EventModifyJob::sendUpdates() const | 71 | SendUpdatesPolicy EventModifyJob::sendUpdates() const | ||
| 75 | { | 72 | { | ||
| 76 | return d->updatesPolicy; | 73 | return d->updatesPolicy; | ||
| 77 | } | 74 | } | ||
| 78 | 75 | | |||
| 79 | void EventModifyJob::start() | 76 | void EventModifyJob::start() | ||
| 80 | { | 77 | { | ||
| 81 | if (d->events.atEnd()) { | 78 | if (d->events.atEnd()) { | ||
| 82 | emitFinished(); | 79 | emitFinished(); | ||
| 83 | return; | 80 | return; | ||
| 84 | } | 81 | } | ||
| 85 | 82 | | |||
| 86 | const EventPtr event = d->events.current(); | 83 | const EventPtr event = d->events.current(); | ||
| 87 | const QUrl url = CalendarService::updateEventUrl(d->calendarId, event->id(), d->updatesPolicy); | 84 | const auto request = CalendarService::prepareRequest(CalendarService::updateEventUrl(d->calendarId, event->id(), d->updatesPolicy)); | ||
| 88 | QNetworkRequest request(url); | | |||
| 89 | request.setRawHeader("GData-Version", CalendarService::APIVersion().toLatin1()); | | |||
| 90 | | ||||
| 91 | const QByteArray rawData = CalendarService::eventToJSON(event); | 85 | const QByteArray rawData = CalendarService::eventToJSON(event); | ||
| 92 | 86 | | |||
| 93 | QStringList headers; | | |||
| 94 | auto rawHeaderList = request.rawHeaderList(); | | |||
| 95 | headers.reserve(rawHeaderList.size()); | | |||
| 96 | for (const QByteArray &str : qAsConst(rawHeaderList)) { | | |||
| 97 | headers << QLatin1String(str) + QLatin1String(": ") + QLatin1String(request.rawHeader(str)); | | |||
| 98 | } | | |||
| 99 | | ||||
| 100 | enqueueRequest(request, rawData, QStringLiteral("application/json")); | 87 | enqueueRequest(request, rawData, QStringLiteral("application/json")); | ||
| 101 | } | 88 | } | ||
| 102 | 89 | | |||
| 103 | ObjectsList EventModifyJob::handleReplyWithItems(const QNetworkReply *reply, const QByteArray& rawData) | 90 | ObjectsList EventModifyJob::handleReplyWithItems(const QNetworkReply *reply, const QByteArray& rawData) | ||
| 104 | { | 91 | { | ||
| 105 | const QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); | 92 | const QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); | ||
| 106 | ContentType ct = Utils::stringToContentType(contentType); | 93 | ContentType ct = Utils::stringToContentType(contentType); | ||
| 107 | ObjectsList items; | 94 | ObjectsList items; | ||
| Show All 16 Lines | |||||