Commit 3802e8c4 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Show an information dialog to inform the user when

his insert rights have been revoked on the server.

svn path=/trunk/KDE/kdepim/runtime/; revision=1194268
parent a62908f7
......@@ -29,6 +29,7 @@
#include "timestampattribute.h"
#include <akonadi/collectionmodifyjob.h>
#include <kmessagebox.h>
ResourceStateInterface::Ptr ResourceState::createRetrieveItemState( ImapResource *resource,
const Akonadi::Item &item,
......@@ -455,3 +456,8 @@ void ResourceState::scheduleConnectionAttempt()
{
m_resource->scheduleConnectionAttempt();
}
void ResourceState::showInformationDialog( const QString &message, const QString &title )
{
KMessageBox::information( 0, message, title );
}
......@@ -136,6 +136,8 @@ public:
virtual void synchronizeCollectionTree();
virtual void scheduleConnectionAttempt();
virtual void showInformationDialog( const QString &message, const QString &title );
private:
ImapResource *m_resource;
......
......@@ -90,6 +90,8 @@ public:
virtual void synchronizeCollectionTree() = 0;
virtual void scheduleConnectionAttempt() = 0;
virtual void showInformationDialog( const QString &message, const QString &title ) = 0;
};
#endif
......@@ -309,6 +309,11 @@ void ResourceTask::synchronizeCollectionTree()
m_resource->synchronizeCollectionTree();
}
void ResourceTask::showInformationDialog( const QString &message, const QString &title )
{
m_resource->showInformationDialog( message, title );
}
QList<QByteArray> ResourceTask::fromAkonadiFlags( const QList<QByteArray> &flags )
{
QList<QByteArray> newFlags;
......
......@@ -110,6 +110,8 @@ protected:
void synchronizeCollectionTree();
void showInformationDialog( const QString &message, const QString &title );
static QList<QByteArray> toAkonadiFlags( const QList<QByteArray> &flags );
static QList<QByteArray> fromAkonadiFlags( const QList<QByteArray> &flags );
......
......@@ -29,8 +29,10 @@
#include <kimap/myrightsjob.h>
#include <kimap/rfccodecs.h>
#include <kimap/session.h>
#include <klocale.h>
#include <akonadi/collectionquotaattribute.h>
#include <akonadi/entitydisplayattribute.h>
#include "collectionannotationsattribute.h"
#include "imapaclattribute.h"
#include "imapquotaattribute.h"
......@@ -259,6 +261,19 @@ void RetrieveCollectionMetadataTask::onRightsReceived( KJob *job )
// << "newRights:" << newRights
// << "oldRights:" << collection.rights();
if ( (m_collection.rights() & Akonadi::Collection::CanCreateItem) &&
!(newRights & Akonadi::Collection::CanCreateItem) ) {
// write access revoked
const QString collectionName = m_collection.hasAttribute<Akonadi::EntityDisplayAttribute>() ?
m_collection.attribute<Akonadi::EntityDisplayAttribute>()->displayName() :
m_collection.name();
showInformationDialog( i18n( "<p>Your access rights to folder <b>%1</b> have been restricted, "
"it will no longer be possible to add messages to this folder.</p>",
collectionName ),
i18n( "Access rights revoked" ) );
}
if ( newRights != m_collection.rights() ) {
m_collection.setRights( newRights );
m_collectionChanged = true;
......
......@@ -273,6 +273,11 @@ void DummyResourceState::scheduleConnectionAttempt()
recordCall( "scheduleConnectionAttempt" );
}
void DummyResourceState::showInformationDialog( const QString &message, const QString &title )
{
recordCall( "showInformationDialog", QVariant::fromValue( message ) );
}
QList< QPair<QByteArray, QVariant> > DummyResourceState::calls() const
{
return m_calls;
......
......@@ -106,6 +106,8 @@ public:
virtual void synchronizeCollectionTree();
virtual void scheduleConnectionAttempt();
virtual void showInformationDialog( const QString &message, const QString &title );
QList< QPair<QByteArray, QVariant> > calls() const;
private:
......
......@@ -200,6 +200,36 @@ private slots:
QTest::newRow( "recent timestamp, but not spontaneous: harvesting" ) << collection << capabilities << scenario
<< callNames << rights << spontaneous;
//
// Test that a warning is issued if the insert rights of a folder have been revoked on the server.
//
collection.setParentCollection( Akonadi::Collection() );
collection.setRights( collection.rights() | Akonadi::Collection::CanCreateItem );
scenario.clear();
scenario << defaultPoolConnectionScenario()
<< "C: A000003 GETANNOTATION \"INBOX/Foo\" \"*\" \"value.shared\""
<< "S: * ANNOTATION INBOX/Foo /vendor/kolab/folder-test ( value.shared true )"
<< "S: A000003 OK annotations retrieved"
<< "C: A000004 GETACL \"INBOX/Foo\""
<< "S: * ACL INBOX/Foo foo@kde.org wi"
<< "S: A000004 OK acl retrieved"
<< "C: A000005 MYRIGHTS \"INBOX/Foo\""
<< "S: * MYRIGHTS \"INBOX/Foo\" w"
<< "S: A000005 OK rights retrieved"
<< "C: A000006 GETQUOTAROOT \"INBOX/Foo\""
<< "S: * QUOTAROOT INBOX/Foo user/foo"
<< "S: * QUOTA user/foo ( )"
<< "S: A000006 OK quota retrieved";
spontaneous = false;
callNames.clear();
callNames << "showInformationDialog";
callNames << "collectionAttributesRetrieved";
rights = Akonadi::Collection::CanChangeItem | Akonadi::Collection::CanChangeCollection;
QTest::newRow( "revoked rights" ) << collection << capabilities << scenario
<< callNames << rights << spontaneous;
}
void shouldCollectionRetrieveMetadata()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment