french -> French
[kdepim.git] / knode / mailsendjob.cpp
blob39cb502a0706e75089c1ec65432382b9000fa38e
1 /*
2 Copyright (c) 2005 by Volker Krause <vkrause@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 You should have received a copy of the GNU General Public License
9 along with this program; if not, write to the Free Software Foundation,
10 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
13 #include "mailsendjob.h"
15 #include "knarticle.h"
16 #include "knserverinfo.h"
18 #include <mailtransport/transportmanager.h>
19 #include <mailtransport/transportjob.h>
21 #include <kdebug.h>
22 #include <klocale.h>
23 #include <kio/job.h>
25 using namespace MailTransport;
27 KNode::MailSendJob::MailSendJob( KNJobConsumer * c, int transportId, KNJobItem::Ptr i ) :
28 KNJobData( KNJobData::JTmail, c, KNServerInfo::Ptr(), i ),
29 mTransportId( transportId )
33 void KNode::MailSendJob::execute()
35 KNLocalArticle::Ptr art = boost::static_pointer_cast<KNLocalArticle>( data() );
37 TransportJob* job = TransportManager::self()->createTransportJob( mTransportId );
38 if ( !job ) {
39 setError( KIO::ERR_INTERNAL, i18n("Could not create mail transport job.") );
40 emitFinished();
41 return;
44 job->setData( art->encodedContent( true ) );
45 job->setSender( art->from()->addresses().first() );
47 // FIXME
48 QStringList to;
49 foreach ( const QByteArray &b, art->to()->addresses() ) {
50 to << QString::fromLatin1( b );
52 job->setTo( to );
54 connect( job, SIGNAL(result(KJob*)), SLOT(slotResult(KJob*)) );
55 setupKJob( job );
56 TransportManager::self()->schedule( job );
59 void KNode::MailSendJob::slotResult( KJob * job )
61 if ( job->error() )
62 setError( job->error(), job->errorString() );
63 emitFinished();