Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb47900' into 'master'
Trigger notification if account credentials are incorrect

See merge request mer-core/messagingframework!50
  • Loading branch information
llewelld committed Nov 26, 2020
2 parents 67701e5 + e5a4d89 commit 783f230
Show file tree
Hide file tree
Showing 25 changed files with 135 additions and 105 deletions.
@@ -1,7 +1,7 @@
From 5e765286bdcf989f5ba68a3230bd88652e8fce43 Mon Sep 17 00:00:00 2001
From f2d4bba3b0e068ae45b7b76c2e1abad6f9f498c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Val=C3=A9rio=20Val=C3=A9rio?= <valerio.valerio@jolla.com>
Date: Mon, 23 Feb 2015 13:08:24 +0200
Subject: [PATCH 01/24] Stop _incomingDataTimer when imapprotocol object is
Subject: [PATCH] Stop _incomingDataTimer when imapprotocol object is
destroyed.

A crash occurs in case the timer is active and the object is destroyed.
Expand All @@ -24,5 +24,5 @@ index 4df62a57..984e2638 100644
delete _fsm;
}
--
2.17.1
2.26.2

@@ -1,7 +1,7 @@
From ebfe9142f6b968a53e7796bdce081e36a852db67 Mon Sep 17 00:00:00 2001
From 69205cb598d6db0c5edeb184ec90de745ddbf51b Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 13 Aug 2018 15:45:24 +0300
Subject: [PATCH 02/24] Introduce acceptUntrustedCertificates() configuration.
Subject: [PATCH] Introduce acceptUntrustedCertificates() configuration.

---
src/libraries/qmfclient/qmailserviceaction.h | 2 ++
Expand Down Expand Up @@ -441,5 +441,5 @@ index e8b28a6b..ed115d53 100644
void setSmtpPassword(const QString& password);
void setSmtpAuthentication(int t);
--
2.17.1
2.26.2

6 changes: 3 additions & 3 deletions rpm/0003-fix-tests-installation-path.patch
@@ -1,7 +1,7 @@
From 86e3b14ee20e9599da9a09ba5c131e8ccbf647cd Mon Sep 17 00:00:00 2001
From fba75e39c44bdb971387ec74c228dc8af7739cbd Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Tue, 30 Apr 2013 14:38:17 +0300
Subject: [PATCH 03/24] fix tests installation path.
Subject: [PATCH] fix tests installation path.

---
.../tst_messageserver/tst_messageserver.pro | 2 +-
Expand Down Expand Up @@ -2935,5 +2935,5 @@ index 4cde1fe3..204ecd5a 100644

INSTALLS += testdata
--
2.17.1
2.26.2

67 changes: 50 additions & 17 deletions rpm/0004-Accounts-qt-integration.patch
@@ -1,7 +1,7 @@
From 0a0fa3662eb6c99bf70994e858eb5380d37a0619 Mon Sep 17 00:00:00 2001
From 1ac228490d30ad5902b608a6d74a947e68ddc4d6 Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Wed, 29 May 2013 09:44:20 +0300
Subject: [PATCH 04/24] Accounts-qt integration.
Subject: [PATCH] Accounts-qt integration.

Squashed commits, either one line description or block comment:

Expand Down Expand Up @@ -116,6 +116,18 @@ Auth in one step introduced by this commit, better to reduce communication with

c: AUTH PLAIN <UserName and password encoded in base64>
S: 235 2.7.0 Authentication successful

----

Trigger notification if account credentials are incorrect

For accounts that use passwords, if the credentials are incorrect this
change will cause the "CredentialsNeedUpdate = true" property to be set
on the account, triggering signond to show a notification to the user.

This mirrors the behavour of qmf-oauth2-plugin. See
SSOOauth2Plugin::credentialsNeedUpdate() in
base-qmf-oauth2-plugin/oauth2plugin.cpp
---
common.pri | 6 +
.../qmfclient/qmailaccountlistmodel.cpp | 44 +-
Expand Down Expand Up @@ -156,11 +168,11 @@ S: 235 2.7.0 Authentication successful
.../messageservices/smtp/smtpservice.cpp | 8 +
src/plugins/plugins.pro | 3 +
src/plugins/ssoauth/password/password.pro | 21 +
.../ssoauth/password/passwordplugin.cpp | 185 +++
src/plugins/ssoauth/password/passwordplugin.h | 72 +
.../ssoauth/password/passwordplugin.cpp | 200 +++
src/plugins/ssoauth/password/passwordplugin.h | 78 +
src/tools/messageserver/servicehandler.cpp | 13 +
tests/tst_qmailstore/tst_qmailstore.cpp | 85 ++
43 files changed, 3651 insertions(+), 65 deletions(-)
43 files changed, 3672 insertions(+), 65 deletions(-)
create mode 100644 src/libraries/qmfclient/share/email.provider
create mode 100644 src/libraries/qmfclient/share/email.service
create mode 100644 src/libraries/qmfclient/ssoaccountmanager.cpp
Expand Down Expand Up @@ -4959,14 +4971,14 @@ index 00000000..f41e80ad
+
diff --git a/src/plugins/ssoauth/password/passwordplugin.cpp b/src/plugins/ssoauth/password/passwordplugin.cpp
new file mode 100644
index 00000000..1d2304c1
index 00000000..4eac2d1b
--- /dev/null
+++ b/src/plugins/ssoauth/password/passwordplugin.cpp
@@ -0,0 +1,185 @@
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Valério Valério <valerio.valerio@jollamobile.com>
+** Copyright (c) 2013-2020 Jolla Ltd.
+** Copyright (c) 2020 Open Mobile Platform LLC.
+**
+** This file is part of the Qt Messaging Framework.
+**
Expand Down Expand Up @@ -5007,6 +5019,10 @@ index 00000000..1d2304c1
+#include "passwordplugin.h"
+#include "qmailnamespace.h"
+
+// libaccounts-qt
+#include <Accounts/Manager>
+#include <Accounts/Account>
+
+// From Qt Messaging Framework IMAP plugin
+// Ensure a string is quoted, if required for IMAP transmission
+// As per IMAP4 rfc 2060 section 4.2
Expand Down Expand Up @@ -5046,6 +5062,7 @@ index 00000000..1d2304c1
+
+SSOPasswordPlugin::SSOPasswordPlugin(QObject *parent)
+ : SSOAuthService(parent)
+ , m_accountManager(new Accounts::Manager(this))
+{
+}
+
Expand Down Expand Up @@ -5133,9 +5150,19 @@ index 00000000..1d2304c1
+
+void SSOPasswordPlugin::credentialsNeedUpdate(int accountId)
+{
+ // For the password method we don't do anything, messageserver
+ // already informs the clients about login failed.
+ Q_UNUSED(accountId);
+ // Mirrors the functionality of SSOOauth2Plugin::credentialsNeedUpdate
+ // See base-qmf-oauth2-plugin/oauth2plugin.cpp
+ Accounts::Account *account = Accounts::Account::fromId(m_accountManager, accountId, this);
+ Accounts::Service srv(m_accountManager->service(QStringLiteral("email")));
+ if (srv.isValid()) {
+ qWarning() << "password-plugin: setting CredentialsNeedUpdate on account:" << account->id();
+ account->selectService(srv);
+ account->setValue("CredentialsNeedUpdate", QVariant::fromValue<bool>(true));
+ account->setValue("CredentialsNeedUpdateFrom", QVariant::fromValue<QString>(QString::fromLatin1("messageserver5")));
+ account->selectService(Accounts::Service());
+ account->syncAndBlock();
+ }
+ account->deleteLater();
+}
+
+SignOn::SessionData SSOPasswordPlugin::sessionData(const QString &accountProvider, QVariantMap authParameters) const
Expand All @@ -5150,14 +5177,14 @@ index 00000000..1d2304c1
+
diff --git a/src/plugins/ssoauth/password/passwordplugin.h b/src/plugins/ssoauth/password/passwordplugin.h
new file mode 100644
index 00000000..1ae046d8
index 00000000..8603694e
--- /dev/null
+++ b/src/plugins/ssoauth/password/passwordplugin.h
@@ -0,0 +1,72 @@
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Valério Valério <valerio.valerio@jollamobile.com>
+** Copyright (c) 2013-2020 Jolla Ltd.
+** Copyright (c) 2020 Open Mobile Platform LLC.
+**
+** This file is part of the Qt Messaging Framework.
+**
Expand Down Expand Up @@ -5203,6 +5230,11 @@ index 00000000..1ae046d8
+#include <QVariantMap>
+#include <SignOn/SessionData>
+
+namespace Accounts {
+ class Manager;
+ class Account;
+}
+
+class SSOPasswordPlugin : public SSOAuthService
+{
+ Q_OBJECT
Expand All @@ -5223,6 +5255,7 @@ index 00000000..1ae046d8
+ QList<QByteArray> getIMAPAuthentication(const QString &password, const QString &username, int serviceAuthentication) const;
+ QList<QByteArray> getPOPAuthentication(const QString &password, const QString &username, int serviceAuthentication) const;
+ QList<QByteArray> getSMTPAuthentication(const QString &password, const QString &username, int serviceAuthentication) const;
+ Accounts::Manager *m_accountManager;
+};
+
+#endif // PASSWORDPLUGIN_H
Expand Down Expand Up @@ -5449,5 +5482,5 @@ index 26719daa..84ca9409 100644
QMailAccount account3(account1.id());
QCOMPARE(QMailStore::instance()->lastError(), QMailStore::InvalidId);
--
2.17.1
2.26.2

@@ -1,8 +1,8 @@
From 4372ae2417889a38fd2352d1608cee8435150638 Mon Sep 17 00:00:00 2001
From 071b29984213918dfee0b375caa82757901b6ba2 Mon Sep 17 00:00:00 2001
From: Evgeny Karpov <evgeny.karpov@oss.tieto.com>
Date: Thu, 24 Oct 2013 09:37:30 +0000
Subject: [PATCH 05/24] Start messageserver on system startup in case there are
email accounts present
Subject: [PATCH] Start messageserver on system startup in case there are email
accounts present

Squashed:
Do not try to restart messageserver when there are no accounts. Fixes: JB#12100
Expand Down Expand Up @@ -172,5 +172,5 @@ index d05c3377..689ad320 100644
+ SUBDIRS += accountscheck
+}
--
2.17.1
2.26.2

6 changes: 3 additions & 3 deletions rpm/0006-Add-keepalive-timer-to-IMAP-IDLE-service.patch
@@ -1,7 +1,7 @@
From f96179ba4c01e11f58a2197eb5e2fe6e8266c1c1 Mon Sep 17 00:00:00 2001
From 15d35e73cd6bc3b1128aa23b7c30b8ce26ab9ba3 Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Wed, 10 Sep 2014 14:36:13 +0300
Subject: [PATCH 06/24] Add keepalive timer to IMAP IDLE service
Subject: [PATCH] Add keepalive timer to IMAP IDLE service

This commit introduce a dependency on nemo-keepalive via
DEFINES+=USE_KEEPALIVE
Expand Down Expand Up @@ -105,5 +105,5 @@ index 00682a87..b3e8dd97 100644

class ImapServicePlugin : public QMailMessageServicePlugin
--
2.17.1
2.26.2

6 changes: 3 additions & 3 deletions rpm/0007-Use-Qt5-booster-to-save-memory.patch
@@ -1,7 +1,7 @@
From 769280d652f4828cbff7c2d0ece3d6fbbb3cf902 Mon Sep 17 00:00:00 2001
From 4f228ab04d182f22253bb66756e3111a57d45ffe Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Mon, 27 Oct 2014 09:49:12 +0200
Subject: [PATCH 07/24] Use Qt5 booster to save memory.
Subject: [PATCH] Use Qt5 booster to save memory.

---
src/tools/messageserver/main.cpp | 2 +-
Expand Down Expand Up @@ -61,5 +61,5 @@ index 0d583d15..a5aa05a9 100644
RestartSec=1

--
2.17.1
2.26.2

@@ -1,8 +1,7 @@
From 1c8ac90c0760b5ea00d5f5625dab35e7f4957b80 Mon Sep 17 00:00:00 2001
From 572179f5aef58be39e6a0e9daa742e0f457c3bd3 Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Mon, 13 Aug 2018 17:24:36 +0300
Subject: [PATCH 08/24] Introduce QMailAccount::HasPersistentConnection status
flag
Subject: [PATCH] Introduce QMailAccount::HasPersistentConnection status flag

Use QMailAccount::HasPersistentConnection status flag for IMAP idle instead of
updating last sync time every minute, this reduces accounts db writes(they
Expand Down Expand Up @@ -60,5 +59,5 @@ index 221fa7c5..ab509afd 100644
ssoAccount->setValue("emailaddress", account->fromAddress().address());
ssoAccount->setValue("fullName", account->fromAddress().name());
--
2.17.1
2.26.2

20 changes: 10 additions & 10 deletions rpm/0009-Introduce-discovery-of-authentication-from-the-anoun.patch
@@ -1,7 +1,7 @@
From 9906e81a475c705655248b955bb05d2d316e3d03 Mon Sep 17 00:00:00 2001
From 275994691f0f2c292437800d413dc4fd159f4a0c Mon Sep 17 00:00:00 2001
From: Pekka Vuorela <pekka.vuorela@jolla.com>
Date: Wed, 15 Aug 2018 11:26:49 +0300
Subject: [PATCH 09/24] Introduce discovery of authentication from the anounced
Subject: [PATCH] Introduce discovery of authentication from the anounced
capabilities(IMAP/SMTP)

Squashed oneliner:
Expand Down Expand Up @@ -1221,10 +1221,10 @@ index ed115d53..7e03e956 100644
};

diff --git a/src/plugins/ssoauth/password/passwordplugin.cpp b/src/plugins/ssoauth/password/passwordplugin.cpp
index 1d2304c1..20d2cf57 100644
index 4eac2d1b..88db5298 100644
--- a/src/plugins/ssoauth/password/passwordplugin.cpp
+++ b/src/plugins/ssoauth/password/passwordplugin.cpp
@@ -88,52 +88,80 @@ SSOPasswordPlugin::~SSOPasswordPlugin()
@@ -93,52 +93,80 @@ SSOPasswordPlugin::~SSOPasswordPlugin()
{
}

Expand Down Expand Up @@ -1339,7 +1339,7 @@ index 1d2304c1..20d2cf57 100644
return result;
}

@@ -146,8 +174,9 @@ QString SSOPasswordPlugin::key() const
@@ -151,8 +179,9 @@ QString SSOPasswordPlugin::key() const
{
return "password";
}
Expand All @@ -1351,7 +1351,7 @@ index 1d2304c1..20d2cf57 100644
{
QString password = sessionData.Secret();
QString username = sessionData.UserName();
@@ -156,13 +185,13 @@ QList<QByteArray> SSOPasswordPlugin::authentication(const SignOn::SessionData &s
@@ -161,13 +190,13 @@ QList<QByteArray> SSOPasswordPlugin::authentication(const SignOn::SessionData &s
username = userName;

if (serviceType == "imap4") {
Expand All @@ -1370,10 +1370,10 @@ index 1d2304c1..20d2cf57 100644
}

diff --git a/src/plugins/ssoauth/password/passwordplugin.h b/src/plugins/ssoauth/password/passwordplugin.h
index 1ae046d8..a7a25676 100644
index 8603694e..a2f66cd9 100644
--- a/src/plugins/ssoauth/password/passwordplugin.h
+++ b/src/plugins/ssoauth/password/passwordplugin.h
@@ -57,16 +57,16 @@ public:
@@ -62,16 +62,16 @@ public:
~SSOPasswordPlugin();

virtual QString key() const;
Expand All @@ -1392,9 +1392,9 @@ index 1ae046d8..a7a25676 100644
+ QMap<QString, QList<QByteArray> > getIMAPAuthentication(const QString &password, const QString &username) const;
+ QMap<QString, QList<QByteArray> > getPOPAuthentication(const QString &password, const QString &username) const;
+ QMap<QString, QList<QByteArray> > getSMTPAuthentication(const QString &password, const QString &username) const;
Accounts::Manager *m_accountManager;
};

#endif // PASSWORDPLUGIN_H
--
2.17.1
2.26.2

6 changes: 3 additions & 3 deletions rpm/0010-Handle-SMTP-response-504.patch
@@ -1,7 +1,7 @@
From 44a6bb349ec2682372242a25bce9ac5f5ada4a49 Mon Sep 17 00:00:00 2001
From 0863fa4521af4ecf2108c403e1250561fc9c1e92 Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Wed, 17 Dec 2014 17:16:45 +0000
Subject: [PATCH 10/24] Handle SMTP response 504.
Subject: [PATCH] Handle SMTP response 504.

Handle SMTP response 504 and reset auth method if auth from caps is
enabled.
Expand Down Expand Up @@ -288,5 +288,5 @@ index 1ca218a8..96852b2b 100644
QTimer *authTimeout;

--
2.17.1
2.26.2

@@ -1,7 +1,7 @@
From c9f9d1e64dd30cd28212b3de8d469c064c3e0d6e Mon Sep 17 00:00:00 2001
From e846fbd37877440a5a13dee50a5ed2cd7d17f781 Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Mon, 19 Jan 2015 11:25:01 +0200
Subject: [PATCH 11/24] Recreate SSO identity for smtp in case of failure.
Subject: [PATCH] Recreate SSO identity for smtp in case of failure.

Similar to what is already done for IMAP.
---
Expand Down Expand Up @@ -65,5 +65,5 @@ index 96852b2b..12003c7e 100644
#endif
};
--
2.17.1
2.26.2

@@ -1,8 +1,7 @@
From fdfddcefb80e40927e63c40eeca4058c5f62e698 Mon Sep 17 00:00:00 2001
From 48d083a0845681f379fd8072e811152895f40784 Mon Sep 17 00:00:00 2001
From: Valerio Valerio <valerio.valerio@jollamobile.com>
Date: Mon, 2 Feb 2015 17:03:21 +0200
Subject: [PATCH 12/24] Listen to sync schedule changes from buteo sync
framework.
Subject: [PATCH] Listen to sync schedule changes from buteo sync framework.

This commit introduces d-bus listeners inside IMAP4 service to
react to changes in the account schedule related to always-on mode
Expand Down Expand Up @@ -467,5 +466,5 @@ index a5aa05a9..9622d701 100644

[Service]
--
2.17.1
2.26.2

0 comments on commit 783f230

Please sign in to comment.