summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-09-21 13:01:31 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-09-21 13:01:31 (GMT)
commitdd02093cedd7466180295fe70953614735dec651 (patch)
tree94a123b1ebe5de59d814ec0974c9b2142438082e
parentb222214e7542075da9bf6dae8f1b079af78a91b9 (diff)
downloadkolab-utils-dd02093cedd7466180295fe70953614735dec651.tar.gz
Initial commit of migration utility
-rw-r--r--CMakeLists.txt26
-rw-r--r--migrationutility/CMakeLists.txt39
-rw-r--r--migrationutility/coordinationjob.cpp39
-rw-r--r--migrationutility/coordinationjob.h33
-rw-r--r--migrationutility/main.cpp61
-rw-r--r--migrationutility/migratefolderjob.cpp31
-rw-r--r--migrationutility/migratefolderjob.h36
-rw-r--r--migrationutility/migrateuserjob.cpp43
-rw-r--r--migrationutility/migrateuserjob.h37
-rw-r--r--migrationutility/sourceaccount.cpp54
-rw-r--r--migrationutility/sourceaccount.h50
-rw-r--r--migrationutility/sourceserver.cpp112
-rw-r--r--migrationutility/sourceserver.h61
-rw-r--r--migrationutility/tests/CMakeLists.txt24
-rw-r--r--migrationutility/tests/migrationtest.cpp29
15 files changed, 673 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dde4eb7..ddabff0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ set(BIN_INSTALL_DIR bin CACHE STRING "Where to install binaries to")
set(LIB_INSTALL_DIR lib CACHE STRING "Where to install libraries to")
find_package(Qt4 4.6.0 REQUIRED)
-find_package(Libkolab 0.3 REQUIRED)
+find_package(Libkolab 0.3.0 REQUIRED)
find_package(Libkolabxml 0.7 REQUIRED) #We should probably add the Libkolabxml_INCLUDES to Libkolab_INCLUDES if we have libkolabxml headers in the installed libkolab headers
if (USE_LIBCALENDARING)
find_package(Libcalendaring)
@@ -96,4 +96,26 @@ install(TARGETS kolab-freebusyd
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
-) \ No newline at end of file
+)
+########## Migration-Utility
+add_subdirectory(migrationutility)
+
+# QT4_WRAP_CPP(MIGRATION_MOC
+# migrationutility/coordinationjob.h
+# migrationutility/migrateuserjob.h
+# migrationutility/sourceaccount.h
+# migrationutility/sourceserver.h
+# )
+#
+# add_executable(kolab-migration ${MIGRATION_SRCS} ${MIGRATION_MOC} ${JOBS_SRCS})
+# target_link_libraries(kolab-migration ${COMMON_DEPENDENCIES})
+#
+# install(TARGETS kolab-migration
+# RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+# LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+# ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+# )
+
+########## tests
+
+add_subdirectory(tests) \ No newline at end of file
diff --git a/migrationutility/CMakeLists.txt b/migrationutility/CMakeLists.txt
new file mode 100644
index 0000000..b14578d
--- /dev/null
+++ b/migrationutility/CMakeLists.txt
@@ -0,0 +1,39 @@
+# set(MIGRATION_SRCS
+# ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
+# ${CMAKE_CURRENT_SOURCE_DIR}/migrateuserjob.cpp
+# ${CMAKE_CURRENT_SOURCE_DIR}/coordinationjob.cpp
+# ${CMAKE_CURRENT_SOURCE_DIR}/sourceaccount.cpp
+# ${CMAKE_CURRENT_SOURCE_DIR}/sourceserver.cpp
+# PARENT_SCOPE
+# )
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+set(MIGRATION_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/migrateuserjob.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/migratefolderjob.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/coordinationjob.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/sourceaccount.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/sourceserver.cpp
+)
+
+
+QT4_WRAP_CPP(MIGRATION_MOC
+ ${CMAKE_CURRENT_SOURCE_DIR}/migrateuserjob.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/migratefolderjob.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/coordinationjob.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/sourceaccount.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/sourceserver.h
+)
+
+
+add_executable(kolab-migration ${MIGRATION_SRCS} ${MIGRATION_MOC} ${JOBS_SRCS} main.cpp)
+target_link_libraries(kolab-migration ${COMMON_DEPENDENCIES})
+
+install(TARGETS kolab-migration
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+)
+
+add_subdirectory(tests) \ No newline at end of file
diff --git a/migrationutility/coordinationjob.cpp b/migrationutility/coordinationjob.cpp
new file mode 100644
index 0000000..e69c843
--- /dev/null
+++ b/migrationutility/coordinationjob.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "coordinationjob.h"
+
+CoordinationJob::CoordinationJob(SourceServer *sourceServer, QObject* parent)
+: KJob(parent),
+ mSourceServer(sourceServer)
+{
+
+}
+
+void CoordinationJob::start()
+{
+ foreach (const QString &user, mSourceServer->getUserList()) {
+ MigrateUserJob *job = mSourceServer->createMigrationJob(user);
+ Q_ASSERT(job);
+ job->exec();
+ }
+
+ emitResult();
+}
+
+// #include "moc_coordinationjob.cxx"
+// #include "coordinationjob.moc"
diff --git a/migrationutility/coordinationjob.h b/migrationutility/coordinationjob.h
new file mode 100644
index 0000000..9e7bc8d
--- /dev/null
+++ b/migrationutility/coordinationjob.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef COORDINATIONJOB_H
+#define COORDINATIONJOB_H
+#include <kjob.h>
+#include "sourceserver.h"
+
+class CoordinationJob: public KJob
+{
+ Q_OBJECT
+public:
+ explicit CoordinationJob(SourceServer *sourceServer, QObject* parent = 0);
+ virtual void start();
+private:
+ SourceServer *mSourceServer;
+};
+
+#endif // COORDINATIONJOB_H
diff --git a/migrationutility/main.cpp b/migrationutility/main.cpp
new file mode 100644
index 0000000..476baaf
--- /dev/null
+++ b/migrationutility/main.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/QStringList>
+#include <QtCore/qfile.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kolab/errorhandler.h>
+
+#include "coordinationjob.h"
+
+/**
+ * kolab-migrate --from caldav --to kolab (implied?) --caldav-host caldav.example.org --caldav-authn <admin> --caldav-authz <user> --caldav-pass <pass> --<folder-selection> --<folder-mapping> --kolab-host kolab.example.org --kolab-authn <admin> --kolab-authz <user> --kolab-pass <pass>
+
+* --regextrans2 '/Public Folders/shared/' Regex transformation of folder paths
+* Incremental conversion (folder by folder or even by batch of messages)
+* Save state persistently and resume from there after interruption (Wipe before starting and start all over as first step)
+ */
+
+int main(int argc, char *argv[])
+{
+ KCmdLineArgs::init(argc, argv, "migrationutility", "migrationutility",ki18n("migrationutility"), "0.1");
+
+ KCmdLineOptions options;
+ options.add("u").add("user <loginname>", ki18n("Username for IMAP Account"));
+ options.add("y").add("proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
+ options.add("p").add("password <password>", ki18n("Password for IMAP Account"));
+ options.add("P").add("port <port>", ki18n("Port to be used on IMAP Server"), "143");
+ options.add("e").add("encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
+ options.add("t").add("type <type>", ki18n("force the type (EVENT, TODO, JOURNAL, CONTACT). Applies only when upgrading a single file or a specific folder."));
+ options.add("a").add("auth <mode>", ki18n("Authentication mode to be used (PLAIN, LOGIN, CRAMMD5, DIGESTMD5, NTLM, GSSAPI, ANONYMOUS, CLEARTEXT)"), "PLAIN");
+ options.add("+[server/file]", ki18n("IMAP Server/File"));
+ KCmdLineArgs::addCmdLineOptions( options );
+ QCoreApplication app(argc, argv);
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ CoordinationJob *job = new CoordinationJob(new SourceServer(&app), &app);
+ job->start();
+ app.exec();
+
+ if (Kolab::ErrorHandler::instance().error() >= Kolab::ErrorHandler::Error) {
+ return -1;
+ }
+ return 0;
+}
diff --git a/migrationutility/migratefolderjob.cpp b/migrationutility/migratefolderjob.cpp
new file mode 100644
index 0000000..d03b82b
--- /dev/null
+++ b/migrationutility/migratefolderjob.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "migratefolderjob.h"
+
+MigrateFolderJob::MigrateFolderJob(const QString &folder, SourceAccount* sourceAccount, QObject* parent)
+: mSourceAccount(sourceAccount),
+ mFolder(folder)
+{
+
+}
+
+void MigrateFolderJob::start()
+{
+ mSourceAccount->getObjects(mFolder);
+ emitResult();
+} \ No newline at end of file
diff --git a/migrationutility/migratefolderjob.h b/migrationutility/migratefolderjob.h
new file mode 100644
index 0000000..cad9414
--- /dev/null
+++ b/migrationutility/migratefolderjob.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MIGRATEFOLDERJOB_H
+#define MIGRATEFOLDERJOB_H
+
+#include <kjob.h>
+#include <qsharedpointer.h>
+#include "sourceaccount.h"
+
+class MigrateFolderJob: public KJob
+{
+ Q_OBJECT
+public:
+ explicit MigrateFolderJob(const QString &folder, SourceAccount *sourceAccount, QObject* parent = 0);
+ virtual void start();
+private:
+ SourceAccount *mSourceAccount;
+ QString mFolder;
+};
+
+#endif // MIGRATEFOLDERJOB_H
diff --git a/migrationutility/migrateuserjob.cpp b/migrationutility/migrateuserjob.cpp
new file mode 100644
index 0000000..d6fac70
--- /dev/null
+++ b/migrationutility/migrateuserjob.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "migrateuserjob.h"
+#include "migratefolderjob.h"
+
+MigrateUserJob::MigrateUserJob(SourceAccount *sourceAccount, QObject* parent)
+: KJob(parent),
+ mSourceAccount(sourceAccount)
+{
+ connect(mSourceAccount, SIGNAL(folderList(QStringList)), this, SLOT(receivedFolderList(QStringList)));
+}
+
+void MigrateUserJob::start()
+{
+ receivedFolderList(mSourceAccount->lookupFolderList());
+}
+
+void MigrateUserJob::receivedFolderList(const QStringList &folders)
+{
+ foreach (const QString &folder, folders) {
+ MigrateFolderJob *job = new MigrateFolderJob(folder, mSourceAccount, this);
+ job->exec();
+ }
+ emitResult();
+}
+
+
+// #include "migrateuserjob.moc"
diff --git a/migrationutility/migrateuserjob.h b/migrationutility/migrateuserjob.h
new file mode 100644
index 0000000..b5b13f2
--- /dev/null
+++ b/migrationutility/migrateuserjob.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MIGRATEUSERJOB_H
+#define MIGRATEUSERJOB_H
+
+#include <kjob.h>
+#include <qsharedpointer.h>
+#include "sourceaccount.h"
+
+class MigrateUserJob: public KJob
+{
+ Q_OBJECT
+public:
+ explicit MigrateUserJob(SourceAccount *sourceAccount, QObject* parent = 0);
+ virtual void start();
+private slots:
+ void receivedFolderList(const QStringList &);
+private:
+ SourceAccount *mSourceAccount;
+};
+
+#endif // MIGRATEUSERJOB_H
diff --git a/migrationutility/sourceaccount.cpp b/migrationutility/sourceaccount.cpp
new file mode 100644
index 0000000..60d2bbc
--- /dev/null
+++ b/migrationutility/sourceaccount.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "sourceaccount.h"
+
+SourceAccount::SourceAccount(QObject* parent)
+: QObject(parent)
+{
+
+}
+
+QStringList SourceAccount::lookupFolderList()
+{
+ return QStringList();
+}
+
+void SourceAccount::getObjects(const QString& folder)
+{
+
+}
+
+TestAccount::TestAccount(QObject* parent)
+{
+ mFolderList << QLatin1String("folder1");
+ mFolderList << QLatin1String("folder2");
+ mFolderList << QLatin1String("folder3");
+}
+
+QStringList TestAccount::lookupFolderList()
+{
+ return mFolderList;
+}
+
+void TestAccount::getObjects(const QString& folder)
+{
+ Q_ASSERT(mFolderList.removeAll(folder) == 1);
+}
+
+
+// #include "sourceaccount.moc"
diff --git a/migrationutility/sourceaccount.h b/migrationutility/sourceaccount.h
new file mode 100644
index 0000000..60c8bfe
--- /dev/null
+++ b/migrationutility/sourceaccount.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SOURCEACCOUNT_H
+#define SOURCEACCOUNT_H
+
+#include <QObject>
+#include <QStringList>
+
+class SourceAccount: public QObject
+{
+ Q_OBJECT
+public:
+ explicit SourceAccount(QObject* parent = 0);
+
+ virtual QStringList lookupFolderList();
+ virtual void getObjects(const QString &folder);
+signals:
+ void folderList(const QStringList &);
+// FindFoldersJob *getFolderList();
+// GetObjectsJob *getObjects(const QString &folder);
+// KolabObject convertObject();
+// QString getDestinationFolder(const QString &folder);
+};
+
+class TestAccount: public SourceAccount
+{
+ Q_OBJECT
+public:
+ explicit TestAccount(QObject* parent = 0);
+ virtual QStringList lookupFolderList();
+ virtual void getObjects(const QString &folder);
+ QStringList mFolderList;
+};
+
+#endif // SOURCEACCOUNT_H
diff --git a/migrationutility/sourceserver.cpp b/migrationutility/sourceserver.cpp
new file mode 100644
index 0000000..94deefa
--- /dev/null
+++ b/migrationutility/sourceserver.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "sourceserver.h"
+#include <commonconversion.h>
+#include <kimap/listjob.h>
+
+
+SourceServer::SourceServer(QObject* parent): QObject(parent)
+{
+
+}
+
+MigrateUserJob* SourceServer::createMigrationJob(const QString& user)
+{
+ return new MigrateUserJob(new SourceAccount(this), this);
+}
+
+QStringList SourceServer::getUserList()
+{
+ return QStringList();
+}
+
+
+TestServer::TestServer(QObject* parent)
+: SourceServer(parent)
+{
+ mUsers << QLatin1String("user1");
+ mUsers << QLatin1String("user2");
+ mUsers << QLatin1String("user3");
+}
+
+QStringList TestServer::getUserList()
+{
+ return mUsers;
+}
+
+MigrateUserJob* TestServer::createMigrationJob(const QString& user)
+{
+ Q_ASSERT(mUsers.removeAll(user) == 1);
+ return new MigrateUserJob(new TestAccount(this), this);
+}
+
+//---------------------------------------------------------------------------
+
+class UiProxy: public KIMAP::SessionUiProxy {
+ public:
+ bool ignoreSslError(const KSslErrorUiData& /*errorData*/) {
+ return true; //Necessary due to the untrusted certificate
+ }
+};
+
+KolabSourceServer::KolabSourceServer(QObject* parent)
+{
+
+}
+
+MigrateUserJob* KolabSourceServer::createMigrationJob(const QString& user)
+{
+ return 0;
+}
+
+QStringList KolabSourceServer::getUserList()
+{
+
+ KIMAP::Session *mSession = new KIMAP::Session( mHostName, mPort, this );
+ mSession->setUiProxy( KIMAP::SessionUiProxy::Ptr(new UiProxy()) );
+// QObject::connect( mSession, SIGNAL(stateChanged(KIMAP::Session::State,KIMAP::Session::State)),
+// this, SLOT(onSessionStateChanged(KIMAP::Session::State,KIMAP::Session::State)) );
+
+ KIMAP::LoginJob *loginJob = new KIMAP::LoginJob( mSession );
+// if (!proxyauth.isEmpty()) {
+// loginJob->setAuthorizationName(proxyauth);
+// }
+ loginJob->setUserName( username );
+ loginJob->setPassword( pw );
+ loginJob->setEncryptionMode( encryptionMode );
+// if (encryptionMode != KIMAP::LoginJob::Unencrypted) {
+// m_requireEncryption = true;
+// } else {
+// m_requireEncryption = false;
+// }
+ loginJob->setAuthenticationMode( authenticationMode );
+/*
+ QObject::connect( loginJob, SIGNAL(result(KJob*)),
+ this, SLOT(onLoginDone(KJob*)) );
+ loginJob->start(); */
+ loginJob->exec();
+
+// KIMAP::ListJob *listJob = new KIMAP::ListJob(mSession);
+// listJob->setOption(KIMAP::ListJob::IncludeUnsubscribed);
+// listJob->exec();
+// listJob->mailBoxes();
+}
+
+
+// #include "moc_sourceserver.cxx"
+// #include "sourceserver.moc"
diff --git a/migrationutility/sourceserver.h b/migrationutility/sourceserver.h
new file mode 100644
index 0000000..fb3caa0
--- /dev/null
+++ b/migrationutility/sourceserver.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SOURCESERVER_H
+#define SOURCESERVER_H
+
+#include <kimap/session.h>
+#include <kimap/loginjob.h>
+#include <qsharedpointer.h>
+#include <QStringList>
+#include "sourceaccount.h"
+#include "migrateuserjob.h"
+
+class SourceServer: public QObject
+{
+ Q_OBJECT
+public:
+ explicit SourceServer(QObject* parent = 0);
+// void setAdminCredentials(const QString &username, const QString &pw);
+ virtual MigrateUserJob *createMigrationJob(const QString &user);
+// QSharedPointer<SourceAccount> getSourceAccount(const QString &username, const QString &pw);
+ virtual QStringList getUserList();
+};
+
+
+class TestServer: public SourceServer
+{
+ Q_OBJECT
+public:
+ explicit TestServer(QObject* parent = 0);
+
+ virtual MigrateUserJob *createMigrationJob(const QString &user);
+ virtual QStringList getUserList();
+ QStringList mUsers;
+};
+
+class KolabSourceServer: public SourceServer
+{
+ Q_OBJECT
+public:
+ explicit KolabSourceServer(QObject* parent = 0);
+
+ virtual MigrateUserJob *createMigrationJob(const QString &user);
+ virtual QStringList getUserList();
+};
+
+#endif // SOURCESERVER_H
diff --git a/migrationutility/tests/CMakeLists.txt b/migrationutility/tests/CMakeLists.txt
new file mode 100644
index 0000000..d7c6144
--- /dev/null
+++ b/migrationutility/tests/CMakeLists.txt
@@ -0,0 +1,24 @@
+
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+# QT4_WRAP_CPP(MIGRATIONTEST_MOC
+# ${CMAKE_CURRENT_SOURCE_DIR}/migrationtest.cpp
+# )
+
+
+# QT4_AUTOMOC(
+# ${CMAKE_CURRENT_SOURCE_DIR}/migrationtest.cpp
+# )
+qt4_generate_moc(
+ ${CMAKE_CURRENT_SOURCE_DIR}/migrationtest.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/migrationtest.moc
+)
+
+# message("blasbblab ${kolabproxy_shared_relative_SRCS} : ${MIGRATION_SRCS}")
+# message("sdfsdf ${MIGRATIONTEST_MOC}")
+
+add_executable(migrationtest ${MIGRATION_SRCS} ${MIGRATION_MOC} migrationtest.cpp)
+# set_target_properties(migrationtest PROPERTIES AUTOMOC TRUE)
+
+target_link_libraries(migrationtest ${COMMON_DEPENDENCIES} ${QT_QTTEST_LIBRARY})
diff --git a/migrationutility/tests/migrationtest.cpp b/migrationutility/tests/migrationtest.cpp
new file mode 100644
index 0000000..521da79
--- /dev/null
+++ b/migrationutility/tests/migrationtest.cpp
@@ -0,0 +1,29 @@
+#include <QObject>
+#include <QTest>
+#include <coordinationjob.h>
+
+class MigrationTest : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testUsersProcessed()
+ {
+ TestServer *server = new TestServer(this);
+ CoordinationJob *job = new CoordinationJob(server, this);
+ job->exec();
+ QVERIFY(server->mUsers.isEmpty());
+ }
+
+ void testFoldersProcessed()
+ {
+ TestAccount *server = new TestAccount(this);
+ MigrateUserJob *job = new MigrateUserJob(server, this);
+ job->exec();
+ QVERIFY(server->mFolderList.isEmpty());
+ }
+};
+
+QTEST_MAIN( MigrationTest )
+
+// #include "moc_migrationtest.cxx"
+#include "migrationtest.moc" \ No newline at end of file