summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-10 07:28:02 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-10 07:28:02 (GMT)
commit4eaf7e6bf187b868bd54ff311266f2ad0cc2222e (patch)
treed0cb7e9cf6b730a15087b461bf6886104b9787e5
parentc19d88e129718f6acaf1d70efe05ebd2c5970c58 (diff)
Reimplement ldap plugins
-rw-r--r--kaddressbook/importexportplugins/CMakeLists.txt2
-rw-r--r--kaddressbook/importexportplugins/ldap/CMakeLists.txt2
-rw-r--r--kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.cpp33
-rw-r--r--kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.h5
-rw-r--r--kaddressbook/importexportplugins/shared/CMakeLists.txt1
-rw-r--r--kaddressbook/importexportplugins/shared/importexportengine.cpp2
-rw-r--r--kaddressbook/importexportplugins/shared/importexportengine.h7
7 files changed, 49 insertions, 3 deletions
diff --git a/kaddressbook/importexportplugins/CMakeLists.txt b/kaddressbook/importexportplugins/CMakeLists.txt
index 60d039b..021bd53 100644
--- a/kaddressbook/importexportplugins/CMakeLists.txt
+++ b/kaddressbook/importexportplugins/CMakeLists.txt
@@ -1,5 +1,7 @@
add_definitions(-DTRANSLATION_DOMAIN=\"kaddressbook_importexportplugins\")
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/shared)
+
add_subdirectory(shared)
add_subdirectory(vcards)
diff --git a/kaddressbook/importexportplugins/ldap/CMakeLists.txt b/kaddressbook/importexportplugins/ldap/CMakeLists.txt
index 1e9aa81..f13ddcd 100644
--- a/kaddressbook/importexportplugins/ldap/CMakeLists.txt
+++ b/kaddressbook/importexportplugins/ldap/CMakeLists.txt
@@ -12,4 +12,6 @@ target_link_libraries(kaddressbook_importexportldapplugin KF5::KaddressbookImpor
KF5::I18n
KF5::XmlGui
KF5::Contacts
+ kaddressbookimportexportlibprivate
+ KF5::Libkdepim
)
diff --git a/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.cpp b/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.cpp
index e78e792..a803ced 100644
--- a/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.cpp
@@ -21,9 +21,14 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
+#include <QPointer>
+#include <KAddressBookImportExport/KAddressBookImportExportContactList>
+#include <Libkdepim/LdapSearchDialog>
+#include "../shared/importexportengine.h"
LDapImportExportPluginInterface::LDapImportExportPluginInterface(QObject *parent)
- : KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent)
+ : KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent),
+ mEngine(Q_NULLPTR)
{
}
@@ -47,6 +52,7 @@ void LDapImportExportPluginInterface::exec()
{
switch(mImportExportAction) {
case Import:
+ importLdap();
break;
case Export:
break;
@@ -59,3 +65,28 @@ void LDapImportExportPluginInterface::slotImportLdap()
mImportExportAction = Import;
Q_EMIT emitPluginActivated(this);
}
+
+void LDapImportExportPluginInterface::importLdap()
+{
+ KAddressBookImportExport::KAddressBookImportExportContactList contactList;
+ QPointer<KLDAP::LdapSearchDialog> dlg = new KLDAP::LdapSearchDialog(parentWidget());
+
+ if (dlg->exec() && dlg) {
+ contactList.setAddressList(dlg->selectedContacts());
+ }
+
+ delete dlg;
+ if (!mEngine) {
+ mEngine = new ImportExportEngine(this);
+ }
+ mEngine->setContactList(contactList);
+ //TODO mEngine->setDefaultAddressBook();
+ connect(mEngine, &ImportExportEngine::finished, this, &LDapImportExportPluginInterface::slotFinished);
+ mEngine->importContacts();
+}
+
+void LDapImportExportPluginInterface::slotFinished()
+{
+ mEngine->deleteLater();
+ mEngine = Q_NULLPTR;
+}
diff --git a/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.h b/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.h
index 07e2228..bd3b4d2 100644
--- a/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/ldap/ldapimportexportplugininterface.h
@@ -21,7 +21,7 @@
#define LDAPIMPORTEXPORTPLUGININTERFACE_H
#include <KAddressBookImportExport/KAddressBookImportExportPluginInterface>
-
+class ImportExportEngine;
class LDapImportExportPluginInterface : public KAddressBookImportExport::KAddressBookImportExportPluginInterface
{
Q_OBJECT
@@ -33,6 +33,9 @@ public:
void exec() Q_DECL_OVERRIDE;
private:
void slotImportLdap();
+ void slotFinished();
+ void importLdap();
+ ImportExportEngine *mEngine;
};
#endif // LDAPIMPORTEXPORTPLUGININTERFACE_H
diff --git a/kaddressbook/importexportplugins/shared/CMakeLists.txt b/kaddressbook/importexportplugins/shared/CMakeLists.txt
index 330412a..8b4fb1e 100644
--- a/kaddressbook/importexportplugins/shared/CMakeLists.txt
+++ b/kaddressbook/importexportplugins/shared/CMakeLists.txt
@@ -1,3 +1,4 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../)
set(kaddressbookimportexportprivatelib_SRCS
importexportengine.cpp
)
diff --git a/kaddressbook/importexportplugins/shared/importexportengine.cpp b/kaddressbook/importexportplugins/shared/importexportengine.cpp
index 373fee6..6133360 100644
--- a/kaddressbook/importexportplugins/shared/importexportengine.cpp
+++ b/kaddressbook/importexportplugins/shared/importexportengine.cpp
@@ -69,6 +69,7 @@ void ImportExportEngine::setDefaultAddressBook(const Akonadi::Collection &defaul
void ImportExportEngine::importContacts()
{
if (mContactsList.isEmpty()) { // nothing to import
+ Q_EMIT finished();
return;
}
@@ -119,6 +120,7 @@ void ImportExportEngine::importContacts()
Akonadi::Job *createJob = new Akonadi::ItemCreateJob(groupItem, collection);
connect(createJob, &KJob::result, this, &ImportExportEngine::slotImportJobDone);
}
+ Q_EMIT finished();
}
void ImportExportEngine::slotImportJobDone(KJob *)
diff --git a/kaddressbook/importexportplugins/shared/importexportengine.h b/kaddressbook/importexportplugins/shared/importexportengine.h
index f3a2d61..63616cd 100644
--- a/kaddressbook/importexportplugins/shared/importexportengine.h
+++ b/kaddressbook/importexportplugins/shared/importexportengine.h
@@ -21,11 +21,12 @@
#define IMPORTEXPORTENGINE_H
#include <QObject>
+#include "kaddressbookimportexportlibprivate_export.h"
#include <KAddressBookImportExport/KAddressBookImportExportContactList>
#include <AkonadiCore/Collection>
class QProgressDialog;
class KJob;
-class ImportExportEngine : public QObject
+class KADDRESSBOOKIMPORTEXPORTLIBPRIVATE_EXPORT ImportExportEngine : public QObject
{
Q_OBJECT
public:
@@ -39,6 +40,10 @@ public:
QWidget *parentWidget() const;
void setDefaultAddressBook(const Akonadi::Collection &defaultAddressBook);
+
+Q_SIGNALS:
+ void finished();
+
private:
KAddressBookImportExport::KAddressBookImportExportContactList mContactsList;
Akonadi::Collection mDefaultAddressBook;