Commit f398e7b3 authored by Laurent Montel's avatar Laurent Montel 😁

Emit signal when job is done

parent 9e1999ed
......@@ -22,7 +22,7 @@
"Description[sv]": "Insticksprogrammet gör det möjligt att importera och exportera GMX.",
"Description[uk]": "За допомогою цього додатка можна імпортувати та експортувати дані у форматі GMX.",
"Description[x-test]": "xxThis plugin allows you to import/export GMX.xx",
"EnabledByDefault": "true",
"EnabledByDefault": "false",
"Id": "kaddressbookimportexportgmx",
"Name": "Import Export GMX",
"Name[ca@valencia]": "Importa/exporta el GMX",
......
......@@ -47,12 +47,12 @@ AutomaticAddContactsJob::~AutomaticAddContactsJob()
void AutomaticAddContactsJob::start()
{
if (mEmails.isEmpty()) {
deleteLater();
deleteLaterAndEmitSignal();
return;
} else {
if (!mCollection.isValid()) {
qCDebug(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Invalid collection";
deleteLater();
deleteLaterAndEmitSignal();
return;
}
}
......@@ -93,7 +93,7 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
{
if (job->error()) {
qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Error during AutomaticAddContactsJob::slotFetchAllCollections : " << job->errorString();
deleteLater();
deleteLaterAndEmitSignal();
return;
}
......@@ -131,15 +131,15 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
job->start();
return;
} else { //if agent is not valid => return error and finish job
deleteLater();
deleteLaterAndEmitSignal();
return;
}
} else { //Canceled create agent => return error and finish job
deleteLater();
deleteLaterAndEmitSignal();
return;
}
} else {
deleteLater();
deleteLaterAndEmitSignal();
return;
}
} else if (nbItemCollection == 1) {
......@@ -157,14 +157,14 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
delete dlg;
if (!gotIt) {
qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to selected Addressbook selected not valid";
deleteLater();
deleteLaterAndEmitSignal();
return;
}
}
if (!addressBook.isValid()) {
qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Addressbook selected not valid";
deleteLater();
deleteLaterAndEmitSignal();
return;
}
addNextContact();
......@@ -174,7 +174,7 @@ void AutomaticAddContactsJob::slotResourceCreationDone(KJob *job)
{
if (job->error()) {
qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to create resource:" << job->errorText();
deleteLater();
deleteLaterAndEmitSignal();
return;
}
addNextContact();
......@@ -240,7 +240,7 @@ void AutomaticAddContactsJob::addNextContact()
if (mCurrentIndex < mEmails.count()) {
verifyContactExist();
} else {
deleteLater();
deleteLaterAndEmitSignal();
}
}
......@@ -255,3 +255,9 @@ void AutomaticAddContactsJob::setCollection(const Akonadi::Collection &collectio
{
mCollection = collection;
}
void AutomaticAddContactsJob::deleteLaterAndEmitSignal()
{
Q_EMIT finished();
deleteLater();
}
......@@ -35,6 +35,9 @@ public:
void setEmails(const QStringList &list);
void setCollection(const Akonadi::Collection &collection);
Q_SIGNALS:
void finished();
private:
void fetchCollection();
void verifyContactExist();
......@@ -44,6 +47,8 @@ private:
void slotSearchDone(KJob *job);
void slotAddContactDone(KJob *job);
void slotResourceCreationDone(KJob *);
void deleteLaterAndEmitSignal();
QStringList mEmails;
QStringList mProcessedEmails;
QString mProcessEmail;
......
......@@ -19,11 +19,12 @@
#include "automaticaddcontactsjobtest.h"
#include <QTest>
#include <QStandardPaths>
AutomaticAddContactsJobTest::AutomaticAddContactsJobTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
AutomaticAddContactsJobTest::~AutomaticAddContactsJobTest()
......
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