File indexing completed on 2024-11-17 04:45:42

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 "settings.h"
0010 #include "singlefileresource.h"
0011 
0012 #include <KContacts/Addressee>
0013 #include <KContacts/VCardConverter>
0014 
0015 class VCardResource : public Akonadi::SingleFileResource<Akonadi_VCard_Resource::Settings>
0016 {
0017     Q_OBJECT
0018 
0019 public:
0020     explicit VCardResource(const QString &id);
0021     ~VCardResource() override;
0022 
0023 protected:
0024     using ResourceBase::retrieveItems; // Suppress -Woverload-virtual
0025 
0026 protected Q_SLOTS:
0027     bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
0028     bool retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts) override;
0029     void retrieveItems(const Akonadi::Collection &col) override;
0030 
0031 protected:
0032     bool readFromFile(const QString &fileName) override;
0033     bool writeToFile(const QString &fileName) override;
0034     void aboutToQuit() override;
0035 
0036     void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
0037     void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
0038     void itemRemoved(const Akonadi::Item &item) override;
0039 
0040 private:
0041     [[nodiscard]] bool doRetrieveItem(Akonadi::Item &item);
0042 
0043 private:
0044     QMap<QString, KContacts::Addressee> mAddressees;
0045     KContacts::VCardConverter mConverter;
0046 };