akonadi
transportresourcebase.cpp
00001 /* 00002 Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "transportresourcebase.h" 00021 #include "transportresourcebase_p.h" 00022 00023 #include "dbusconnectionpool.h" 00024 #include "transportadaptor.h" 00025 00026 #include <akonadi/itemfetchjob.h> 00027 #include <akonadi/itemfetchscope.h> 00028 00029 #include <QtDBus/QDBusConnection> 00030 00031 using namespace Akonadi; 00032 00033 TransportResourceBasePrivate::TransportResourceBasePrivate( TransportResourceBase *qq ) 00034 : QObject(), q( qq ) 00035 { 00036 new Akonadi__TransportAdaptor( this ); 00037 DBusConnectionPool::threadConnection().registerObject( QLatin1String( "/Transport" ), 00038 this, QDBusConnection::ExportAdaptors ); 00039 } 00040 00041 void TransportResourceBasePrivate::send( Item::Id id ) 00042 { 00043 ItemFetchJob *job = new ItemFetchJob( Item( id ) ); 00044 job->fetchScope().fetchFullPayload(); 00045 job->setProperty( "id", QVariant( id ) ); 00046 connect( job, SIGNAL(result(KJob*)), SLOT(fetchResult(KJob*)) ); 00047 } 00048 00049 void TransportResourceBasePrivate::fetchResult( KJob *job ) 00050 { 00051 if ( job->error() ) { 00052 const Item::Id id = job->property( "id" ).toLongLong(); 00053 emit transportResult( id, (int)TransportResourceBase::TransportFailed, job->errorText() ); 00054 return; 00055 } 00056 00057 ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob*>( job ); 00058 Q_ASSERT( fetchJob ); 00059 00060 const Item item = fetchJob->items().first(); 00061 q->sendItem( item ); 00062 } 00063 00064 TransportResourceBase::TransportResourceBase() 00065 : d( new TransportResourceBasePrivate( this ) ) 00066 { 00067 } 00068 00069 TransportResourceBase::~TransportResourceBase() 00070 { 00071 delete d; 00072 } 00073 00074 void TransportResourceBase::itemSent( const Item &item, 00075 TransportResult result, 00076 const QString &message ) 00077 { 00078 emit d->transportResult( item.id(), (int)result, message ); 00079 } 00080 00081 #include "transportresourcebase_p.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:00:46 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:00:46 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.