pmailimportdata.cpp 1.84 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
8
*/

#include "pmailimportdata.h"
#include "pmailsettings.h"
Laurent Montel's avatar
Laurent Montel committed
9
#include <MailImporter/FilterInfo>
Laurent Montel's avatar
Laurent Montel committed
10
#include <MailImporter/FilterPMail>
11
12

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

Laurent Montel's avatar
Laurent Montel committed
16
K_PLUGIN_CLASS_WITH_JSON(PMailImporterFactory, "pmailimporter.json")
17
18
19
20
21
22
23
24
25
26
27
28
29
PMailImportData::PMailImportData(QObject *parent, const QList<QVariant> &)
    : LibImportWizard::AbstractImporter(parent)
{
    mPath = QDir::homePath();
}

PMailImportData::~PMailImportData()
{
}

bool PMailImportData::foundMailer() const
{
#ifdef Q_OS_WIN
Laurent Montel's avatar
Laurent Montel committed
30
    // TODO find a method to search it. Perhaps look at binary.
31
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
    QDir directory(mPath);
    if (directory.exists()) {
        return true;
    }
#endif
    return false;
}

QString PMailImportData::name() const
{
    return QStringLiteral("Pegasus Mail");
}

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

bool PMailImportData::importSettings()
{
Laurent Montel's avatar
Laurent Montel committed
61
    // TODO verify path
62
63
64
65
66
67
68
69
70
71
72
    const QString settingFile(mPath + QLatin1String("pmail.ini"));
    PMailSettings settings(settingFile);
    settings.setAbstractDisplayInfo(mAbstractDisplayInfo);
    settings.importSettings();
    return true;
}

LibImportWizard::AbstractImporter::TypeSupportedOptions PMailImportData::supportedOption()
{
    TypeSupportedOptions options;
    options |= LibImportWizard::AbstractImporter::Mails;
Laurent Montel's avatar
Laurent Montel committed
73
    // options |=LibImportWizard::AbstractImporter::Settings;
74
75
76
77
    return options;
}

#include "pmailimportdata.moc"