Commit 658e673b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Return info when we can't import mail. + remove warning

parent 1d409dd4
......@@ -25,7 +25,8 @@ FilterImporterTest::FilterImporterTest(MailImporter::FilterInfo *info)
bool FilterImporterTest::importMessage(const QString &folderName, const QString &msgPath, bool duplicateCheck, const MailImporter::MessageStatus &status)
{
qDebug() << "FilterImporterTest::importMessage folderName " << folderName << " msgPath " << msgPath;
Q_UNUSED(status);
qDebug() << "FilterImporterTest::importMessage folderName " << folderName << " msgPath " << msgPath << " duplicateCheck " << duplicateCheck;
return false;
}
......@@ -49,6 +50,10 @@ QString FilterImporterTest::topLevelFolder() const
bool FilterImporterTest::importMessage(const KArchiveFile *file, const QString &folderPath, int &nbTotal, int &fileDone)
{
Q_UNUSED(file);
Q_UNUSED(folderPath);
Q_UNUSED(nbTotal);
Q_UNUSED(fileDone);
return false;
}
......
......@@ -202,7 +202,9 @@ void FilterEvolution::importMBox(const QString &mboxName, const QString &rootDir
destFolder = QLatin1String("Evolution-Import/") + destFolder;
}
importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
const int currentPercentage = (int)(((float)mbox.pos() / filenameInfo.size()) * 100);
filterInfo()->setCurrent(currentPercentage);
......
......@@ -264,7 +264,9 @@ void FilterEvolution_v2::importMBox(const QString &mboxName, const QString &root
}
}
importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
int currentPercentage = (int)(((float)mbox.pos() / filenameInfo.size()) * 100);
filterInfo()->setCurrent(currentPercentage);
......
......@@ -139,7 +139,10 @@ void FilterLNotes::ImportLNotes(const QString &file)
// close file, send it
tempfile->close();
importMessage(folder, tempfile->fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folder, tempfile->fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tempfile->fileName()));
}
tempfile->setAutoRemove(true);
state = 0;
......@@ -168,7 +171,9 @@ void FilterLNotes::ImportLNotes(const QString &file)
if (state != 0) {
Q_ASSERT(tempfile);
importMessage(folder, tempfile->fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folder, tempfile->fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tempfile->fileName()));
}
}
if (tempfile) {
tempfile->setAutoRemove(true);
......
......@@ -125,7 +125,10 @@ void FilterMailApp::importMails(const QString &maildir)
tmp.flush();
first_msg = false;
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
int currentPercentage = (int)(((float)mbox.pos() / filenameInfo.size()) * 100);
filterInfo()->setCurrent(currentPercentage);
......
......@@ -122,7 +122,9 @@ void FilterMailmanGzip::importMails(const QStringList &filenames)
first_msg = false;
if (tmp.size() > 0) {
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
} else {
qCWarning(MAILIMPORTER_LOG) << "Message size is 0 bytes, not importing it.";
}
......
......@@ -118,7 +118,9 @@ void FilterMBox::importMails(const QStringList &filenames)
first_msg = false;
if (tmp.size() > 0) {
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
} else {
qCWarning(MAILIMPORTER_LOG) << "Message size is 0 bytes, not importing it.";
}
......
......@@ -210,7 +210,9 @@ void FilterOE::mbxImport(QDataStream &ds)
}
} while (!ds.atEnd());
tmp.flush();
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
if (filterInfo()->shouldTerminate()) {
return;
......@@ -371,7 +373,9 @@ void FilterOE::dbxReadEmail(QDataStream &ds, int filePos)
tmp.flush();
if (!_break) {
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
currentEmail++;
int currentPercentage = (int)(((float)currentEmail / totalEmails) * 100);
......
......@@ -129,7 +129,9 @@ void FilterOpera::importBox(const QDir &importDir, const QStringList &files, con
tmp.flush();
first_msg = false;
importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folderName, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
int currentPercentage = (int)(((float)operaArchiv.pos() / filenameInfo.size()) * 100);
filterInfo()->setCurrent(currentPercentage);
......
......@@ -116,7 +116,9 @@ void FilterPMail::importNewMessage(const QString &file)
QString destFolder(QStringLiteral("PegasusMail-Import/New Messages"));
filterInfo()->setTo(destFolder);
importMessage(destFolder, file, filterInfo()->removeDupMessage());
if (!importMessage(destFolder, file, filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", file));
}
}
/** this function imports one mail folder file (*.PMM) */
......@@ -193,7 +195,9 @@ void FilterPMail::importMailFolder(const QString &file)
}
}
tempfile.flush();
importMessage(folder, tempfile.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folder, tempfile.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tempfile.fileName()));
}
first_msg = false;
}
......@@ -256,7 +260,9 @@ void FilterPMail::importUnixMailFolder(const QString &file)
}
}
tempfile.flush();
importMessage(folder, tempfile.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(folder, tempfile.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tempfile.fileName()));
}
n++;
filterInfo()->setCurrent(i18n("Message %1", n));
......
......@@ -241,7 +241,9 @@ void FilterTheBat::importFiles(const QString &FileName)
tmp.write(input.constData(), endPos - lastPos);
tmp.flush();
importMessage(_path, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(_path, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
lastPos = endPos + 48;
tbb.seek(lastPos);
......
......@@ -350,8 +350,9 @@ void FilterThunderbird::importMBox(const QString &mboxName, const QString &rootD
destFolder.remove(QStringLiteral(".sbd"));
}
}
importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage());
if (!importMessage(destFolder, tmp.fileName(), filterInfo()->removeDupMessage())) {
filterInfo()->addErrorLogEntry(i18n("Could not import %1", tmp.fileName()));
}
int currentPercentage = (int)(((float)mbox.pos() / filenameInfo.size()) * 100);
filterInfo()->setCurrent(currentPercentage);
......
......@@ -25,7 +25,8 @@ FilterImporterTest::FilterImporterTest(MailImporter::FilterInfo *info)
bool FilterImporterTest::importMessage(const QString &folderName, const QString &msgPath, bool duplicateCheck, const MailImporter::MessageStatus &status)
{
qDebug() << "FilterImporterTest::importMessage folderName " << folderName << " msgPath " << msgPath;
Q_UNUSED(status)
qDebug() << "FilterImporterTest::importMessage folderName " << folderName << " msgPath " << msgPath << " duplicateCheck " << duplicateCheck;
return false;
}
......@@ -49,6 +50,11 @@ QString FilterImporterTest::topLevelFolder() const
bool FilterImporterTest::importMessage(const KArchiveFile *file, const QString &folderPath, int &nbTotal, int &fileDone)
{
Q_UNUSED(file);
Q_UNUSED(folderPath);
Q_UNUSED(nbTotal);
Q_UNUSED(fileDone);
return false;
}
......
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