00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "itemserializerplugin.h"
00022 #include "item.h"
00023
00024 #include <QtCore/QBuffer>
00025
00026 using namespace Akonadi;
00027
00028 ItemSerializerPlugin::~ItemSerializerPlugin()
00029 {
00030 }
00031
00032 QSet<QByteArray> ItemSerializerPlugin::parts( const Item & item ) const
00033 {
00034 QSet<QByteArray> set;
00035 if ( item.hasPayload() )
00036 set.insert( Item::FullPayload );
00037
00038 return set;
00039 }
00040
00041 ItemSerializerPluginV2::~ItemSerializerPluginV2()
00042 {
00043 }
00044
00045 QSet<QByteArray> ItemSerializerPluginV2::availableParts( const Item & item ) const
00046 {
00047 if ( item.hasPayload() )
00048 return QSet<QByteArray>();
00049
00050 return QSet<QByteArray>() << Item::FullPayload;
00051 }
00052
00053 void ItemSerializerPluginV2::apply( Item &item, const Item &other )
00054 {
00055 QBuffer buffer;
00056 QByteArray data( other.payloadData() );
00057 buffer.setBuffer( &data );
00058 buffer.open( QIODevice::ReadOnly );
00059
00060 foreach ( const QByteArray &part, other.loadedPayloadParts() ) {
00061 buffer.seek( 0 );
00062 deserialize( item, part, buffer, 0 );
00063 }
00064
00065 buffer.close();
00066 }