HarmattanSyncApplications
CalendarStorage.h
1/*
2 * This file is part of buteo-sync-plugins package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2013 - 2021 Jolla Ltd.
6 *
7 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24#ifndef CALENDARSTORAGE_H
25#define CALENDARSTORAGE_H
26
27//sync backend related includes
28#include "definitions.h"
29#include "StoragePlugin.h"
30#include "StorageItem.h"
31#include "CalendarBackend.h"
32
33#include <buteosyncfw5/StoragePlugin.h>
34#include <buteosyncfw5/StoragePluginLoader.h>
35#include <buteosyncfw5/ProfileEngineDefs.h>
36
37enum STORAGE_TYPE {VCALENDAR_FORMAT,ICALENDAR_FORMAT};
38
40class CalendarStorage : public Buteo::StoragePlugin
41{
42
43
44public:
46 CalendarStorage(const QString& aPluginName);
47
50
54 virtual bool init( const QMap<QString, QString>& aProperties );
55
59 virtual bool uninit();
60
64 virtual bool getAllItems( QList<Buteo::StorageItem*>& aItems );
65
69 virtual bool getAllItemIds( QList<QString>& aItemIds );
70
74 virtual bool getNewItems( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime );
75
79 virtual bool getNewItemIds( QList<QString>& aNewItemIds, const QDateTime& aTime );
80
84 virtual bool getModifiedItems( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime );
85
89 virtual bool getModifiedItemIds( QList<QString>& aModifiedItemIds, const QDateTime& aTime );
90
94 virtual bool getDeletedItemIds( QList<QString>& aDeletedItemIds, const QDateTime& aTime );
95
99 virtual Buteo::StorageItem* newItem();
100
104 virtual Buteo::StorageItem* getItem( const QString& aItemId );
105
109 virtual QList<Buteo::StorageItem*> getItems( const QStringList& aItemIdList );
110
114 virtual OperationStatus addItem( Buteo::StorageItem& aItem );
115
119 virtual QList<OperationStatus> addItems( const QList<Buteo::StorageItem*>& aItems );
120
124 virtual OperationStatus modifyItem( Buteo::StorageItem& aItem );
125
129 virtual QList<OperationStatus> modifyItems( const QList<Buteo::StorageItem*>& aItems );
130
134 virtual OperationStatus deleteItem( const QString& aItemId );
135
139 virtual QList<OperationStatus> deleteItems( const QList<QString>& aItemIds );
140
141private:
142
143 KCalendarCore::Incidence::Ptr generateIncidence( Buteo::StorageItem& aItem );
144
145 void retrieveItems( KCalendarCore::Incidence::List& aIncidences, QList<Buteo::StorageItem*>& aItems );
146
147 Buteo::StorageItem* retrieveItem( KCalendarCore::Incidence::Ptr& aIncidence );
148
149 void retrieveIds( KCalendarCore::Incidence::List& aIncidences, QList<QString>& aIds );
150
151 QDateTime normalizeTime( const QDateTime& aTime ) const;
152
153 QByteArray getCtCaps( const QString& aFilename ) const;
154
155 CalendarStorage::OperationStatus mapErrorStatus(const CalendarBackend::ErrorStatus &aCalenderError) const;
156
157 CalendarBackend iCalendar;
158 STORAGE_TYPE iStorageType;
159
160 bool iCommitNow;
161
162};
163
164
165class CalendarStoragePluginLoader : public Buteo::StoragePluginLoader
166{
167 Q_OBJECT
168 Q_PLUGIN_METADATA(IID "com.buteo.plugins.storage.CalendarStoragePluginLoader")
169 Q_INTERFACES(Buteo::StoragePluginLoader)
170
171public:
177 Buteo::StoragePlugin* createPlugin(const QString& aPluginName) override;
178};
179
180#endif // CALENDARSTORAGE_H
181
Calendar implementation for synchronization.
Definition CalendarBackend.h:42
ErrorStatus
Definition CalendarBackend.h:47
Definition CalendarStorage.h:166
Buteo::StoragePlugin * createPlugin(const QString &aPluginName) override
Creates calendar storage plugin.
StoragePlugin class for harmattan.
Definition CalendarStorage.h:41
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)
virtual bool uninit()
virtual bool getAllItemIds(QList< QString > &aItemIds)
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)
virtual bool getAllItems(QList< Buteo::StorageItem * > &aItems)
virtual Buteo::StorageItem * newItem()
virtual bool getNewItems(QList< Buteo::StorageItem * > &aNewItems, const QDateTime &aTime)
virtual QList< OperationStatus > modifyItems(const QList< Buteo::StorageItem * > &aItems)
virtual QList< Buteo::StorageItem * > getItems(const QStringList &aItemIdList)
CalendarStorage(const QString &aPluginName)
constructor
~CalendarStorage()
destructor
virtual bool getModifiedItems(QList< Buteo::StorageItem * > &aModifiedItems, const QDateTime &aTime)
virtual OperationStatus addItem(Buteo::StorageItem &aItem)
virtual QList< OperationStatus > addItems(const QList< Buteo::StorageItem * > &aItems)
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)
virtual bool init(const QMap< QString, QString > &aProperties)
virtual OperationStatus modifyItem(Buteo::StorageItem &aItem)
virtual OperationStatus deleteItem(const QString &aItemId)
virtual Buteo::StorageItem * getItem(const QString &aItemId)