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>
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
);
39 setError( KIO::ERR_INTERNAL
, i18n("Could not create mail transport job.") );
44 job
->setData( art
->encodedContent( true ) );
45 job
->setSender( art
->from()->addresses().first() );
49 foreach ( const QByteArray
&b
, art
->to()->addresses() ) {
50 to
<< QString::fromLatin1( b
);
54 connect( job
, SIGNAL(result(KJob
*)), SLOT(slotResult(KJob
*)) );
56 TransportManager::self()->schedule( job
);
59 void KNode::MailSendJob::slotResult( KJob
* job
)
62 setError( job
->error(), job
->errorString() );
66 #include "mailsendjob.moc"