MailImporter

filterimporterakonadi.h
1/*
2 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "mailimporterakonadi_export.h"
10#include <Akonadi/Collection>
11#include <Akonadi/MessageStatus>
12#include <KMime/Message>
13#include <MailImporter/FilterImporterBase>
14#include <QString>
15namespace MailImporter
16{
17/**
18 * @brief The FilterImporterAkonadi class
19 * @author Laurent Montel <montel@kde.org>
20 */
21class MAILIMPORTERAKONADI_EXPORT FilterImporterAkonadi : public MailImporter::FilterImporterBase
22{
23public:
25 ~FilterImporterAkonadi() override;
26
27 bool importMessage(const QString &folderName, const QString &msgPath, bool duplicateCheck, const MailImporter::MessageStatus &status) override;
28 void clear() override;
29 void clearCountDuplicate() override;
30 int countDuplicates() const override;
31 static Akonadi::MessageStatus convertToAkonadiMessageStatus(const MailImporter::MessageStatus &status);
32
33 Akonadi::Collection rootCollection() const;
34 void setRootCollection(const Akonadi::Collection &collection);
35
36 QString topLevelFolder() const override;
37 bool importMessage(const KArchiveFile *file, const QString &folderPath, int &nbTotal, int &fileDone) override;
38
39private:
40 /**
41 * Creates a hierarchy of collections based on the given path string. The collection
42 * hierarchy will be placed under the root collection.
43 * For example, if the folderParseString "foo/bar/test" is passsed to this method, it
44 * will make sure the root collection has a subcollection named "foo", which in turn
45 * has a subcollection named "bar", which again has a subcollection named "test".
46 * The "test" collection will be returned.
47 * An invalid collection will be returned in case of an error.
48 */
49 MAILIMPORTERAKONADI_NO_EXPORT Akonadi::Collection parseFolderString(const QString &folderParseString);
50 /**
51 * Checks for duplicate messages in the collection by message ID.
52 * returns true if a duplicate was detected.
53 * NOTE: Only call this method if a message ID exists, otherwise
54 * you could get false positives.
55 */
56 MAILIMPORTERAKONADI_NO_EXPORT bool checkForDuplicates(const QString &msgID, const Akonadi::Collection &msgCollection, const QString &messageFolder);
57 /**
58 * Adds a single subcollection to the given base collection and returns it.
59 * Use parseFolderString() instead if you want to create hierarchies of collections.
60 */
61 MAILIMPORTERAKONADI_NO_EXPORT Akonadi::Collection addSubCollection(const Akonadi::Collection &baseCollection, const QString &newCollectionPathName);
62 MAILIMPORTERAKONADI_NO_EXPORT bool
63 addAkonadiMessage(const Akonadi::Collection &collection, const KMime::Message::Ptr &message, Akonadi::MessageStatus status);
64
65 QMultiMap<QString, QString> mMessageFolderMessageIDMap;
66 QMap<QString, Akonadi::Collection> mMessageFolderCollectionMap;
67 Akonadi::Collection mRootCollection;
68 int mCountDuplicates = 0;
69};
70}
The FilterImporterAkonadi class.
The FilterImporterBase class.
The FilterInfo class.
Definition filterinfo.h:21
The MessageStatus class.
Q_SCRIPTABLE CaptureState status()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.