Commit 23762ced authored by Volker Krause's avatar Volker Krause
Browse files

check if the transport is correctly configured before starting a job

svn path=/trunk/KDE/kdepim/mailtransport/; revision=619891
parent 81407585
......@@ -34,7 +34,6 @@ Transport
TransportJob
------------
- use QByteArray for addresses instead of QString
- Transport validity checking
SMTPJob
-------
......
......@@ -37,7 +37,7 @@ SendmailJob::SendmailJob(Transport * transport, QObject * parent) :
SLOT(receivedStdErr(KProcess*,char*,int)) );
}
void SendmailJob::start()
void SendmailJob::doStart()
{
*mProcess << transport()->host() << "-i" << "-f" << sender() << to() << cc() << bcc();
if ( !mProcess->start( KProcess::NotifyOnExit, KProcess::All ) ) {
......
......@@ -40,9 +40,8 @@ class MAILTRANSPORT_EXPORT SendmailJob : public TransportJob
*/
SendmailJob( Transport* transport, QObject* parent = 0 );
virtual void start();
protected:
virtual void doStart();
virtual bool doKill();
private slots:
......
......@@ -71,7 +71,7 @@ SmtpJob::~SmtpJob()
}
}
void SmtpJob::start()
void SmtpJob::doStart()
{
QString query = "headers=0&from=";
query += KUrl::toPercentEncoding( sender() );
......
......@@ -52,9 +52,8 @@ class MAILTRANSPORT_EXPORT SmtpJob : public TransportJob
*/
virtual ~SmtpJob();
virtual void start();
protected:
virtual void doStart();
virtual bool doKill();
protected slots:
......
......@@ -75,8 +75,8 @@ void TransportMgr::sendBtnClicked()
job->setData( mMailEdit->document()->toPlainText().toLatin1() );
connect( job, SIGNAL(result(KJob*)), SLOT(jobResult(KJob*)) );
connect( job, SIGNAL(percent(KJob*,unsigned long)), SLOT(jobPercent(KJob*,unsigned long)) );
job->start();
mCurrentJob = job;
job->start();
}
void TransportMgr::cancelBtnClicked()
......
......@@ -20,6 +20,8 @@
#include "transport.h"
#include "transportjob.h"
#include <klocale.h>
#include <qbuffer.h>
using namespace KPIM;
......@@ -113,3 +115,14 @@ QBuffer* TransportJob::buffer()
}
return d->buffer;
}
void KPIM::TransportJob::start()
{
if ( !transport()->isValid() ) {
setError( UserDefinedError );
setErrorText( i18n("The mail transport \"%1\" is not correcty configured.", transport()->name() ) );
emitResult();
return;
}
doStart();
}
......@@ -74,6 +74,8 @@ class MAILTRANSPORT_EXPORT TransportJob : public KCompositeJob
*/
void setData( const QByteArray &data );
virtual void start();
protected:
/**
Returns the Transport object containing the mail transport settings.
......@@ -111,6 +113,11 @@ class MAILTRANSPORT_EXPORT TransportJob : public KCompositeJob
*/
QBuffer* buffer();
/**
Do the actual work, implement in your subclass.
*/
virtual void doStart() = 0;
private:
class Private;
Private* const d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment