Commit 4eaf7e6b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reimplement ldap plugins

parent c19d88e1
add_definitions(-DTRANSLATION_DOMAIN=\"kaddressbook_importexportplugins\")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/shared)
add_subdirectory(shared)
add_subdirectory(vcards)
......
......@@ -12,4 +12,6 @@ target_link_libraries(kaddressbook_importexportldapplugin KF5::KaddressbookImpor
KF5::I18n
KF5::XmlGui
KF5::Contacts
kaddressbookimportexportlibprivate
KF5::Libkdepim
)
......@@ -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;
}
......@@ -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
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../)
set(kaddressbookimportexportprivatelib_SRCS
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 *)
......
......@@ -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;
......
Supports Markdown
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