File indexing completed on 2024-11-10 04:40:30
0001 /* 0002 SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "item.h" 0010 #include "session.h" 0011 0012 namespace Akonadi 0013 { 0014 namespace Protocol 0015 { 0016 class Command; 0017 } 0018 0019 /** 0020 * @internal 0021 */ 0022 class JobPrivate 0023 { 0024 public: 0025 explicit JobPrivate(Job *parent) 0026 : q_ptr(parent) 0027 { 0028 } 0029 0030 virtual ~JobPrivate() = default; 0031 0032 void init(QObject *parent); 0033 0034 void handleResponse(qint64 tag, const Protocol::CommandPtr &response); 0035 void startQueued(); 0036 void lostConnection(); 0037 void slotSubJobAboutToStart(Akonadi::Job *job); 0038 void startNext(); 0039 void signalCreationToJobTracker(); 0040 void signalStartedToJobTracker(); 0041 void delayedEmitResult(); 0042 void publishJob(); 0043 /* 0044 Returns a string to display in akonadi console's job tracker. E.g. item ID. 0045 */ 0046 virtual QString jobDebuggingString() const 0047 { 0048 return QString(); 0049 } 0050 /** 0051 Returns a new unique command tag for communication with the backend. 0052 */ 0053 [[nodiscard]] qint64 newTag(); 0054 0055 /** 0056 Return the tag used for the request. 0057 */ 0058 [[nodiscard]] qint64 tag() const; 0059 0060 /** 0061 Sends the @p command to the backend 0062 */ 0063 void sendCommand(qint64 tag, const Protocol::CommandPtr &command); 0064 0065 /** 0066 * Same as calling JobPrivate::sendCommand(newTag(), command) 0067 */ 0068 void sendCommand(const Protocol::CommandPtr &command); 0069 0070 /** 0071 * Notify following jobs about item revision changes. 0072 * This is used to avoid phantom conflicts between pipelined modify jobs on the same item. 0073 * @param itemId the id of the item which has changed 0074 * @param oldRevision the old item revision 0075 * @param newRevision the new item revision 0076 */ 0077 void itemRevisionChanged(Akonadi::Item::Id itemId, int oldRevision, int newRevision); 0078 0079 /** 0080 * Propagate item revision changes to this job and its sub-jobs. 0081 */ 0082 void updateItemRevision(Akonadi::Item::Id itemId, int oldRevision, int newRevision); 0083 0084 /** 0085 * Overwrite this if your job does operations with conflict detection and update 0086 * the item revisions if your items are affected. The default implementation does nothing. 0087 */ 0088 virtual void doUpdateItemRevision(Akonadi::Item::Id, int oldRevision, int newRevision); 0089 0090 /** 0091 * This method is called right before result() and finished() signals are emitted. 0092 * Overwrite this method in your job if you need to emit some signals or process 0093 * some data before the job finishes. 0094 * 0095 * Default implementation does nothing. 0096 */ 0097 virtual void aboutToFinish(); 0098 0099 [[nodiscard]] int protocolVersion() const; 0100 0101 Job *q_ptr; 0102 Q_DECLARE_PUBLIC(Job) 0103 0104 Job *mParentJob = nullptr; 0105 Job *mCurrentSubJob = nullptr; 0106 qint64 mTag = -1; 0107 Session *mSession = nullptr; 0108 bool mWriteFinished = false; 0109 bool mReadingFinished = false; 0110 bool mStarted = false; 0111 bool mFinishPending = false; 0112 0113 private: 0114 Q_DISABLE_COPY_MOVE(JobPrivate) 0115 }; 0116 0117 }