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