Commit 588c1a14 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement importmailjobinterfaceimpl

parent c94397ab
......@@ -15,7 +15,7 @@ set(pimdataexporter_addressbook_SRCS
set(pimdataexporter_mail_SRCS
mail/exportmailjobinterfaceimpl.cpp
mail/importmailjobinterface.cpp
mail/importmailjobinterfaceimpl.cpp
mail/importexportmailutil.cpp
)
......@@ -34,6 +34,7 @@ set(pimdataexporter_interfaces_SRCS
alarm/importalarmjobinterface.cpp
alarm/exportalarmjobinterface.cpp
mail/exportmailjobinterface.cpp
mail/importmailjobinterface.cpp
)
set(pimdataexporter_notes_SRCS
......
......@@ -653,7 +653,7 @@ void ImportMailJobInterface::restoreMails()
}
}
Q_EMIT info(i18n("Mails restored."));
startSynchronizeResources(listResourceToSync);
synchronizeResource(listResourceToSync);
}
void ImportMailJobInterface::restoreConfig()
......@@ -718,7 +718,7 @@ void ImportMailJobInterface::restoreConfig()
MailCommon::FilterImporterExporter exportFilters;
QVector<MailCommon::MailFilter *> lstFilter = exportFilters.importFilters(canceled, MailCommon::FilterImporterExporter::KMailFilter, filterFileName);
if (canceled) {
MailCommon::FilterManager::instance()->appendFilters(lstFilter);
importFilters(lstFilter);
}
}
}
......@@ -957,18 +957,6 @@ void ImportMailJobInterface::importSimpleFilesInDirectory(const QString &relativ
}
}
void ImportMailJobInterface::registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId)
{
auto fetch = new Akonadi::CollectionFetchJob(Akonadi::Collection(colId), Akonadi::CollectionFetchJob::Base, this);
connect(fetch, &Akonadi::CollectionFetchJob::collectionsReceived,
this, [ type](const Akonadi::Collection::List &cols) {
if (cols.count() != 1) {
return;
}
Akonadi::SpecialMailCollections::self()->registerCollection(type, cols.first());
});
}
void ImportMailJobInterface::restoreIdentity()
{
increaseProgressDialog();
......@@ -1478,9 +1466,3 @@ void ImportMailJobInterface::convertCollectionStrToAkonadiId(const KSharedConfig
(void)convertRealPathToCollection(eventGroup, key, false);
}
}
QString ImportMailJobInterface::createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings)
{
return mCreateResource->createResource(resources, name, settings);
}
......@@ -33,6 +33,9 @@ class ArchiveStorage;
namespace MailTransport {
class Transport;
}
namespace MailCommon {
class MailFilter;
}
class PIMDATAEXPORTER_TESTS_EXPORT ImportMailJobInterface : public AbstractImportExportJob
{
Q_OBJECT
......@@ -49,10 +52,13 @@ protected:
void convertCollectionStrToAkonadiId(const KSharedConfig::Ptr &config, const QString &groupName, const QString &key);
virtual void restoreMails();
virtual void restoreResources();
void restoreResources();
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings);
virtual void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId);
virtual Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings) = 0;
virtual void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) = 0;
virtual void synchronizeResource(const QStringList &lst) = 0;
virtual void importFilters(const QVector<MailCommon::MailFilter *> &filters) = 0;
private:
void restoreTransports();
void restoreConfig();
......
This diff is collapsed.
......@@ -17,10 +17,10 @@
Boston, MA 02110-1301, USA.
*/
#ifndef ImportMailJobINTERFACE_H
#define ImportMailJobINTERFACE_H
#ifndef ImportMailJobINTERFACEIMPL_H
#define ImportMailJobINTERFACEIMPL_H
#include "abstractimportexportjob.h"
#include "importmailjobinterface.h"
#include "pimdataexportercore_private_export.h"
#include <AkonadiCore/Collection>
#include <Akonadi/KMime/SpecialMailCollections>
......@@ -33,51 +33,17 @@ class ArchiveStorage;
namespace MailTransport {
class Transport;
}
class PIMDATAEXPORTER_TESTS_EXPORT ImportMailJobInterfaceImpl : public AbstractImportExportJob
class PIMDATAEXPORTER_TESTS_EXPORT ImportMailJobInterfaceImpl : public ImportMailJobInterface
{
Q_OBJECT
public:
explicit ImportMailJobInterfaceImpl(QObject *widget, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep);
~ImportMailJobInterfaceImpl() override;
void start() override;
//For debugging
void importMailTransport(const QString &tempDirName);
protected:
void slotNextStep() override;
void restoreResources() override;
private:
void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId);
void restoreTransports();
void restoreMails();
void restoreConfig();
void restoreIdentity();
void importTemplatesConfig(const KArchiveFile *templatesconfiguration, const QString &templatesconfigurationrc, const QString &filename, const QString &prefix);
void importKmailConfig(const KArchiveFile *kmailsnippet, const QString &kmail2rc, const QString &filename, const QString &prefix);
void importArchiveConfig(const KArchiveFile *archiveconfiguration, const QString &archiveconfigurationrc, const QString &filename, const QString &prefix);
void importFolderArchiveConfig(const KArchiveFile *archiveconfiguration, const QString &archiveconfigurationrc, const QString &filename, const QString &prefix);
void searchAllMailsFiles(const KArchiveDirectory *dir, const QString &prefix);
void storeMailArchiveResource(const KArchiveDirectory *dir, const QString &prefix);
void importMailArchiveConfig(const KArchiveFile *archiveconfiguration, const QString &archiveconfigurationrc, const QString &filename, const QString &prefix);
void mergeLdapConfig(const KArchiveFile *archivefile, const QString &filename, const QString &prefix);
void mergeKmailSnippetConfig(const KArchiveFile *archivefile, const QString &filename, const QString &prefix);
void mergeArchiveMailAgentConfig(const KArchiveFile *archivefile, const QString &filename, const QString &prefix);
void copyArchiveMailAgentConfigGroup(const KSharedConfig::Ptr &archiveConfigOrigin, const KSharedConfig::Ptr &archiveConfigDestination);
void copyMailArchiveConfig(const KSharedConfig::Ptr &archiveConfigOrigin, const KSharedConfig::Ptr &archiveConfigDestination);
void mergeMailArchiveConfig(const KArchiveFile *archivefile, const QString &filename, const QString &prefix);
void mergeSieveTemplate(const KArchiveFile *archivefile, const QString &filename, const QString &prefix);
void importSimpleFilesInDirectory(const QString &relativePath);
void addMailTransport(MailTransport::Transport *mt, int defaultTransport, int transportId);
Q_REQUIRED_RESULT QString uniqueIdentityName(const QString &name);
QHash<int, uint> mHashIdentity;
QHash<int, int> mHashTransport;
QHash<QString, QString> mHashResources;
QStringList mFileList;
void registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) override;
Q_REQUIRED_RESULT QString createResource(const QString &resources, const QString &name, const QMap<QString, QVariant> &settings) override;
void synchronizeResource(const QStringList &lst) override;
void importFilters(const QVector<MailCommon::MailFilter *> &filters) override;
};
#endif // ImportMailJob_H
......@@ -22,7 +22,7 @@
#include "importexportprogressindicatorbase.h"
#include "mail/exportmailjobinterfaceimpl.h"
#include "mail/importmailjobinterface.h"
#include "mail/importmailjobinterfaceimpl.h"
#include "addressbook/exportaddressbookjobinterfaceimpl.h"
#include "addressbook/importaddressbookjobinterfaceimpl.h"
......@@ -205,7 +205,7 @@ void PimDataBackupRestore::restoreNextStep()
switch (mStoreIterator.key()) {
case Utils::KMail:
if (mStoreIterator.value().numberSteps != 0) {
mImportExportData = new ImportMailJobInterface(this, mStoreIterator.value().types, mArchiveStorage, mStoreIterator.value().numberSteps);
mImportExportData = new ImportMailJobInterfaceImpl(this, mStoreIterator.value().types, mArchiveStorage, mStoreIterator.value().numberSteps);
executeJob();
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment