summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-07-17 08:00:40 +0200
committerMontel Laurent <[email protected]>2016-07-17 08:00:40 +0200
commit01a8437c479e90c06a5734db95332bf103f368ca (patch)
tree746fc7f54db7428e55d4c728b2c43ed483b0e625
parent502f9bb6676198dbdf1e1bcfd7b9824d000667f8 (diff)
Add more logic
-rw-r--r--kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp26
-rw-r--r--kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.h1
2 files changed, 21 insertions, 6 deletions
diff --git a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
index e94d247..ebb0657 100644
--- a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
+++ b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp
@@ -24,6 +24,7 @@
#include <AkonadiCore/CollectionFetchScope>
#include <AkonadiCore/AgentInstanceCreateJob>
#include <KContacts/Addressee>
+#include <KContacts/ContactGroup>
#include <KMessageBox>
#include <KLocalizedString>
#include <AkonadiWidgets/AgentTypeDialog>
@@ -31,6 +32,8 @@
#include <AkonadiCore/ItemCreateJob>
#include <KEmailAddress>
#include <QPointer>
+#include <akonadi/contact/selectaddressbookdialog.h>
+#include <AkonadiCore/AgentFilterProxyModel>
//#define IMPLEMENTATION_DONE 1
@@ -113,7 +116,7 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
canCreateItemCollections.append(collection);
}
}
-#if 0
+#if 1
Akonadi::Collection addressBook;
@@ -124,7 +127,7 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
i18nc("@info",
"You must create an address book before adding a contact. Do you want to create an address book?"),
i18nc("@title:window", "No Address Book Available")) == KMessageBox::Yes) {
- Akonadi::AgentTypeDialog dlg(mParentWidget);
+ Akonadi::AgentTypeDialog dlg(0);
dlg.setWindowTitle(i18n("Add Address Book"));
dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType());
dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType());
@@ -135,8 +138,8 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
if (agentType.isValid()) {
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(agentType, this);
- q->connect(job, SIGNAL(result(KJob*)), SLOT(slotResourceCreationDone(KJob*)));
- //job->configure(mParentWidget);
+ connect(job, &KJob::result, this, &AutomaticAddContactsJob::slotResourceCreationDone);
+ job->configure();
job->start();
return;
} else { //if agent is not valid => return error and finish job
@@ -161,18 +164,18 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
if (dlg->exec()) {
addressBook = dlg->selectedCollection();
} else {
- q->setError(UserDefinedError);
- q->emitResult();
gotIt = false;
}
delete dlg;
if (!gotIt) {
+ qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to selected Addressbook selected not valid";
deleteLater();
return;
}
}
if (!addressBook.isValid()) {
+ qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Addressbook selected not valid";
deleteLater();
return;
}
@@ -180,6 +183,17 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
addNextContact();
}
+
+void AutomaticAddContactsJob::slotResourceCreationDone(KJob *job)
+{
+ if (job->error()) {
+ qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to create resource:" << job->errorText();
+ deleteLater();
+ return;
+ }
+ addNextContact();
+}
+
void AutomaticAddContactsJob::verifyContactExist()
{
QString email = mEmails.at(mCurrentIndex);
diff --git a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.h b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.h
index 70ab4b1..45c82c3 100644
--- a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.h
+++ b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.h
@@ -43,6 +43,7 @@ private:
void slotFetchAllCollections(KJob *job);
void slotSearchDone(KJob *job);
void slotAddContactDone(KJob *job);
+ void slotResourceCreationDone(KJob *);
QStringList mEmails;
QStringList mProcessedEmails;
QString mProcessEmail;