[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [sink/develop] examples/imapresource: Use username instead of just user
From:       Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date:       2016-06-30 19:49:32
Message-ID: E1bIhxs-0005c3-N3 () code ! kde ! org
[Download RAW message or body]

Git commit 2ce8dcf40f22dd4e9cf4a6b1c8f5386993ebba6e by Christian Mollekopf.
Committed on 23/06/2016 at 14:44.
Pushed by cmollekopf into branch 'develop'.

Use username instead of just user

M  +14   -1    examples/imapresource/imapresource.cpp
M  +5    -1    examples/imapresource/imapserverproxy.cpp
M  +2    -2    examples/imapresource/tests/imapmailsynctest.cpp
M  +1    -1    examples/imapresource/tests/imapmailtest.cpp

http://commits.kde.org/akonadi-next/2ce8dcf40f22dd4e9cf4a6b1c8f5386993ebba6e

diff --git a/examples/imapresource/imapresource.cpp \
b/examples/imapresource/imapresource.cpp index a97f860..18747bf 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -294,6 +294,8 @@ public:
     {
         Log() << " Synchronizing";
         return KAsync::start<void>([this](KAsync::Future<void> future) {
+            Trace() << "Connecting to:" << mServer << mPort;
+            Trace() << "as:" << mUser;
             ImapServerProxy imap(mServer, mPort);
             auto loginFuture = imap.login(mUser, mPassword).exec();
             loginFuture.waitForFinished();
@@ -542,8 +544,17 @@ ImapResource::ImapResource(const QByteArray &instanceIdentifier, \
const QSharedPo  auto config = ResourceConfig::getConfiguration(instanceIdentifier);
     mServer = config.value("server").toString();
     mPort = config.value("port").toInt();
-    mUser = config.value("user").toString();
+    mUser = config.value("username").toString();
     mPassword = config.value("password").toString();
+    if (mServer.startsWith("imap")) {
+        mServer.remove("imap://");
+        mServer.remove("imaps://");
+    }
+    if (mServer.contains(':')) {
+        auto list = mServer.split(':');
+        mServer = list.at(0);
+        mPort = list.at(1).toInt();
+    }
 
     auto synchronizer = QSharedPointer<ImapSynchronizer>::create(PLUGIN_NAME, \
instanceIdentifier);  synchronizer->mServer = mServer;
@@ -603,6 +614,8 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const \
QByteArray &in  scope.mode = KIMAP::FetchJob::FetchScope::Full;
         auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort);
         auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create();
+        Trace() << "Connecting to:" << mServer << mPort;
+        Trace() << "as:" << mUser;
         auto inspectionJob = imap->login(mUser, mPassword)
             .then<void>(imap->select(folderRemoteId))
             .then<void>(imap->fetch(set, scope, [imap, messageByUid](const \
                QVector<Imap::Message> &messages) {
diff --git a/examples/imapresource/imapserverproxy.cpp \
b/examples/imapresource/imapserverproxy.cpp index 703caca..fbda02e 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -99,7 +99,11 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, \
const QString  loginJob->setUserName(username);
     loginJob->setPassword(password);
     loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain);
-    loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion);
+    if (mSession->port() == 143) {
+        loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::TlsV1);
+    } else {
+        loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion);
+    }
 
     auto capabilitiesJob = new KIMAP::CapabilitiesJob(mSession);
     QObject::connect(capabilitiesJob, &KIMAP::CapabilitiesJob::capabilitiesReceived, \
                [this](const QStringList &capabilities) {
diff --git a/examples/imapresource/tests/imapmailsynctest.cpp \
b/examples/imapresource/tests/imapmailsynctest.cpp index b0d5b22..968cde5 100644
--- a/examples/imapresource/tests/imapmailsynctest.cpp
+++ b/examples/imapresource/tests/imapmailsynctest.cpp
@@ -48,7 +48,7 @@ protected:
         auto resource = ApplicationDomain::ImapResource::create("account1");
         resource.setProperty("server", "localhost");
         resource.setProperty("port", 993);
-        resource.setProperty("user", "doe");
+        resource.setProperty("username", "doe");
         resource.setProperty("password", "doe");
         return resource;
     }
@@ -58,7 +58,7 @@ protected:
         auto resource = ApplicationDomain::ImapResource::create("account1");
         resource.setProperty("server", "foobar");
         resource.setProperty("port", 993);
-        resource.setProperty("user", "doe");
+        resource.setProperty("username", "doe");
         resource.setProperty("password", "doe");
         return resource;
     }
diff --git a/examples/imapresource/tests/imapmailtest.cpp \
b/examples/imapresource/tests/imapmailtest.cpp index 82324af..d17d7da 100644
--- a/examples/imapresource/tests/imapmailtest.cpp
+++ b/examples/imapresource/tests/imapmailtest.cpp
@@ -29,7 +29,7 @@ protected:
         auto resource = ApplicationDomain::ImapResource::create("account1");
         resource.setProperty("server", "localhost");
         resource.setProperty("port", 993);
-        resource.setProperty("user", "doe");
+        resource.setProperty("username", "doe");
         resource.setProperty("password", "doe");
         return resource;
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic