summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-04 10:11:57 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-04 10:11:57 (GMT)
commitad1c198795df3f01746d2058d204499a42c76d59 (patch)
treeabc16a0907a5eb7590063eaf616b36850ed34719
parent295c5d4e2bd7cf415927b514fac18edc424a5f02 (diff)
downloadkolab-utils-ad1c198795df3f01746d2058d204499a42c76d59.tar.gz
Changed command-line options to a more explicit notation for future extensions.
-rw-r--r--migrationutility/main.cpp65
1 files changed, 45 insertions, 20 deletions
diff --git a/migrationutility/main.cpp b/migrationutility/main.cpp
index d887998..d04dff6 100644
--- a/migrationutility/main.cpp
+++ b/migrationutility/main.cpp
@@ -39,17 +39,21 @@ int main(int argc, char *argv[])
KCmdLineOptions options;
options.add("dry", ki18n("Dry run, doesn't change anything on the server, but only prints what would be done (Use with care until this is well tested)."));
- options.add("from <host>", ki18n("Username for IMAP Account"));
- options.add("from-port <port>", ki18n("Port to be used on IMAP Server"), "143");
- options.add("u").add("from-user <loginname>", ki18n("Username for IMAP Account"));
- options.add("y").add("from-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
- options.add("p").add("from-password <password>", ki18n("Password for IMAP Account"));
- options.add("to <host>", ki18n("Username for IMAP Account"));
- options.add("to-port <port>", ki18n("Port to be used on IMAP Server"), "143");
- options.add("to-user <loginname>", ki18n("Username for IMAP Account"));
- options.add("to-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
- options.add("to-password <password>", ki18n("Password for IMAP Account"));
+ options.add("from <type>", ki18n("Source host type"));
+ options.add("from-kolab2-host <host>", ki18n("Source Kolab2 host"));
+ 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("to <type>", ki18n("Target host type"));
+ options.add("to-kolab3-host <host>", ki18n("Target Kolab3 host"));
+ options.add("to-kolab3-port <port>", ki18n("Port"), "143");
+ options.add("to-kolab3-user <loginname>", ki18n("Username for single-user migration"));
+ options.add("to-kolab3-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
+ options.add("to-kolab3-password <password>", ki18n("Password"));
+
// options.add("e").add("encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
// 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"));
@@ -58,20 +62,41 @@ int main(int argc, char *argv[])
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- KolabSourceServer *sourceServer = new KolabSourceServer(&app);
- sourceServer->setHost(args->getOption("from"), args->getOption("from-port").toInt());
- sourceServer->setAdminCredentials(args->getOption("from-proxyauth"), args->getOption("from-password"));
- if (args->isSet("from-user")) {
- sourceServer->setSingleUser(args->getOption("from-user"));
+ SourceServer *sourceServer = 0;
+ if (!args->getOption("from").compare("kolab2", Qt::CaseInsensitive)) {
+ 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"));
+ if (args->isSet("from-kolab2-user")) {
+ kolabSourceServer->setSingleUser(args->getOption("from-kolab2-user"));
+ }
+ sourceServer = kolabSourceServer;
+ }
+ if (!args->getOption("from").compare("kolab3", Qt::CaseInsensitive)) {
+ 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"));
+ if (args->isSet("from-kolab3-user")) {
+ kolabSourceServer->setSingleUser(args->getOption("from-kolab3-user"));
+ }
+ sourceServer = kolabSourceServer;
}
- KolabServer *kolabServer = new KolabServer(&app);
- kolabServer->setHost(args->getOption("to"), args->getOption("to-port").toInt());
- kolabServer->setAdminCredentials(args->getOption("to-proxyauth"), args->getOption("to-password"));
- if (args->isSet("dry")) {
- kolabServer->setDryRun(true);
+ KolabServer *kolabServer = 0;
+ if (!args->getOption("to").compare("kolab3", Qt::CaseInsensitive)) {
+ 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"));
+ if (args->isSet("dry")) {
+ kolabServer->setDryRun(true);
+ }
}
+ if (!sourceServer || !kolabServer) {
+ Error() << "Target or Source-Server not specified";
+ return -1;
+ }
+
CoordinationJob *job = new CoordinationJob(sourceServer, kolabServer, &app);
QObject::connect(job, SIGNAL(done()), &app, SLOT(quit()));
job->start();