File indexing completed on 2024-11-10 04:40:32
0001 /* 0002 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "transactionjobs.h" 0008 0009 #include "job_p.h" 0010 #include "private/protocol_p.h" 0011 0012 using namespace Akonadi; 0013 0014 class Akonadi::TransactionJobPrivate : public JobPrivate 0015 { 0016 public: 0017 explicit TransactionJobPrivate(Job *parent) 0018 : JobPrivate(parent) 0019 { 0020 } 0021 }; 0022 0023 TransactionJob::TransactionJob(QObject *parent) 0024 : Job(new TransactionJobPrivate(this), parent) 0025 { 0026 Q_ASSERT(parent); 0027 } 0028 0029 TransactionJob::~TransactionJob() 0030 { 0031 } 0032 0033 void TransactionJob::doStart() 0034 { 0035 Q_D(TransactionJob); 0036 0037 Protocol::TransactionCommand::Mode mode; 0038 if (qobject_cast<TransactionBeginJob *>(this)) { 0039 mode = Protocol::TransactionCommand::Begin; 0040 } else if (qobject_cast<TransactionRollbackJob *>(this)) { 0041 mode = Protocol::TransactionCommand::Rollback; 0042 } else if (qobject_cast<TransactionCommitJob *>(this)) { 0043 mode = Protocol::TransactionCommand::Commit; 0044 } else { 0045 Q_ASSERT(false); 0046 mode = Protocol::TransactionCommand::Invalid; 0047 } 0048 0049 d->sendCommand(Protocol::TransactionCommandPtr::create(mode)); 0050 } 0051 0052 bool TransactionJob::doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) 0053 { 0054 if (!response->isResponse() || response->type() != Protocol::Command::Transaction) { 0055 return Job::doHandleResponse(tag, response); 0056 } 0057 0058 return true; 0059 } 0060 0061 TransactionBeginJob::TransactionBeginJob(QObject *parent) 0062 : TransactionJob(parent) 0063 { 0064 } 0065 0066 TransactionBeginJob::~TransactionBeginJob() 0067 { 0068 } 0069 0070 TransactionRollbackJob::TransactionRollbackJob(QObject *parent) 0071 : TransactionJob(parent) 0072 { 0073 } 0074 0075 TransactionRollbackJob::~TransactionRollbackJob() 0076 { 0077 } 0078 0079 TransactionCommitJob::TransactionCommitJob(QObject *parent) 0080 : TransactionJob(parent) 0081 { 0082 } 0083 0084 TransactionCommitJob::~TransactionCommitJob() 0085 { 0086 } 0087 0088 #include "moc_transactionjobs.cpp"