Commit 84b6d16d authored by Volker Krause's avatar Volker Krause
Browse files

- always enable autosave

- share retrieveCollections()
- report correct collections access rights

svn path=/trunk/KDE/kdepim/akonadi/; revision=868066
parent f0450a72
......@@ -43,6 +43,11 @@ typedef boost::shared_ptr<KCal::Incidence> IncidencePtr;
ICalResource::ICalResource( const QString &id )
: SingleFileResource<Settings>( id ), mCalendar( 0 ), mMimeVisitor( new KCalMimeTypeVisitor() )
{
QStringList mimeTypes;
mimeTypes << QLatin1String( "text/calendar" );
mimeTypes += mMimeVisitor->allMimeTypes();
setSupportedMimetypes( mimeTypes );
new SettingsAdaptor( Settings::self() );
QDBusConnection::sessionBus().registerObject( QLatin1String( "/Settings" ),
Settings::self(), QDBusConnection::ExportAdaptors );
......@@ -132,21 +137,6 @@ void ICalResource::itemRemoved(const Akonadi::Item & item)
changeProcessed();
}
void ICalResource::retrieveCollections()
{
Collection c;
c.setParent( Collection::root() );
c.setRemoteId( Settings::self()->path() );
c.setName( name() );
QStringList mimeTypes;
mimeTypes << QLatin1String( "text/calendar" );
mimeTypes += mMimeVisitor->allMimeTypes();
c.setContentMimeTypes( mimeTypes );
Collection::List list;
list << c;
collectionsRetrieved( list );
}
void ICalResource::retrieveItems( const Akonadi::Collection & col )
{
Q_UNUSED( col );
......
......@@ -44,7 +44,6 @@ class ICalResource : public Akonadi::SingleFileResource<Settings>, public Akonad
virtual void configure( WId windowId );
protected Q_SLOTS:
void retrieveCollections();
void retrieveItems( const Akonadi::Collection &col );
bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts );
......
......@@ -13,10 +13,6 @@
<label>Do not change the actual backend data.</label>
<default>false</default>
</entry>
<entry name="Autosave" type="Bool">
<label>Saves changes at given interval.</label>
<default>true</default>
</entry>
<entry name="AutosaveInterval" type="UInt">
<label>Autosave interval time (in minutes).</label>
<default>5</default>
......
......@@ -44,7 +44,7 @@ class SingleFileResource : public SingleFileResourceBase
*/
void fileDirty()
{
if( Settings::self()->autosave() && !mDirtyTimer.isActive() ) {
if( !mDirtyTimer.isActive() ) {
mDirtyTimer.setInterval( Settings::self()->autosaveInterval() * 60 * 1000 );
mDirtyTimer.start();
}
......@@ -103,6 +103,29 @@ class SingleFileResource : public SingleFileResourceBase
emit status( Idle, i18n( "Data successfully saved to '%1'.", mCurrentUrl.url() ) );
}
protected:
void retrieveCollections()
{
Collection c;
c.setParent( Collection::root() );
c.setRemoteId( Settings::self()->path() );
c.setName( name() );
QStringList mimeTypes;
c.setContentMimeTypes( mSupportedMimetypes );
if ( Settings::self()->readOnly() ) {
c.setRights( Collection::ReadOnly );
} else {
Collection::Rights rights;
rights |= Collection::CanChangeItem;
rights |= Collection::CanCreateItem;
rights |= Collection::CanDeleteItem;
c.setRights( rights );
}
Collection::List list;
list << c;
collectionsRetrieved( list );
}
};
}
......
......@@ -32,4 +32,9 @@ SingleFileResourceBase::SingleFileResourceBase( const QString & id ) :
QTimer::singleShot( 0, this, SLOT(readFile()) );
}
void SingleFileResourceBase::setSupportedMimetypes(const QStringList & mimeTypes)
{
mSupportedMimetypes = mimeTypes;
}
#include "singlefileresourcebase.moc"
......@@ -23,6 +23,7 @@
#include <akonadi/resourcebase.h>
#include <KDE/KUrl>
#include <QtCore/QStringList>
#include <QtCore/QTimer>
namespace Akonadi
......@@ -38,6 +39,11 @@ class SingleFileResourceBase : public ResourceBase
public:
SingleFileResourceBase( const QString &id );
/**
* Set the mimetypes supported by this resource.
*/
void setSupportedMimetypes( const QStringList &mimeTypes );
public Q_SLOTS:
virtual void readFile() = 0;
virtual void writeFile() = 0;
......@@ -60,6 +66,7 @@ class SingleFileResourceBase : public ResourceBase
protected:
QTimer mDirtyTimer;
KUrl mCurrentUrl;
QStringList mSupportedMimetypes;
};
}
......
......@@ -35,6 +35,8 @@ using namespace Akonadi;
VCardResource::VCardResource( const QString &id )
: SingleFileResource<Settings>( id )
{
setSupportedMimetypes( QStringList() << "text/directory" );
new SettingsAdaptor( Settings::self() );
QDBusConnection::sessionBus().registerObject( QLatin1String( "/Settings" ),
Settings::self(), QDBusConnection::ExportAdaptors );
......@@ -126,20 +128,6 @@ void VCardResource::itemRemoved(const Akonadi::Item & item)
changeProcessed();
}
void VCardResource::retrieveCollections()
{
Collection c;
c.setParent( Collection::root() );
c.setRemoteId( Settings::self()->path() );
c.setName( name() );
QStringList mimeTypes;
mimeTypes << "text/directory";
c.setContentMimeTypes( mimeTypes );
Collection::List list;
list << c;
collectionsRetrieved( list );
}
void VCardResource::retrieveItems( const Akonadi::Collection & col )
{
// VCard does not support folders so we can savely ignore the collection
......
......@@ -38,7 +38,6 @@ class VCardResource : public Akonadi::SingleFileResource<Settings>, public Akona
virtual void configure( WId windowId );
protected Q_SLOTS:
void retrieveCollections();
void retrieveItems( const Akonadi::Collection &col );
bool retrieveItem( const Akonadi::Item &item, const QSet<QByteArray> &parts );
......
......@@ -9,10 +9,6 @@
<label>Path to vCard file.</label>
<default></default>
</entry>
<entry name="Autosave" type="Bool">
<label>Saves changes at given interval.</label>
<default>true</default>
</entry>
<entry name="AutosaveInterval" type="UInt">
<label>Autosave interval time (in minutes).</label>
<default>5</default>
......
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