File indexing completed on 2024-10-27 04:50:49
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "sendlaterremovemessagejob.h" 0008 #include "sendlateragent_debug.h" 0009 #include <Akonadi/ItemDeleteJob> 0010 0011 SendLaterRemoveMessageJob::SendLaterRemoveMessageJob(const QList<Akonadi::Item::Id> &listItem, QObject *parent) 0012 : QObject(parent) 0013 , mListItems(listItem) 0014 { 0015 } 0016 0017 SendLaterRemoveMessageJob::~SendLaterRemoveMessageJob() = default; 0018 0019 void SendLaterRemoveMessageJob::start() 0020 { 0021 removeMessageItem(); 0022 } 0023 0024 void SendLaterRemoveMessageJob::removeMessageItem() 0025 { 0026 if (mIndex < mListItems.count()) { 0027 auto job = new Akonadi::ItemDeleteJob(Akonadi::Item(mListItems.at(mIndex)), this); 0028 connect(job, &Akonadi::ItemDeleteJob::result, this, &SendLaterRemoveMessageJob::slotItemDeleteDone); 0029 } else { 0030 deleteLater(); 0031 } 0032 } 0033 0034 void SendLaterRemoveMessageJob::slotItemDeleteDone(KJob *job) 0035 { 0036 if (job->error()) { 0037 qCDebug(SENDLATERAGENT_LOG) << " Error during delete item :" << job->errorString(); 0038 } 0039 ++mIndex; 0040 removeMessageItem(); 0041 } 0042 0043 #include "moc_sendlaterremovemessagejob.cpp"