Commit 4f85f00a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to new api

parent c877feb1
......@@ -69,6 +69,16 @@ Akonadi::MessageStatus FilterImporterAkonadi::convertToAkonadiMessageStatus(cons
return akonadiStatus;
}
Akonadi::Collection FilterImporterAkonadi::rootCollection() const
{
return mRootCollection;
}
void FilterImporterAkonadi::setRootCollection(const Akonadi::Collection &collection)
{
mRootCollection = collection;
}
bool FilterImporterAkonadi::importMessage(const QString &folderName, const QString &msgPath, bool duplicateCheck, const MailImporter::MessageStatus &mailImporterstatus)
{
const Akonadi::MessageStatus status = convertToAkonadiMessageStatus(mailImporterstatus);
......@@ -117,7 +127,7 @@ bool FilterImporterAkonadi::importMessage(const QString &folderName, const QStri
addAkonadiMessage(mailFolder, newMessage, status);
} else {
mInfo->alert(i18n("<b>Warning:</b> Got a bad message folder, adding to root folder."));
addAkonadiMessage(mInfo->rootCollection(), newMessage, status);
addAkonadiMessage(rootCollection(), newMessage, status);
}
} else {
qCWarning(MAILIMPORTER_LOG) << "Url is not temporary file: " << msgUrl;
......@@ -141,7 +151,7 @@ Akonadi::Collection FilterImporterAkonadi::parseFolderString(const QString &fold
// Create each folder on the folder list and add it the map.
for (const QString &folder : folderList) {
if (isFirst) {
mMessageFolderCollectionMap[folder] = addSubCollection(mInfo->rootCollection(), folder);
mMessageFolderCollectionMap[folder] = addSubCollection(rootCollection(), folder);
folderBuilder = folder;
lastCollection = mMessageFolderCollectionMap[folder];
isFirst = false;
......
......@@ -36,6 +36,11 @@ public:
void clearCountDuplicate() Q_DECL_OVERRIDE;
int countDuplicates() const Q_DECL_OVERRIDE;
static Akonadi::MessageStatus convertToAkonadiMessageStatus(const MailImporter::MessageStatus &status);
Akonadi::Collection rootCollection() const;
void setRootCollection(const Akonadi::Collection &collection);
private:
/**
* Creates a hierachy of collections based on the given path string. The collection
......@@ -68,6 +73,7 @@ private:
QMultiMap<QString, QString> mMessageFolderMessageIDMap;
QMap<QString, Akonadi::Collection> mMessageFolderCollectionMap;
Akonadi::Collection mRootCollection;
int mCountDuplicates;
};
......
......@@ -34,7 +34,6 @@ public:
delete m_filterInfoGui;
m_filterInfoGui = 0;
}
Akonadi::Collection m_rootCollection;
bool m_removeDupMsg;
FilterInfoGui *m_filterInfoGui;
static bool s_terminateASAP;
......@@ -140,21 +139,6 @@ bool FilterInfo::shouldTerminate() const
return Private::s_terminateASAP;
}
QString FilterInfo::rootCollectionName() const
{
return d->m_rootCollection.name();
}
Akonadi::Collection FilterInfo::rootCollection() const
{
return d->m_rootCollection;
}
void FilterInfo::setRootCollection(const Akonadi::Collection &collection)
{
d->m_rootCollection = collection;
}
void FilterInfo::setRemoveDupMessage(bool removeDupMessage)
{
d->m_removeDupMsg = removeDupMessage;
......
......@@ -19,9 +19,9 @@
***************************************************************************/
/* Copyright (c) 2012-2017 Montel Laurent <montel@kde.org> */
#include <AkonadiCore/Collection>
#include "mailimporter_export.h"
#include <QString>
#include <QObject>
namespace MailImporter
{
......@@ -50,9 +50,6 @@ public:
bool shouldTerminate() const;
QString rootCollectionName() const;
Akonadi::Collection rootCollection() const;
void setRootCollection(const Akonadi::Collection &collection);
QWidget *parentWidget() const;
void setRemoveDupMessage(bool removeDupMessage);
bool removeDupMessage() const;
......
......@@ -118,7 +118,7 @@ bool FilterKMailArchive::importFolder(const KArchiveDirectory *folder, const QSt
{
qCDebug(MAILIMPORTER_LOG) << "Importing folder" << folder->name();
filterInfo()->addInfoLogEntry(i18n("Importing folder '%1'...", folderPath));
filterInfo()->setTo(filterInfo()->rootCollectionName() + folderPath);
//FIXME filterInfo()->setTo(filterInfo()->rootCollectionName() + folderPath);
const KArchiveDirectory *const messageDir =
dynamic_cast<const KArchiveDirectory *>(folder->entry(QStringLiteral("cur")));
if (messageDir) {
......@@ -244,8 +244,10 @@ void FilterKMailArchive::importMails(const QString &archiveFile)
if (importDirectory(archive->directory(), QString())) {
filterInfo()->setOverall(100);
filterInfo()->setCurrent(100);
#if 0 //FIXME
filterInfo()->addInfoLogEntry(i18n("Importing the archive file '%1' into the folder '%2' succeeded.",
archiveFile, filterInfo()->rootCollectionName()));
#endif
filterInfo()->addInfoLogEntry(i18np("1 message was imported.", "%1 messages were imported.",
d->mFilesDone));
} else {
......
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