CalendarStorage.h
/*
* This file is part of buteo-sync-plugins package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2013 - 2021 Jolla Ltd.
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef CALENDARSTORAGE_H
#define CALENDARSTORAGE_H
//sync backend related includes
#include "definitions.h"
#include "StoragePlugin.h"
#include "StorageItem.h"
#include "CalendarBackend.h"
#include <buteosyncfw5/StoragePlugin.h>
#include <buteosyncfw5/StoragePluginLoader.h>
#include <buteosyncfw5/ProfileEngineDefs.h>
enum STORAGE_TYPE {VCALENDAR_FORMAT,ICALENDAR_FORMAT};
class CalendarStorage : public Buteo::StoragePlugin
{
public:
CalendarStorage(const QString& aPluginName);
~CalendarStorage();
virtual bool init( const QMap<QString, QString>& aProperties );
virtual bool uninit();
virtual bool getAllItems( QList<Buteo::StorageItem*>& aItems );
virtual bool getAllItemIds( QList<QString>& aItemIds );
virtual bool getNewItems( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime );
virtual bool getNewItemIds( QList<QString>& aNewItemIds, const QDateTime& aTime );
virtual bool getModifiedItems( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime );
virtual bool getModifiedItemIds( QList<QString>& aModifiedItemIds, const QDateTime& aTime );
virtual bool getDeletedItemIds( QList<QString>& aDeletedItemIds, const QDateTime& aTime );
virtual Buteo::StorageItem* newItem();
virtual Buteo::StorageItem* getItem( const QString& aItemId );
virtual QList<Buteo::StorageItem*> getItems( const QStringList& aItemIdList );
virtual OperationStatus addItem( Buteo::StorageItem& aItem );
virtual QList<OperationStatus> addItems( const QList<Buteo::StorageItem*>& aItems );
virtual OperationStatus modifyItem( Buteo::StorageItem& aItem );
virtual QList<OperationStatus> modifyItems( const QList<Buteo::StorageItem*>& aItems );
virtual OperationStatus deleteItem( const QString& aItemId );
virtual QList<OperationStatus> deleteItems( const QList<QString>& aItemIds );
private:
KCalendarCore::Incidence::Ptr generateIncidence( Buteo::StorageItem& aItem );
void retrieveItems( KCalendarCore::Incidence::List& aIncidences, QList<Buteo::StorageItem*>& aItems );
Buteo::StorageItem* retrieveItem( KCalendarCore::Incidence::Ptr& aIncidence );
void retrieveIds( KCalendarCore::Incidence::List& aIncidences, QList<QString>& aIds );
QDateTime normalizeTime( const QDateTime& aTime ) const;
QByteArray getCtCaps( const QString& aFilename ) const;
CalendarStorage::OperationStatus mapErrorStatus(const CalendarBackend::ErrorStatus &aCalenderError) const;
CalendarBackend iCalendar;
STORAGE_TYPE iStorageType;
bool iCommitNow;
};
class CalendarStoragePluginLoader : public Buteo::StoragePluginLoader
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.buteo.plugins.storage.CalendarStoragePluginLoader")
Q_INTERFACES(Buteo::StoragePluginLoader)
public:
Buteo::StoragePlugin* createPlugin(const QString& aPluginName) override;
};
#endif // CALENDARSTORAGE_H
CalendarBackend
Calendar implementation for synchronization.
Definition CalendarBackend.h:42
CalendarBackend::ErrorStatus
ErrorStatus
Definition CalendarBackend.h:47
CalendarStoragePluginLoader
Definition CalendarStorage.h:166
CalendarStoragePluginLoader::createPlugin
Buteo::StoragePlugin * createPlugin(const QString &aPluginName) override
Creates calendar storage plugin.
CalendarStorage::getDeletedItemIds
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)
CalendarStorage::uninit
virtual bool uninit()
CalendarStorage::getAllItemIds
virtual bool getAllItemIds(QList< QString > &aItemIds)
CalendarStorage::getModifiedItemIds
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)
CalendarStorage::getNewItemIds
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)
CalendarStorage::getAllItems
virtual bool getAllItems(QList< Buteo::StorageItem * > &aItems)
CalendarStorage::newItem
virtual Buteo::StorageItem * newItem()
CalendarStorage::getNewItems
virtual bool getNewItems(QList< Buteo::StorageItem * > &aNewItems, const QDateTime &aTime)
CalendarStorage::modifyItems
virtual QList< OperationStatus > modifyItems(const QList< Buteo::StorageItem * > &aItems)
CalendarStorage::getItems
virtual QList< Buteo::StorageItem * > getItems(const QStringList &aItemIdList)
CalendarStorage::CalendarStorage
CalendarStorage(const QString &aPluginName)
constructor
CalendarStorage::~CalendarStorage
~CalendarStorage()
destructor
CalendarStorage::getModifiedItems
virtual bool getModifiedItems(QList< Buteo::StorageItem * > &aModifiedItems, const QDateTime &aTime)
CalendarStorage::addItem
virtual OperationStatus addItem(Buteo::StorageItem &aItem)
CalendarStorage::addItems
virtual QList< OperationStatus > addItems(const QList< Buteo::StorageItem * > &aItems)
CalendarStorage::deleteItems
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)
CalendarStorage::init
virtual bool init(const QMap< QString, QString > &aProperties)
CalendarStorage::modifyItem
virtual OperationStatus modifyItem(Buteo::StorageItem &aItem)
CalendarStorage::deleteItem
virtual OperationStatus deleteItem(const QString &aItemId)
CalendarStorage::getItem
virtual Buteo::StorageItem * getItem(const QString &aItemId)