Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'contrib-pgp-signature' into 'master'
[messagingframework] Update to upstream digital signatures. Contributes to JB#43783 See merge request mer-core/messagingframework!18
- Loading branch information
Showing
3 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
From 6573f8dff024a3a863f9e70cc38f6cf5e2832509 Mon Sep 17 00:00:00 2001 | ||
From: Damien Caliste <dcaliste@free.fr> | ||
Date: Mon, 5 Nov 2018 16:11:29 +0100 | ||
Subject: [PATCH] Add signature settings in account | ||
|
||
--- | ||
src/libraries/qmfclient/qmailaccount.cpp | 48 ++++++++++++++++++++++++++++++++ | ||
src/libraries/qmfclient/qmailaccount.h | 6 ++++ | ||
src/libraries/qmfclient/qmailstore_p.cpp | 18 ++++++++++++ | ||
3 files changed, 72 insertions(+) | ||
|
||
diff --git a/src/libraries/qmfclient/qmailaccount.cpp b/src/libraries/qmfclient/qmailaccount.cpp | ||
index 8579636..b9381b9 100644 | ||
--- a/src/libraries/qmfclient/qmailaccount.cpp | ||
+++ b/src/libraries/qmfclient/qmailaccount.cpp | ||
@@ -61,6 +61,7 @@ static quint64 canCreateFoldersFlag = 0; | ||
static quint64 useSmartReplyFlag = 0; | ||
static quint64 canSearchOnServerFlag = 0; | ||
static quint64 hasPersistentConnectionFlag = 0; | ||
+static quint64 useCryptoSignatureFlag = 0; | ||
|
||
class QMailAccountPrivate : public QSharedData | ||
{ | ||
@@ -80,6 +81,8 @@ public: | ||
QMailMessage::MessageType _messageType; | ||
quint64 _status; | ||
QString _signature; | ||
+ QStringList _cryptoSignatureIds; | ||
+ QString _cryptoSignatureType; | ||
QMailTimeStamp _lastSynchronized; | ||
QMailAddress _address; | ||
QStringList _sources; | ||
@@ -371,6 +374,7 @@ const quint64 &QMailAccount::CanCreateFolders = canCreateFoldersFlag; | ||
const quint64 &QMailAccount::UseSmartReply = useSmartReplyFlag; | ||
const quint64 &QMailAccount::CanSearchOnServer = canSearchOnServerFlag; | ||
const quint64 &QMailAccount::HasPersistentConnection = hasPersistentConnectionFlag; | ||
+const quint64 &QMailAccount::UseCryptoSignature = useCryptoSignatureFlag; | ||
|
||
/*! | ||
Creates an uninitialised account object. | ||
@@ -480,6 +484,50 @@ void QMailAccount::setSignature(const QString &str) | ||
} | ||
|
||
/*! | ||
+ Returns an id list configured for the account. These ids should be used to | ||
+ numericaly sign an outgoing mail of this account. | ||
+ | ||
+ \sa setCryptoSignatureIds() | ||
+*/ | ||
+QStringList QMailAccount::cryptoSignatureIds() const | ||
+{ | ||
+ return d->_cryptoSignatureIds; | ||
+} | ||
+ | ||
+/*! | ||
+ Sets the ids configured for the account to \a str. These ids should be used | ||
+ to numericaly sign an outgoing mail of this account. | ||
+ | ||
+ \sa cryptoSignatureIds() | ||
+*/ | ||
+void QMailAccount::setCryptoSignatureIds(const QStringList &ids) | ||
+{ | ||
+ d->_cryptoSignatureIds = ids; | ||
+} | ||
+ | ||
+/*! | ||
+ Returns a crypto type configured for the account. This type should be used to | ||
+ numericaly sign an outgoing mail of this account. | ||
+ | ||
+ \sa setCryptoSignatureType() | ||
+*/ | ||
+QString QMailAccount::cryptoSignatureType() const | ||
+{ | ||
+ return d->_cryptoSignatureType; | ||
+} | ||
+ | ||
+/*! | ||
+ Sets the crypto type configured for the account to \a str. This type should be used | ||
+ to numericaly sign an outgoing mail of this account. | ||
+ | ||
+ \sa cryptoSignatureType() | ||
+*/ | ||
+void QMailAccount::setCryptoSignatureType(const QString &type) | ||
+{ | ||
+ d->_cryptoSignatureType = type; | ||
+} | ||
+ | ||
+/*! | ||
Returns the time the account was last succesfully synchronized. | ||
|
||
Should be updated by QMailRetrievalAction::retrieveMessageList() when an account is synchronized. | ||
diff --git a/src/libraries/qmfclient/qmailaccount.h b/src/libraries/qmfclient/qmailaccount.h | ||
index 8ba3efa..2eb24fe 100644 | ||
--- a/src/libraries/qmfclient/qmailaccount.h | ||
+++ b/src/libraries/qmfclient/qmailaccount.h | ||
@@ -77,6 +77,7 @@ public: | ||
static const quint64 &UseSmartReply; | ||
static const quint64 &CanSearchOnServer; | ||
static const quint64 &HasPersistentConnection; | ||
+ static const quint64 &UseCryptoSignature; | ||
|
||
QMailAccount(); | ||
explicit QMailAccount(const QMailAccountId& id); | ||
@@ -98,6 +99,11 @@ public: | ||
QString signature() const; | ||
void setSignature(const QString &str); | ||
|
||
+ QStringList cryptoSignatureIds() const; | ||
+ void setCryptoSignatureIds(const QStringList &ids); | ||
+ QString cryptoSignatureType() const; | ||
+ void setCryptoSignatureType(const QString &type); | ||
+ | ||
QMailTimeStamp lastSynchronized() const; | ||
void setLastSynchronized(const QMailTimeStamp &synced); | ||
|
||
diff --git a/src/libraries/qmfclient/qmailstore_p.cpp b/src/libraries/qmfclient/qmailstore_p.cpp | ||
index 599b573..f6af612 100644 | ||
--- a/src/libraries/qmfclient/qmailstore_p.cpp | ||
+++ b/src/libraries/qmfclient/qmailstore_p.cpp | ||
@@ -2671,6 +2671,10 @@ bool SSOAccountSatisfyTheProperty(Accounts::Account* ssoAccount, const QMailAcco | ||
status &= (~QMailAccount::AppendSignature); | ||
status |= appendSignature?(QMailAccount::AppendSignature):0; | ||
|
||
+ bool useCryptoSignature = ssoAccount->valueAsBool("crypto/sign"); | ||
+ status &= (~QMailAccount::UseCryptoSignature); | ||
+ status |= useCryptoSignature?(QMailAccount::UseCryptoSignature):0; | ||
+ | ||
bool hasPersistentConnection = ssoAccount->valueAsBool("hasPersistentConnection", false); | ||
status &= (~QMailAccount::HasPersistentConnection); | ||
status |= hasPersistentConnection?(QMailAccount::HasPersistentConnection):0; | ||
@@ -3224,6 +3228,8 @@ bool QMailStorePrivate::initStore() | ||
63, true, const_cast<quint64 *>(&QMailMessage::Todo), t, false) | ||
|| attemptRegisterStatusBit(QLatin1String("HasSignature"), QLatin1String("messagestatus"), | ||
63, true, const_cast<quint64 *>(&QMailMessage::HasSignature), t, false) | ||
+ || attemptRegisterStatusBit(QLatin1String("UseCryptoSignature"), QLatin1String("accountstatus"), | ||
+ 63, true, const_cast<quint64 *>(&QMailAccount::UseCryptoSignature), t, false) | ||
|| attemptRegisterStatusBit(QLatin1String("NoNotification"), QLatin1String("messagestatus"), | ||
63, true, const_cast<quint64 *>(&QMailMessage::NoNotification), t, false); | ||
|
||
@@ -3717,17 +3723,21 @@ QMailAccount QMailStorePrivate::extractAccount(const QSharedPointer<Accounts::Ac | ||
const bool& canTransmit = ssoAccount->valueAsBool("canTransmit", true); | ||
const bool& appendSignature = ssoAccount->valueAsBool("signatureEnabled", true); | ||
const bool& hasPersistentConnection = ssoAccount->valueAsBool("hasPersistentConnection", false); | ||
+ const bool& useCryptoSignature = ssoAccount->valueAsBool("crypto/sign"); | ||
|
||
result.setStatus(QMailAccount::Enabled, enabled); | ||
result.setStatus(QMailAccount::PreferredSender, isDefault); | ||
result.setStatus(QMailAccount::CanTransmit, canTransmit); | ||
result.setStatus(QMailAccount::AppendSignature, appendSignature); | ||
result.setStatus(QMailAccount::HasPersistentConnection, hasPersistentConnection); | ||
+ result.setStatus(QMailAccount::UseCryptoSignature, useCryptoSignature); | ||
|
||
result.setSignature(ssoAccount->valueAsString("signature")); | ||
result.setFromAddress(ssoAccount->contains("fullName")? | ||
QMailAddress(ssoAccount->valueAsString("fullName"),ssoAccount->valueAsString("emailaddress")): | ||
QMailAddress(ssoAccount->valueAsString("emailaddress"))); | ||
+ result.setCryptoSignatureType(ssoAccount->valueAsString("crypto/pluginName")); | ||
+ result.setCryptoSignatureIds(ssoAccount->value("crypto/keyNames").toStringList()); | ||
|
||
if ((static_cast<uint>(ssoAccount->valueAsUInt64("lastSynchronized"))) == 0) { | ||
result.setLastSynchronized(QMailTimeStamp()); | ||
@@ -6229,7 +6239,11 @@ QMailStorePrivate::AttemptResult QMailStorePrivate::attemptAddAccount(QMailAccou | ||
ssoAccount->setValue("signatureEnabled", appendSignature); | ||
const bool hasPersistentConnection = (account->status() & QMailAccount::HasPersistentConnection); | ||
ssoAccount->setValue("hasPersistentConnection", hasPersistentConnection); | ||
+ const bool useCryptoSignature = (account->status() & QMailAccount::UseCryptoSignature); | ||
+ ssoAccount->setValue("crypto/sign", useCryptoSignature); | ||
ssoAccount->setValue("signature", account->signature()); | ||
+ ssoAccount->setValue("crypto/pluginName", account->cryptoSignatureType()); | ||
+ ssoAccount->setValue("crypto/keyNames", account->cryptoSignatureIds()); | ||
ssoAccount->setValue("emailaddress", account->fromAddress().address()); | ||
ssoAccount->setValue("fullName", account->fromAddress().name()); | ||
//Account was never synced | ||
@@ -7033,7 +7047,11 @@ QMailStorePrivate::AttemptResult QMailStorePrivate::attemptUpdateAccount(QMailAc | ||
ssoAccount->setValue("signatureEnabled", signatureEnabled); | ||
bool hasPersistentConnection = account->status() & QMailAccount::HasPersistentConnection; | ||
ssoAccount->setValue("hasPersistentConnection", hasPersistentConnection); | ||
+ bool useCryptoSignature = account->status() & QMailAccount::UseCryptoSignature; | ||
+ ssoAccount->setValue("crypto/sign", useCryptoSignature); | ||
ssoAccount->setValue("signature", account->signature()); | ||
+ ssoAccount->setValue("crypto/pluginName", account->cryptoSignatureType()); | ||
+ ssoAccount->setValue("crypto/keyNames", account->cryptoSignatureIds()); | ||
ssoAccount->setValue("emailaddress", account->fromAddress().address()); | ||
ssoAccount->setValue("fullName", account->fromAddress().name()); | ||
if (account->lastSynchronized().isValid()) { | ||
-- | ||
2.7.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters