akonadi/clients
appendcommand.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "appendcommand.h"
00021 #include "out.h"
00022
00023 #include <akonadi/private/collectionpathresolver_p.h>
00024 #include <akonadi/item.h>
00025 #include <akonadi/itemcreatejob.h>
00026
00027 using namespace Akonadi;
00028
00029 AppendCommand::AppendCommand(const QString & path, const QString & mimetype, const QString & content) : mPath( path ), mMimeType( mimetype ), mContent( content )
00030 {
00031 }
00032
00033 void AppendCommand::exec()
00034 {
00035 CollectionPathResolver *resolver = new CollectionPathResolver( mPath );
00036 if ( !resolver->exec() ) {
00037 err() << "Error resolving path '" << mPath << "': " << resolver->errorString() << endl;
00038 return;
00039 }
00040
00041 Collection::Id currentColId = resolver->collection();
00042
00043 Item item;
00044 item.setMimeType( mMimeType );
00045 item.setPayloadFromData( mContent.toUtf8() );
00046
00047 ItemCreateJob* appendJob = new ItemCreateJob( item, Collection( currentColId ) );
00048 if ( !appendJob->exec() ) {
00049 err() << "Error appending item '" << endl;
00050 }
00051 }