akonadi/clients
fetchcommand.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 "fetchcommand.h"
00021 #include "out.h"
00022
00023 #include <akonadi/itemfetchjob.h>
00024 #include <akonadi/itemfetchscope.h>
00025
00026 using namespace Akonadi;
00027
00028 FetchCommand::FetchCommand(const QString & uid, const QByteArray & part ) :
00029 mUid( uid ), mPart( part )
00030 {
00031 if ( mPart.isEmpty() )
00032 mPart = Item::FullPayload;
00033 }
00034
00035 void FetchCommand::exec()
00036 {
00037 const Item item( mUid.toLongLong() );
00038 ItemFetchJob* fetchJob = new ItemFetchJob( item );
00039 fetchJob->fetchScope().fetchPayloadPart( mPart );
00040 if ( !fetchJob->exec() ) {
00041 err() << "Error fetching item '" << mUid << "': "
00042 << fetchJob->errorString()
00043 << endl;
00044 } else {
00045 foreach( const Item &item, fetchJob->items() ) {
00046 QByteArray data = item.payloadData();
00047 out() << data << endl;
00048 }
00049 }
00050 }