ContactsStorage.h
/*
* This file is part of buteo-sync-plugins package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2013 - 2021 Jolla Ltd.
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef CONTACT_STORAGE_HEADER_1717
#define CONTACT_STORAGE_HEADER_1717
#include <QDateTime>
#include <QMap>
#include "StoragePlugin.h"
#include "StoragePluginLoader.h"
#include "ContactsBackend.h"
#include "buteosyncfw5/DeletedItemsIdStorage.h"
class SimpleItem;
//
// Interface to Storage Plugin towards Sync FW
class ContactStorage : public Buteo::StoragePlugin
{
public:
ContactStorage(const QString& aPluginName);
virtual ~ContactStorage();
// Functions below are derived from storage plugin ///////////////
virtual bool init( const QMap<QString, QString>& aProperties );
virtual bool uninit();
virtual bool getAllItems(QList<Buteo::StorageItem*> &aItems);
virtual bool getAllItemIds( QList<QString>& aItems );
virtual bool getNewItems( QList<Buteo::StorageItem*>& aNewItems, const QDateTime& aTime );
virtual bool getNewItemIds( QList<QString>& aNewItemIds, const QDateTime& aTime );
virtual bool getModifiedItems( QList<Buteo::StorageItem*>& aModifiedItems, const QDateTime& aTime );
virtual bool getModifiedItemIds( QList<QString>& aModifiedItemIds, const QDateTime& aTime );
virtual bool getDeletedItemIds( QList<QString>& aDeletedItemIds, const QDateTime& aTime );
virtual Buteo::StorageItem* newItem();
virtual Buteo::StorageItem* getItem( const QString& aItemId );
virtual QList<Buteo::StorageItem*> getItems( const QStringList& aItemIdList );
virtual OperationStatus addItem( Buteo::StorageItem& aItem );
virtual QList<OperationStatus> addItems( const QList<Buteo::StorageItem*>& aItems );
virtual OperationStatus modifyItem( Buteo::StorageItem& aItem );
virtual QList<OperationStatus> modifyItems( const QList<Buteo::StorageItem*>& aItems );
virtual OperationStatus deleteItem( const QString& aItemId );
virtual QList<OperationStatus> deleteItems( const QList<QString>& aItemIds );
private:
bool doInitItemAnalysis();
bool doUninitItemAnalysis();
QList<Buteo::StorageItem*> getStoreList(QList<QContactLocalId>&aList);
QByteArray getCtCaps( const QString& aFilename ) const;
ContactStorage::OperationStatus mapErrorStatus(const QContactManager::Error &aContactError) const;
SimpleItem* convertVcardToStorageItem(const QContactLocalId aItemKey,
const QString& aItemData);
ContactsBackend* iBackend;
Buteo::DeletedItemsIdStorage iDeletedItems;
QMap<QString, QDateTime> iSnapshot;
QList<QString> iFreshItems;
};
class ContactsStoragePluginLoader : public Buteo::StoragePluginLoader
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.buteo.plugins.storage.ContactsStoragePluginLoader")
Q_INTERFACES(Buteo::StoragePluginLoader)
public:
Buteo::StoragePlugin* createPlugin(const QString& aPluginName) override;
};
#endif //CONTACT_STORAGE_HEADER_1717
ContactStorage::modifyItems
virtual QList< OperationStatus > modifyItems(const QList< Buteo::StorageItem * > &aItems)
Modifies item in the storage.
ContactStorage::getItems
virtual QList< Buteo::StorageItem * > getItems(const QStringList &aItemIdList)
Returns items based on ids.
ContactStorage::deleteItems
virtual QList< OperationStatus > deleteItems(const QList< QString > &aItemIds)
Deletes an item from the storage.
ContactStorage::ContactStorage
ContactStorage(const QString &aPluginName)
Constructor.
ContactStorage::addItems
virtual QList< OperationStatus > addItems(const QList< Buteo::StorageItem * > &aItems)
Adds items to the storage.
ContactStorage::modifyItem
virtual OperationStatus modifyItem(Buteo::StorageItem &aItem)
Modifies an item in the storage.
ContactStorage::getModifiedItems
virtual bool getModifiedItems(QList< Buteo::StorageItem * > &aModifiedItems, const QDateTime &aTime)
Returns all modified items since aTime.
ContactStorage::newItem
virtual Buteo::StorageItem * newItem()
Generates a new item.
ContactStorage::deleteItem
virtual OperationStatus deleteItem(const QString &aItemId)
Deletes an item from the storage.
ContactStorage::getModifiedItemIds
virtual bool getModifiedItemIds(QList< QString > &aModifiedItemIds, const QDateTime &aTime)
Returns id's of all modified items since aTime.
ContactStorage::getDeletedItemIds
virtual bool getDeletedItemIds(QList< QString > &aDeletedItemIds, const QDateTime &aTime)
Returns id's of all deleted items since aTime.
ContactStorage::addItem
virtual OperationStatus addItem(Buteo::StorageItem &aItem)
Adds an item to the storage.
ContactStorage::getAllItemIds
virtual bool getAllItemIds(QList< QString > &aItems)
Returns id's of all known items.
ContactStorage::getNewItems
virtual bool getNewItems(QList< Buteo::StorageItem * > &aNewItems, const QDateTime &aTime)
Returns all new items since aTime.
ContactStorage::getAllItems
virtual bool getAllItems(QList< Buteo::StorageItem * > &aItems)
Returns all known items.
ContactStorage::init
virtual bool init(const QMap< QString, QString > &aProperties)
Initializes the plugin.
ContactStorage::~ContactStorage
virtual ~ContactStorage()
Destructor.
ContactStorage::uninit
virtual bool uninit()
Uninitializes the plugin.
ContactStorage::getItem
virtual Buteo::StorageItem * getItem(const QString &aItemId)
Returns an item based on id.
ContactStorage::getNewItemIds
virtual bool getNewItemIds(QList< QString > &aNewItemIds, const QDateTime &aTime)
Returns id's of all new items since aTime.
ContactsBackend
Harmattan Contact storage plugin backend interface class.
Definition ContactsBackend.h:50
ContactsStoragePluginLoader
Definition ContactsStorage.h:241
SimpleItem
Simple implementation for storage item.
Definition debian/tmp/usr/include/syncmlcommon/SimpleItem.h:37