File indexing completed on 2024-11-24 04:44:18

0001 /*
0002     SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0003     SPDX-FileContributor: Kevin Krammer <kevin.krammer@kdab.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <Akonadi/Collection>
0011 #include <Akonadi/Item>
0012 #include <KMime/Message>
0013 
0014 #include <QObject>
0015 
0016 namespace KIMAP
0017 {
0018 class Session;
0019 }
0020 
0021 namespace Akonadi
0022 {
0023 class Tag;
0024 }
0025 
0026 class KolabRelationResourceTask;
0027 
0028 struct TagConverter {
0029     KMime::Message::Ptr createMessage(const Akonadi::Tag &tag, const Akonadi::Item::List &items, const QString &username);
0030 };
0031 
0032 class TagChangeHelper : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit TagChangeHelper(KolabRelationResourceTask *parent = nullptr);
0037 
0038     void start(const Akonadi::Tag &tag, const KMime::Message::Ptr &message, KIMAP::Session *session);
0039 
0040 Q_SIGNALS:
0041     void applyCollectionChanges(const Akonadi::Collection &collection);
0042     void cancelTask(const QString &errorText);
0043     void changeCommitted();
0044 
0045 private:
0046     KolabRelationResourceTask *const mTask;
0047 
0048 private:
0049     void recordNewUid(qint64 newUid, const Akonadi::Tag &tag);
0050 
0051 private Q_SLOTS:
0052     void onReplaceDone(KJob *job);
0053     void onModifyDone(KJob *job);
0054 };