Akonadi

relationcreatejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Christian Mollekopf <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "relationcreatejob.h"
8 #include "akonadicore_debug.h"
9 #include "job_p.h"
10 #include "private/protocol_p.h"
11 #include "protocolhelper_p.h"
12 #include "relation.h"
13 #include <KLocalizedString>
14 
15 using namespace Akonadi;
16 
17 class Akonadi::RelationCreateJobPrivate : public JobPrivate
18 {
19 public:
20  explicit RelationCreateJobPrivate(RelationCreateJob *parent)
21  : JobPrivate(parent)
22  {
23  }
24 
25  Relation mRelation;
26 };
27 
29  : Job(new RelationCreateJobPrivate(this), parent)
30 {
32  d->mRelation = relation;
33 }
34 
36 {
38 
39  if (!d->mRelation.isValid()) {
40  qCWarning(AKONADICORE_LOG) << "The relation is invalid";
42  setErrorText(i18n("Failed to create relation."));
43  emitResult();
44  return;
45  }
46 
47  d->sendCommand(
48  Protocol::ModifyRelationCommandPtr::create(d->mRelation.left().id(), d->mRelation.right().id(), d->mRelation.type(), d->mRelation.remoteId()));
49 }
50 
52 {
53  if (!response->isResponse() || response->type() != Protocol::Command::ModifyRelation) {
54  return Job::doHandleResponse(tag, response);
55  }
56 
57  return true;
58 }
59 
61 {
62  Q_D(const RelationCreateJob);
63  return d->mRelation;
64 }
void doStart() override
This method must be reimplemented in the concrete jobs.
@ Unknown
Unknown error.
Definition: job.h:102
void setErrorText(const QString &errorText)
An Akonadi Relation.
Definition: relation.h:39
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.
QString i18n(const char *text, const TYPE &arg...)
Base class for all actions in the Akonadi storage.
Definition: job.h:80
RelationCreateJob(const Relation &relation, QObject *parent=nullptr)
Creates a new relation create job.
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
Relation relation() const
Returns the relation.
void emitResult()
Job that creates a new relation in the Akonadi storage.
void setError(int errorCode)
Q_D(Todo)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.