• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

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"

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal