Support for cancelling dimap checks.

Fixed bugs related to cancelling.

svn path=/trunk/kdepim/; revision=313148
wilder-work
David Faure 22 years ago
parent 1930c8d695
commit 58a8cbdd93
  1. 5
      imapaccountbase.cpp
  2. 53
      kmacctcachedimap.cpp
  3. 4
      kmacctcachedimap.h
  4. 5
      kmacctexppop.h
  5. 10
      kmfoldercachedimap.cpp
  6. 6
      progressdialog.cpp
  7. 7
      progressmanager.cpp
  8. 2
      progressmanager.h

@ -691,6 +691,9 @@ namespace KMail {
// These mean that we'll have to reconnect on the next attempt, so set mSlave to 0.
killAllJobs( true );
break;
case KIO::ERR_USER_CANCELED:
killAllJobs( false );
break;
default:
if ( abortSync )
killAllJobs( false );
@ -700,7 +703,7 @@ namespace KMail {
}
// check if we still display an error
if ( !mErrorDialogIsActive )
if ( !mErrorDialogIsActive && errorCode != KIO::ERR_USER_CANCELED )
{
mErrorDialogIsActive = true;
QString msg;

@ -88,7 +88,6 @@ void KMAcctCachedImap::init() {
//-----------------------------------------------------------------------------
void KMAcctCachedImap::pseudoAssign( const KMAccount * a ) {
mIdleTimer.stop();
killAllJobs( true );
if (mFolder)
{
@ -121,50 +120,6 @@ void KMAcctCachedImap::setAutoExpunge( bool /*aAutoExpunge*/ )
mAutoExpunge = false;
}
//-----------------------------------------------------------------------------
void KMAcctCachedImap::displayProgress()
{
mIdle = false;
mIdleTimer.start( 15000 );
/*
if (mProgressEnabled == mapJobData.isEmpty())
{
mProgressEnabled = !mapJobData.isEmpty();
KMBroadcastStatus::instance()->setStatusProgressEnable( "I" + mName,
mProgressEnabled );
if (!mProgressEnabled) kmkernel->filterMgr()->deref(true);
}
mIdle = FALSE;
if( mapJobData.isEmpty() )
mIdleTimer.start(0);
else
mIdleTimer.stop();
int total = 0, done = 0;
// This is a loop, but it seems that we can currently have only one job at a time in this map.
for (QMap<KIO::Job*, jobData>::Iterator it = mapJobData.begin();
it != mapJobData.end(); ++it)
{
total += (*it).total; // always ==1 (in kmfoldercachedimap.cpp)
if( (*it).parent )
done += static_cast<KMFolderCachedImap*>((*it).parent)->progress();
else
done += (*it).done;
}
if (total == 0) // can't happen
{
mTotal = 0;
return;
}
//if (total > mTotal) mTotal = total;
//done += mTotal - total;
KMBroadcastStatus::instance()->setStatusProgressPercent( "I" + mName,
done / total );
//100*done / mTotal );
*/
}
//-----------------------------------------------------------------------------
void KMAcctCachedImap::killAllJobs( bool disconnectSlave )
{
@ -176,6 +131,11 @@ void KMAcctCachedImap::killAllJobs( bool disconnectSlave )
for (; it != mapJobData.end(); ++it) {
if ((*it).parent)
folderList << static_cast<KMFolderCachedImap*>((*it).parent->storage());
// Kill the job - except if it's the one that already died and is calling us
if ( !it.key()->error() && mSlave ) {
it.key()->kill();
mSlave = 0; // killing a job, kills the slave
}
}
mapJobData.clear();
@ -183,7 +143,6 @@ void KMAcctCachedImap::killAllJobs( bool disconnectSlave )
for( QPtrListIterator<CachedImapJob> it( mJobList ); it.current(); ++it )
it.current()->setPassiveDestructor( true );
KMAccount::deleteFolderJobs();
displayProgress();
if ( disconnectSlave && slave() ) {
KIO::Scheduler::disconnectSlave( slave() );
@ -287,7 +246,7 @@ void KMAcctCachedImap::processNewMail( KMFolderCachedImap* folder,
mMailCheckProgressItem = KMail::ProgressManager::createProgressItem(
"MailCheck" + QString::number( id() ),
folder->label(), // will be changed immediately in serverSync anyway
QString::null, false);
QString::null, true);
connect( mMailCheckProgressItem, SIGNAL( progressItemCanceled( ProgressItem* ) ),
this, SLOT( slotProgressItemCanceled( ProgressItem* ) ) );

@ -78,9 +78,9 @@ public:
virtual void processNewMail( bool interactive );
/**
* Update the progress bar
* Does nothing for cached imap
*/
virtual void displayProgress();
virtual void displayProgress() {}
/**
* Kill all jobs related the the specified folder

@ -19,8 +19,9 @@ namespace KIO {
class Job;
}
/** KMail account for experimental pop mail account
*
/**
* KMail account for pop mail account
* The Exp in the name used to mean Experimental, but it's the stable one now :)
*/
class KMAcctExpPop: public KMail::NetworkAccount {
Q_OBJECT

@ -463,7 +463,6 @@ void KMFolderCachedImap::serverSync( bool recurse )
account()->mailCheckProgressItem()->setProgress( 100 );
mProgress = 100; // all done
newState( mProgress, i18n("Synchronization skipped"));
mAccount->displayProgress();
mSyncState = SYNC_STATE_INITIAL;
emit folderComplete( this, true );
return;
@ -782,7 +781,6 @@ void KMFolderCachedImap::serverSyncInternal()
mProgress = 100; // all done
newState( mProgress, i18n("Synchronization done"));
emit syncRunning( folder(), false );
mAccount->displayProgress();
if ( !mRecurse ) // "check mail for this folder" only
mSubfoldersForSync.clear();
@ -1150,7 +1148,6 @@ void KMFolderCachedImap::slotGetMessagesData(KIO::Job * job, const QByteArray &
(*it).cdata.remove(0, pos);
(*it).done++;
pos = (*it).cdata.find("\r\n--IMAPDIGEST", 1);
mAccount->displayProgress();
}
}
@ -1289,7 +1286,6 @@ void KMFolderCachedImap::slotListResult( QStringList folderNames,
kmkernel->dimapFolderMgr()->remove( doomed );
mProgress += 5;
mAccount->displayProgress();
serverSyncInternal();
}
@ -1522,7 +1518,11 @@ void KMFolderCachedImap::resetSyncState()
mSubfoldersForSync.clear();
mSyncState = SYNC_STATE_INITIAL;
close();
newState( mProgress, i18n("Aborted") );
// Don't use newState here, it would revert to mProgress (which is < current value when listing messages)
ProgressItem *progressItem = mAccount->mailCheckProgressItem();
QString str = i18n("Aborted");
progressItem->setStatus( str );
emit statusMsg( str );
}
void KMFolderCachedImap::slotIncreaseProgress()

@ -160,8 +160,7 @@ void TransactionItem::setStatus( const QString& status )
void TransactionItem::slotItemCanceled()
{
item()->setStatus( i18n("cancelling ... ") );
item()->cancel();
mItem->cancel();
}
@ -244,7 +243,6 @@ void ProgressDialog::slotTransactionCompleted( ProgressItem *item )
{
if ( mTransactionsToListviewItems.contains( item ) ) {
TransactionItem *ti = mTransactionsToListviewItems[ item ];
ti->setStatus(i18n("Completed"));
mTransactionsToListviewItems.remove( item );
QTimer::singleShot( 5000, ti, SLOT( deleteLater() ) );
}
@ -253,7 +251,7 @@ void ProgressDialog::slotTransactionCompleted( ProgressItem *item )
QTimer::singleShot( 6000, this, SLOT( slotHide() ) );
}
void ProgressDialog::slotTransactionCanceled( ProgressItem* /* item */ )
void ProgressDialog::slotTransactionCanceled( ProgressItem* )
{
}

@ -34,6 +34,7 @@
#include <kdebug.h>
#include "progressmanager.h"
#include <klocale.h>
namespace KMail {
@ -55,8 +56,9 @@ ProgressItem::~ProgressItem()
void ProgressItem::setComplete()
{
kdDebug(5006) << "ProgressItem::setComplete - " << label() << endl;
setProgress( 100 );
if ( mChildren.count() == 0 ) {
if ( !mCanceled )
setProgress( 100 );
if ( mChildren.isEmpty() ) {
emit progressItemCompleted( this );
if ( parent() )
parent()->removeChild( this );
@ -95,6 +97,7 @@ void ProgressItem::cancel()
if ( kid->canBeCanceled() )
kid->cancel();
}
setStatus( i18n( "Aborting..." ) );
emit progressItemCanceled( this );
}

@ -130,6 +130,8 @@ class ProgressItem : public QObject
void addChild( ProgressItem *kiddo );
void removeChild( ProgressItem *kiddo );
bool canceled() const { return mCanceled; }
signals:
/**
* Emitted when a new ProgressItem is added.

Loading…
Cancel
Save