Debian Codegraph @

storageplugins/hcalendar/CalendarStorage.h

raw
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 <[email protected]>
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
37 enum STORAGE_TYPE {VCALENDAR_FORMAT,ICALENDAR_FORMAT};
38
39 /// \brief StoragePlugin class for harmattan
40 class CalendarStorage : public Buteo::StoragePlugin
41 {
42
43
44 public:
45 /// \brief constructor
46 CalendarStorage(const QString& aPluginName);
47
48 /// \brief destructor
49 ~CalendarStorage();
50
51 /*! \see StoragePlugin::init()
52 *
53 */
54 virtual bool init( const QMap<QString, QString>& aProperties );
55
56 /*! \see StoragePlugin::uninit()
57 *
58 */
59 virtual bool uninit();
60
61 /*! \see StoragePlugin::getAllItems()
62 *
63 */
64 virtual bool getAllItems( QList<Buteo::StorageItem*>& aItems );
65
66 /*! \see StoragePlugin::getAllItemIds()
67 *
68 */
69 virtual bool getAllItemIds( QList<QString>& aItemIds );
70
71 /*! \see StoragePlugin::getNewItems()
72 *
73 */
74 virtual bool getNewItems( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime );
75
76 /*! \see StoragePlugin::getNewItemIds()
77 *
78 */
79 virtual bool getNewItemIds( QList<QString>& aNewItemIds, const QDateTime& aTime );
80
81 /*! \see StoragePlugin::getModifiedItems()
82 *
83 */
84 virtual bool getModifiedItems( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime );
85
86 /*! \see StoragePlugin::getModifiedItemIds()
87 *
88 */
89 virtual bool getModifiedItemIds( QList<QString>& aModifiedItemIds, const QDateTime& aTime );
90
91 /*! \see StoragePlugin::getDeletedItemIds()
92 *
93 */
94 virtual bool getDeletedItemIds( QList<QString>& aDeletedItemIds, const QDateTime& aTime );
95
96 /*! \see StoragePlugin::newItem()
97 *
98 */
99 virtual Buteo::StorageItem* newItem();
100
101 /*! \see StoragePlugin::getItem()
102 *
103 */
104 virtual Buteo::StorageItem* getItem( const QString& aItemId );
105
106 /*! \see StoragePlugin::getItems()
107 *
108 */
109 virtual QList<Buteo::StorageItem*> getItems( const QStringList& aItemIdList );
110
111 /*! \see StoragePlugin::addItem()
112 *
113 */
114 virtual OperationStatus addItem( Buteo::StorageItem& aItem );
115
116 /*! \see StoragePlugin::addItems()
117 *
118 */
119 virtual QList<OperationStatus> addItems( const QList<Buteo::StorageItem*>& aItems );
120
121 /*! \see StoragePlugin::modifyItem()
122 *
123 */
124 virtual OperationStatus modifyItem( Buteo::StorageItem& aItem );
125
126 /*! \see StoragePlugin::modifyItems()
127 *
128 */
129 virtual QList<OperationStatus> modifyItems( const QList<Buteo::StorageItem*>& aItems );
130
131 /*! \see StoragePlugin::deleteItem()
132 *
133 */
134 virtual OperationStatus deleteItem( const QString& aItemId );
135
136 /*! \see StoragePlugin::deleteItems()
137 *
138 */
139 virtual QList<OperationStatus> deleteItems( const QList<QString>& aItemIds );
140
141 private:
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
165 class CalendarStoragePluginLoader : public Buteo::StoragePluginLoader
166 {
167 Q_OBJECT
168 Q_PLUGIN_METADATA(IID "com.buteo.plugins.storage.CalendarStoragePluginLoader")
169 Q_INTERFACES(Buteo::StoragePluginLoader)
170
171 public:
172 /*! \brief Creates calendar storage plugin
173 *
174 * @param aPluginName Human-readable name for plugin
175 * @return Calendar storage plugin instance
176 */
177 Buteo::StoragePlugin* createPlugin(const QString& aPluginName) override;
178 };
179
180 #endif // CALENDARSTORAGE_H
181