Akonadi

tagmodifyjob.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "tagmodifyjob.h"
8#include "job_p.h"
9#include "protocolhelper_p.h"
10#include "tag.h"
11#include "tag_p.h"
12
13using namespace Akonadi;
14
15class Akonadi::TagModifyJobPrivate : public JobPrivate
16{
17public:
18 explicit TagModifyJobPrivate(TagModifyJob *parent)
19 : JobPrivate(parent)
20 {
21 }
22
23 QString jobDebuggingString() const override;
24 Tag mTag;
25};
26
27QString Akonadi::TagModifyJobPrivate::jobDebuggingString() const
28{
29 return QStringLiteral("Modify Tag: %1").arg(mTag.name());
30}
31
33 : Job(new TagModifyJobPrivate(this), parent)
34{
36 d->mTag = tag;
37}
38
40{
42
43 auto cmd = Protocol::ModifyTagCommandPtr::create(d->mTag.id());
44 if (!d->mTag.remoteId().isNull()) {
45 cmd->setRemoteId(d->mTag.remoteId());
46 }
47 if (!d->mTag.type().isEmpty()) {
48 cmd->setType(d->mTag.type());
49 }
50 if (d->mTag.parent().isValid() && !d->mTag.isImmutable()) {
51 cmd->setParentId(d->mTag.parent().id());
52 }
53 if (!d->mTag.d_ptr->mAttributeStorage.deletedAttributes().isEmpty()) {
54 cmd->setRemovedAttributes(d->mTag.d_ptr->mAttributeStorage.deletedAttributes());
55 }
56 if (d->mTag.d_ptr->mAttributeStorage.hasModifiedAttributes()) {
57 cmd->setAttributes(ProtocolHelper::attributesToProtocol(d->mTag.d_ptr->mAttributeStorage.modifiedAttributes()));
58 }
59
60 d->sendCommand(cmd);
61}
62
64{
66
67 if (response->isResponse()) {
68 if (response->type() == Protocol::Command::FetchTags || response->type() == Protocol::Command::DeleteTag) {
69 // Tag was modified, deleted or merged, we ignore the response for now
70 return false;
71 } else if (response->type() == Protocol::Command::ModifyTag) {
72 // Done.
73 d->mTag.d_ptr->resetChangeLog();
74 return true;
75 }
76 }
77
78 return Job::doHandleResponse(tag, response);
79}
80
81#include "moc_tagmodifyjob.cpp"
Base class for all actions in the Akonadi storage.
Definition job.h:81
virtual bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
Definition job.cpp:381
Job that modifies a tag in the Akonadi storage.
void doStart() override
This method must be reimplemented in the concrete jobs.
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
TagModifyJob(const Tag &tag, QObject *parent=nullptr)
Creates a new tag modify job.
Tag tag() const
Returns the modified tag.
An Akonadi Tag.
Definition tag.h:26
Helper integration between Akonadi and Qt.
QString arg(Args &&... args) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.