File indexing completed on 2024-12-22 04:52:51

0001 /*
0002    SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "trojitaimportdata.h"
0008 #include "trojitaaddressbook.h"
0009 #include "trojitasettings.h"
0010 #include <MailImporter/FilterInfo>
0011 #include <MailImporter/OtherMailerUtil>
0012 
0013 #include <KPluginFactory>
0014 
0015 #include <QDir>
0016 
0017 K_PLUGIN_CLASS_WITH_JSON(TrojitaImportData, "trojitaimporter.json")
0018 
0019 TrojitaImportData::TrojitaImportData(QObject *parent, const QList<QVariant> &)
0020     : LibImportWizard::AbstractImporter(parent)
0021 {
0022     mPath = MailImporter::OtherMailerUtil::trojitaDefaultPath();
0023 }
0024 
0025 TrojitaImportData::~TrojitaImportData() = default;
0026 
0027 bool TrojitaImportData::foundMailer() const
0028 {
0029     QDir directory(mPath);
0030     if (directory.exists()) {
0031         return true;
0032     }
0033     return false;
0034 }
0035 
0036 QString TrojitaImportData::name() const
0037 {
0038     return QStringLiteral("Trojita");
0039 }
0040 
0041 bool TrojitaImportData::importMails()
0042 {
0043     return false;
0044 }
0045 
0046 bool TrojitaImportData::importSettings()
0047 {
0048     const QString settingsPath = mPath + QLatin1StringView("trojita.conf");
0049     TrojitaSettings settings(settingsPath);
0050     settings.setAbstractDisplayInfo(mAbstractDisplayInfo);
0051     settings.importSettings();
0052     return true;
0053 }
0054 
0055 bool TrojitaImportData::importAddressBook()
0056 {
0057     const QString addressbookPath = QDir::homePath() + QLatin1StringView("/.abook/addressbook");
0058     TrojitaAddressBook addressBooks(addressbookPath);
0059     addressBooks.setAbstractDisplayInfo(mAbstractDisplayInfo);
0060     addressBooks.readAddressBook();
0061     return true;
0062 }
0063 
0064 LibImportWizard::AbstractImporter::TypeSupportedOptions TrojitaImportData::supportedOption()
0065 {
0066     TypeSupportedOptions options;
0067     // options |=LibImportWizard::AbstractImporter::Mails;
0068     options |= LibImportWizard::AbstractImporter::Settings;
0069     options |= LibImportWizard::AbstractImporter::AddressBooks;
0070     return options;
0071 }
0072 
0073 #include "trojitaimportdata.moc"