mailtransport
resourcesendjob.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 "resourcesendjob_p.h" 00021 #include "messagequeuejob.h" 00022 #include "transport.h" 00023 00024 #include <QDBusConnection> 00025 #include <QDBusConnectionInterface> 00026 #include <QDBusInterface> 00027 #include <QString> 00028 00029 #include <KLocalizedString> 00030 00031 #include <kmime/kmime_message.h> 00032 00033 #include <akonadi/collection.h> 00034 #include <akonadi/itemcreatejob.h> 00035 #include <akonadi/itemfetchjob.h> 00036 #include <akonadi/itemfetchscope.h> 00037 #include <akonadi/kmime/addressattribute.h> 00038 00039 using namespace Akonadi; 00040 using namespace KMime; 00041 using namespace MailTransport; 00042 00047 class MailTransport::ResourceSendJobPrivate 00048 { 00049 public: 00050 ResourceSendJobPrivate( ResourceSendJob *qq ) 00051 : q( qq ) 00052 { 00053 } 00054 00055 void slotEmitResult(); // slot 00056 00057 ResourceSendJob *const q; 00058 }; 00059 00060 void ResourceSendJobPrivate::slotEmitResult() 00061 { 00062 // KCompositeJob took care of the error. 00063 q->emitResult(); 00064 } 00065 00066 ResourceSendJob::ResourceSendJob( Transport *transport, QObject *parent ) 00067 : TransportJob( transport, parent ), d( new ResourceSendJobPrivate( this ) ) 00068 { 00069 } 00070 00071 ResourceSendJob::~ResourceSendJob() 00072 { 00073 delete d; 00074 } 00075 00076 void ResourceSendJob::doStart() 00077 { 00078 Message::Ptr msg = Message::Ptr( new Message ); 00079 msg->setContent( data() ); 00080 MessageQueueJob *job = new MessageQueueJob; 00081 job->setMessage( msg ); 00082 job->transportAttribute().setTransportId( transport()->id() ); 00083 // Default dispatch mode (send now). 00084 // Move to default sent-mail collection. 00085 job->addressAttribute().setFrom( sender() ); 00086 job->addressAttribute().setTo( to() ); 00087 job->addressAttribute().setCc( cc() ); 00088 job->addressAttribute().setBcc( bcc() ); 00089 addSubjob( job ); 00090 // Once the item is in the outbox, there is nothing more we can do. 00091 connect( job, SIGNAL(result(KJob*)), this, SLOT(slotEmitResult()) ); 00092 job->start(); 00093 } 00094 00095 #include "resourcesendjob_p.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:03 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:03 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.