Commit cd778de6 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Include the 'References' header in the ENVELOPE query mode.

This allows us to use an Envelope query instead of an Headers query
for the message list in kmail. This makes loading a folder 20% faster.

svn path=/trunk/KDE/kdepim/runtime/; revision=1186483
parent cc5c9631
......@@ -118,6 +118,9 @@ bool SerializerPluginMail::deserialize( Item& item, const QByteArray& label, QIO
msg->inReplyTo()->from7BitString( env[8] );
// message id
msg->messageID()->from7BitString( env[9] );
// references
if ( env.count() > 10 )
msg->references()->from7BitString( env[10] );
}
return true;
......@@ -171,6 +174,7 @@ void SerializerPluginMail::serialize( const Item& item, const QByteArray& label,
env << buildAddrStruct( m->bcc() );
env << quoteImapListEntry( m->inReplyTo()->as7BitString( false ) );
env << quoteImapListEntry( m->messageID()->as7BitString( false ) );
env << quoteImapListEntry( m->references()->as7BitString( false ) );
data.write( buildImapList( env ) );
} else if ( label == MessagePart::Header ) {
data.write( m->head() );
......
......@@ -52,6 +52,31 @@ void MailSerializerTest::testEnvelopeDeserialize()
delete serializer;
}
void MailSerializerTest::testEnvelopeDeserializeWithReferencesHeader()
{
Item i;
i.setMimeType( "message/rfc822" );
SerializerPluginMail *serializer = new SerializerPluginMail();
// envelope
QByteArray env( "(\"Wed, 1 Feb 2006 13:37:19 UT\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL <{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org> \"<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>\")" );
QBuffer buffer;
buffer.setData( env );
buffer.open( QIODevice::ReadOnly );
buffer.seek( 0 );
serializer->deserialize( i, MessagePart::Envelope, buffer, 0 );
QVERIFY( i.hasPayload<KMime::Message::Ptr>() );
KMime::Message::Ptr msg = i.payload<KMime::Message::Ptr>();
QCOMPARE( msg->subject()->asUnicodeString(), QString::fromUtf8( "IMPORTANT: Akonadi Test" ) );
QCOMPARE( msg->from()->asUnicodeString(), QString::fromUtf8( "Tobias Koenig <tokoe@kde.org>" ) );
QCOMPARE( msg->to()->asUnicodeString(), QString::fromUtf8( "Ingo Kloecker <kloecker@kde.org>" ) );
QCOMPARE( msg->references()->asUnicodeString(), QString::fromUtf8( "<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>" ) );
delete serializer;
}
void MailSerializerTest::testEnvelopeSerialize()
{
Item i;
......@@ -68,7 +93,7 @@ void MailSerializerTest::testEnvelopeSerialize()
SerializerPluginMail *serializer = new SerializerPluginMail();
// envelope
QByteArray expEnv( "(\"Wed, 01 Feb 2006 13:37:19 +0000\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL \"<{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>\")" );
QByteArray expEnv( "(\"Wed, 01 Feb 2006 13:37:19 +0000\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL \"<{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>\" NIL)" );
QByteArray env;
QBuffer buffer;
buffer.setBuffer( &env );
......@@ -78,8 +103,27 @@ void MailSerializerTest::testEnvelopeSerialize()
serializer->serialize( i, MessagePart::Envelope, buffer, version );
QCOMPARE( env, expEnv );
delete serializer;
// envelop with references header
msg->references()->from7BitString( "<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org>" );
expEnv = QByteArray( "(\"Wed, 01 Feb 2006 13:37:19 +0000\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL \"<{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>\" \"<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org>\")" );
buffer.close();
buffer.open( QIODevice::ReadWrite );
buffer.seek( 0 );
serializer->serialize( i, MessagePart::Envelope, buffer, version );
QCOMPARE( env, expEnv );
// envelop with references header with multiple entries
msg->references()->from7BitString( "<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>" );
expEnv = QByteArray( "(\"Wed, 01 Feb 2006 13:37:19 +0000\" \"IMPORTANT: Akonadi Test\" ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) ((\"Tobias Koenig\" NIL \"tokoe\" \"kde.org\")) NIL ((\"Ingo Kloecker\" NIL \"kloecker\" \"kde.org\")) NIL NIL NIL \"<{7b55527e-77f4-489d-bf18-e805be96718c}@server.kde.org>\" \"<{8888827e-77f4-489d-bf18-e805be96718c}@server.kde.org> <{9999927e-77f4-489d-bf18-e805be96718c}@server.kde.org>\")" );
buffer.close();
buffer.open( QIODevice::ReadWrite );
buffer.seek( 0 );
serializer->serialize( i, MessagePart::Envelope, buffer, version );
QCOMPARE( env, expEnv );
delete serializer;
}
void MailSerializerTest::testParts()
......
......@@ -27,6 +27,7 @@ class MailSerializerTest : public QObject
Q_OBJECT
private slots:
void testEnvelopeDeserialize();
void testEnvelopeDeserializeWithReferencesHeader();
void testEnvelopeSerialize();
void testParts();
void testHeaderFetch();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment