summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-04 17:11:19 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-04 17:11:19 (GMT)
commitfbd448e99d4d02a10e17baa36d0030ed877b7580 (patch)
treef0b44fe7a810a5161e5426cea67437c71c77b175
parentad1c198795df3f01746d2058d204499a42c76d59 (diff)
downloadkolab-utils-fbd448e99d4d02a10e17baa36d0030ed877b7580.tar.gz
Don't crash on login failure.
-rw-r--r--migrationutility/coordinationjob.cpp14
-rw-r--r--migrationutility/main.cpp5
-rw-r--r--migrationutility/migrateuserjob.cpp6
-rw-r--r--migrationutility/sourceserver.cpp2
4 files changed, 24 insertions, 3 deletions
diff --git a/migrationutility/coordinationjob.cpp b/migrationutility/coordinationjob.cpp
index a1bc809..57b68e6 100644
--- a/migrationutility/coordinationjob.cpp
+++ b/migrationutility/coordinationjob.cpp
@@ -20,6 +20,7 @@
#include "kolabserver.h"
#include "migrateuserjob.h"
#include <kolab/errorhandler.h>
+#include <QDebug>
CoordinationJob::CoordinationJob(SourceServer *sourceServer, KolabServer *kolabServer, QObject* parent)
: KJob(parent),
@@ -31,10 +32,21 @@ CoordinationJob::CoordinationJob(SourceServer *sourceServer, KolabServer *kolabS
void CoordinationJob::start()
{
- foreach (const QString &user, mSourceServer->getUserList()) {
+ const QStringList &userList = mSourceServer->getUserList();
+ if (userList.isEmpty()) {
+ Debug() << "no users found";
+ } else {
+ Debug() << "migrating the following users: ";
+ qDebug() << userList;
+ }
+ foreach (const QString &user, userList) {
MigrateUserJob *job = new MigrateUserJob(mSourceServer->getSourceAccount(user), mKolabServer->getAccount(user), this);
Q_ASSERT(job);
job->exec();
+ if (job->error()) {
+ Error() << job->errorString();
+ continue;
+ }
}
Debug() << "done";
diff --git a/migrationutility/main.cpp b/migrationutility/main.cpp
index d04dff6..3410f6c 100644
--- a/migrationutility/main.cpp
+++ b/migrationutility/main.cpp
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
options.add("from-kolab2-port <port>", ki18n("Port"), "143");
options.add("from-kolab2-user <loginname>", ki18n("Username for single-user migration"));
options.add("from-kolab2-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
- options.add("from-kolab2-password <password>", ki18n("Password for IMAP Account"));
+ options.add("from-kolab2-password <password>", ki18n("Password"));
options.add("to <type>", ki18n("Target host type"));
options.add("to-kolab3-host <host>", ki18n("Target Kolab3 host"));
@@ -64,6 +64,7 @@ int main(int argc, char *argv[])
SourceServer *sourceServer = 0;
if (!args->getOption("from").compare("kolab2", Qt::CaseInsensitive)) {
+ Debug() << "From Kolab2 Server";
KolabSourceServer *kolabSourceServer = new KolabSourceServer(&app);
kolabSourceServer->setHost(args->getOption("from-kolab2-host"), args->getOption("from-kolab2-port").toInt());
kolabSourceServer->setAdminCredentials(args->getOption("from-kolab2-proxyauth"), args->getOption("from-kolab2-password"));
@@ -73,6 +74,7 @@ int main(int argc, char *argv[])
sourceServer = kolabSourceServer;
}
if (!args->getOption("from").compare("kolab3", Qt::CaseInsensitive)) {
+ Debug() << "From Kolab3 Server";
KolabSourceServer *kolabSourceServer = new KolabSourceServer(&app);
kolabSourceServer->setHost(args->getOption("from-kolab3-host"), args->getOption("from-kolab3-port").toInt());
kolabSourceServer->setAdminCredentials(args->getOption("from-kolab3-proxyauth"), args->getOption("from-kolab3-password"));
@@ -84,6 +86,7 @@ int main(int argc, char *argv[])
KolabServer *kolabServer = 0;
if (!args->getOption("to").compare("kolab3", Qt::CaseInsensitive)) {
+ Debug() << "To Kolab3 Server";
kolabServer = new KolabServer(&app);
kolabServer->setHost(args->getOption("to-kolab3-host"), args->getOption("to-kolab3-port").toInt());
kolabServer->setAdminCredentials(args->getOption("to-kolab3-proxyauth"), args->getOption("to-kolab3-password"));
diff --git a/migrationutility/migrateuserjob.cpp b/migrationutility/migrateuserjob.cpp
index e56a003..f46afee 100644
--- a/migrationutility/migrateuserjob.cpp
+++ b/migrationutility/migrateuserjob.cpp
@@ -31,6 +31,12 @@ MigrateUserJob::MigrateUserJob(SourceAccount *sourceAccount, KolabAccount *kolab
void MigrateUserJob::start()
{
+ if (!mKolabAccount || !mSourceAccount) {
+ setError(KJob::UserDefinedError);
+ setErrorText("Failed to get source or target account");
+ emitResult();
+ return;
+ }
mKolabAccount->cleanAccount();
mKolabAccount->setupFolders();
migrateFolders(mSourceAccount->lookupFolderList());
diff --git a/migrationutility/sourceserver.cpp b/migrationutility/sourceserver.cpp
index 5cd7d51..012759d 100644
--- a/migrationutility/sourceserver.cpp
+++ b/migrationutility/sourceserver.cpp
@@ -31,7 +31,7 @@ SourceServer::SourceServer(QObject* parent): QObject(parent)
SourceAccount* SourceServer::getSourceAccount(const QString& user)
{
- return new SourceAccount(this);
+ return 0;
}