diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-23 16:44:12 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-23 16:44:12 +0200 |
commit | 2ce8dcf40f22dd4e9cf4a6b1c8f5386993ebba6e (patch) | |
tree | a18576f6b4b01abcc1e632f17304a0f360db8b48 | |
parent | 751f2c82c4121d28d0740bffb29a4fb273ec55c5 (diff) | |
download | sink-2ce8dcf40f22dd4e9cf4a6b1c8f5386993ebba6e.tar.gz sink-2ce8dcf40f22dd4e9cf4a6b1c8f5386993ebba6e.zip |
Use username instead of just user
-rw-r--r-- | examples/imapresource/imapresource.cpp | 15 | ||||
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 6 | ||||
-rw-r--r-- | examples/imapresource/tests/imapmailsynctest.cpp | 4 | ||||
-rw-r--r-- | examples/imapresource/tests/imapmailtest.cpp | 2 |
4 files changed, 22 insertions, 5 deletions
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: | |||
294 | { | 294 | { |
295 | Log() << " Synchronizing"; | 295 | Log() << " Synchronizing"; |
296 | return KAsync::start<void>([this](KAsync::Future<void> future) { | 296 | return KAsync::start<void>([this](KAsync::Future<void> future) { |
297 | Trace() << "Connecting to:" << mServer << mPort; | ||
298 | Trace() << "as:" << mUser; | ||
297 | ImapServerProxy imap(mServer, mPort); | 299 | ImapServerProxy imap(mServer, mPort); |
298 | auto loginFuture = imap.login(mUser, mPassword).exec(); | 300 | auto loginFuture = imap.login(mUser, mPassword).exec(); |
299 | loginFuture.waitForFinished(); | 301 | loginFuture.waitForFinished(); |
@@ -542,8 +544,17 @@ ImapResource::ImapResource(const QByteArray &instanceIdentifier, const QSharedPo | |||
542 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); | 544 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); |
543 | mServer = config.value("server").toString(); | 545 | mServer = config.value("server").toString(); |
544 | mPort = config.value("port").toInt(); | 546 | mPort = config.value("port").toInt(); |
545 | mUser = config.value("user").toString(); | 547 | mUser = config.value("username").toString(); |
546 | mPassword = config.value("password").toString(); | 548 | mPassword = config.value("password").toString(); |
549 | if (mServer.startsWith("imap")) { | ||
550 | mServer.remove("imap://"); | ||
551 | mServer.remove("imaps://"); | ||
552 | } | ||
553 | if (mServer.contains(':')) { | ||
554 | auto list = mServer.split(':'); | ||
555 | mServer = list.at(0); | ||
556 | mPort = list.at(1).toInt(); | ||
557 | } | ||
547 | 558 | ||
548 | auto synchronizer = QSharedPointer<ImapSynchronizer>::create(PLUGIN_NAME, instanceIdentifier); | 559 | auto synchronizer = QSharedPointer<ImapSynchronizer>::create(PLUGIN_NAME, instanceIdentifier); |
549 | synchronizer->mServer = mServer; | 560 | synchronizer->mServer = mServer; |
@@ -603,6 +614,8 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in | |||
603 | scope.mode = KIMAP::FetchJob::FetchScope::Full; | 614 | scope.mode = KIMAP::FetchJob::FetchScope::Full; |
604 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 615 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); |
605 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | 616 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); |
617 | Trace() << "Connecting to:" << mServer << mPort; | ||
618 | Trace() << "as:" << mUser; | ||
606 | auto inspectionJob = imap->login(mUser, mPassword) | 619 | auto inspectionJob = imap->login(mUser, mPassword) |
607 | .then<void>(imap->select(folderRemoteId)) | 620 | .then<void>(imap->select(folderRemoteId)) |
608 | .then<void>(imap->fetch(set, scope, [imap, messageByUid](const QVector<Imap::Message> &messages) { | 621 | .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 | |||
99 | loginJob->setUserName(username); | 99 | loginJob->setUserName(username); |
100 | loginJob->setPassword(password); | 100 | loginJob->setPassword(password); |
101 | loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain); | 101 | loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain); |
102 | loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion); | 102 | if (mSession->port() == 143) { |
103 | loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::TlsV1); | ||
104 | } else { | ||
105 | loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion); | ||
106 | } | ||
103 | 107 | ||
104 | auto capabilitiesJob = new KIMAP::CapabilitiesJob(mSession); | 108 | auto capabilitiesJob = new KIMAP::CapabilitiesJob(mSession); |
105 | QObject::connect(capabilitiesJob, &KIMAP::CapabilitiesJob::capabilitiesReceived, [this](const QStringList &capabilities) { | 109 | 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: | |||
48 | auto resource = ApplicationDomain::ImapResource::create("account1"); | 48 | auto resource = ApplicationDomain::ImapResource::create("account1"); |
49 | resource.setProperty("server", "localhost"); | 49 | resource.setProperty("server", "localhost"); |
50 | resource.setProperty("port", 993); | 50 | resource.setProperty("port", 993); |
51 | resource.setProperty("user", "doe"); | 51 | resource.setProperty("username", "doe"); |
52 | resource.setProperty("password", "doe"); | 52 | resource.setProperty("password", "doe"); |
53 | return resource; | 53 | return resource; |
54 | } | 54 | } |
@@ -58,7 +58,7 @@ protected: | |||
58 | auto resource = ApplicationDomain::ImapResource::create("account1"); | 58 | auto resource = ApplicationDomain::ImapResource::create("account1"); |
59 | resource.setProperty("server", "foobar"); | 59 | resource.setProperty("server", "foobar"); |
60 | resource.setProperty("port", 993); | 60 | resource.setProperty("port", 993); |
61 | resource.setProperty("user", "doe"); | 61 | resource.setProperty("username", "doe"); |
62 | resource.setProperty("password", "doe"); | 62 | resource.setProperty("password", "doe"); |
63 | return resource; | 63 | return resource; |
64 | } | 64 | } |
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: | |||
29 | auto resource = ApplicationDomain::ImapResource::create("account1"); | 29 | auto resource = ApplicationDomain::ImapResource::create("account1"); |
30 | resource.setProperty("server", "localhost"); | 30 | resource.setProperty("server", "localhost"); |
31 | resource.setProperty("port", 993); | 31 | resource.setProperty("port", 993); |
32 | resource.setProperty("user", "doe"); | 32 | resource.setProperty("username", "doe"); |
33 | resource.setProperty("password", "doe"); | 33 | resource.setProperty("password", "doe"); |
34 | return resource; | 34 | return resource; |
35 | } | 35 | } |