File indexing completed on 2024-11-24 04:44:29
0001 /* 0002 This file is part of oxaccess. 0003 0004 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "objectsrequestdeltajob.h" 0010 0011 #include "objectsrequestjob.h" 0012 0013 using namespace OXA; 0014 0015 ObjectsRequestDeltaJob::ObjectsRequestDeltaJob(const Folder &folder, qulonglong lastSync, QObject *parent) 0016 : KJob(parent) 0017 , mFolder(folder) 0018 , mLastSync(lastSync) 0019 , mJobFinishedCount(0) 0020 { 0021 } 0022 0023 void ObjectsRequestDeltaJob::start() 0024 { 0025 auto modifiedJob = new ObjectsRequestJob(mFolder, mLastSync, ObjectsRequestJob::Modified, this); 0026 connect(modifiedJob, &ObjectsRequestJob::result, this, &ObjectsRequestDeltaJob::fetchModifiedJobFinished); 0027 modifiedJob->start(); 0028 0029 auto deletedJob = new ObjectsRequestJob(mFolder, mLastSync, ObjectsRequestJob::Deleted, this); 0030 connect(deletedJob, &ObjectsRequestJob::result, this, &ObjectsRequestDeltaJob::fetchDeletedJobFinished); 0031 deletedJob->start(); 0032 } 0033 0034 Object::List ObjectsRequestDeltaJob::modifiedObjects() const 0035 { 0036 return mModifiedObjects; 0037 } 0038 0039 Object::List ObjectsRequestDeltaJob::deletedObjects() const 0040 { 0041 return mDeletedObjects; 0042 } 0043 0044 void ObjectsRequestDeltaJob::fetchModifiedJobFinished(KJob *job) 0045 { 0046 if (job->error()) { 0047 setError(job->error()); 0048 setErrorText(job->errorText()); 0049 emitResult(); 0050 return; 0051 } 0052 0053 const ObjectsRequestJob *requestJob = qobject_cast<ObjectsRequestJob *>(job); 0054 0055 mModifiedObjects << requestJob->objects(); 0056 0057 mJobFinishedCount++; 0058 0059 if (mJobFinishedCount == 2) { 0060 emitResult(); 0061 } 0062 } 0063 0064 void ObjectsRequestDeltaJob::fetchDeletedJobFinished(KJob *job) 0065 { 0066 if (job->error()) { 0067 setError(job->error()); 0068 setErrorText(job->errorText()); 0069 emitResult(); 0070 return; 0071 } 0072 0073 const ObjectsRequestJob *requestJob = qobject_cast<ObjectsRequestJob *>(job); 0074 0075 mDeletedObjects << requestJob->objects(); 0076 0077 mJobFinishedCount++; 0078 0079 if (mJobFinishedCount == 2) { 0080 emitResult(); 0081 } 0082 } 0083 0084 #include "moc_objectsrequestdeltajob.cpp"