From 27f9fdedfff51c4a0664fd36ed52624b43d88430 Mon Sep 17 00:00:00 2001 From: Damien Caliste Date: Wed, 18 Jun 2025 11:43:13 +0200 Subject: Setup references header when replying to a message 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 --- tests/tst_qmailmessage/tst_qmailmessage.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/tst_qmailmessage/tst_qmailmessage.cpp b/tests/tst_qmailmessage/tst_qmailmessage.cpp index 484c2154..e3091edc 100644 --- a/tests/tst_qmailmessage/tst_qmailmessage.cpp +++ b/tests/tst_qmailmessage/tst_qmailmessage.cpp @@ -112,6 +112,8 @@ private slots: void inReplyTo(); void setInReplyTo(); + void setInResponseTo(); + void setSingleHeaderField(); /* void status(); @@ -1287,6 +1289,32 @@ void tst_QMailMessage::setInReplyTo() testSingleHeader("In-Reply-To"); } +void tst_QMailMessage::setInResponseTo() +{ + const QString id = QLatin1String("12345"); + const QString id2 = QLatin1String("1234"); + QMailMessage message; + message.setHeaderField(QLatin1String("Message-ID"), id); + message.setHeaderField(QLatin1String("References"), id2); + + QMailMessage reply; + reply.setInResponseTo(message); + QCOMPARE(reply.inReplyTo(), id); + QCOMPARE(reply.headerField(QLatin1String("References")).content(), + QString::fromLatin1("%1 %2").arg(id2).arg(id).toUtf8()); + + QMailMessage noref; + noref.setHeaderField(QLatin1String("Message-ID"), id); + noref.setInReplyTo(id2); + + QMailMessage forward; + forward.setInResponseTo(noref); + QCOMPARE(forward.inReplyTo(), id); + QCOMPARE(forward.headerField(QLatin1String("References")).content(), + QString::fromLatin1("%1 %2").arg(id2).arg(id).toUtf8()); + +} + void tst_QMailMessage::serverUid() { // Tested by: setServerUid -- cgit v1.2.3