00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036 #include "imapjob.h"
00037 #include "kmfolderimap.h"
00038 #include "kmfolder.h"
00039 #include "kmmsgpart.h"
00040 #include "progressmanager.h"
00041 using KPIM::ProgressManager;
00042 #include "util.h"
00043
00044 #include <qstylesheet.h>
00045 #include <kio/scheduler.h>
00046 #include <kdebug.h>
00047 #include <klocale.h>
00048 #include <mimelib/body.h>
00049 #include <mimelib/bodypart.h>
00050 #include <mimelib/string.h>
00051
00052
00053 namespace KMail {
00054
00055
00056 ImapJob::ImapJob( KMMessage *msg, JobType jt, KMFolderImap* folder,
00057 QString partSpecifier, const AttachmentStrategy *as )
00058 : FolderJob( msg, jt, folder? folder->folder() : 0, partSpecifier ),
00059 mAttachmentStrategy( as ), mParentProgressItem(0)
00060 {
00061 }
00062
00063
00064 ImapJob::ImapJob( QPtrList<KMMessage>& msgList, QString sets, JobType jt,
00065 KMFolderImap* folder )
00066 : FolderJob( msgList, sets, jt, folder? folder->folder() : 0 ),
00067 mAttachmentStrategy ( 0 ), mParentProgressItem(0)
00068 {
00069 }
00070
00071 void ImapJob::init( JobType jt, QString sets, KMFolderImap* folder,
00072 QPtrList<KMMessage>& msgList )
00073 {
00074 mJob = 0;
00075
00076 assert(jt == tGetMessage || folder);
00077 KMMessage* msg = msgList.first();
00078
00079 if ( !msg ) {
00080 deleteLater();
00081 return;
00082 }
00083 mType = jt;
00084 mDestFolder = folder? folder->folder() : 0;
00085
00086 if (folder) {
00087 folder->open("imapjobdest");
00088 }
00089 KMFolder *msg_parent = msg->parent();
00090 if (msg_parent) {
00091 msg_parent->open("imapjobsrc");
00092 }
00093 mSrcFolder = msg_parent;
00094
00095
00096
00097
00098 KMAcctImap *account = 0;
00099 if (folder) {
00100 account = folder->account();
00101 } else {
00102 if ( msg_parent && msg_parent->storage() )
00103 account = static_cast<KMFolderImap*>(msg_parent->storage())->account();
00104 }
00105 if ( !account ||
00106 account->makeConnection() == ImapAccountBase::Error ) {
00107 deleteLater();
00108 return;
00109 }
00110 account->mJobList.append( this );
00111 if ( jt == tPutMessage )
00112 {
00113
00114 QPtrListIterator<KMMessage> it( msgList );
00115 KMMessage* curMsg;
00116 while ( ( curMsg = it.current() ) != 0 )
00117 {
00118 ++it;
00119 if ( mSrcFolder && !curMsg->isMessage() )
00120 {
00121 int idx = mSrcFolder->find( curMsg );
00122 curMsg = mSrcFolder->getMsg( idx );
00123 }
00124 KURL url = account->getUrl();
00125 QString flags = KMFolderImap::statusToFlags( curMsg->status(), folder->permanentFlags() );
00126 url.setPath( folder->imapPath() + ";SECTION=" + flags );
00127 ImapAccountBase::jobData jd;
00128 jd.parent = 0; jd.offset = 0; jd.done = 0;
00129 jd.total = ( curMsg->msgSizeServer() > 0 ) ?
00130 curMsg->msgSizeServer() : curMsg->msgSize();
00131 jd.msgList.append( curMsg );
00132 QCString cstr( curMsg->asString() );
00133 int a = cstr.find("\nX-UID: ");
00134 int b = cstr.find('\n', a);
00135 if (a != -1 && b != -1 && cstr.find("\n\n") > a) cstr.remove(a, b-a);
00136 jd.data.resize( cstr.length() + cstr.contains( "\n" ) - cstr.contains( "\r\n" ) );
00137 unsigned int i = 0;
00138 char prevChar = '\0';
00139
00140 for ( char *ch = cstr.data(); *ch; ch++ )
00141 {
00142 if ( *ch == '\n' && (prevChar != '\r') ) {
00143 jd.data.at( i ) = '\r';
00144 i++;
00145 }
00146 jd.data.at( i ) = *ch;
00147 prevChar = *ch;
00148 i++;
00149 }
00150 jd.progressItem = ProgressManager::createProgressItem(
00151 mParentProgressItem,
00152 "ImapJobUploading"+ProgressManager::getUniqueID(),
00153 i18n("Uploading message data"),
00154 QStyleSheet::escape( curMsg->subject() ),
00155 true,
00156 account->useSSL() || account->useTLS() );
00157 jd.progressItem->setTotalItems( jd.total );
00158 connect ( jd.progressItem, SIGNAL( progressItemCanceled( KPIM::ProgressItem*)),
00159 account, SLOT( slotAbortRequested( KPIM::ProgressItem* ) ) );
00160 KIO::SimpleJob *job = KIO::put( url, 0, false, false, false );
00161 KIO::Scheduler::assignJobToSlave( account->slave(), job );
00162 account->insertJob( job, jd );
00163 connect( job, SIGNAL(result(KIO::Job *)),
00164 SLOT(slotPutMessageResult(KIO::Job *)) );
00165 connect( job, SIGNAL(dataReq(KIO::Job *, QByteArray &)),
00166 SLOT(slotPutMessageDataReq(KIO::Job *, QByteArray &)) );
00167 connect( job, SIGNAL(infoMessage(KIO::Job *, const QString &)),
00168 SLOT(slotPutMessageInfoData(KIO::Job *, const QString &)) );
00169 connect( job, SIGNAL(processedSize(KIO::Job *, KIO::filesize_t)),
00170 SLOT(slotProcessedSize(KIO::Job *, KIO::filesize_t)));
00171 }
00172 }
00173 else if ( jt == tCopyMessage || jt == tMoveMessage )
00174 {
00175 KURL url = account->getUrl();
00176 KURL destUrl = account->getUrl();
00177 destUrl.setPath(folder->imapPath());
00178 KMFolderImap *imapDestFolder = static_cast<KMFolderImap*>(msg_parent->storage());
00179 url.setPath( imapDestFolder->imapPath() + ";UID=" + sets );
00180 ImapAccountBase::jobData jd;
00181 jd.parent = 0; jd.offset = 0;
00182 jd.total = 1; jd.done = 0;
00183 jd.msgList = msgList;
00184
00185 QByteArray packedArgs;
00186 QDataStream stream( packedArgs, IO_WriteOnly );
00187
00188 stream << (int) 'C' << url << destUrl;
00189 jd.progressItem = ProgressManager::createProgressItem(
00190 mParentProgressItem,
00191 "ImapJobCopyMove"+ProgressManager::getUniqueID(),
00192 i18n("Server operation"),
00193 i18n("Source folder: %1 - Destination folder: %2")
00194 .arg( QStyleSheet::escape( msg_parent->prettyURL() ),
00195 QStyleSheet::escape( mDestFolder->prettyURL() ) ),
00196 true,
00197 account->useSSL() || account->useTLS() );
00198 jd.progressItem->setTotalItems( jd.total );
00199 connect ( jd.progressItem, SIGNAL(progressItemCanceled(KPIM::ProgressItem*)),
00200 account, SLOT( slotAbortRequested(KPIM::ProgressItem* ) ) );
00201 KIO::SimpleJob *simpleJob = KIO::special( url, packedArgs, false );
00202 KIO::Scheduler::assignJobToSlave( account->slave(), simpleJob );
00203 mJob = simpleJob;
00204 account->insertJob( mJob, jd );
00205 connect( mJob, SIGNAL(result(KIO::Job *)),
00206 SLOT(slotCopyMessageResult(KIO::Job *)) );
00207 if ( jt == tMoveMessage )
00208 {
00209 connect( mJob, SIGNAL(infoMessage(KIO::Job *, const QString &)),
00210 SLOT(slotCopyMessageInfoData(KIO::Job *, const QString &)) );
00211 }
00212 }
00213 else {
00214 slotGetNextMessage();
00215 }
00216 }
00217
00218
00219
00220 ImapJob::~ImapJob()
00221 {
00222 if ( mDestFolder )
00223 {
00224 KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
00225 if ( account ) {
00226 if ( mJob ) {
00227 ImapAccountBase::JobIterator it = account->findJob( mJob );
00228 if ( it != account->jobsEnd() ) {
00229 if( (*it).progressItem ) {
00230 (*it).progressItem->setComplete();
00231 (*it).progressItem = 0;
00232 }
00233 if ( !(*it).msgList.isEmpty() ) {
00234 for ( QPtrListIterator<KMMessage> mit( (*it).msgList ); mit.current(); ++mit )
00235 mit.current()->setTransferInProgress( false );
00236 }
00237 }
00238 account->removeJob( mJob );
00239 }
00240 account->mJobList.remove( this );
00241 }
00242 mDestFolder->close("imapjobdest");
00243 }
00244
00245 if ( mSrcFolder ) {
00246 if (!mDestFolder || mDestFolder != mSrcFolder) {
00247 if (! (mSrcFolder->folderType() == KMFolderTypeImap) ) return;
00248 KMAcctImap *account = static_cast<KMFolderImap*>(mSrcFolder->storage())->account();
00249 if ( account ) {
00250 if ( mJob ) {
00251 ImapAccountBase::JobIterator it = account->findJob( mJob );
00252 if ( it != account->jobsEnd() ) {
00253 if( (*it).progressItem ) {
00254 (*it).progressItem->setComplete();
00255 (*it).progressItem = 0;
00256 }
00257 if ( !(*it).msgList.isEmpty() ) {
00258 for ( QPtrListIterator<KMMessage> mit( (*it).msgList ); mit.current(); ++mit )
00259 mit.current()->setTransferInProgress( false );
00260 }
00261 }
00262 account->removeJob( mJob );
00263 }
00264 account->mJobList.remove( this );
00265 }
00266 }
00267 mSrcFolder->close("imapjobsrc");
00268 }
00269 }
00270
00271
00272
00273 void ImapJob::slotGetNextMessage()
00274 {
00275 KMMessage *msg = mMsgList.first();
00276 KMFolderImap *msgParent = msg ? static_cast<KMFolderImap*>(msg->storage()) : 0;
00277 if ( !msgParent || !msg || msg->UID() == 0 )
00278 {
00279
00280 emit messageRetrieved( 0 );
00281 deleteLater();
00282 return;
00283 }
00284 KMAcctImap *account = msgParent->account();
00285 KURL url = account->getUrl();
00286 QString path = msgParent->imapPath() + ";UID=" + QString::number(msg->UID());
00287 ImapAccountBase::jobData jd;
00288 jd.parent = 0; jd.offset = 0;
00289 jd.total = 1; jd.done = 0;
00290 jd.msgList.append( msg );
00291 if ( !mPartSpecifier.isEmpty() )
00292 {
00293 if ( mPartSpecifier.find ("STRUCTURE", 0, false) != -1 ) {
00294 path += ";SECTION=STRUCTURE";
00295 } else if ( mPartSpecifier == "HEADER" ) {
00296 path += ";SECTION=HEADER";
00297 } else {
00298 path += ";SECTION=BODY.PEEK[" + mPartSpecifier + "]";
00299 DwBodyPart * part = msg->findDwBodyPart( msg->getFirstDwBodyPart(), mPartSpecifier );
00300 if (part)
00301 jd.total = part->BodySize();
00302 }
00303 } else {
00304 path += ";SECTION=BODY.PEEK[]";
00305 if (msg->msgSizeServer() > 0)
00306 jd.total = msg->msgSizeServer();
00307 }
00308 url.setPath( path );
00309
00310
00311 msg->setTransferInProgress( true );
00312 jd.progressItem = ProgressManager::createProgressItem(
00313 mParentProgressItem,
00314 "ImapJobDownloading"+ProgressManager::getUniqueID(),
00315 i18n("Downloading message data"),
00316 i18n("Message with subject: ") +
00317 QStyleSheet::escape( msg->subject() ),
00318 true,
00319 account->useSSL() || account->useTLS() );
00320 connect ( jd.progressItem, SIGNAL( progressItemCanceled( KPIM::ProgressItem*)),
00321 account, SLOT( slotAbortRequested( KPIM::ProgressItem* ) ) );
00322 jd.progressItem->setTotalItems( jd.total );
00323
00324 KIO::SimpleJob *simpleJob = KIO::get( url, false, false );
00325 KIO::Scheduler::assignJobToSlave( account->slave(), simpleJob );
00326 mJob = simpleJob;
00327 account->insertJob( mJob, jd );
00328 if ( mPartSpecifier.find( "STRUCTURE", 0, false ) != -1 )
00329 {
00330 connect( mJob, SIGNAL(result(KIO::Job *)),
00331 this, SLOT(slotGetBodyStructureResult(KIO::Job *)) );
00332 } else {
00333 connect( mJob, SIGNAL(result(KIO::Job *)),
00334 this, SLOT(slotGetMessageResult(KIO::Job *)) );
00335 }
00336 connect( mJob, SIGNAL(data(KIO::Job *, const QByteArray &)),
00337 msgParent, SLOT(slotSimpleData(KIO::Job *, const QByteArray &)) );
00338 if ( jd.total > 1 )
00339 {
00340 connect(mJob, SIGNAL(processedSize(KIO::Job *, KIO::filesize_t)),
00341 this, SLOT(slotProcessedSize(KIO::Job *, KIO::filesize_t)));
00342 }
00343 }
00344
00345
00346
00347 void ImapJob::slotGetMessageResult( KIO::Job * job )
00348 {
00349 KMMessage *msg = mMsgList.first();
00350 if (!msg || !msg->parent() || !job) {
00351 emit messageRetrieved( 0 );
00352 deleteLater();
00353 return;
00354 }
00355 KMFolderImap* parent = static_cast<KMFolderImap*>(msg->storage());
00356 if (msg->transferInProgress())
00357 msg->setTransferInProgress( false );
00358 KMAcctImap *account = parent->account();
00359 if ( !account ) {
00360 emit messageRetrieved( 0 );
00361 deleteLater();
00362 return;
00363 }
00364 ImapAccountBase::JobIterator it = account->findJob( job );
00365 if ( it == account->jobsEnd() ) return;
00366
00367 bool gotData = true;
00368 if (job->error())
00369 {
00370 QString errorStr = i18n( "Error while retrieving messages from the server." );
00371 if ( (*it).progressItem )
00372 (*it).progressItem->setStatus( errorStr );
00373 account->handleJobError( job, errorStr );
00374 return;
00375 } else {
00376 if ((*it).data.size() > 0)
00377 {
00378 kdDebug(5006) << "ImapJob::slotGetMessageResult - retrieved part " << mPartSpecifier << endl;
00379 if ( mPartSpecifier.isEmpty() ||
00380 mPartSpecifier == "HEADER" )
00381 {
00382 uint size = msg->msgSizeServer();
00383 if ( size > 0 && mPartSpecifier.isEmpty() )
00384 (*it).done = size;
00385 ulong uid = msg->UID();
00386
00387 if ( mPartSpecifier.isEmpty() )
00388 msg->setComplete( true );
00389 else
00390 msg->setReadyToShow( false );
00391
00392
00393 size_t dataSize = (*it).data.size();
00394 dataSize = Util::crlf2lf( (*it).data.data(), dataSize );
00395 (*it).data.resize( dataSize );
00396
00397
00398
00399
00400 msg->parent()->storage()->blockSignals( true );
00401 msg->fromByteArray( (*it).data );
00402
00403 msg->parent()->storage()->blockSignals( false );
00404 if ( size > 0 && msg->msgSizeServer() == 0 ) {
00405 msg->setMsgSizeServer(size);
00406 }
00407
00408 msg->setUID(uid);
00409
00410 } else {
00411
00412 size_t dataSize = (*it).data.size();
00413 dataSize = Util::crlf2lf( (*it).data.data(), dataSize );
00414 (*it).data.resize( dataSize );
00415
00416
00417 msg->updateBodyPart( mPartSpecifier, (*it).data );
00418 msg->setReadyToShow( true );
00419
00420
00421 if (msg->attachmentState() != KMMsgHasAttachment)
00422 msg->updateAttachmentState();
00423 }
00424 } else {
00425 kdDebug(5006) << "ImapJob::slotGetMessageResult - got no data for " << mPartSpecifier << endl;
00426 gotData = false;
00427 msg->setReadyToShow( true );
00428
00429 msg->notify();
00430 }
00431 }
00432 if (account->slave()) {
00433 account->removeJob(it);
00434 account->mJobList.remove(this);
00435 }
00436
00437
00438 if ( mPartSpecifier.isEmpty() ||
00439 mPartSpecifier == "HEADER" )
00440 {
00441 if ( gotData )
00442 emit messageRetrieved(msg);
00443 else
00444 {
00445
00446
00447 emit messageRetrieved( 0 );
00448 parent->ignoreJobsForMessage( msg );
00449 int idx = parent->find( msg );
00450 if (idx != -1) parent->removeMsg( idx, true );
00451
00452
00453 return;
00454 }
00455 } else {
00456 emit messageUpdated(msg, mPartSpecifier);
00457 }
00458 deleteLater();
00459 }
00460
00461
00462 void ImapJob::slotGetBodyStructureResult( KIO::Job * job )
00463 {
00464 KMMessage *msg = mMsgList.first();
00465 if (!msg || !msg->parent() || !job) {
00466 deleteLater();
00467 return;
00468 }
00469 KMFolderImap* parent = static_cast<KMFolderImap*>(msg->storage());
00470 if (msg->transferInProgress())
00471 msg->setTransferInProgress( false );
00472 KMAcctImap *account = parent->account();
00473 if ( !account ) {
00474 deleteLater();
00475 return;
00476 }
00477 ImapAccountBase::JobIterator it = account->findJob( job );
00478 if ( it == account->jobsEnd() ) return;
00479
00480
00481 if (job->error())
00482 {
00483 account->handleJobError( job, i18n( "Error while retrieving information on the structure of a message." ) );
00484 return;
00485 } else {
00486 if ((*it).data.size() > 0)
00487 {
00488 QDataStream stream( (*it).data, IO_ReadOnly );
00489 account->handleBodyStructure(stream, msg, mAttachmentStrategy);
00490 }
00491 }
00492 if (account->slave()) {
00493 account->removeJob(it);
00494 account->mJobList.remove(this);
00495 }
00496 deleteLater();
00497 }
00498
00499
00500 void ImapJob::slotPutMessageDataReq( KIO::Job *job, QByteArray &data )
00501 {
00502 KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
00503 if ( !account )
00504 {
00505 emit finished();
00506 deleteLater();
00507 return;
00508 }
00509 ImapAccountBase::JobIterator it = account->findJob( job );
00510 if ( it == account->jobsEnd() ) return;
00511
00512 if ((*it).data.size() - (*it).offset > 0x8000)
00513 {
00514 data.duplicate((*it).data.data() + (*it).offset, 0x8000);
00515 (*it).offset += 0x8000;
00516 }
00517 else if ((*it).data.size() - (*it).offset > 0)
00518 {
00519 data.duplicate((*it).data.data() + (*it).offset, (*it).data.size() - (*it).offset);
00520 (*it).offset = (*it).data.size();
00521 } else data.resize(0);
00522 }
00523
00524
00525
00526 void ImapJob::slotPutMessageResult( KIO::Job *job )
00527 {
00528 KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
00529 if ( !account )
00530 {
00531 emit finished();
00532 deleteLater();
00533 return;
00534 }
00535 ImapAccountBase::JobIterator it = account->findJob( job );
00536 if ( it == account->jobsEnd() ) return;
00537 bool deleteMe = false;
00538 if (job->error())
00539 {
00540 if ( (*it).progressItem )
00541 (*it).progressItem->setStatus( i18n("Uploading message data failed.") );
00542 account->handlePutError( job, *it, mDestFolder );
00543 return;
00544 } else {
00545 if ( (*it).progressItem )
00546 (*it).progressItem->setStatus( i18n("Uploading message data completed.") );
00547 if ( mParentProgressItem )
00548 {
00549 mParentProgressItem->incCompletedItems();
00550 mParentProgressItem->updateProgress();
00551 }
00552 KMMessage *msg = (*it).msgList.first();
00553 emit messageStored( msg );
00554 if ( msg == mMsgList.getLast() )
00555 {
00556 emit messageCopied( mMsgList );
00557 if (account->slave()) {
00558 account->mJobList.remove( this );
00559 }
00560 deleteMe = true;
00561 }
00562 }
00563 if (account->slave()) {
00564 account->removeJob( it );
00565 }
00566 if ( deleteMe )
00567 deleteLater();
00568 }
00569
00570
00571 void ImapJob::slotCopyMessageInfoData(KIO::Job * job, const QString & data)
00572 {
00573 KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
00574 KMAcctImap *account = imapFolder->account();
00575 if ( !account )
00576 {
00577 emit finished();
00578 deleteLater();
00579 return;
00580 }
00581 ImapAccountBase::JobIterator it = account->findJob( job );
00582 if ( it == account->jobsEnd() ) return;
00583
00584 if (data.find("UID") != -1)
00585 {
00586
00587 QString oldUid = data.section(' ', 1, 1);
00588 QString newUid = data.section(' ', 2, 2);
00589
00590
00591 QValueList<ulong> olduids = KMFolderImap::splitSets(oldUid);
00592 QValueList<ulong> newuids = KMFolderImap::splitSets(newUid);
00593
00594 int index = -1;
00595 KMMessage * msg;
00596 for ( msg = (*it).msgList.first(); msg; msg = (*it).msgList.next() )
00597 {
00598 ulong uid = msg->UID();
00599 index = olduids.findIndex(uid);
00600 if (index > -1)
00601 {
00602
00603 imapFolder->saveMsgMetaData( msg, newuids[index] );
00604 }
00605 }
00606 }
00607 }
00608
00609
00610 void ImapJob::slotPutMessageInfoData(KIO::Job *job, const QString &data)
00611 {
00612 KMFolderImap * imapFolder = static_cast<KMFolderImap*>(mDestFolder->storage());
00613 KMAcctImap *account = imapFolder->account();
00614 if ( !account )
00615 {
00616 emit finished();
00617 deleteLater();
00618 return;
00619 }
00620 ImapAccountBase::JobIterator it = account->findJob( job );
00621 if ( it == account->jobsEnd() ) return;
00622
00623 if ( data.find("UID") != -1 )
00624 {
00625 ulong uid = ( data.right(data.length()-4) ).toInt();
00626 if ( !(*it).msgList.isEmpty() )
00627 {
00628 imapFolder->saveMsgMetaData( (*it).msgList.first(), uid );
00629 }
00630 }
00631 }
00632
00633
00634
00635 void ImapJob::slotCopyMessageResult( KIO::Job *job )
00636 {
00637 KMAcctImap *account = static_cast<KMFolderImap*>(mDestFolder->storage())->account();
00638 if ( !account )
00639 {
00640 emit finished();
00641 deleteLater();
00642 return;
00643 }
00644 ImapAccountBase::JobIterator it = account->findJob( job );
00645 if ( it == account->jobsEnd() ) return;
00646
00647 if (job->error())
00648 {
00649 mErrorCode = job->error();
00650 QString errStr = i18n("Error while copying messages.");
00651 if ( (*it).progressItem )
00652 (*it).progressItem->setStatus( errStr );
00653 if ( account->handleJobError( job, errStr ) )
00654 deleteLater();
00655 return;
00656 } else {
00657 if ( !(*it).msgList.isEmpty() )
00658 {
00659 emit messageCopied((*it).msgList);
00660 } else if (mMsgList.first()) {
00661 emit messageCopied(mMsgList.first());
00662 }
00663 }
00664 if (account->slave()) {
00665 account->removeJob(it);
00666 account->mJobList.remove(this);
00667 }
00668 deleteLater();
00669 }
00670
00671
00672 void ImapJob::execute()
00673 {
00674 init( mType, mSets, mDestFolder?
00675 dynamic_cast<KMFolderImap*>( mDestFolder->storage() ):0, mMsgList );
00676 }
00677
00678
00679 void ImapJob::setParentFolder( const KMFolderImap* parent )
00680 {
00681 mParentFolder = const_cast<KMFolderImap*>( parent );
00682 }
00683
00684
00685 void ImapJob::slotProcessedSize(KIO::Job * job, KIO::filesize_t processed)
00686 {
00687 KMMessage *msg = mMsgList.first();
00688 if (!msg || !job) {
00689 return;
00690 }
00691 KMFolderImap* parent = 0;
00692 if ( msg->parent() && msg->parent()->folderType() == KMFolderTypeImap )
00693 parent = static_cast<KMFolderImap*>(msg->parent()->storage());
00694 else if (mDestFolder)
00695 parent = static_cast<KMFolderImap*>(mDestFolder->storage());
00696 if (!parent) return;
00697 KMAcctImap *account = parent->account();
00698 if ( !account ) return;
00699 ImapAccountBase::JobIterator it = account->findJob( job );
00700 if ( it == account->jobsEnd() ) return;
00701 (*it).done = processed;
00702 if ( (*it).progressItem ) {
00703 (*it).progressItem->setCompletedItems( processed );
00704 (*it).progressItem->updateProgress();
00705 }
00706 emit progress( (*it).done, (*it).total );
00707 }
00708
00709 }
00710
00711 #include "imapjob.moc"