diff options
author | Damien Caliste <[email protected]> | 2025-06-18 11:43:13 +0200 |
---|---|---|
committer | Damien Caliste <[email protected]> | 2025-06-23 15:16:19 +0200 |
commit | 27f9fdedfff51c4a0664fd36ed52624b43d88430 (patch) | |
tree | 406b169b959ecad13cf6c38acd0386ae30fedd44 /src | |
parent | 40673be64fd311c219fcc4f2c29774e2265bdc6a (diff) |
Add a convenient function in QMailMessage to
properly compute the In-Reply-to: and References:
headers when replying to a message.
Change-Id: Ibe962383d95e101b612258eb0ced980fef7e7203
Reviewed-by: Pekka Vuorela <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/libraries/qmfclient/qmailmessage.cpp | 28 | ||||
-rw-r--r-- | src/libraries/qmfclient/qmailmessage.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/libraries/qmfclient/qmailmessage.cpp b/src/libraries/qmfclient/qmailmessage.cpp index cb900418..70fb5c66 100644 --- a/src/libraries/qmfclient/qmailmessage.cpp +++ b/src/libraries/qmfclient/qmailmessage.cpp @@ -8564,6 +8564,34 @@ void QMailMessage::setInReplyTo(const QString &messageId) } /*! + Setup In-Reply-To: and References: header fields according to RFC2822 + section 3.6.4. Also internally set the metadata inResponseTo to point + to the id() of \a msg, if valid. + */ +void QMailMessage::setInResponseTo(const QMailMessage &msg) +{ + if (msg.id().isValid()) { + setInResponseTo(msg.id()); + } + QString references(msg.headerFieldText(QLatin1String("References"))); + if (references.isEmpty()) { + references = msg.inReplyTo(); + } + const QString precursorId(msg.headerFieldText(QLatin1String("Message-ID"))); + if (!precursorId.isEmpty()) { + setInReplyTo(precursorId); + + if (!references.isEmpty()) { + references.append(' '); + } + references.append(precursorId); + } + if (!references.isEmpty()) { + setHeaderField(QLatin1String("References"), references); + } +} + +/*! Returns a list of all the recipients specified for the message, either as To, CC, or BCC addresses. \sa to(), cc(), bcc(), hasRecipients() diff --git a/src/libraries/qmfclient/qmailmessage.h b/src/libraries/qmfclient/qmailmessage.h index 2e3c211f..86525fad 100644 --- a/src/libraries/qmfclient/qmailmessage.h +++ b/src/libraries/qmfclient/qmailmessage.h @@ -786,6 +786,8 @@ public: virtual QString inReplyTo() const; virtual void setInReplyTo(const QString &s); + void setInResponseTo(const QMailMessage &msg); + virtual uint contentSize() const; virtual void setContentSize(uint size); |