HarmattanSyncApplications
ContactsStorage.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 CONTACT_STORAGE_HEADER_1717
25#define CONTACT_STORAGE_HEADER_1717
26
27#include <QDateTime>
28#include <QMap>
29
30#include "StoragePlugin.h"
31#include "StoragePluginLoader.h"
32#include "ContactsBackend.h"
33#include "buteosyncfw5/DeletedItemsIdStorage.h"
34
35class SimpleItem;
36
38//
39// Interface to Storage Plugin towards Sync FW
40class ContactStorage : public Buteo::StoragePlugin
41{
42
43public:
47 ContactStorage(const QString& aPluginName);
48
52 virtual ~ContactStorage();
53
55 // Functions below are derived from storage plugin ///////////////
57
64 virtual bool init( const QMap<QString, QString>& aProperties );
65
69 virtual bool uninit();
70
76 virtual bool getAllItems(QList<Buteo::StorageItem*> &aItems);
77
78
84 virtual bool getAllItemIds( QList<QString>& aItems );
85
86
93 virtual bool getNewItems( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime );
94
95
102 virtual bool getNewItemIds( QList<QString>& aNewItemIds, const QDateTime& aTime );
103
110 virtual bool getModifiedItems( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime );
111
118 virtual bool getModifiedItemIds( QList<QString>& aModifiedItemIds, const QDateTime& aTime );
119
120
127 virtual bool getDeletedItemIds( QList<QString>& aDeletedItemIds, const QDateTime& aTime );
128
137 virtual Buteo::StorageItem* newItem();
138
139
145 virtual Buteo::StorageItem* getItem( const QString& aItemId );
146
152 virtual QList<Buteo::StorageItem*> getItems( const QStringList& aItemIdList );
153
162 virtual OperationStatus addItem( Buteo::StorageItem& aItem );
163
164
173 virtual QList<OperationStatus> addItems( const QList<Buteo::StorageItem*>& aItems );
174
175
181 virtual OperationStatus modifyItem( Buteo::StorageItem& aItem );
182
188 virtual QList<OperationStatus> modifyItems( const QList<Buteo::StorageItem*>& aItems );
189
195 virtual OperationStatus deleteItem( const QString& aItemId );
196
202 virtual QList<OperationStatus> deleteItems( const QList<QString>& aItemIds );
203
204
205private:
206
207 bool doInitItemAnalysis();
208
209 bool doUninitItemAnalysis();
210
217 QList<Buteo::StorageItem*> getStoreList(QList<QContactLocalId>&aList);
218
219 QByteArray getCtCaps( const QString& aFilename ) const;
220
221 ContactStorage::OperationStatus mapErrorStatus(const QContactManager::Error &aContactError) const;
222
229 SimpleItem* convertVcardToStorageItem(const QContactLocalId aItemKey,
230 const QString& aItemData);
231
232 ContactsBackend* iBackend;
233
234 Buteo::DeletedItemsIdStorage iDeletedItems;
235
236 QMap<QString, QDateTime> iSnapshot;
237 QList<QString> iFreshItems;
238};
239
240class ContactsStoragePluginLoader : public Buteo::StoragePluginLoader
241{
242 Q_OBJECT
243 Q_PLUGIN_METADATA(IID "com.buteo.plugins.storage.ContactsStoragePluginLoader")
244 Q_INTERFACES(Buteo::StoragePluginLoader)
245
246public:
247 Buteo::StoragePlugin* createPlugin(const QString& aPluginName) override;
248};
249
250#endif //CONTACT_STORAGE_HEADER_1717
251
Harmattan Contact storage plugin.
Definition ContactsStorage.h:41
virtual QList< OperationStatus > modifyItems(const QList< Buteo::StorageItem * > &aItems)
Modifies item in the storage.
virtual QList< Buteo::StorageItem * > getItems(const QStringList &aItemIdList)
Returns items based on ids.
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)
Deletes an item from the storage.
ContactStorage(const QString &aPluginName)
Constructor.
virtual QList< OperationStatus > addItems(const QList< Buteo::StorageItem * > &aItems)
Adds items to the storage.
virtual OperationStatus modifyItem(Buteo::StorageItem &aItem)
Modifies an item in the storage.
virtual bool getModifiedItems(QList< Buteo::StorageItem * > &aModifiedItems, const QDateTime &aTime)
Returns all modified items since aTime.
virtual Buteo::StorageItem * newItem()
Generates a new item.
virtual OperationStatus deleteItem(const QString &aItemId)
Deletes an item from the storage.
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)
Returns id's of all modified items since aTime.
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)
Returns id's of all deleted items since aTime.
virtual OperationStatus addItem(Buteo::StorageItem &aItem)
Adds an item to the storage.
virtual bool getAllItemIds(QList< QString > &aItems)
Returns id's of all known items.
virtual bool getNewItems(QList< Buteo::StorageItem * > &aNewItems, const QDateTime &aTime)
Returns all new items since aTime.
virtual bool getAllItems(QList< Buteo::StorageItem * > &aItems)
Returns all known items.
virtual bool init(const QMap< QString, QString > &aProperties)
Initializes the plugin.
virtual ~ContactStorage()
Destructor.
virtual bool uninit()
Uninitializes the plugin.
virtual Buteo::StorageItem * getItem(const QString &aItemId)
Returns an item based on id.
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)
Returns id's of all new items since aTime.
Harmattan Contact storage plugin backend interface class.
Definition ContactsBackend.h:50
Definition ContactsStorage.h:241
Simple implementation for storage item.
Definition debian/tmp/usr/include/syncmlcommon/SimpleItem.h:37