SVN_SILENT made messages (.desktop file)
[kdepim.git] / mailimporter / filter_clawsmail.cpp
blobc2146e47ffeab819d213b94f5797cc542b44868d
1 /*
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>
23 #include <qdebug.h>
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>"));
42 /** Destructor. */
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()) {
56 QDomDocument doc;
57 QString errorMsg;
58 int errorRow;
59 int errorCol;
60 if (!doc.setContent(&folderListFile, &errorMsg, &errorRow, &errorCol)) {
61 qDebug() << "Unable to load document.Parse error in line " << errorRow
62 << ", col " << errorCol << ": " << errorMsg;
63 return QString();
65 QDomElement settings = doc.documentElement();
67 if (settings.isNull()) {
68 return QString();
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");
81 return QString();
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"))) {
89 return true;
91 return false;
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");