Get rid of the mResync hack, and delete all sets of consecutive UIDs one after

the other in CachedImapJob. This allows coolo to finally read his mail, so it's worth it :)

svn path=/trunk/kdepim/; revision=349960
wilder-work
David Faure 22 years ago
parent 70e1bee969
commit f7a6329f49
  1. 60
      cachedimapjob.cpp
  2. 14
      cachedimapjob.h
  3. 23
      kmfoldercachedimap.cpp
  4. 4
      kmfoldercachedimap.h

@ -90,20 +90,21 @@ CachedImapJob::CachedImapJob( const QValueList<KMFolderCachedImap*>& fList,
{
}
// Delete message ; Rename folder
CachedImapJob::CachedImapJob( const QString& uids, JobType type,
// Rename folder
CachedImapJob::CachedImapJob( const QString& string1, JobType type,
KMFolderCachedImap* folder )
: FolderJob( type ), mFolder(folder), mMsg( 0 ), mString( uids ),
: FolderJob( type ), mFolder(folder), mMsg( 0 ), mString( string1 ),
mParentFolder ( 0 )
{
assert( folder );
assert( type != tDeleteMessage ); // moved to another ctor
}
// Delete folders
CachedImapJob::CachedImapJob( const QStringList& folderpaths, JobType type,
// Delete folders or messages
CachedImapJob::CachedImapJob( const QStringList& foldersOrMsgs, JobType type,
KMFolderCachedImap* folder )
: FolderJob( type ), mFolder( folder ), mFolderPathList( folderpaths ),
mMsg( 0 ), mParentFolder ( 0 )
: FolderJob( type ), mFolder( folder ), mFoldersOrMessages( foldersOrMsgs ),
mMsg( 0 ), mParentFolder( 0 )
{
assert( folder );
}
@ -147,7 +148,7 @@ void CachedImapJob::execute()
switch( mType ) {
case tGetMessage: slotGetNextMessage(); break;
case tPutMessage: slotPutNextMessage(); break;
case tDeleteMessage: deleteMessages(mString); break;
case tDeleteMessage: slotDeleteNextMessages(); break;
case tExpungeFolder: expungeFolder(); break;
case tAddSubfolders: slotAddNextSubfolder(); break;
case tDeleteFolders: slotDeleteNextFolder(); break;
@ -176,18 +177,41 @@ void CachedImapJob::listMessages()
mFolder, SLOT( slotGetMessagesData( KIO::Job* , const QByteArray& ) ) );
}
void CachedImapJob::deleteMessages( const QString& uids )
void CachedImapJob::slotDeleteNextMessages( KIO::Job* job )
{
if (job) {
KMAcctCachedImap::JobIterator it = mAccount->findJob(job);
if ( it == mAccount->jobsEnd() ) { // Shouldn't happen
delete this;
return;
}
if( job->error() ) {
mAccount->handleJobError( job, i18n( "Error while deleting messages on the server: " ) + '\n' );
delete this;
return;
}
mAccount->removeJob(it);
}
if( mFoldersOrMessages.isEmpty() ) {
// No more messages to delete
delete this;
return;
}
QString uids = mFoldersOrMessages.front(); mFoldersOrMessages.pop_front();
KURL url = mAccount->getUrl();
url.setPath( mFolder->imapPath() +
QString::fromLatin1(";UID=%1").arg(uids) );
KIO::SimpleJob *job = KIO::file_delete( url, false );
KIO::Scheduler::assignJobToSlave( mAccount->slave(), job );
KIO::SimpleJob *simpleJob = KIO::file_delete( url, false );
KIO::Scheduler::assignJobToSlave( mAccount->slave(), simpleJob );
ImapAccountBase::jobData jd( url.url(), mFolder->folder() );
mAccount->insertJob( job, jd );
connect( job, SIGNAL( result(KIO::Job *) ),
this, SLOT( slotDeleteResult(KIO::Job *) ) );
mAccount->insertJob( simpleJob, jd );
connect( simpleJob, SIGNAL( result(KIO::Job *) ),
this, SLOT( slotDeleteNextMessages(KIO::Job *) ) );
}
void CachedImapJob::expungeFolder()
@ -201,10 +225,10 @@ void CachedImapJob::expungeFolder()
ImapAccountBase::jobData jd( url.url(), mFolder->folder() );
mAccount->insertJob( job, jd );
connect( job, SIGNAL( result(KIO::Job *) ),
this, SLOT( slotDeleteResult(KIO::Job *) ) );
this, SLOT( slotExpungeResult(KIO::Job *) ) );
}
void CachedImapJob::slotDeleteResult( KIO::Job * job )
void CachedImapJob::slotExpungeResult( KIO::Job * job )
{
KMAcctCachedImap::JobIterator it = mAccount->findJob(job);
if ( it == mAccount->jobsEnd() ) { // Shouldn't happen
@ -522,13 +546,13 @@ void CachedImapJob::slotDeleteNextFolder( KIO::Job *job )
mAccount->removeJob(it);
}
if( mFolderPathList.isEmpty() ) {
if( mFoldersOrMessages.isEmpty() ) {
// No more folders to delete
delete this;
return;
}
QString folderPath = mFolderPathList.front(); mFolderPathList.pop_front();
QString folderPath = mFoldersOrMessages.front(); mFoldersOrMessages.pop_front();
KURL url = mAccount->getUrl();
url.setPath(folderPath);
ImapAccountBase::jobData jd( url.url(), mFolder->folder() );

@ -83,12 +83,12 @@ public:
CachedImapJob( const QValueList<KMFolderCachedImap*>& folders,
JobType type = tAddSubfolders,
KMFolderCachedImap* folder = 0 );
// Delete message ; Rename folder
// Rename folder
CachedImapJob( const QString& string1, JobType type,
KMFolderCachedImap* folder );
// Delete folders
CachedImapJob( const QStringList& folders, JobType type,
KMFolderCachedImap* folder = 0 );
// Delete folders or messages
CachedImapJob( const QStringList& foldersOrMsgs, JobType type,
KMFolderCachedImap* folder );
// Other jobs (list messages,expunge folder, check uid validity)
CachedImapJob( JobType type, KMFolderCachedImap* folder );
@ -98,7 +98,6 @@ public:
protected:
virtual void execute();
void deleteMessages( const QString& uids );
void expungeFolder();
void checkUidValidity();
void renameFolder( const QString &newName );
@ -111,11 +110,12 @@ protected slots:
virtual void slotPutMessageDataReq( KIO::Job *job, QByteArray &data );
virtual void slotPutMessageResult( KIO::Job *job );
virtual void slotPutMessageInfoData(KIO::Job *, const QString &data);
virtual void slotDeleteResult( KIO::Job *job );
virtual void slotExpungeResult( KIO::Job *job );
virtual void slotDeleteNextFolder( KIO::Job *job = 0 );
virtual void slotCheckUidValidityResult( KIO::Job *job );
virtual void slotRenameFolderResult( KIO::Job *job );
virtual void slotListMessagesResult( KIO::Job * job );
void slotDeleteNextMessages( KIO::Job* job = 0 );
void slotProcessedSize( KIO::Job *, KIO::filesize_t processed );
private:
@ -126,7 +126,7 @@ private:
QValueList<unsigned long> mSerNumMsgList;
ulong mSentBytes; // previous messages
ulong mTotalBytes;
QStringList mFolderPathList; // Used only for folder deletion
QStringList mFoldersOrMessages; // Folder deletion: path list. Message deletion: sets of uids
KMMessage* mMsg;
QString mString; // Used as uids and as rename target
KMFolderCachedImap *mParentFolder;

@ -127,7 +127,7 @@ KMFolderCachedImap::KMFolderCachedImap( KMFolder* folder, const char* aName )
mCheckFlags( true ), mAccount( NULL ), uidMapDirty( true ),
uidWriteTimer( -1 ), mLastUid( 0 ), mTentativeHighestUid( 0 ),
mUserRights( 0 ), mSilentUpload( false ),
mFolderRemoved( false ), mResync( false ),
mFolderRemoved( false ),
/*mHoldSyncs( false ),*/ mRecurse( true ),
mStatusChangedLocally( false ), mAnnotationFolderTypeChanged( false )
{
@ -184,7 +184,7 @@ void KMFolderCachedImap::readConfig()
kmkernel->iCalIface().setStorageFormat( folder(), KMailICalIfaceImpl::StorageXML );
KMFolderMaildir::readConfig();
mStatusChangedLocally =
config->readBoolEntry( "StatusChangedLocally", false );
@ -480,7 +480,6 @@ void KMFolderCachedImap::serverSync( bool recurse )
#endif
mTentativeHighestUid = 0; // reset, last sync could have been canceled
mResync = false;
serverSyncInternal();
}
@ -759,14 +758,7 @@ void KMFolderCachedImap::serverSyncInternal()
// Wrap up the 'download emails' stage. We always end up at 95 here.
mProgress = 95;
if( mResync ) {
// Some conflict have been resolved, so restart the sync
mResync = false;
mSyncState = SYNC_STATE_INITIAL;
serverSyncInternal();
break;
} else
mSyncState = SYNC_STATE_GET_ANNOTATIONS;
mSyncState = SYNC_STATE_GET_ANNOTATIONS;
case SYNC_STATE_GET_ANNOTATIONS:
#define KOLAB_FOLDERTYPE "/vendor/kolab/folder-type"
@ -1118,13 +1110,8 @@ bool KMFolderCachedImap::deleteMessages()
newState( mProgress, i18n("Deleting removed messages from server"));
QStringList sets = KMFolderImap::makeSets( uidsForDeletionOnServer, true );
uidsForDeletionOnServer.clear();
if( sets.count() > 1 ) {
// Rerun the sync until the messages are all deleted
mResync = true;
}
//kdDebug(5006) << "Deleting " << sets.front() << " from server folder " << imapPath() << endl;
CachedImapJob *job = new CachedImapJob( sets.front(), CachedImapJob::tDeleteMessage,
this );
kdDebug(5006) << "Deleting " << sets.count() << " sets of messages from server folder " << imapPath() << endl;
CachedImapJob *job = new CachedImapJob( sets, CachedImapJob::tDeleteMessage, this );
connect( job, SIGNAL( result(KMail::FolderJob *) ),
this, SLOT( slotDeleteMessagesResult(KMail::FolderJob *) ) );
job->start();

@ -184,9 +184,6 @@ public:
virtual int createIndexFromContents()
{ return KMFolderMaildir::createIndexFromContents(); }
// Mark for resync
void resync() { mResync = true; }
//virtual void holdSyncs( bool hold ) { mHoldSyncs = hold; }
/**
@ -394,7 +391,6 @@ private:
bool mSilentUpload;
bool mFolderRemoved;
bool mResync;
//bool mHoldSyncs;
bool mRecurse;
bool mCreateInbox;

Loading…
Cancel
Save