Akonadi

transactionjobs.cpp
1 /*
2  Copyright (c) 2006 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "transactionjobs.h"
21 
22 #include "job_p.h"
23 #include "private/protocol_p.h"
24 
25 using namespace Akonadi;
26 
27 class Akonadi::TransactionJobPrivate : public JobPrivate
28 {
29 public:
30  TransactionJobPrivate(Job *parent)
31  : JobPrivate(parent)
32  {}
33 };
34 
35 TransactionJob::TransactionJob(QObject *parent)
36  : Job(new TransactionJobPrivate(this), parent)
37 {
38  Q_ASSERT(parent);
39 }
40 
41 TransactionJob::~TransactionJob()
42 {
43 }
44 
45 void TransactionJob::doStart()
46 {
47  Q_D(TransactionJob);
48 
49  Protocol::TransactionCommand::Mode mode;
50  if (qobject_cast<TransactionBeginJob *>(this)) {
51  mode = Protocol::TransactionCommand::Begin;
52  } else if (qobject_cast<TransactionRollbackJob *>(this)) {
53  mode = Protocol::TransactionCommand::Rollback;
54  } else if (qobject_cast<TransactionCommitJob *>(this)) {
55  mode = Protocol::TransactionCommand::Commit;
56  } else {
57  Q_ASSERT(false);
58  mode = Protocol::TransactionCommand::Invalid;
59  }
60 
61  d->sendCommand(Protocol::TransactionCommandPtr::create(mode));
62 }
63 
64 bool TransactionJob::doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
65 {
66  if (!response->isResponse() || response->type() != Protocol::Command::Transaction) {
67  return Job::doHandleResponse(tag, response);
68  }
69 
70  return true;
71 }
72 
74  : TransactionJob(parent)
75 {
76 }
77 
79 {
80 }
81 
83  : TransactionJob(parent)
84 {
85 }
86 
88 {
89 }
90 
92  : TransactionJob(parent)
93 {
94 }
95 
97 {
98 }
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:385
~TransactionCommitJob()
Destroys the transaction commit job.
TransactionRollbackJob(QObject *parent)
Creates a new transaction rollback job.
Base class for all actions in the Akonadi storage.
Definition: job.h:93
~TransactionRollbackJob()
Destroys the transaction rollback job.
quint64 tag() const
The tag of the command associated with this handler.
Definition: handler.cpp:208
TransactionBeginJob(QObject *parent)
Creates a new transaction begin job.
Helper integration between Akonadi and Qt.
~TransactionBeginJob()
Destroys the transaction begin job.
TransactionCommitJob(QObject *parent)
Creates a new transaction commit job.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.