File indexing completed on 2024-05-12 05:11:14

0001 /*
0002  * This file is part of the KDE Akonadi Search Project
0003  * SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  *
0007  */
0008 
0009 #pragma once
0010 
0011 #include <xapian.h>
0012 
0013 #include "abstractindexer.h"
0014 
0015 #include <Akonadi/Collection>
0016 #include <Akonadi/Item>
0017 #include <KMime/Message>
0018 
0019 class AkonotesIndexer : public AbstractIndexer
0020 {
0021 public:
0022     /**
0023      * You must provide the path where the indexed information
0024      * should be stored
0025      */
0026     explicit AkonotesIndexer(const QString &path);
0027     ~AkonotesIndexer() override;
0028 
0029     [[nodiscard]] QStringList mimeTypes() const override;
0030 
0031     void index(const Akonadi::Item &item) override;
0032     void commit() override;
0033 
0034     void remove(const Akonadi::Item &item) override;
0035     void remove(const Akonadi::Collection &collection) override;
0036     void move(Akonadi::Item::Id itemId, Akonadi::Collection::Id from, Akonadi::Collection::Id to) override;
0037 
0038 private:
0039     void processPart(KMime::Content *content, KMime::Content *mainContent);
0040     void process(const KMime::Message::Ptr &msg);
0041     Xapian::WritableDatabase *m_db = nullptr;
0042     Xapian::Document *m_doc = nullptr;
0043     Xapian::TermGenerator *m_termGen = nullptr;
0044 };