File indexing completed on 2024-12-22 04:52:48
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 "balsaimportdata.h" 0008 #include "balsaaddressbook.h" 0009 #include "balsasettings.h" 0010 #include <MailCommon/FilterImporterBalsa> 0011 #include <MailImporter/FilterBalsa> 0012 #include <MailImporter/FilterInfo> 0013 0014 #include <KLocalizedString> 0015 #include <KPluginFactory> 0016 #include <QDir> 0017 0018 K_PLUGIN_CLASS_WITH_JSON(BalsaImportData, "balsaimporter.json") 0019 0020 BalsaImportData::BalsaImportData(QObject *parent, const QList<QVariant> &) 0021 : LibImportWizard::AbstractImporter(parent) 0022 { 0023 mPath = MailImporter::FilterBalsa::defaultSettingsPath(); 0024 } 0025 0026 BalsaImportData::~BalsaImportData() = default; 0027 0028 bool BalsaImportData::foundMailer() const 0029 { 0030 QDir directory(mPath); 0031 if (directory.exists()) { 0032 return true; 0033 } 0034 return false; 0035 } 0036 0037 QString BalsaImportData::name() const 0038 { 0039 return QStringLiteral("Balsa"); 0040 } 0041 0042 bool BalsaImportData::importMails() 0043 { 0044 MailImporter::FilterBalsa balsa; 0045 initializeFilter(balsa); 0046 balsa.filterInfo()->setStatusMessage(i18n("Import in progress")); 0047 QDir directory(balsa.localMailDirPath()); 0048 if (directory.exists()) { 0049 balsa.importMails(directory.absolutePath()); 0050 } else { 0051 balsa.import(); 0052 } 0053 balsa.filterInfo()->setStatusMessage(i18n("Import finished")); 0054 return true; 0055 } 0056 0057 bool BalsaImportData::importAddressBook() 0058 { 0059 const QString addressbookFile(mPath + QStringLiteral("config")); 0060 BalsaAddressBook addressbook(addressbookFile); 0061 addressbook.setAbstractDisplayInfo(mAbstractDisplayInfo); 0062 addressbook.importAddressBook(); 0063 return true; 0064 } 0065 0066 bool BalsaImportData::importSettings() 0067 { 0068 const QString settingFile(mPath + QStringLiteral("config")); 0069 BalsaSettings settings(settingFile); 0070 settings.setAbstractDisplayInfo(mAbstractDisplayInfo); 0071 settings.importSettings(); 0072 return true; 0073 } 0074 0075 bool BalsaImportData::importFilters() 0076 { 0077 const QString filterPath = mPath + QStringLiteral("config"); 0078 return addFilters(filterPath, MailCommon::FilterImporterExporter::BalsaFilter); 0079 } 0080 0081 LibImportWizard::AbstractImporter::TypeSupportedOptions BalsaImportData::supportedOption() 0082 { 0083 TypeSupportedOptions options; 0084 options |= LibImportWizard::AbstractImporter::Mails; 0085 options |= LibImportWizard::AbstractImporter::AddressBooks; 0086 options |= LibImportWizard::AbstractImporter::Settings; 0087 options |= LibImportWizard::AbstractImporter::Filters; 0088 return options; 0089 } 0090 0091 #include "balsaimportdata.moc"