1 /***************************************************************************
2 filters.h - description
4 begin : Fri Jun 30 2000
5 copyright : (C) 2000 by Hans Dijkema
6 email : kmailcvt@hum.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
17 /* Copyright (c) 2012 Montel Laurent <montel@kde.org> */
26 #include "filterinfo.h"
28 #include "mailimporter_export.h"
30 #include <Akonadi/Collection>
31 #include <KMime/KMimeMessage>
32 #include <akonadi/kmime/messagestatus.h>
38 namespace MailImporter
{
39 class MAILIMPORTER_EXPORT Filter
42 explicit Filter( const QString
& name
, const QString
& author
,
43 const QString
& info
= QString() );
45 virtual void import() = 0;
47 QString
author() const;
51 void setAuthor(const QString
&);
52 void setName(const QString
&);
53 void setInfo(const QString
&);
57 void setFilterInfo( MailImporter::FilterInfo
* info
);
59 MailImporter::FilterInfo
* filterInfo();
61 void setCountDuplicates( int countDuplicate
);
62 int countDuplicates() const;
64 void setMailDir( const QString
& mailDir
);
65 QString
mailDir() const;
68 static int countDirectory(const QDir
& dir
, bool searchHiddenDirectory
);
70 * Adds a single subcollection to the given base collection and returns it.
71 * Use parseFolderString() instead if you want to create hierachies of collections.
73 Akonadi::Collection
addSubCollection( const Akonadi::Collection
&baseCollection
,
74 const QString
&newCollectionPathName
);
77 * Creates a hierachy of collections based on the given path string. The collection
78 * hierachy will be placed under the root collection.
79 * For example, if the folderParseString "foo/bar/test" is passsed to this method, it
80 * will make sure the root collection has a subcollection named "foo", which in turn
81 * has a subcollection named "bar", which again has a subcollection named "test".
82 * The "test" collection will be returned.
83 * An invalid collection will be returned in case of an error.
85 Akonadi::Collection
parseFolderString( const QString
&folderParseString
);
87 bool addAkonadiMessage( const Akonadi::Collection
&collection
,
88 const KMime::Message::Ptr
& message
, Akonadi::MessageStatus status
= Akonadi::MessageStatus() );
90 bool addMessage( const QString
& folder
,
91 const QString
& msgFile
,
92 Akonadi::MessageStatus status
= Akonadi::MessageStatus() );
95 * Checks for duplicate messages in the collection by message ID.
96 * returns true if a duplicate was detected.
97 * NOTE: Only call this method if a message ID exists, otherwise
98 * you could get false positives.
100 bool checkForDuplicates( const QString
& msgID
,
101 const Akonadi::Collection
& msgCollection
,
102 const QString
& messageFolder
);
103 bool addMessage_fastImport( const QString
& folder
,
104 const QString
& msgFile
,
105 Akonadi::MessageStatus status
= Akonadi::MessageStatus() );
108 bool doAddMessage( const QString
& folderName
,
109 const QString
& msgPath
,
111 Akonadi::MessageStatus status
= Akonadi::MessageStatus() );