SVN_SILENT made messages (.desktop file)
[kdepim.git] / mailimporter / filters.h
blobed1c5771b96fe3b719b71f75b2bafb318e8d7c9f
1 /***************************************************************************
2 filters.h - description
3 -------------------
4 begin : Fri Jun 30 2000
5 copyright : (C) 2000 by Hans Dijkema
6 email : kmailcvt@hum.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
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. *
15 * *
16 ***************************************************************************/
17 /* Copyright (c) 2012 Montel Laurent <montel@kde.org> */
19 #ifndef FILTERS_HXX
20 #define FILTERS_HXX
22 #ifndef MAX_LINE
23 #define MAX_LINE 4096
24 #endif
26 #include "filterinfo.h"
27 #include "filters.h"
28 #include "mailimporter_export.h"
30 #include <Akonadi/Collection>
31 #include <KMime/KMimeMessage>
32 #include <akonadi/kmime/messagestatus.h>
36 #include <QDir>
38 namespace MailImporter {
39 class MAILIMPORTER_EXPORT Filter
41 public:
42 explicit Filter( const QString& name, const QString& author,
43 const QString& info = QString() );
44 virtual ~Filter();
45 virtual void import() = 0;
47 QString author() const;
48 QString name() const;
49 QString info() const;
51 void setAuthor(const QString&);
52 void setName(const QString&);
53 void setInfo(const QString&);
56 void clear();
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;
67 protected:
68 static int countDirectory(const QDir& dir, bool searchHiddenDirectory);
69 /**
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 );
76 /**
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() );
94 /**
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() );
107 private:
108 bool doAddMessage( const QString& folderName,
109 const QString& msgPath,
110 bool duplicateCheck,
111 Akonadi::MessageStatus status = Akonadi::MessageStatus() );
112 class Private;
113 Private *const d;
118 #endif