Akonadi

transactionjobs.cpp
1 /*
2  SPDX-FileCopyrightText: 2006 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "transactionjobs.h"
8 
9 #include "job_p.h"
10 #include "private/protocol_p.h"
11 
12 using namespace Akonadi;
13 
14 class Akonadi::TransactionJobPrivate : public JobPrivate
15 {
16 public:
17  explicit TransactionJobPrivate(Job *parent)
18  : JobPrivate(parent)
19  {
20  }
21 };
22 
23 TransactionJob::TransactionJob(QObject *parent)
24  : Job(new TransactionJobPrivate(this), parent)
25 {
26  Q_ASSERT(parent);
27 }
28 
29 TransactionJob::~TransactionJob()
30 {
31 }
32 
33 void TransactionJob::doStart()
34 {
35  Q_D(TransactionJob);
36 
37  Protocol::TransactionCommand::Mode mode;
38  if (qobject_cast<TransactionBeginJob *>(this)) {
39  mode = Protocol::TransactionCommand::Begin;
40  } else if (qobject_cast<TransactionRollbackJob *>(this)) {
41  mode = Protocol::TransactionCommand::Rollback;
42  } else if (qobject_cast<TransactionCommitJob *>(this)) {
43  mode = Protocol::TransactionCommand::Commit;
44  } else {
45  Q_ASSERT(false);
46  mode = Protocol::TransactionCommand::Invalid;
47  }
48 
49  d->sendCommand(Protocol::TransactionCommandPtr::create(mode));
50 }
51 
52 bool TransactionJob::doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
53 {
54  if (!response->isResponse() || response->type() != Protocol::Command::Transaction) {
55  return Job::doHandleResponse(tag, response);
56  }
57 
58  return true;
59 }
60 
62  : TransactionJob(parent)
63 {
64 }
65 
67 {
68 }
69 
71  : TransactionJob(parent)
72 {
73 }
74 
76 {
77 }
78 
80  : TransactionJob(parent)
81 {
82 }
83 
85 {
86 }
TransactionBeginJob(QObject *parent)
Creates a new transaction begin job.
~TransactionCommitJob() override
Destroys the transaction commit job.
TransactionRollbackJob(QObject *parent)
Creates a new transaction rollback job.
TransactionCommitJob(QObject *parent)
Creates a new transaction commit job.
~TransactionBeginJob() override
Destroys the transaction begin job.
Base class for all actions in the Akonadi storage.
Definition: job.h:80
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
~TransactionRollbackJob() override
Destroys the transaction rollback job.
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 Thu Oct 6 2022 04:03:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.