Buteo Synchronization Framework: StoragePlugin.h Source File

Buteo Synchronization Framework

StoragePlugin.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23#ifndef STORAGEPLUGIN_H_89943984899843
24#define STORAGEPLUGIN_H_89943984899843
25
26#include <QObject>
27#include <QMap>
28#include <QList>
29#include <QDateTime>
30
31namespace Buteo {
32
33class StorageItem;
34
38 class StoragePlugin : public QObject
39{
40 Q_OBJECT
41
42public:
43
47 enum OperationStatus {
48 STATUS_INVALID_FORMAT = -6,
49 STATUS_STORAGE_FULL = -5,
50 STATUS_OBJECT_TOO_BIG = -4,
51 STATUS_ERROR = -3,
52 STATUS_DUPLICATE = -2,
53 STATUS_NOT_FOUND = -1,
54 STATUS_OK = 0
55 };
56
61 StoragePlugin(const QString &aPluginName);
62
66 virtual ~StoragePlugin();
67
72 const QString &getPluginName() const;
73
79 QString getProperty(const QString &aProperty) const;
80
85 void getProperties(QMap<QString, QString> &aProperties) const;
86
96 virtual bool init(const QMap<QString, QString> &aProperties) = 0;
97
101 virtual bool uninit() = 0;
102
108 virtual bool getAllItems(QList<StorageItem *> &aItems) = 0;
109
115 virtual bool getAllItemIds(QList<QString> &aItems) = 0;
116
123 virtual bool getNewItems(QList<StorageItem *> &aNewItems, const QDateTime &aTime) = 0;
124
131 virtual bool getNewItemIds(QList<QString> &aNewItemIds, const QDateTime &aTime) = 0;
132
140 virtual bool getModifiedItems(QList<StorageItem *> &aModifiedItems, const QDateTime &aTime) = 0;
141
149 virtual bool getModifiedItemIds(QList<QString> &aModifiedItemIds, const QDateTime &aTime) = 0;
150
158 virtual bool getDeletedItemIds(QList<QString> &aDeletedItemIds, const QDateTime &aTime) = 0;
159
168 virtual StorageItem *newItem() = 0;
169
175 virtual StorageItem *getItem(const QString &aItemId) = 0;
176
182 virtual QList<StorageItem *> getItems(const QStringList &aItemIdList) = 0;
183
192 virtual OperationStatus addItem(StorageItem &aItem) = 0;
193
202 virtual QList<OperationStatus> addItems(const QList<StorageItem *> &aItems) = 0;
203
209 virtual OperationStatus modifyItem(StorageItem &aItem) = 0;
210
216 virtual QList<OperationStatus> modifyItems(const QList<StorageItem *> &aItems) = 0;
217
223 virtual OperationStatus deleteItem(const QString &aItemId) = 0;
224
230 virtual QList<OperationStatus> deleteItems(const QList<QString> &aItemIds) = 0;
231
232protected:
233
235 QString iPluginName;
236
238 QMap<QString, QString> iProperties;
239};
240
241}
242
243#endif // STORAGEPLUGIN_H_89943984899843
Buteo::StorageItem
Class to describe a storable item.
Definition: StorageItem.h:37
Buteo::StoragePlugin
Base class for storage plugins.
Definition: StoragePlugin.h:39
Buteo::StoragePlugin::getProperties
void getProperties(QMap< QString, QString > &aProperties) const
Returns the properties set for this plugin.
Definition: StoragePlugin.cpp:51
Buteo::StoragePlugin::deleteItems
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)=0
Deletes an item from the storage.
Buteo::StoragePlugin::deleteItem
virtual OperationStatus deleteItem(const QString &aItemId)=0
Deletes an item from the storage.
Buteo::StoragePlugin::getProperty
QString getProperty(const QString &aProperty) const
Returns the value of the given property.
Definition: StoragePlugin.cpp:41
Buteo::StoragePlugin::getItems
virtual QList< StorageItem * > getItems(const QStringList &aItemIdList)=0
Returns items based on ids.
Buteo::StoragePlugin::getNewItemIds
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)=0
Returns id's of all new items since aTime (creation time > aTime)
Buteo::StoragePlugin::getModifiedItems
virtual bool getModifiedItems(QList< StorageItem * > &aModifiedItems, const QDateTime &aTime)=0
Returns all modified items since aTime.
Buteo::StoragePlugin::uninit
virtual bool uninit()=0
Uninitializes the plugin.
Buteo::StoragePlugin::getItem
virtual StorageItem * getItem(const QString &aItemId)=0
Returns an item based on id.
Buteo::StoragePlugin::iProperties
QMap< QString, QString > iProperties
Properties of the plugin as read from profile xml.
Definition: StoragePlugin.h:238
Buteo::StoragePlugin::StoragePlugin
StoragePlugin(const QString &aPluginName)
Constructor.
Definition: StoragePlugin.cpp:27
Buteo::StoragePlugin::OperationStatus
OperationStatus
Status of operation performed by storage plugin.
Definition: StoragePlugin.h:47
Buteo::StoragePlugin::STATUS_OBJECT_TOO_BIG
@ STATUS_OBJECT_TOO_BIG
Definition: StoragePlugin.h:50
Buteo::StoragePlugin::STATUS_INVALID_FORMAT
@ STATUS_INVALID_FORMAT
Definition: StoragePlugin.h:48
Buteo::StoragePlugin::STATUS_NOT_FOUND
@ STATUS_NOT_FOUND
Definition: StoragePlugin.h:53
Buteo::StoragePlugin::STATUS_ERROR
@ STATUS_ERROR
Definition: StoragePlugin.h:51
Buteo::StoragePlugin::STATUS_STORAGE_FULL
@ STATUS_STORAGE_FULL
Definition: StoragePlugin.h:49
Buteo::StoragePlugin::STATUS_OK
@ STATUS_OK
Definition: StoragePlugin.h:54
Buteo::StoragePlugin::STATUS_DUPLICATE
@ STATUS_DUPLICATE
Definition: StoragePlugin.h:52
Buteo::StoragePlugin::newItem
virtual StorageItem * newItem()=0
Generates a new item.
Buteo::StoragePlugin::getModifiedItemIds
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)=0
Returns id's of all modified items since aTime.
Buteo::StoragePlugin::getPluginName
const QString & getPluginName() const
Returns the name of this plugin.
Definition: StoragePlugin.cpp:36
Buteo::StoragePlugin::iPluginName
QString iPluginName
Name of the plugin.
Definition: StoragePlugin.h:235
Buteo::StoragePlugin::init
virtual bool init(const QMap< QString, QString > &aProperties)=0
Initializes the plugin.
Buteo::StoragePlugin::getAllItems
virtual bool getAllItems(QList< StorageItem * > &aItems)=0
Returns all known items.
Buteo::StoragePlugin::modifyItems
virtual QList< OperationStatus > modifyItems(const QList< StorageItem * > &aItems)=0
Modifies item in the storage.
Buteo::StoragePlugin::getNewItems
virtual bool getNewItems(QList< StorageItem * > &aNewItems, const QDateTime &aTime)=0
Returns all new items since aTime.
Buteo::StoragePlugin::addItem
virtual OperationStatus addItem(StorageItem &aItem)=0
Adds an item to the storage.
Buteo::StoragePlugin::addItems
virtual QList< OperationStatus > addItems(const QList< StorageItem * > &aItems)=0
Adds items to the storage.
Buteo::StoragePlugin::getDeletedItemIds
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)=0
Returns id's of all deleted items since aTime.
Buteo::StoragePlugin::getAllItemIds
virtual bool getAllItemIds(QList< QString > &aItems)=0
Returns id's of all known items.
Buteo::StoragePlugin::~StoragePlugin
virtual ~StoragePlugin()
Destructor.
Definition: StoragePlugin.cpp:32
Buteo::StoragePlugin::modifyItem
virtual OperationStatus modifyItem(StorageItem &aItem)=0
Modifies an item in the storage.
QList
Definition: SyncBackupAdaptor.h:40
QMap< QString, QString >