oeimportdata.cpp 1.45 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
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"
Laurent Montel's avatar
Laurent Montel committed
8
#include <MailImporter/FilterInfo>
Laurent Montel's avatar
Laurent Montel committed
9
#include <MailImporter/FilterOE>
10
11

#include <KLocalizedString>
12
#include <KPluginFactory>
13
14
15

#include <QDir>

Laurent Montel's avatar
Laurent Montel committed
16
K_PLUGIN_CLASS_WITH_JSON(OEImporterFactory, "oeimporter.json")
17
18
19
20
21
22
23
24
25
26
27
28
29
30

OeImportData::OeImportData(QObject *parent, const QList<QVariant> &)
    : LibImportWizard::AbstractImporter(parent)
{
    mPath = QDir::homePath();
}

OeImportData::~OeImportData()
{
}

bool OeImportData::foundMailer() const
{
#ifdef Q_OS_WIN
Laurent Montel's avatar
Laurent Montel committed
31
    // TODO find a method to search it. Perhaps look at binary.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    QDir directory(mPath);
    if (directory.exists()) {
        return true;
    }
#endif
    return false;
}

QString OeImportData::name() const
{
    return QStringLiteral("Outlook Express");
}

bool OeImportData::importMails()
{
    MailImporter::FilterOE opera;
    initializeFilter(opera);
    opera.filterInfo()->setStatusMessage(i18n("Import in progress"));
    QDir directory(mPath);
    if (directory.exists()) {
        opera.importMails(mPath);
    } else {
        opera.import();
    }
    opera.filterInfo()->setStatusMessage(i18n("Import finished"));
    return true;
}

LibImportWizard::AbstractImporter::TypeSupportedOptions OeImportData::supportedOption()
{
    TypeSupportedOptions options;
    options |= LibImportWizard::AbstractImporter::Mails;
    return options;
}

#include "oeimportdata.moc"