[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim-runtime/KDE/4.12] resources/imap: Don't CLOSE mailbox before moving it to prevent triggering
From: Dan_Vrátil <dvratil () redhat ! com>
Date: 2014-01-14 12:12:26
Message-ID: E1W32r4-0001c2-Gi () scm ! kde ! org
[Download RAW message or body]
Git commit 5b623834d4bd3b9c6d168f065b751dd40e443009 by Dan Vrátil.
Committed on 14/01/2014 at 12:05.
Pushed by dvratil into branch 'KDE/4.12'.
Don't CLOSE mailbox before moving it to prevent triggering EXPUNGE
We don't want to trigger EXPUNGE before moving a mailbox, so instead of
calling CLOSE, we EXAMINE a non-existent folder, which will effectively
close the current mailbox, but will not trigger the EXPUNGE
Reviewed-By: Christian Mollekopf
M +18 -14 resources/imap/movecollectiontask.cpp
M +1 -1 resources/imap/movecollectiontask.h
http://commits.kde.org/kdepim-runtime/5b623834d4bd3b9c6d168f065b751dd40e443009
diff --git a/resources/imap/movecollectiontask.cpp \
b/resources/imap/movecollectiontask.cpp index 68eaf55..b119801 100644
--- a/resources/imap/movecollectiontask.cpp
+++ b/resources/imap/movecollectiontask.cpp
@@ -27,7 +27,9 @@
#include <kimap/renamejob.h>
#include <kimap/session.h>
#include <kimap/subscribejob.h>
-#include <kimap/closejob.h>
+#include <kimap/selectjob.h>
+
+#include <QtCore/QUuid>
MoveCollectionTask::MoveCollectionTask( ResourceStateInterface::Ptr resource, \
QObject *parent ) : ResourceTask( DeferIfNoSession, resource, parent )
@@ -64,27 +66,29 @@ void MoveCollectionTask::doStart( KIMAP::Session *session )
return;
}
- // Some IMAP servers don't allow renaming an opened mailbox, so make sure
- // it's not opened (https://bugs.kde.org/show_bug.cgi?id=324932)
if ( session->selectedMailBox() != mailBoxForCollection( collection() ) ) {
doRename( session );
return;
}
- KIMAP::CloseJob *close = new KIMAP::CloseJob( session );
- connect( close, SIGNAL(result(KJob*)),
- this, SLOT(onCloseDone(KJob*)) );
- close->start();
+ // Some IMAP servers don't allow moving an opened mailbox, so make sure
+ // it's not opened (https://bugs.kde.org/show_bug.cgi?id=324932) by examining
+ // a non-existent mailbox. We don't use CLOSE in order not to trigger EXPUNGE
+ KIMAP::SelectJob *examine = new KIMAP::SelectJob( session );
+ examine->setOpenReadOnly( true ); // use EXAMINE instead of SELECT
+ examine->setMailBox( QString::fromLatin1( "IMAP Resource non existing folder %1" \
).arg( QUuid::createUuid().toString() ) ); + connect( examine, \
SIGNAL(result(KJob*)), + this, SLOT(onExamineDone(KJob*)) );
+ examine->start();
}
-void MoveCollectionTask::onCloseDone(KJob* job)
+void MoveCollectionTask::onExamineDone( KJob* job )
{
- if ( job->error() ) {
- changeProcessed();
- } else {
- KIMAP::CloseJob *close = static_cast<KIMAP::CloseJob*>( job );
- doRename( close->session() );
- }
+ // We deliberately ignore any error here, because the SelectJob will always fail
+ // when examining a non-existent mailbox
+
+ KIMAP::SelectJob *examine = static_cast<KIMAP::SelectJob*>( job );
+ doRename( examine->session() );
}
void MoveCollectionTask::doRename( KIMAP::Session *session )
diff --git a/resources/imap/movecollectiontask.h \
b/resources/imap/movecollectiontask.h index 0237e12..85cc68f 100644
--- a/resources/imap/movecollectiontask.h
+++ b/resources/imap/movecollectiontask.h
@@ -33,7 +33,7 @@ public:
virtual ~MoveCollectionTask();
private slots:
- void onCloseDone( KJob *job );
+ void onExamineDone( KJob *job );
void onRenameDone( KJob *job );
void onSubscribeDone( KJob *job );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic