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