3 commits - imapupgradejob.cpp imapupgradejob.h testfiles/dictionary.mime upgradetool.cpp upgradeutilities.cpp

Christian Mollekopf mollekopf at kolabsys.com
Mon Jun 18 21:13:13 CEST 2012


 imapupgradejob.cpp        |   12 ++++++++++++
 imapupgradejob.h          |    1 +
 testfiles/dictionary.mime |   35 +++++++++++++++++++++++++++++++++++
 upgradetool.cpp           |   18 ++++++++++++++++--
 upgradeutilities.cpp      |    9 +++++++++
 5 files changed, 73 insertions(+), 2 deletions(-)

New commits:
commit 6a1ab003b3bfb46de49eec29447db3b88ebc10f8
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Jun 7 17:12:24 2012 +0200

    support a bunch of authentication methods

diff --git a/upgradetool.cpp b/upgradetool.cpp
index 02fda17..219fae1 100644
--- a/upgradetool.cpp
+++ b/upgradetool.cpp
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
     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("a").add("auth <mode>", ki18n("Authentication mode to be used (PLAIN)"), "PLAIN");
+    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);
@@ -75,11 +75,25 @@ int main(int argc, char *argv[])
             kWarning() << "unknown encryption mode";
             return -1;
         }
-        
+
         KIMAP::LoginJob::AuthenticationMode authenticationMode = KIMAP::LoginJob::Plain;
         const QString &auth = args->getOption("auth");
         if (auth == "PLAIN") {
             authenticationMode = KIMAP::LoginJob::Plain;
+        } else if (auth == "LOGIN") {
+            authenticationMode = KIMAP::LoginJob::Login;
+        } else if (auth == "CRAMMD5") {
+            authenticationMode = KIMAP::LoginJob::CramMD5;
+        } else if (auth == "DIGESTMD5") {
+            authenticationMode = KIMAP::LoginJob::DigestMD5;
+        } else if (auth == "NTLM") {
+            authenticationMode = KIMAP::LoginJob::NTLM;
+        } else if (auth == "GSSAPI") {
+            authenticationMode = KIMAP::LoginJob::GSSAPI;
+        } else if (auth == "ANONYMOUS") {
+            authenticationMode = KIMAP::LoginJob::Anonymous;
+        } else if (auth == "CLEARTEXT") {
+            authenticationMode = KIMAP::LoginJob::ClearText;
         } else {
             kWarning() << "unknown authentication mode";
             return -1;


commit f04df3caa2536b42000e917b950323e7062e937b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Jun 7 16:50:49 2012 +0200

    support for dictionary entries

diff --git a/testfiles/dictionary.mime b/testfiles/dictionary.mime
new file mode 100644
index 0000000..da284d7
--- /dev/null
+++ b/testfiles/dictionary.mime
@@ -0,0 +1,35 @@
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="=_5f7ebb6cefb61acbd6a18243e5afb997"
+From: thomas at debian-vm.local
+To: thomas at debian-vm.local
+Date: Wed, 23 May 2012 11:34:43 +0200
+X-Kolab-Type: application/x-vnd.kolab.configuration.dictionary.en
+Subject: 81458fc3b41e2857702702a027cc7e96
+Message-ID: <f5a028649377240641aab6f6176f670d at debian-vm.local>
+
+
+--=_5f7ebb6cefb61acbd6a18243e5afb997
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain; charset=ISO-8859-1
+
+This is a Kolab Groupware object. To view this object you will need an emai=
+l client that understands the Kolab Groupware format. For a list of such em=
+ail clients please visit http://www.kolab.org/kolab2-clients.html
+--=_5f7ebb6cefb61acbd6a18243e5afb997
+Content-Transfer-Encoding: 8bit
+Content-Type: application/xml; charset=UTF-8; name=configuration.dictionary.en.xml
+Content-Disposition: attachment; filename=configuration.dictionary.en.xml
+
+<?xml version="1.0"?>
+<configuration version="2.1">
+  <uid>81458fc3b41e2857702702a027cc7e96</uid>
+  <creation-date>2012-05-23T09:34:43Z</creation-date>
+  <last-modification-date>2012-05-23T09:34:43Z</last-modification-date>
+  <product-id>Horde::Kolab</product-id>
+  <type>dictionary</type>
+  <language>en</language>
+  <e>Kolab</e>
+  <e>Roundcube</e>
+</configuration>
+
+--=_5f7ebb6cefb61acbd6a18243e5afb997--
\ No newline at end of file
diff --git a/upgradeutilities.cpp b/upgradeutilities.cpp
index 5408cb3..85626be 100644
--- a/upgradeutilities.cpp
+++ b/upgradeutilities.cpp
@@ -43,7 +43,13 @@ KMime::Message::Ptr upgradeMessage(KMime::Message::Ptr msg)
             return Kolab::KolabObjectWriter::writeDistlist(reader.getDistlist());
         case Kolab::NoteObject:
             return Kolab::KolabObjectWriter::writeNote(reader.getNote());
+        case Kolab::DictionaryConfigurationObject: {
+            QString lang;
+            const QStringList &dict = reader.getDictionary(lang);
+            return Kolab::KolabObjectWriter::writeDictionary(dict, lang);
+        }
         case Kolab::InvalidObject:
+            //TODO handle configuration objects
             kWarning() << "failed to read mime file";
     }
     return KMime::Message::Ptr();
@@ -60,6 +66,9 @@ QString upgradeMime(const QByteArray &input)
     msg->content(KMime::ContentIndex());
         
     KMime::Message::Ptr message = upgradeMessage(msg);
+    if (!message) {
+        return QString();
+    }
 
     QString result;
     QTextStream s(&result);


commit c3bc3072c70e2804be64065dae31d6ee31ace29b
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date:   Thu Jun 7 16:48:53 2012 +0200

    Ensure that connection is encrypted if encryption was requested.

diff --git a/imapupgradejob.cpp b/imapupgradejob.cpp
index 49006d3..46c95e7 100644
--- a/imapupgradejob.cpp
+++ b/imapupgradejob.cpp
@@ -78,6 +78,11 @@ void ImapUpgradeJob::connectToAccount(const QString &hostName, qint16 port, cons
     loginJob->setPassword( pw );
     //TODO make configureable
     loginJob->setEncryptionMode( encryptionMode );
+    if (encryptionMode != KIMAP::LoginJob::Unencrypted) {
+        m_requireEncryption = true;
+    } else {
+        m_requireEncryption = false;
+    }
     loginJob->setAuthenticationMode( authenticationMode );
     
     QObject::connect( loginJob, SIGNAL(result(KJob*)),
@@ -104,6 +109,13 @@ void ImapUpgradeJob::onLoginDone( KJob *job )
         emitResult();
         return;
     }
+
+    if (m_requireEncryption && login->encryptionMode() == KIMAP::LoginJob::Unencrypted) {
+        setError(KJob::UserDefinedError);
+        setErrorText("failed to encrypt communication");
+        emitResult();
+        return;
+    }
     
     KIMAP::CapabilitiesJob *capabilities = new KIMAP::CapabilitiesJob(m_session);
     connect(capabilities, SIGNAL(result(KJob*)), this, SLOT(onCapabilitiesTestDone(KJob*)));
diff --git a/imapupgradejob.h b/imapupgradejob.h
index e7ba86c..ff12f37 100644
--- a/imapupgradejob.h
+++ b/imapupgradejob.h
@@ -53,6 +53,7 @@ private:
     QList<KIMAP::MailBoxDescriptor> m_personalNamespaces;
     QList<KIMAP::MailBoxDescriptor> m_excludedNamespaces;
     QStringList m_capabilities;
+    bool m_requireEncryption;
 };
 
 #endif // IMAPUPGRADER_H





More information about the commits mailing list