~ken-vandine/buteo-syncfw/0.8.5

« back to all changes in this revision

Viewing changes to libsyncpluginmgr/DeletedItemsIdStorage.h

  • Committer: Sergey Gerasimenko
  • Date: 2010-06-29 12:51:21 UTC
  • Revision ID: git-v1:cd8dab07b102ac96752ece4f3cde5fc62697d717
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
24
#ifndef DELETEDITEMSIDSTORAGE_H
 
25
#define DELETEDITEMSIDSTORAGE_H
 
26
 
 
27
#include <QSqlDatabase>
 
28
#include <QDateTime>
 
29
 
 
30
namespace Buteo {
 
31
    
 
32
/*!
 
33
 * \brief Persistent storage for storing deleted item IDs
 
34
 */
 
35
class DeletedItemsIdStorage{
 
36
public:
 
37
    
 
38
    /**
 
39
     * \brief Contructor
 
40
     */
 
41
    DeletedItemsIdStorage();
 
42
 
 
43
    /**
 
44
     * \brief Destructor
 
45
     */
 
46
    ~DeletedItemsIdStorage();
 
47
 
 
48
    /*! \brief Initializes backend
 
49
     *
 
50
     *
 
51
     * @param aDbFile Path to database to use as persistent storage
 
52
     * @return True on success, otherwise false
 
53
     */
 
54
    bool init( const QString& aDbFile );
 
55
 
 
56
    /*! \brief Uninitializes backend
 
57
     *
 
58
     * @return True on success, otherwise false
 
59
     */
 
60
    bool uninit();
 
61
 
 
62
    /*! \brief Retrieves persistently stored snapshot of item id's
 
63
     *
 
64
     * @param aItems Items of the snapshot
 
65
     * @param aCreationTimes Creation times of the items
 
66
     * @return True on success, otherwise false
 
67
     */
 
68
    bool getSnapshot( QList<QString>& aItems, QList<QDateTime>& aCreationTimes ) const;
 
69
 
 
70
    /*! \brief Store a snapshot of item id's persistently
 
71
     *
 
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
 
76
     */
 
77
    bool setSnapshot( const QList<QString>& aItems, const QList<QDateTime>& aCreationTimes, bool clear = true );
 
78
 
 
79
    /*! \brief Adds a deleted item to backend
 
80
     *
 
81
     * @param aItem Item Id
 
82
     * @param aCreationTime Time when item was initially created
 
83
     * @param aDeleteTime Time of deletion
 
84
     */
 
85
    void addDeletedItem( const QString& aItem, const QDateTime& aCreationTime, const QDateTime& aDeleteTime );
 
86
 
 
87
    /*! \brief Returns the deleted items after given time
 
88
     *
 
89
     * @param aItems Returned deleted items
 
90
     * @param aTime Items deleted after this time are considered deleted
 
91
     * @return True on success, otherwise false
 
92
     */
 
93
    bool getDeletedItems( QList<QString>& aItems, const QDateTime& aTime );
 
94
 
 
95
protected:
 
96
 
 
97
    /**
 
98
     * \brief Checks whether snapshot table exists and creates it if needed
 
99
     * @return True on success, otherwise false
 
100
     */
 
101
    bool ensureItemSnapshotExists();
 
102
 
 
103
    /**
 
104
     * \brief Checks whether item id table exists and creates it if needed
 
105
     * @return True on success, otherwise false
 
106
     */
 
107
    bool ensureDeletedItemsExists();
 
108
 
 
109
private:
 
110
 
 
111
    QSqlDatabase    iDb;                ///< Database handle
 
112
    QString         iConnectionName;    ///< Database connection ID string
 
113
 
 
114
};
 
115
 
 
116
}
 
117
 
 
118
#endif