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 
31 namespace Buteo {
32 
33 class StorageItem;
34 
38 class StoragePlugin : public QObject
39 {
40  Q_OBJECT
41 
42 public:
43 
51  STATUS_ERROR = -3,
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 
203 
210 
217 
223  virtual OperationStatus deleteItem(const QString &aItemId) = 0;
224 
230  virtual QList<OperationStatus> deleteItems(const QList<QString> &aItemIds) = 0;
231 
232 protected:
233 
235  QString iPluginName;
236 
239 };
240 
241 }
242 
243 #endif // STORAGEPLUGIN_H_89943984899843
Class to describe a storable item.
Definition: StorageItem.h:37
Base class for storage plugins.
Definition: StoragePlugin.h:39
void getProperties(QMap< QString, QString > &aProperties) const
Returns the properties set for this plugin.
Definition: StoragePlugin.cpp:51
virtual OperationStatus deleteItem(const QString &aItemId)=0
Deletes an item from the storage.
QString getProperty(const QString &aProperty) const
Returns the value of the given property.
Definition: StoragePlugin.cpp:41
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)=0
Returns id's of all new items since aTime (creation time > aTime)
virtual bool getModifiedItems(QList< StorageItem * > &aModifiedItems, const QDateTime &aTime)=0
Returns all modified items since aTime.
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)=0
Deletes an item from the storage.
virtual bool uninit()=0
Uninitializes the plugin.
virtual QList< OperationStatus > modifyItems(const QList< StorageItem * > &aItems)=0
Modifies item in the storage.
virtual QList< StorageItem * > getItems(const QStringList &aItemIdList)=0
Returns items based on ids.
virtual StorageItem * getItem(const QString &aItemId)=0
Returns an item based on id.
QMap< QString, QString > iProperties
Properties of the plugin as read from profile xml.
Definition: StoragePlugin.h:238
StoragePlugin(const QString &aPluginName)
Constructor.
Definition: StoragePlugin.cpp:27
OperationStatus
Status of operation performed by storage plugin.
Definition: StoragePlugin.h:47
@ STATUS_OBJECT_TOO_BIG
Definition: StoragePlugin.h:50
@ STATUS_INVALID_FORMAT
Definition: StoragePlugin.h:48
@ STATUS_NOT_FOUND
Definition: StoragePlugin.h:53
@ STATUS_ERROR
Definition: StoragePlugin.h:51
@ STATUS_STORAGE_FULL
Definition: StoragePlugin.h:49
@ STATUS_OK
Definition: StoragePlugin.h:54
@ STATUS_DUPLICATE
Definition: StoragePlugin.h:52
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)=0
Returns id's of all modified items since aTime.
const QString & getPluginName() const
Returns the name of this plugin.
Definition: StoragePlugin.cpp:36
virtual StorageItem * newItem()=0
Generates a new item.
QString iPluginName
Name of the plugin.
Definition: StoragePlugin.h:235
virtual bool init(const QMap< QString, QString > &aProperties)=0
Initializes the plugin.
virtual QList< OperationStatus > addItems(const QList< StorageItem * > &aItems)=0
Adds items to the storage.
virtual bool getAllItems(QList< StorageItem * > &aItems)=0
Returns all known items.
virtual bool getNewItems(QList< StorageItem * > &aNewItems, const QDateTime &aTime)=0
Returns all new items since aTime.
virtual OperationStatus addItem(StorageItem &aItem)=0
Adds an item to the storage.
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)=0
Returns id's of all deleted items since aTime.
virtual bool getAllItemIds(QList< QString > &aItems)=0
Returns id's of all known items.
virtual ~StoragePlugin()
Destructor.
Definition: StoragePlugin.cpp:32
virtual OperationStatus modifyItem(StorageItem &aItem)=0
Modifies an item in the storage.
Definition: SyncBackupAdaptor.h:40