Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 04fb5189 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Import Akonadi Serializer plugins for emails from kdepim-runtime

See commit cde643e6d840d591b6ae1b7f1a49488c495c4774 in kdepim-runtime
for details.
parent feb1f795
......@@ -63,6 +63,7 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_subdirectory(src)
add_subdirectory(serializers)
if(BUILD_TESTING)
add_subdirectory(autotests)
......@@ -92,4 +93,6 @@ install(FILES
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
)
install(FILES akonadi-mime.categories DESTINATION ${KDE_INSTALL_CONFDIR})
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
org.kde.pim.akonadi_serializer_mail akonadi-mime (akonadi_serializer_mail)
include(ECMAddTests)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Test Widgets)
add_subdirectory(messagetests)
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories(
${CMAKE_SOURCE_DIR}/serializers
${CMAKE_BINARY_DIR}/serializers
)
macro(add_akonadi_isolated_test _source)
get_filename_component(_targetName ${_source} NAME_WE)
set(_srcList ${_source} )
......@@ -46,3 +54,12 @@ if (KDEPIMLIBS_RUN_KDEPIMRUNTIME_ISOLATED_TESTS)
endif()
add_subdirectory(benchmarker)
ecm_add_test(mailserializerplugintest.cpp ${CMAKE_BINARY_DIR}/serializers/akonadi_serializer_mail_debug.cpp
LINK_LIBRARIES KF5::AkonadiMime KF5::AkonadiCore KF5::AkonadiPrivate KF5::Mime Qt5::Test
TEST_NAME mailserializerplugintest
)
ecm_add_test(mailserializertest.cpp ${CMAKE_BINARY_DIR}/serializers/akonadi_serializer_mail_debug.cpp
LINK_LIBRARIES KF5::AkonadiMime KF5::AkonadiCore KF5::AkonadiPrivate KF5::Mime Qt5::Test
TEST_NAME mailserializertest
)
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "mailserializerplugintest.h"
#include <AkonadiCore/Item>
#include <KMime/Message>
#include <QDebug>
#include <QTest>
QTEST_MAIN(MailSerializerPluginTest)
using namespace Akonadi;
using namespace KMime;
void MailSerializerPluginTest::testMailPlugin()
{
QByteArray serialized
= "From: sender@test.org\n"
"Subject: Serializer Test\n"
"To: receiver@test.org\n"
"Date: Fri, 22 Jun 2007 17:24:24 +0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain\n"
"\n"
"Body data.";
// deserializing
Item item;
item.setMimeType(QStringLiteral("message/rfc822"));
item.setPayloadFromData(serialized);
QVERIFY(item.hasPayload<KMime::Message::Ptr>());
KMime::Message::Ptr msg = item.payload<KMime::Message::Ptr>();
QVERIFY(msg != nullptr);
QCOMPARE(msg->to()->asUnicodeString(), QStringLiteral("receiver@test.org"));
QCOMPARE(msg->body(), QByteArray("Body data."));
// serializing
QByteArray data = item.payloadData();
QCOMPARE(data, serialized);
}
void MailSerializerPluginTest::testMessageIntegrity()
{
// A message that will be slightly modified if KMime::Content::assemble() is
// called. We want to avoid this, because it breaks signatures.
QByteArray serialized
= "from: sender@example.com\n"
"to: receiver@example.com\n"
"Subject: Serializer Test\n"
"Date: Thu, 30 Jul 2009 13:46:31 +0300\n"
"MIME-Version: 1.0\n"
"Content-type: text/plain; charset=us-ascii\n"
"\n"
"Bla bla bla.";
// Deserialize.
Item item;
item.setMimeType(QStringLiteral("message/rfc822"));
item.setPayloadFromData(serialized);
QVERIFY(item.hasPayload<KMime::Message::Ptr>());
KMime::Message::Ptr msg = item.payload<KMime::Message::Ptr>();
QVERIFY(msg != nullptr);
qDebug() << "original data:" << serialized;
qDebug() << "message content:" << msg->encodedContent();
QCOMPARE(msg->encodedContent(), serialized);
// Serialize.
QByteArray data = item.payloadData();
qDebug() << "original data:" << serialized;
qDebug() << "serialized data:" << data;
QCOMPARE(data, serialized);
}
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef MAILSERIALIZERPLUGINTEST_H
#define MAILSERIALIZERPLUGINTEST_H
#include <QObject>
class MailSerializerPluginTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testMailPlugin();
void testMessageIntegrity();
};
#endif
This diff is collapsed.
/*
Copyright (c) 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef MAILSERIALIZERTEST_H
#define MAILSERIALIZERTEST_H
#include <QObject>
class MailSerializerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testEnvelopeDeserialize_data();
void testEnvelopeDeserialize();
void testEnvelopeSerialize_data();
void testEnvelopeSerialize();
void testParts();
void testHeaderFetch();
void testMultiDeserialize();
};
#endif
add_definitions(-DTRANSLATION_DOMAIN=\"libakonadi-kmime5-serializer\")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(akonadi_serializer_mail_SRCS
akonadi_serializer_mail.cpp
)
ecm_qt_declare_logging_category(akonadi_serializer_mail_SRCS
HEADER akonadi_serializer_mail_debug.h
IDENTIFIER AKONADI_SERIALIZER_MAIL_LOG
CATEGORY_NAME org.kde.pim.akonadi_serializer_mail
)
add_library(akonadi_serializer_mail MODULE ${akonadi_serializer_mail_SRCS})
target_link_libraries(akonadi_serializer_mail
KF5::Mime
KF5::AkonadiCore
KF5::AkonadiMime
KF5::AkonadiPrivate
)
install(TARGETS akonadi_serializer_mail
DESTINATION ${KDE_INSTALL_PLUGINDIR}
)
install(FILES akonadi_serializer_mail.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/akonadi/plugins/serializer
)
#!/bin/sh
$XGETTEXT *.cpp -o $podir/libakonadi-kmime5-serializer.pot
This diff is collapsed.
[Misc]
Name=Mail Serializer
Name[ar]=مُسلسِل البريد
Name[bs]=Serializator maila
Name[ca]=Serialitzador de correu
Name[ca@valencia]=Serialitzador de correu
Name[da]=Serieordning af post
Name[de]=E-Mail-Serialisierung
Name[el]=Σειριακοποιητής αλληλογραφίας
Name[en_GB]=Mail Serialiser
Name[es]=Serializador de correo
Name[et]=Kirjade jadasti
Name[fi]=Sähköpostiserialisoija
Name[fr]=Sérialiseur de courriers électroniques
Name[ga]=Srathóir Ríomhphoist
Name[gl]=Serializador de correo
Name[hu]=Levélkezelő
Name[ia]=Divulgator partial de posta
Name[it]=Serializzatore posta elettronica
Name[ja]=メール用シリアライザ
Name[kk]=Пошта тізбектеуіші
Name[km]=ម៉ាស៊ីន​បោះពុម្ព​សំបុត្រ
Name[ko]=메일 시리얼라이저
Name[lt]=Pašto serializatorius
Name[lv]=Pasta serializētājs
Name[nb]=E-postserialisator
Name[nds]=Nettpost-Reegmoduul
Name[ne]=पत्र मलानकर्ता
Name[nl]=E-mailadministratie
Name[nn]=E-postserialisator
Name[pa]=ਮੇਲ ਸੀਰੀਅਲਾਈਜ਼ਰ
Name[pl]=Szeregowanie poczty
Name[pt]=Serializador de Correio
Name[pt_BR]=Serializador de mensagem
Name[ro]=Serializator de poștă
Name[ru]=Сохранение писем
Name[sk]=Serializátor pošty
Name[sl]=Razvrščevalnik pošte v zaporedje
Name[sr]=Серијализатор поште
Name[sr@ijekavian]=Серијализатор поште
Name[sr@ijekavianlatin]=Serijalizator pošte
Name[sr@latin]=Serijalizator pošte
Name[sv]=E-postserialisering
Name[tr]=E-posta Sıralandırıcı
Name[uk]=Серіалізатор пошти
Name[x-test]=xxMail Serializerxx
Name[zh_CN]=邮件序列转换器
Name[zh_TW]=信件序列器
Comment=An Akonadi serializer plugin for mail objects
Comment[ar]=ملحقة سَلسَلة «أكونادي» لكائنات البريد
Comment[bs]=Akonadi dodatak serializatora za mail objekte
Comment[ca]=Un connector de serialització de l'Akonadi pels objectes correu
Comment[ca@valencia]=Un connector de serialització de l'Akonadi pels objectes correu
Comment[da]=Et Akonadi-plugin til serieordning af postobjekter
Comment[de]=Akonadi-Modul zur Serialisierung von E-Mail-Objekten
Comment[el]=Ένα πρόσθετο σειριακοποιητή Akonadi για αντικείμενα αλληλογραφίας
Comment[en_GB]=An Akonadi serialiser plugin for mail objects
Comment[es]=Un complemento serializador de Akonadi para objetos correo
Comment[et]=Akonadi kirjaobjektide jadastamisplugin
Comment[fi]=Akonadi-serialisoijaliitännäinen sähköpostiobjekteille
Comment[fr]=Un module externe Akonadi pour la sérialisation des courriers électroniques
Comment[ga]=Breiseán srathóra Akonadi le haghaidh ríomhphoist
Comment[gl]=Un complemento de serialización do Akonadi para obxectos correo
Comment[hu]=Akonadi-modul levelek kezeléséhez
Comment[ia]=Un plug-in pro divulgator partial de Akonadi pro objectos de posta
Comment[it]=Un'estensione di Akonadi per la serializzazione di posta elettronica
Comment[ja]=メールオブジェクトのための Akonadi シリアライザプラグイン
Comment[kk]=Akonadi пошта нысандарының тізбектеуіш плагині
Comment[km]=កម្មវិធី​ជំនួយ​កម្មវិធី​បោះពុម្ព Akonadi សម្រាប់​វត្ថុ​សំបុត្រ
Comment[ko]=메일 객체를 위한 Akonadi 시리얼라이저 플러그인
Comment[lt]=Akonadi serializatoriaus papildinys pašto objektams
Comment[lv]=Akonadi pasta serializēšanas spraudnis
Comment[nb]=Et Akonadi programtillegg for serialisering av e-postobjekter
Comment[nds]=Akonadi-Inreegmoduul för Nettbreven
Comment[ne]=पत्र वस्तुका लागि एउटा एकोनाडी मिलानकर्ता प्लगइन
Comment[nl]=Een administratieplug-in voor Akonadi voor e-mails
Comment[nn]=Eit Akonadi-serialisatortillegg for e-postobjekt
Comment[pa]=ਮੇਲ ਆਬਜੈਕਟ ਲਈ ਅਕੌਂਡੀ ਸੀਰੀਲਾਈਜ਼ਰ
Comment[pl]=Wtyczka Akonadi do szeregowania obiektów pocztowych
Comment[pt]=Um 'plugin' de serialização do Akonadi para os objectos de correio
Comment[pt_BR]=Um plugin de serialização do Akonadi para os objetos de mensagem
Comment[ro]=Modul de serializare Akonadi pentru obiecte poștă
Comment[ru]=Модуль сохранения писем для Akonadi
Comment[sk]=Plugin serializátora Akonadi pre poštové objekty
Comment[sl]=Akonadijev vstavek za razvrščanje predmetov pošte v zaporedje
Comment[sr]=Аконадијев прикључак серијализатора за објекте поште
Comment[sr@ijekavian]=Аконадијев прикључак серијализатора за објекте поште
Comment[sr@ijekavianlatin]=Akonadijev priključak serijalizatora za objekte pošte
Comment[sr@latin]=Akonadijev priključak serijalizatora za objekte pošte
Comment[sv]=Ett insticksprogram till Akonadi för serialisering av e-postobjekt
Comment[tr]=E-posta nesneleri için bir Akonadi sıralandırıcısı
Comment[uk]=Додаток серіалізації Akonadi для об'єктів пошти
Comment[x-test]=xxAn Akonadi serializer plugin for mail objectsxx
Comment[zh_CN]=对邮件对象进行序列转换的 Akonadi 插件
Comment[zh_TW]=信件物件的 Akonadi 序列器外掛程式
[Plugin]
Type=message/rfc822,message/news,text/x-vnd.akonadi.note
X-Akonadi-Class=legacy;default;KMime::Message*;
X-KDE-Library=akonadi_serializer_mail
X-KDE-ClassName=Akonadi::SerializerPluginMail
/*
Copyright (c) 2007 Till Adam <adam@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef __AKONADI_SERIALIZER_MAIL_H__
#define __AKONADI_SERIALIZER_MAIL_H__
#include <QObject>
#include <QMutex>
#include <AkonadiCore/itemserializerplugin.h>
#include <AkonadiCore/gidextractorinterface.h>
namespace Akonadi {
/**
* Levare QString implicit sharing to decrease memory consumption.
*
* This class is thread safe. Apparenlty required for usage in
* legacy KRes compat bridges.
*/
class StringPool
{
public:
/**
* Lookup @p value in the pool and return the known value
* to reuse it and leverage the implicit sharing. Otherwise
* add the value to the pool and return it again.
*/
QString sharedValue(const QString &value);
private:
QMutex m_mutex;
QSet<QString> m_pool;
};
class SerializerPluginMail : public QObject, public ItemSerializerPlugin, public GidExtractorInterface
{
Q_OBJECT
Q_INTERFACES(Akonadi::ItemSerializerPlugin Akonadi::GidExtractorInterface)
Q_PLUGIN_METADATA(IID "org.kde.akonadi.SerializerPluginMail")
public:
bool deserialize(Item &item, const QByteArray &label, QIODevice &data, int version) override;
void serialize(const Item &item, const QByteArray &label, QIODevice &data, int &version) override;
QSet<QByteArray> parts(const Item &item) const override;
QString extractGid(const Item &item) const override;
private:
StringPool m_stringPool;
};
}
#endif
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