summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-10-26 15:17:05 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-10-26 15:17:05 (GMT)
commit51ed0b5b899caf806a4429e32a9d78391d49f048 (patch)
treebd59af94a3dabe05985819bb9cdf7c326a309404
parent49273576d059c21a3aba58ee4f371b40f12eaf14 (diff)
downloadkolab-utils-51ed0b5b899caf806a4429e32a9d78391d49f048.tar.gz
Kolab v2 as target.
-rw-r--r--lib/kolabaccount.cpp21
-rw-r--r--lib/kolabaccount.h5
-rw-r--r--migrationutility/kolabserver.cpp9
-rw-r--r--migrationutility/kolabserver.h3
-rw-r--r--migrationutility/main.cpp25
5 files changed, 49 insertions, 14 deletions
diff --git a/lib/kolabaccount.cpp b/lib/kolabaccount.cpp
index 8d744a1..6f62555 100644
--- a/lib/kolabaccount.cpp
+++ b/lib/kolabaccount.cpp
@@ -42,11 +42,17 @@ KolabAccount::KolabAccount(QObject* parent)
mSession(0),
mEncryptionMode(KIMAP::LoginJob::TlsV1),
mAuthenticationMode(KIMAP::LoginJob::Plain),
- mDryRun(false)
+ mDryRun(false),
+ mVersion(Kolab::KolabV3)
{
}
+void KolabAccount::setVersion(Kolab::Version version)
+{
+ mVersion = version;
+}
+
void KolabAccount::setHost(const QString& host, qint16 port)
{
mHost = host;
@@ -118,22 +124,23 @@ const char* FlagRecent2 = "\\Recent";
-KMime::Message::Ptr writeObject(const Object &obj)
+KMime::Message::Ptr KolabAccount::writeObject(const Object &obj)
{
+ const QString productId("migration-utility");
KMime::Message::Ptr msg;
if (obj.object.canConvert<KMime::Message::Ptr>()) {
msg = obj.object.value<KMime::Message::Ptr>();
} else if (obj.object.canConvert<KCalCore::Incidence::Ptr>()) {
- msg = Kolab::KolabObjectWriter::writeIncidence(obj.object.value<KCalCore::Incidence::Ptr>());
+ msg = Kolab::KolabObjectWriter::writeIncidence(obj.object.value<KCalCore::Incidence::Ptr>(), mVersion, productId);
} else if (obj.object.canConvert<KABC::Addressee>()) {
- msg = Kolab::KolabObjectWriter::writeContact(obj.object.value<KABC::Addressee>());
+ msg = Kolab::KolabObjectWriter::writeContact(obj.object.value<KABC::Addressee>(), mVersion, productId);
} else if (obj.object.canConvert<KABC::ContactGroup>()) {
- msg = Kolab::KolabObjectWriter::writeDistlist(obj.object.value<KABC::ContactGroup>());
+ msg = Kolab::KolabObjectWriter::writeDistlist(obj.object.value<KABC::ContactGroup>(), mVersion, productId);
} else if (obj.object.canConvert<Note>()) {
- msg = Kolab::KolabObjectWriter::writeNote(obj.object.value<Note>().msg);
+ msg = Kolab::KolabObjectWriter::writeNote(obj.object.value<Note>().msg, mVersion, productId);
} else if (obj.object.canConvert<Dictionary>()) {
const Dictionary dict = obj.object.value<Dictionary>();
- msg = Kolab::KolabObjectWriter::writeDictionary(dict.dict, dict.lang);
+ msg = Kolab::KolabObjectWriter::writeDictionary(dict.dict, dict.lang, mVersion, productId);
} else {
Error() << "Type not handled";
}
diff --git a/lib/kolabaccount.h b/lib/kolabaccount.h
index 3d32f1f..15c4354 100644
--- a/lib/kolabaccount.h
+++ b/lib/kolabaccount.h
@@ -19,6 +19,7 @@
#define KOLABACCOUNT_H
#include <QObject>
#include <formathelpers.h>
+#include <kolabobject.h>
#include <kimap/loginjob.h>
#include <kimap/listjob.h>
#include <kmime/kmime_message.h>
@@ -49,10 +50,13 @@ public:
QList<Object> getObjects(const QString& folder);
QStringList lookupFolderList();
+
+ void setVersion(Kolab::Version);
private slots:
void mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor> &descriptors, const QList< QList< QByteArray > > &flags);
private:
+ KMime::Message::Ptr writeObject(const Object &obj);
KIMAP::Session *mSession;
QString mHost;
int mPort;
@@ -67,6 +71,7 @@ private:
QStringList mFolders;
QStringList mCapabilities;
bool mDryRun;
+ Kolab::Version mVersion;
};
#endif // KOLABACCOUNT_H
diff --git a/migrationutility/kolabserver.cpp b/migrationutility/kolabserver.cpp
index e1cd5a5..a967bc3 100644
--- a/migrationutility/kolabserver.cpp
+++ b/migrationutility/kolabserver.cpp
@@ -24,11 +24,17 @@ KolabServer::KolabServer(QObject* parent)
mSession(0),
mEncryptionMode(KIMAP::LoginJob::TlsV1),
mAuthenticationMode(KIMAP::LoginJob::Plain),
- mDryRun(false)
+ mDryRun(false),
+ mVersion(Kolab::KolabV3)
{
}
+void KolabServer::setVersion(Kolab::Version version)
+{
+ mVersion = version;
+}
+
void KolabServer::setHost(const QString& host, qint16 port)
{
mHost = host;
@@ -53,6 +59,7 @@ KolabAccount* KolabServer::getAccount(const QString& user)
account->setHost(mHost, mPort);
account->setCredentials(user, mPw, mUsername);
account->setDryRun(mDryRun);
+ account->setVersion(mVersion);
if (!account->init()) {
account->deleteLater();
return 0;
diff --git a/migrationutility/kolabserver.h b/migrationutility/kolabserver.h
index 1c009ac..5a8c71b 100644
--- a/migrationutility/kolabserver.h
+++ b/migrationutility/kolabserver.h
@@ -18,6 +18,7 @@
#ifndef KOLABSERVER_H
#define KOLABSERVER_H
#include <QObject>
+#include <kolabobject.h>
#include <kimap/loginjob.h>
namespace KIMAP {
@@ -36,6 +37,7 @@ public:
void setDryRun(bool);
KolabAccount *getAccount(const QString &user);
+ void setVersion(Kolab::Version);
private:
void logout();
KIMAP::Session *mSession;
@@ -46,6 +48,7 @@ private:
KIMAP::LoginJob::EncryptionMode mEncryptionMode;
KIMAP::LoginJob::AuthenticationMode mAuthenticationMode;
bool mDryRun;
+ Kolab::Version mVersion;
};
#endif // KOLABSERVER_H
diff --git a/migrationutility/main.cpp b/migrationutility/main.cpp
index 73e6d4a..f475ada 100644
--- a/migrationutility/main.cpp
+++ b/migrationutility/main.cpp
@@ -105,7 +105,14 @@ int main(int argc, char *argv[])
options.add("from-exchangeimap-encrypt <mode>", ki18n("Encryption mode to be used (NONE, TLS, SSL)"), "TLS");
options.add("from-exchangeimap-auth <mode>", ki18n("Authentication mode to be used (PLAIN, LOGIN, CRAMMD5, DIGESTMD5, NTLM, GSSAPI, ANONYMOUS, CLEARTEXT)"), "PLAIN");
- options.add("to <type>", ki18n("Target host type (kolab3)"));
+ options.add("to <type>", ki18n("Target host type (kolab2, kolab3)"));
+
+ options.add("to-kolab2-host <host>", ki18n("Target Kolab2 host"));
+ options.add("to-kolab2-port <port>", ki18n("Port"), "143");
+ options.add("to-kolab2-user <loginname>", ki18n("Username for single-user migration"));
+ options.add("to-kolab2-proxyauth <loginname>", ki18n("Username to be used for authentication together with password (optional, works with PLAIN/SASL authentication)"));
+ options.add("to-kolab2-password <password>", ki18n("Password"));
+
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"));
@@ -154,21 +161,27 @@ int main(int argc, char *argv[])
}
KolabServer *kolabServer = 0;
- if (!args->getOption("to").compare("kolab3", Qt::CaseInsensitive)) {
+ if (!args->getOption("to").compare("kolab2", Qt::CaseInsensitive)) {
+ Debug() << "To Kolab2 Server";
+ kolabServer = new KolabServer(&app);
+ kolabServer->setHost(args->getOption("to-kolab2-host"), args->getOption("to-kolab2-port").toInt());
+ kolabServer->setAdminCredentials(args->getOption("to-kolab2-proxyauth"), args->getOption("to-kolab2-password"));
+ kolabServer->setVersion(Kolab::KolabV2);
+ } else 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"));
- if (args->isSet("dry")) {
- kolabServer->setDryRun(true);
- }
+ kolabServer->setVersion(Kolab::KolabV3);
}
if (!sourceServer || !kolabServer) {
Error() << "Target or Source-Server not specified";
return -1;
}
-
+ if (args->isSet("dry")) {
+ kolabServer->setDryRun(true);
+ }
CoordinationJob *job = new CoordinationJob(sourceServer, kolabServer, &app);
QObject::connect(job, SIGNAL(done()), &app, SLOT(quit()));
job->start();