1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifndef HSACTIVITYSTORAGEPRIVATE_H |
|
18 #define HSACTIVITYSTORAGEPRIVATE_H |
|
19 #include "hsactivitydbclientinterface.h" |
|
20 #include <QSqlDatabase> |
|
21 |
|
22 /** |
|
23 * Class implements HsActivityDbClientInterface and storage functionality using |
|
24 * database subsystem |
|
25 */ |
|
26 class HsActivityStoragePrivate: public HsActivityDbClientInterface |
|
27 { |
|
28 public: |
|
29 /** |
|
30 * Constructor |
|
31 */ |
|
32 HsActivityStoragePrivate(); |
|
33 |
|
34 /** |
|
35 * Destructor |
|
36 */ |
|
37 ~HsActivityStoragePrivate(); |
|
38 |
|
39 /** |
|
40 * Interface implementation. |
|
41 * @see int HsActivityDbClientInterface::addActivity(const QVariantHash&) |
|
42 */ |
|
43 int addActivity(const QVariantHash &); |
|
44 |
|
45 /** |
|
46 * Interface implementation. |
|
47 * @see int HsActivityDbClientInterface::updateActivity(const QVariantHash&) |
|
48 */ |
|
49 int updateActivity(const QVariantHash &); |
|
50 |
|
51 /** |
|
52 * Interface implementation. |
|
53 * @see int HsActivityDbClientInterface::removeActivity(const QVariantHash &) |
|
54 */ |
|
55 int removeActivity(const QVariantHash &activity); |
|
56 |
|
57 /** |
|
58 * Interface implementation. |
|
59 * @see int HsActivityDbClientInterface::removeApplicationActivities(const QVariantHash &) |
|
60 */ |
|
61 int removeApplicationActivities(const QVariantHash &activity); |
|
62 |
|
63 /** |
|
64 * Interface implementation. |
|
65 * @see int HsActivityDbClientInterface::requestedActivityName( QString &, const QVariantHash &) |
|
66 */ |
|
67 int requestedActivityName(QString &result, |
|
68 const QVariantHash &activity); |
|
69 |
|
70 /** |
|
71 * Interface implementation. |
|
72 * @see int HsActivityDbClientInterface::activities(QList<QVariantHash> &) |
|
73 */ |
|
74 int activities(QList<QVariantHash> &); |
|
75 |
|
76 /** |
|
77 * Interface implementation. |
|
78 * @see int HsActivityDbClientInterface::applicationActivities(QList<QVariantHash> &, const QVariantHash &) |
|
79 */ |
|
80 int applicationActivities(QList<QVariantHash> &, const QVariantHash &); |
|
81 |
|
82 /** |
|
83 * Interface implementation. |
|
84 * @see int HsActivityDbClientInterface::waitActivity(const QVariantHash &) |
|
85 */ |
|
86 int waitActivity(const QVariantHash &activity); |
|
87 |
|
88 /** |
|
89 * Interface implementation. |
|
90 * @see int HsActivityDbClientInterface::launchActivity(const QVariantHash &) |
|
91 */ |
|
92 int launchActivity(const QVariantHash &activity); |
|
93 private: |
|
94 /** |
|
95 * Function check database structure |
|
96 * @return true if structure is valid, false otherwise |
|
97 */ |
|
98 bool checkTables(); |
|
99 |
|
100 /** |
|
101 * Function create database structure |
|
102 */ |
|
103 void recreateTables(); |
|
104 |
|
105 /** |
|
106 * Function return last SQL query error code |
|
107 * @param querty - executed sql query |
|
108 * @return SQL query error code |
|
109 */ |
|
110 int getSqlErrorCode(const QSqlQuery &query); |
|
111 |
|
112 /** |
|
113 * Function exeute SQL query |
|
114 * @param query - SQL |
|
115 * @return true on succees, false otherwise |
|
116 */ |
|
117 bool exec(QSqlQuery &query); |
|
118 |
|
119 /** |
|
120 * Function exeute SQL query |
|
121 * @param query - SQL query that has to be executed |
|
122 * @return true on succees, false otherwise |
|
123 */ |
|
124 bool exec(const QString &query, const QVariantHash ¶ms); |
|
125 |
|
126 /** |
|
127 * Funciton bind provided filtering rules with prepared SQL query |
|
128 * @param query - SQL query |
|
129 * @param activity - filtering rules |
|
130 * @param additionalData - additional filetering rules |
|
131 */ |
|
132 void bind(QSqlQuery &query, |
|
133 const QVariantHash &activity, |
|
134 const QVariantHash &additionalData = QVariantHash()); |
|
135 |
|
136 /** |
|
137 * Funciton get records that match conditions |
|
138 * @param result - output destination |
|
139 * @param query - SQL query sting |
|
140 * @param conditions - query conditions |
|
141 */ |
|
142 int activities(QList<QVariantHash> &results, |
|
143 const QString &query, |
|
144 const QVariantHash &conditions); |
|
145 |
|
146 private: |
|
147 /** |
|
148 * Connectioin to SQL engine |
|
149 */ |
|
150 QSqlDatabase mConn; |
|
151 }; |
|
152 #endif //HSACTIVITYSTORAGEPRIVATE_H |
|