2
* This file is part of buteo-syncfw package
4
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
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.
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.
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
24
#ifndef DELETEDITEMSIDSTORAGE_H
25
#define DELETEDITEMSIDSTORAGE_H
27
#include <QSqlDatabase>
33
* \brief Persistent storage for storing deleted item IDs
35
class DeletedItemsIdStorage{
41
DeletedItemsIdStorage();
46
~DeletedItemsIdStorage();
48
/*! \brief Initializes backend
51
* @param aDbFile Path to database to use as persistent storage
52
* @return True on success, otherwise false
54
bool init( const QString& aDbFile );
56
/*! \brief Uninitializes backend
58
* @return True on success, otherwise false
62
/*! \brief Retrieves persistently stored snapshot of item id's
64
* @param aItems Items of the snapshot
65
* @param aCreationTimes Creation times of the items
66
* @return True on success, otherwise false
68
bool getSnapshot( QList<QString>& aItems, QList<QDateTime>& aCreationTimes ) const;
70
/*! \brief Store a snapshot of item id's persistently
72
* @param aItems Item id's to store
73
* @param aCreationTimes Creation times of the items
74
* @param clear clear snapshot table contents before setting a new one of true
75
* @return True on success, otherwise false
77
bool setSnapshot( const QList<QString>& aItems, const QList<QDateTime>& aCreationTimes, bool clear = true );
79
/*! \brief Adds a deleted item to backend
81
* @param aItem Item Id
82
* @param aCreationTime Time when item was initially created
83
* @param aDeleteTime Time of deletion
85
void addDeletedItem( const QString& aItem, const QDateTime& aCreationTime, const QDateTime& aDeleteTime );
87
/*! \brief Returns the deleted items after given time
89
* @param aItems Returned deleted items
90
* @param aTime Items deleted after this time are considered deleted
91
* @return True on success, otherwise false
93
bool getDeletedItems( QList<QString>& aItems, const QDateTime& aTime );
98
* \brief Checks whether snapshot table exists and creates it if needed
99
* @return True on success, otherwise false
101
bool ensureItemSnapshotExists();
104
* \brief Checks whether item id table exists and creates it if needed
105
* @return True on success, otherwise false
107
bool ensureDeletedItemsExists();
111
QSqlDatabase iDb; ///< Database handle
112
QString iConnectionName; ///< Database connection ID string