Commit 822d2653 authored by Laurent Montel's avatar Laurent Montel 😁

continue to implement add contact

parent af37a812
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <KMessageBox> #include <KMessageBox>
#include <KLocalizedString> #include <KLocalizedString>
#include <AkonadiWidgets/AgentTypeDialog> #include <AkonadiWidgets/AgentTypeDialog>
#include <KEmailAddress>
//#define IMPLEMENTATION_DONE 1
AutomaticAddContactsJob::AutomaticAddContactsJob(QObject *parent) AutomaticAddContactsJob::AutomaticAddContactsJob(QObject *parent)
: QObject(parent), : QObject(parent),
...@@ -53,12 +57,11 @@ void AutomaticAddContactsJob::start() ...@@ -53,12 +57,11 @@ void AutomaticAddContactsJob::start()
} }
} }
mCurrentIndex = 0; mCurrentIndex = 0;
//1) fetch collection to be sure that it's ok #ifdef IMPLEMENTATION_DONE
fetchCollection(); fetchCollection();
//TODO #else
//Remove it when implemented
deleteLater(); deleteLater();
#endif
} }
void AutomaticAddContactsJob::fetchCollection() void AutomaticAddContactsJob::fetchCollection()
...@@ -186,6 +189,17 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job) ...@@ -186,6 +189,17 @@ void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job)
void AutomaticAddContactsJob::verifyContactExist() void AutomaticAddContactsJob::verifyContactExist()
{ {
QString email = mEmails.at(mCurrentIndex);
QString tname, temail;
KEmailAddress::extractEmailAddressAndName(email, temail, tname);
if (temail.isEmpty()) {
addNextContact();
} else {
if (mProcessedEmails.contains(email)) {
addNextContact();
} else {
mProcessEmail = email;
mProcessedEmails.append(email);
#if 0 #if 0
Akonadi::ContactSearchJob *searchJob = new Akonadi::ContactSearchJob(this); Akonadi::ContactSearchJob *searchJob = new Akonadi::ContactSearchJob(this);
searchJob->setLimit(1); searchJob->setLimit(1);
...@@ -193,18 +207,22 @@ void AutomaticAddContactsJob::verifyContactExist() ...@@ -193,18 +207,22 @@ void AutomaticAddContactsJob::verifyContactExist()
Akonadi::ContactSearchJob::ExactMatch); Akonadi::ContactSearchJob::ExactMatch);
connect(searchJob, SIGNAL(result(KJob*)), SLOT(slotSearchDone(KJob*))); connect(searchJob, SIGNAL(result(KJob*)), SLOT(slotSearchDone(KJob*)));
#endif #endif
//TODO
}
}
} }
void AutomaticAddContactsJob::slotSearchDone(KJob *job) void AutomaticAddContactsJob::slotSearchDone(KJob *job)
{ {
//if empty => create new one //if empty => create new one
//TODO //TODO
mCurrentIndex++;
addNextContact(); addNextContact();
} }
void AutomaticAddContactsJob::addNextContact() void AutomaticAddContactsJob::addNextContact()
{ {
mCurrentIndex++;
if (mCurrentIndex < mEmails.count()) { if (mCurrentIndex < mEmails.count()) {
verifyContactExist(); verifyContactExist();
} else { } 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