• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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 "transportadaptor.h"
00024 
00025 #include <akonadi/itemfetchjob.h>
00026 #include <akonadi/itemfetchscope.h>
00027 
00028 #include <QtDBus/QDBusConnection>
00029 
00030 using namespace Akonadi;
00031 
00032 TransportResourceBasePrivate::TransportResourceBasePrivate( TransportResourceBase *qq )
00033   : QObject(), q( qq )
00034 {
00035   new TransportAdaptor( this );
00036   QDBusConnection::sessionBus().registerObject( QLatin1String( "/Transport" ),
00037                                                 this, QDBusConnection::ExportAdaptors );
00038 }
00039 
00040 void TransportResourceBasePrivate::send( Item::Id id )
00041 {
00042   ItemFetchJob *job = new ItemFetchJob( Item( id ) );
00043   job->fetchScope().fetchFullPayload();
00044   job->setProperty( "id", QVariant( id ) );
00045   connect( job, SIGNAL( result( KJob* ) ), SLOT( fetchResult( KJob* ) ) );
00046 }
00047 
00048 void TransportResourceBasePrivate::fetchResult( KJob *job )
00049 {
00050   if ( job->error() ) {
00051     const Item::Id id = job->property( "id" ).toLongLong();
00052     emit transportResult( id, (int)TransportResourceBase::TransportFailed, job->errorText() );
00053     return;
00054   }
00055 
00056   ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob*>( job );
00057   Q_ASSERT( fetchJob );
00058 
00059   const Item item = fetchJob->items().first();
00060   q->sendItem( item );
00061 }
00062 
00063 TransportResourceBase::TransportResourceBase()
00064   : d( new TransportResourceBasePrivate( this ) )
00065 {
00066 }
00067 
00068 TransportResourceBase::~TransportResourceBase()
00069 {
00070   delete d;
00071 }
00072 
00073 void TransportResourceBase::itemSent( const Item &item,
00074                                       TransportResult result,
00075                                       const QString &message )
00076 {
00077   emit d->transportResult( item.id(), (int)result, message );
00078 }
00079 
00080 #include "transportresourcebase_p.moc"

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.2-20100208
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