From 68a85ec67b4f9967ca9f2788411529c7d4c97421 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Sun, 31 Aug 2008 10:19:30 +0000 Subject: [PATCH] Merged revisions 854399 via svnmerge from svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise4/kdepim ................ r854399 | vkrause | 2008-08-29 15:04:19 +0200 (Fri, 29 Aug 2008) | 13 lines Merged revisions 850513 via svnmerge from https://vkrause@svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim ........ r850513 | vkrause | 2008-08-21 19:11:57 +0200 (Thu, 21 Aug 2008) | 6 lines Allow deletion of message only if the IMAP ACLs allow it. The current code assumed that deletion was not possible iff a folder is read-only, which is too simple for IMAP. Kolab issue 2954 ........ ................ svn path=/trunk/KDE/kdepim/; revision=855221 --- folderstorage.cpp | 5 +++++ folderstorage.h | 3 +++ kmfolder.cpp | 5 +++++ kmfolder.h | 3 +++ kmfoldercachedimap.cpp | 9 +++++++++ kmfoldercachedimap.h | 1 + kmfolderimap.cpp | 10 ++++++++++ kmfolderimap.h | 1 + kmmainwidget.cpp | 6 +++--- 9 files changed, 40 insertions(+), 3 deletions(-) diff --git a/folderstorage.cpp b/folderstorage.cpp index cd23289bf..364d90ccb 100644 --- a/folderstorage.cpp +++ b/folderstorage.cpp @@ -1247,4 +1247,9 @@ QString FolderStorage::sortedLocation() const return location( "sorted" ); } +bool FolderStorage::canDeleteMessages() const +{ + return !isReadOnly(); +} + #include "folderstorage.moc" diff --git a/folderstorage.h b/folderstorage.h index 809a751dc..6eff1188f 100644 --- a/folderstorage.h +++ b/folderstorage.h @@ -355,6 +355,9 @@ public: /** Is the folder read-only? */ virtual bool isReadOnly() const = 0; + /** Can messages in this folder be deleted? */ + virtual bool canDeleteMessages() const; + /** Returns the label of the folder for visualization. */ QString label() const; diff --git a/kmfolder.cpp b/kmfolder.cpp index 9966d660a..09186414f 100644 --- a/kmfolder.cpp +++ b/kmfolder.cpp @@ -585,6 +585,11 @@ bool KMFolder::isReadOnly() const return mStorage->isReadOnly(); } +bool KMFolder::canDeleteMessages() const +{ + return mStorage->canDeleteMessages(); +} + QString KMFolder::label() const { if ( !mSystemLabel.isEmpty() ) diff --git a/kmfolder.h b/kmfolder.h index c32595dfb..8ac6fb445 100644 --- a/kmfolder.h +++ b/kmfolder.h @@ -365,6 +365,9 @@ public: /** Is the folder read-only? */ bool isReadOnly() const; + /** Can messages in this folder be deleted? */ + bool canDeleteMessages() const; + /** Returns true if the folder is a kmail system folder. These are the folders 'inbox', 'outbox', 'sent', 'trash', 'drafts', 'templates'. The name of these folders is nationalized in the folder display and diff --git a/kmfoldercachedimap.cpp b/kmfoldercachedimap.cpp index 4838c29b3..4ba3e81d9 100644 --- a/kmfoldercachedimap.cpp +++ b/kmfoldercachedimap.cpp @@ -3194,4 +3194,13 @@ void KMFolderCachedImap::slotRescueDone(KMCommand * command) serverSyncInternal(); } +bool KMFolderCachedImap::canDeleteMessages() const +{ + if ( isReadOnly() ) + return false; + if ( userRights() > 0 && !(userRights() & ACLJobs::Delete) ) + return false; + return true; +} + #include "kmfoldercachedimap.moc" diff --git a/kmfoldercachedimap.h b/kmfoldercachedimap.h index 32fda6007..61fe67633 100644 --- a/kmfoldercachedimap.h +++ b/kmfoldercachedimap.h @@ -227,6 +227,7 @@ class KMFolderCachedImap : public KMFolderMaildir /** Reimplemented from KMFolderMaildir */ virtual KMMessage *take( int idx ); + bool canDeleteMessages() const; /** Reimplemented from KMFolderMaildir */ virtual int addMsg( KMMessage *msg, int *index_return = 0 ); diff --git a/kmfolderimap.cpp b/kmfolderimap.cpp index 115a70481..b6c4bf565 100644 --- a/kmfolderimap.cpp +++ b/kmfolderimap.cpp @@ -45,6 +45,7 @@ using KMail::ListJob; using KMail::SearchJob; #include "renamejob.h" using KMail::RenameJob; +#include "acljobs.h" #include #include @@ -2464,4 +2465,13 @@ void KMFolderImap::finishMailCheck( const char *dbg, imapState state ) close( dbg ); } +bool KMFolderImap::canDeleteMessages() const +{ + if ( isReadOnly() ) + return false; + if ( mUserRights > 0 && !(mUserRights & KMail::ACLJobs::Delete) ) + return false; + return true; +} + #include "kmfolderimap.moc" diff --git a/kmfolderimap.h b/kmfolderimap.h index 2c35d7c7d..1ee9d6402 100644 --- a/kmfolderimap.h +++ b/kmfolderimap.h @@ -296,6 +296,7 @@ bool isReadOnly() const { return KMFolderMbox::isReadOnly() || mReadOnly; } * @return 0 when not known yet */ unsigned int userRights() const { return mUserRights; } +bool canDeleteMessages() const; /** Set the user's rights on this folder - called by getUserRights */ void setUserRights( unsigned int userRights ); diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 9c8913cf8..d2c49cd0b 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -3451,7 +3451,7 @@ void KMMainWidget::updateMessageActions() mMarkThreadAsUnreadAction->setEnabled( thread_actions ); mToggleThreadToActAction->setEnabled( thread_actions && flags_available ); mToggleThreadImportantAction->setEnabled( thread_actions && flags_available ); - mTrashThreadAction->setEnabled( thread_actions && !mFolder->isReadOnly() ); + mTrashThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() ); mDeleteThreadAction->setEnabled( thread_actions && !mFolder->isReadOnly() ); if (mFolder && mHeaders && mHeaders->currentMsg()) { @@ -3467,8 +3467,8 @@ void KMMainWidget::updateMessageActions() mMoveActionMenu->setEnabled( mass_actions && !mFolder->isReadOnly() ); mCopyActionMenu->setEnabled( mass_actions ); - mTrashAction->setEnabled( mass_actions && !mFolder->isReadOnly() ); - mDeleteAction->setEnabled( mass_actions && !mFolder->isReadOnly() ); + mTrashAction->setEnabled( mass_actions && mFolder->canDeleteMessages() ); + mDeleteAction->setEnabled( mass_actions && mFolder->canDeleteMessages() ); mFindInMessageAction->setEnabled( mass_actions ); mForwardAction->setEnabled( mass_actions ); mForwardAttachedAction->setEnabled( mass_actions );