1 /*
2    SPDX-FileCopyrightText: 2012-2021 Laurent Montel <montel@kde.org>
3 
4    SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "oeimportdata.h"
8 #include <MailImporter/FilterInfo>
9 #include <MailImporter/FilterOE>
10 
11 #include <KLocalizedString>
12 #include <KPluginFactory>
13 
14 #include <QDir>
15 
16 K_PLUGIN_CLASS_WITH_JSON(OEImporterFactory, "oeimporter.json")
17 
OeImportData(QObject * parent,const QList<QVariant> &)18 OeImportData::OeImportData(QObject *parent, const QList<QVariant> &)
19     : LibImportWizard::AbstractImporter(parent)
20 {
21     mPath = QDir::homePath();
22 }
23 
~OeImportData()24 OeImportData::~OeImportData()
25 {
26 }
27 
foundMailer() const28 bool OeImportData::foundMailer() const
29 {
30 #ifdef Q_OS_WIN
31     // TODO find a method to search it. Perhaps look at binary.
32     QDir directory(mPath);
33     if (directory.exists()) {
34         return true;
35     }
36 #endif
37     return false;
38 }
39 
name() const40 QString OeImportData::name() const
41 {
42     return QStringLiteral("Outlook Express");
43 }
44 
importMails()45 bool OeImportData::importMails()
46 {
47     MailImporter::FilterOE opera;
48     initializeFilter(opera);
49     opera.filterInfo()->setStatusMessage(i18n("Import in progress"));
50     QDir directory(mPath);
51     if (directory.exists()) {
52         opera.importMails(mPath);
53     } else {
54         opera.import();
55     }
56     opera.filterInfo()->setStatusMessage(i18n("Import finished"));
57     return true;
58 }
59 
supportedOption()60 LibImportWizard::AbstractImporter::TypeSupportedOptions OeImportData::supportedOption()
61 {
62     TypeSupportedOptions options;
63     options |= LibImportWizard::AbstractImporter::Mails;
64     return options;
65 }
66 
67 #include "oeimportdata.moc"
68