2 Copyright (c) 2012 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 /* based on filter_sylpheed filter */
20 #include "filter_clawsmail.h"
22 #include <KLocalizedString>
24 #include <QDomDocument>
25 #include <QDomElement>
27 using namespace MailImporter
;
29 /** Default constructor. */
30 FilterClawsMail::FilterClawsMail() : FilterSylpheed()
32 setName(i18n("Import Claws-mail Maildirs and Folder Structure"));
33 setAuthor("Laurent Montel");
34 setInfo(i18n("<p><b>Claws-mail import filter</b></p>"
35 "<p>Select the base directory of the Claws-mail mailfolder you want to import "
36 "(usually: ~/Mail ).</p>"
37 "<p>Since it is possible to recreate the folder structure, the folders "
38 "will be stored under: \"ClawsMail-Import\" in your local folder.</p>"
39 "<p>This filter also recreates the status of message, e.g. new or forwarded.</p>"));
43 FilterClawsMail::~FilterClawsMail()
47 QString
FilterClawsMail::defaultSettingsPath()
49 return QDir::homePath() + QLatin1String("/.claws-mail/");
52 QString
FilterClawsMail::localMailDirPath()
54 QFile
folderListFile(FilterClawsMail::defaultSettingsPath() + QLatin1String("/folderlist.xml"));
55 if (folderListFile
.exists()) {
60 if (!doc
.setContent(&folderListFile
, &errorMsg
, &errorRow
, &errorCol
)) {
61 qDebug() << "Unable to load document.Parse error in line " << errorRow
62 << ", col " << errorCol
<< ": " << errorMsg
;
65 QDomElement settings
= doc
.documentElement();
67 if (settings
.isNull()) {
71 for (QDomElement e
= settings
.firstChildElement(); !e
.isNull(); e
= e
.nextSiblingElement()) {
72 if (e
.tagName() == QLatin1String("folder")) {
73 if (e
.hasAttribute("type")) {
74 if (e
.attribute("type") == QLatin1String("mh")) {
75 return QDir::homePath() + QDir::separator() + e
.attribute("path");
84 bool FilterClawsMail::excludeFile(const QString
&file
)
86 if (file
.endsWith(QLatin1String(".claws_cache")) ||
87 file
.endsWith(QLatin1String(".claws_mark")) ||
88 file
.endsWith(QLatin1String(".mh_sequences"))) {
94 QString
FilterClawsMail::defaultInstallFolder() const
96 return i18nc("define folder name where we will import clawsmail mails", "ClawsMail-Import") + QLatin1Char('/');
99 QString
FilterClawsMail::markFile() const
101 return QStringLiteral(".claws_mark");