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 #pragma once
0008 
0009 #include "akonadicore_export.h"
0010 #include "job.h"
0011 
0012 namespace Akonadi
0013 {
0014 class TransactionJobPrivate;
0015 class AKONADICORE_EXPORT TransactionJob : public Job
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     ~TransactionJob() override;
0021 
0022 protected:
0023     explicit TransactionJob(QObject *parent);
0024 
0025     void doStart() override;
0026     bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
0027 
0028 private:
0029     Q_DECLARE_PRIVATE(TransactionJob)
0030 };
0031 
0032 class TransactionJobPrivate;
0033 
0034 /**
0035  * @short Job that begins a session-global transaction.
0036  *
0037  * Sometimes you want to execute a sequence of commands in
0038  * an atomic way, so that either all commands or none shall
0039  * be executed. The TransactionBeginJob, TransactionCommitJob and
0040  * TransactionRollbackJob provide these functionality for the
0041  * Akonadi Job classes.
0042  *
0043  * @note This will only have an effect when used as a subjob or with a Session.
0044  *
0045  * @author Volker Krause <vkrause@kde.org>
0046  */
0047 class AKONADICORE_EXPORT TransactionBeginJob : public TransactionJob
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052     /**
0053      * Creates a new transaction begin job.
0054      *
0055      * @param parent The parent job or Session, must not be 0.
0056      */
0057     explicit TransactionBeginJob(QObject *parent);
0058 
0059     /**
0060      * Destroys the transaction begin job.
0061      */
0062     ~TransactionBeginJob() override;
0063 };
0064 
0065 /**
0066  * @short Job that aborts a session-global transaction.
0067  *
0068  * If a job inside a TransactionBeginJob has been failed,
0069  * the TransactionRollbackJob can be used to rollback all changes done by these
0070  * jobs.
0071  *
0072  * @note This will only have an effect when used as a subjob or with a Session.
0073  *
0074  * @author Volker Krause <vkrause@kde.org>
0075  */
0076 class AKONADICORE_EXPORT TransactionRollbackJob : public TransactionJob
0077 {
0078     Q_OBJECT
0079 
0080 public:
0081     /**
0082      * Creates a new transaction rollback job.
0083      * The parent must be the same parent as for the TransactionBeginJob.
0084      *
0085      * @param parent The parent job or Session, must not be 0.
0086      */
0087     explicit TransactionRollbackJob(QObject *parent);
0088 
0089     /**
0090      * Destroys the transaction rollback job.
0091      */
0092     ~TransactionRollbackJob() override;
0093 };
0094 
0095 /**
0096  * @short Job that commits a session-global transaction.
0097  *
0098  * This job commits all changes of this transaction.
0099  *
0100  * @author Volker Krause <vkrause@kde.org>
0101  */
0102 class AKONADICORE_EXPORT TransactionCommitJob : public TransactionJob
0103 {
0104     Q_OBJECT
0105 
0106 public:
0107     /**
0108      * Creates a new transaction commit job.
0109      * The parent must be the same parent as for the TransactionBeginJob.
0110      *
0111      * @param parent The parent job or Session, must not be 0.
0112      */
0113     explicit TransactionCommitJob(QObject *parent);
0114 
0115     /**
0116      * Destroys the transaction commit job.
0117      */
0118     ~TransactionCommitJob() override;
0119 };
0120 
0121 }