1 /* |
|
2 * Copyright (c) 2008 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: Class that directly interacts with Sqlite database. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_EVTDATABASE_H |
|
20 #define C_EVTDATABASE_H |
|
21 |
|
22 // System Includes |
|
23 #include <sqldb.h> |
|
24 |
|
25 // User Includes |
|
26 #include "evtbasiceventinfo.h" |
|
27 #include "evtevent.h" |
|
28 #include "evtdbobserver.h" |
|
29 #include "evtstoragedbobserver.h" |
|
30 |
|
31 // Forward Declarations |
|
32 class CEvtDbNotifier; |
|
33 |
|
34 // extern data types |
|
35 |
|
36 // global Functions |
|
37 |
|
38 // constants |
|
39 const TInt KTempStringLength=32; |
|
40 |
|
41 /** |
|
42 * Interface class to Location Events Database. |
|
43 * This class allows for Events to be stored in persistent database |
|
44 * - Sqlite. Events can be added, deleted and modified from |
|
45 * database. |
|
46 * |
|
47 * @lib evtstorage.lib |
|
48 * @since S60 v9.1 |
|
49 */ |
|
50 class CEvtDatabase : public CBase, |
|
51 public MEvtDbObserver |
|
52 { |
|
53 public: // Member Functions |
|
54 /** |
|
55 * Constructs a new instance of CEvtDatabase. |
|
56 * |
|
57 * @return The new instance of CEvtDatabase. |
|
58 * @leave System wide error code if the object creation fails. |
|
59 */ |
|
60 static CEvtDatabase* NewL( ); |
|
61 |
|
62 /** |
|
63 * Constructs a new instance of Event Storage Manager interface. |
|
64 * Leaves the created instance on the cleanup stack. |
|
65 * |
|
66 * @return The new instance of CEvtDatabase. |
|
67 * @leave System wide error code if the object creation fails. |
|
68 */ |
|
69 static CEvtDatabase* NewLC( ); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 virtual ~CEvtDatabase(); |
|
75 |
|
76 /** |
|
77 * Get Events List based on status. |
|
78 */ |
|
79 void GetEventsL( TEvtEventStatus aEvtStatus, |
|
80 RPointerArray<CEvtBasicEventInfo>& aEvtEventArray ); |
|
81 |
|
82 /** |
|
83 * Get Events List based on status. |
|
84 */ |
|
85 void GetEventsL( RPointerArray<CEvtBasicEventInfo>& aEvtEventArray ); |
|
86 |
|
87 /** |
|
88 * Get Event based on unique Id. |
|
89 */ |
|
90 CEvtEvent* GetEventL( TEvtEventId aEvtId ); |
|
91 |
|
92 /** |
|
93 * Update Event based on unique Id. |
|
94 */ |
|
95 void UpdateEventL( CEvtEvent& aEvtEvent ); |
|
96 |
|
97 /** |
|
98 * Insert Event to database. |
|
99 */ |
|
100 void AddEventL( CEvtEvent& aEvtEvent ); |
|
101 |
|
102 /** |
|
103 * Remove Events from database. |
|
104 */ |
|
105 void RemoveEventsL( const RArray<TEvtEventId>& aEvtIdArray ); |
|
106 |
|
107 /** |
|
108 * Update Event Status. |
|
109 */ |
|
110 void UpdateEventsStatusL( const RArray<TEvtEventId>& aEventArray, TEvtEventStatus aEvtStatus ); |
|
111 |
|
112 /** |
|
113 * Update Event Status based on unique Id. |
|
114 */ |
|
115 void UpdateEventStatusL( |
|
116 TEvtEventId aEvtId, |
|
117 TEvtEventStatus aEvtStatus); |
|
118 |
|
119 /** |
|
120 * Remove Event from database based on unique Id. |
|
121 */ |
|
122 void RemoveEventL( TEvtEventId aEvtId ); |
|
123 |
|
124 /** |
|
125 * Set the Observer fo Storage Database. |
|
126 */ |
|
127 void SetObserver( MEvtStorageDbObserver* aStorageDbObserver ); |
|
128 |
|
129 // Inherited from MEvtDbObserver |
|
130 /** |
|
131 * Observer for TDbChangeType changes in Storage Database. |
|
132 */ |
|
133 void HandleDbChangedL( ); |
|
134 |
|
135 |
|
136 private: |
|
137 |
|
138 /** |
|
139 * Open Database Connection. |
|
140 */ |
|
141 void OpenDatabaseL( ); |
|
142 |
|
143 /** |
|
144 * Create and Open Database Connection. |
|
145 */ |
|
146 void CreateOpenDatabaseL( ); |
|
147 |
|
148 /** |
|
149 * Close Database Connection. |
|
150 */ |
|
151 void CloseDatabase(); |
|
152 |
|
153 /** |
|
154 * Create the Schema for Events Storage. |
|
155 */ |
|
156 void CreateSchemaL(); |
|
157 |
|
158 /** |
|
159 * Create All the Tables. |
|
160 */ |
|
161 void CreateTablesL(); |
|
162 |
|
163 /** |
|
164 * Create All the Indexes. |
|
165 */ |
|
166 void CreateIndexL(); |
|
167 |
|
168 /** |
|
169 * Create All the related Triggers. |
|
170 */ |
|
171 void CreateTriggerL(); |
|
172 |
|
173 /** |
|
174 * Get Events based on Query String. |
|
175 */ |
|
176 void GetEventsL( RSqlStatement& aStmt, |
|
177 RPointerArray<CEvtBasicEventInfo>& aEvtEventArray ); |
|
178 |
|
179 /** |
|
180 * Update Event Table. |
|
181 */ |
|
182 void UpdateEventTableL( CEvtEvent& aEvtEvent ); |
|
183 |
|
184 /** |
|
185 * Delete Event. |
|
186 */ |
|
187 void DeleteEventL( TEvtEventId aEventId ); |
|
188 |
|
189 /** |
|
190 * check if Event is present. |
|
191 */ |
|
192 TBool CheckIfEventPresentL( TEvtEventId aId ); |
|
193 |
|
194 /** |
|
195 * check if Action is present. |
|
196 */ |
|
197 TBool CheckIfActionPresentL( TInt64 aId ); |
|
198 |
|
199 /** |
|
200 * Get the action Id based on Event Id. |
|
201 */ |
|
202 TInt64 GetActionId( TEvtEventId aId ); |
|
203 |
|
204 /** |
|
205 * Create Action. |
|
206 */ |
|
207 void CreateActionL( CEvtAction& aEvtAction ); |
|
208 |
|
209 /** |
|
210 * Update Action. |
|
211 */ |
|
212 void UpdateActionL( CEvtAction& aEvtAction ); |
|
213 |
|
214 /** |
|
215 * Delete Action. |
|
216 */ |
|
217 void DeleteActionL( TEvtEventId aEventId ); |
|
218 |
|
219 /** |
|
220 * Default C++ Constructor. |
|
221 */ |
|
222 CEvtDatabase( ); |
|
223 |
|
224 /** |
|
225 * Second phase of the two phase constructor. |
|
226 */ |
|
227 void ConstructL(); |
|
228 |
|
229 private: // data |
|
230 |
|
231 /** |
|
232 * RSqlDatabase Instance |
|
233 */ |
|
234 RSqlDatabase iDb; |
|
235 |
|
236 /** |
|
237 * CEvtDbNotifier Instance |
|
238 */ |
|
239 CEvtDbNotifier* iDbNotifier; |
|
240 |
|
241 /** |
|
242 * CEvtDbNotifier Instance |
|
243 */ |
|
244 MEvtStorageDbObserver* iStorageDbObserver; |
|
245 |
|
246 }; |
|
247 |
|
248 #endif // C_EVTDATABASE_H |
|