evolutionv1importdata.cpp 2.29 KB
Newer Older
1
/*
2
   Copyright (C) 2012-2017 Montel Laurent <montel@kde.org>
3

Laurent Montel's avatar
Laurent Montel committed
4 5 6 7
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
8

Laurent Montel's avatar
Laurent Montel committed
9 10 11 12
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
13

Laurent Montel's avatar
Laurent Montel committed
14 15 16 17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
18 19 20
*/

#include "evolutionv1/evolutionv1importdata.h"
21
#include "mailimporter/filterevolution.h"
22 23 24
#include "mailimporter/filterinfo.h"
#include "importfilterinfogui.h"

Laurent Montel's avatar
Laurent Montel committed
25
#include <KLocalizedString>
26
#include <kpluginfactory.h>
27 28 29

#include <QDir>

Laurent Montel's avatar
Laurent Montel committed
30 31 32
K_PLUGIN_FACTORY_WITH_JSON(Evolutionv1ImporterFactory, "evolutionv1importer.json", registerPlugin<Evolutionv1ImportData>();)


33
Evolutionv1ImportData::Evolutionv1ImportData(QObject *parent, const QList<QVariant> &)
Laurent Montel's avatar
Laurent Montel committed
34
    : AbstractImporter(parent)
35
{
36
    mPath = MailImporter::FilterEvolution::defaultSettingsPath();
37 38 39 40 41 42 43 44
}

Evolutionv1ImportData::~Evolutionv1ImportData()
{
}

bool Evolutionv1ImportData::foundMailer() const
{
Laurent Montel's avatar
Laurent Montel committed
45 46
    QDir directory(mPath);
    if (directory.exists()) {
47
        return true;
Laurent Montel's avatar
Laurent Montel committed
48
    }
49
    return false;
50 51 52 53
}

QString Evolutionv1ImportData::name() const
{
Laurent Montel's avatar
Laurent Montel committed
54
    return QStringLiteral("Evolution 1.x");
55 56 57 58
}

bool Evolutionv1ImportData::importMails()
{
59
    MailImporter::FilterEvolution evolution;
Laurent Montel's avatar
Laurent Montel committed
60 61
    initializeFilter(evolution);
    evolution.filterInfo()->setStatusMessage(i18n("Import in progress"));
62 63
    const QString mailsPath = mPath;
    QDir directory(mailsPath);
Laurent Montel's avatar
Laurent Montel committed
64
    if (directory.exists()) {
65
        evolution.importMails(mailsPath);
Laurent Montel's avatar
Laurent Montel committed
66
    } else {
67
        evolution.import();
Laurent Montel's avatar
Laurent Montel committed
68
    }
Laurent Montel's avatar
Laurent Montel committed
69
    evolution.filterInfo()->setStatusMessage(i18n("Import finished"));
70
    return true;
71 72
}

Laurent Montel's avatar
Laurent Montel committed
73
AbstractImporter::TypeSupportedOptions Evolutionv1ImportData::supportedOption()
74
{
75
    TypeSupportedOptions options;
Laurent Montel's avatar
Laurent Montel committed
76
    options |= AbstractImporter::Mails;
77
    return options;
78
}
Laurent Montel's avatar
Laurent Montel committed
79 80 81

#include "evolutionv1importdata.moc"