Commit f75077cd authored by Volker Krause's avatar Volker Krause
Browse files

implement job killing

svn path=/trunk/KDE/kdepim/mailtransport/; revision=619853
parent 7204275a
......@@ -41,11 +41,6 @@ TransportJob
- use QByteArray for addresses instead of QString
- Transport validity checking
SendmailJob
-----------
- implement doKill()
SMTPJob
-------
- get rid of kmail specific stuff in start()
- implement doKill()
......@@ -76,4 +76,11 @@ void SendmailJob::receivedStdErr(KProcess * proc, char * data, int len)
mLastError += QString::fromLocal8Bit( data, len );
}
bool SendmailJob::doKill()
{
delete mProcess;
mProcess = 0;
return true;
}
#include "sendmailjob.moc"
......@@ -42,6 +42,9 @@ class MAILTRANSPORT_EXPORT SendmailJob : public TransportJob
virtual void start();
protected:
virtual bool doKill();
private slots:
void sendmailExited();
void wroteStdin();
......
......@@ -165,6 +165,16 @@ void SmtpJob::start()
setTotalSize( data().length() );
}
bool SmtpJob::doKill()
{
if ( !hasSubjobs() )
return false;
KIO::SimpleJob *job = static_cast<KIO::SimpleJob*>( subjobs().first() );
clearSubjobs();
KIO::Scheduler::cancelJob( job );
return true;
}
void SmtpJob::slotResult(KJob * job)
{
kDebug() << k_funcinfo << job->error() << error() << endl;
......
......@@ -54,6 +54,9 @@ class MAILTRANSPORT_EXPORT SmtpJob : public TransportJob
virtual void start();
protected:
virtual bool doKill();
protected slots:
virtual void slotResult( KJob *job );
void slaveError(KIO::Slave *slave, int errorCode, const QString &errorMsg);
......
/*
Copyright (c) 2006 Volker Krause <vkrause@kde.org>
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
......@@ -33,7 +33,8 @@
using namespace KPIM;
TransportMgr::TransportMgr()
TransportMgr::TransportMgr() :
mCurrentJob( 0 )
{
new TransportManagementWidget( this );
mComboBox = new TransportComboBox( this );
......@@ -52,6 +53,8 @@ TransportMgr::TransportMgr()
mMailEdit->setLineWrapMode( QTextEdit::NoWrap );
b = new QPushButton( "&Send", this );
connect( b, SIGNAL(clicked(bool)), SLOT(sendBtnClicked()) );
b = new QPushButton( "&Cancel", this );
connect( b, SIGNAL(clicked(bool)), SLOT(cancelBtnClicked()) );
}
void TransportMgr::editBtnClicked()
......@@ -73,6 +76,14 @@ void TransportMgr::sendBtnClicked()
connect( job, SIGNAL(result(KJob*)), SLOT(jobResult(KJob*)) );
connect( job, SIGNAL(percent(KJob*,unsigned long)), SLOT(jobPercent(KJob*,unsigned long)) );
job->start();
mCurrentJob = job;
}
void TransportMgr::cancelBtnClicked()
{
if ( mCurrentJob )
kDebug() << k_funcinfo << "kill success: " << mCurrentJob->kill() << endl;
mCurrentJob = 0;
}
int main( int argc, char** argv )
......@@ -87,6 +98,7 @@ int main( int argc, char** argv )
void TransportMgr::jobResult( KJob* job )
{
kDebug() << k_funcinfo << job->error() << job->errorText() << endl;
mCurrentJob = 0;
}
void TransportMgr::jobPercent(KJob * job, unsigned long percent)
......
/*
Copyright (c) 2006 Volker Krause <vkrause@kde.org>
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
......@@ -37,6 +37,7 @@ class TransportMgr : public KVBox
private slots:
void editBtnClicked();
void sendBtnClicked();
void cancelBtnClicked();
void jobResult( KJob* job );
void jobPercent( KJob* job, unsigned long percent );
......@@ -44,6 +45,7 @@ class TransportMgr : public KVBox
KPIM::TransportComboBox* mComboBox;
KLineEdit *mSenderEdit, *mToEdit, *mCcEdit, *mBccEdit;
QTextEdit *mMailEdit;
KJob *mCurrentJob;
};
#endif
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