|
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: Main class in the SQL Wrapper component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include <bautils.h> |
|
24 #include "cmsqlconnection.h" |
|
25 #include "cmsqldbmaintenance.h" |
|
26 #include "cmsqldbclause.h" |
|
27 #include "cmsqlmain.h" |
|
28 #include "msdebug.h" |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT(KCmSqlDirC, "C:\\System\\Data\\MediaServant\\"); |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CCmSqlMain::NewL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CCmSqlMain* CCmSqlMain::NewL( RFs& aFs ) |
|
38 { |
|
39 LOG(_L("[SQL Wrapper]\t CCmSqlMain::NewL")); |
|
40 CCmSqlMain* self = CCmSqlMain::NewLC( aFs ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CCmSqlMain::NewLC |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CCmSqlMain* CCmSqlMain::NewLC( RFs& aFs ) |
|
50 { |
|
51 LOG(_L("[SQL Wrapper]\t CCmSqlMain::NewLC")); |
|
52 CCmSqlMain* self = new ( ELeave ) CCmSqlMain( aFs ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CCmSqlMain::~CCmSqlMain |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CCmSqlMain::~CCmSqlMain() |
|
63 { |
|
64 LOG(_L("[SQL Wrapper]\t CCmSqlMain::~CCmSqlMain")); |
|
65 delete iClause; |
|
66 delete iMaintenance; |
|
67 delete iConnection; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CCmSqlMain::CancelAsyncOperation |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CCmSqlMain::CancelAsyncOperation() |
|
75 { |
|
76 LOG(_L("[SQL Wrapper]\t CCmSqlMain::CancelAsyncOperation")); |
|
77 |
|
78 iConnection->CancelAsyncOperation(); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CCmSqlMain::SetMsId |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CCmSqlMain::SetMsId( TUint aId ) |
|
86 { |
|
87 LOG(_L("[SQL Wrapper]\t CCmSqlMain::SetMsId")); |
|
88 |
|
89 iConnection->SetMsId( aId ); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CCmSqlMain::SetQuota |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CCmSqlMain::SetQuota( TInt64 aQuota ) |
|
97 { |
|
98 LOG(_L("[SQL Wrapper]\t CCmSqlMain::SetQuota")); |
|
99 |
|
100 iConnection->SetQuota( aQuota ); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CCmSqlMain::SetDlnaProfileFilters |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CCmSqlMain::SetDlnaProfileFilters( |
|
108 const RArray<TInt64>& aProfileIds ) |
|
109 { |
|
110 LOG(_L("[SQL Wrapper]\t CCmSqlMain::SetDlnaProfileFilters")); |
|
111 |
|
112 iClause->SetDlnaProfileFilters( aProfileIds ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CCmSqlMain::AsyncBatchAdd |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void CCmSqlMain::AsyncBatchAdd( |
|
120 RPointerArray<CCmSqlGenericItem>& aItems, TRequestStatus& aStatus ) |
|
121 { |
|
122 LOG(_L("[SQL Wrapper]\t CCmSqlMain::AsyncBatchAdd")); |
|
123 |
|
124 iConnection->AsyncBatchAdd( aItems, aStatus ); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CCmSqlMain::AsyncBatchAddPropertyItems |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CCmSqlMain::AsyncBatchAddPropertyItems( |
|
132 RPointerArray<CCmSqlPropertyItem>& aItems, TCmMetadataField aField, |
|
133 TRequestStatus& aStatus ) |
|
134 { |
|
135 LOG(_L("[SQL Wrapper]\t CCmSqlMain::AsyncBatchAddPropertyItems")); |
|
136 |
|
137 iConnection->AsyncBatchAddPropertyItems( aItems, aField, aStatus ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CCmSqlMain::SyncAddPropertyItemL |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CCmSqlMain::SyncAddPropertyItemL( |
|
145 CCmSqlPropertyItem& aItem, TCmMetadataField aField ) |
|
146 { |
|
147 LOG(_L("[SQL Wrapper]\t CCmSqlMain::SyncAddPropertyItemL")); |
|
148 |
|
149 iConnection->SyncAddPropertyItemL( aItem, aField ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CCmSqlMain::AsyncBatchDelete |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CCmSqlMain::AsyncBatchDelete( |
|
157 RPointerArray<CCmSqlBaseItem>& aItems, |
|
158 TRequestStatus& aStatus ) |
|
159 { |
|
160 LOG(_L("[SQL Wrapper]\t CCmSqlMain::AsyncBatchDelete")); |
|
161 |
|
162 iConnection->AsyncBatchDelete( aItems, aStatus ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CCmSqlMain::AsyncMetadataDelete |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CCmSqlMain::AsyncMetadataDelete( |
|
170 RArray<TInt>& aMsIds, TRequestStatus& aStatus ) |
|
171 { |
|
172 LOG(_L("[SQL Wrapper]\t CCmSqlMain::AsyncMetadataDelete")); |
|
173 |
|
174 iConnection->AsyncMetadataDelete( aMsIds, aStatus ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CCmSqlMain::DeleteOldestMediaItemsL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CCmSqlMain::DeleteOldestMediaItemsL( TCmMediaType aType, |
|
182 TInt64 aCount ) |
|
183 { |
|
184 LOG(_L("[SQL Wrapper]\t CCmSqlMain::DeleteOldestMediaItemsL")); |
|
185 |
|
186 iConnection->DeleteOldestMediaItemsL( aType, aCount ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CCmSqlMain::DeleteUnusedPropertys |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CCmSqlMain::DeleteUnusedPropertys( ) |
|
194 { |
|
195 LOG(_L("[SQL Wrapper]\t CCmSqlMain::DeleteUnusedPropertys")); |
|
196 |
|
197 iConnection->DeleteUnusedPropertys( ); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CCmSqlMain::GetItemsL |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CCmSqlMain::GetItemsL( RPointerArray<CCmSqlBaseItem>& aItems, |
|
205 TRequestStatus& aStatus ) |
|
206 { |
|
207 LOG(_L("[SQL Wrapper]\t CCmSqlMain::GetItemsL")); |
|
208 |
|
209 iConnection->GetItemsL( aItems, aStatus ); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // CCmSqlMain::GetFillItemsL |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 void CCmSqlMain::GetFillItemsL( |
|
217 RPointerArray<CCmFillListItem>& aItems, CCmFillRule& aRule, |
|
218 TRequestStatus& aStatus ) |
|
219 { |
|
220 LOG(_L("[SQL Wrapper]\t CCmSqlMain::GetFillItemsL")); |
|
221 |
|
222 iClause->FormatClauseL( aRule ); |
|
223 iConnection->GetFillItemsL( aItems, iClause->ClauseL(), aRule, aStatus ); |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CCmSqlMain::GetPropertyValuesL |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CCmSqlMain::GetPropertyValuesL( |
|
231 RPointerArray<CCmSqlPropertyItem>& aItems, TRequestStatus& aStatus, |
|
232 TCmMetadataField aField, TCmMediaType aMedia ) |
|
233 { |
|
234 LOG(_L("[SQL Wrapper]\t CCmSqlMain::GetPropertyValuesL")); |
|
235 |
|
236 CCmFillRule* rule = NULL; |
|
237 iClause->FormatClauseL( *rule, aField, aMedia ); |
|
238 iConnection->GetPropertyValuesL( aItems, iClause->ClauseL(), |
|
239 aStatus ); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CCmSqlMain::GetFilteredPropertyValuesL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CCmSqlMain::GetFilteredPropertyValuesL( |
|
247 CCmSqlPropertyCollector& aPropertys, TRequestStatus& aStatus ) |
|
248 { |
|
249 LOG(_L("[SQL Wrapper]\t CCmSqlMain::GetFilteredPropertyValuesL")); |
|
250 |
|
251 iClause->FormatFilteringClauseL( aPropertys ); |
|
252 iConnection->GetFilteredPropertyValuesL( aPropertys, iClause->ClauseL(), |
|
253 aStatus ); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // CCmSqlMain::GetMediaCountL |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CCmSqlMain::GetMediaCountL( TInt64& aCount, |
|
261 TCmMediaType aType ) |
|
262 { |
|
263 LOG(_L("[SQL Wrapper]\t CCmSqlMain::GetMediaCountL")); |
|
264 |
|
265 iConnection->GetMediaCountL( aCount, aType ); |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // CCmSqlMain::Exists |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 TBool CCmSqlMain::ExistsL( const CCmBaseListItem& aItem, |
|
273 const TInt aDevId ) |
|
274 { |
|
275 LOG(_L("[SQL Wrapper]\t CCmSqlMain::ExistsL")); |
|
276 |
|
277 return iConnection->ExistsL( aItem, aDevId ); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CCmSqlMain::Close |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CCmSqlMain::Close() |
|
285 { |
|
286 LOG(_L("[SQL Wrapper]\t CCmSqlMain::Close")); |
|
287 |
|
288 delete this; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // CCmSqlMain::CCmSqlMain |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 CCmSqlMain::CCmSqlMain( RFs& aFs ): iFs( aFs ) |
|
296 { |
|
297 LOG(_L("[SQL Wrapper]\t CCmSqlMain::CCmSqlMain")); |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CCmSqlMain::ConstructL |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CCmSqlMain::ConstructL() |
|
305 { |
|
306 LOG(_L("[SQL Wrapper]\t CCmSqlMain::ConstructL")); |
|
307 |
|
308 TRAP_IGNORE( BaflUtils::EnsurePathExistsL( iFs, KCmSqlDirC ) ); |
|
309 iClause = CCmSqlDbClause::NewL(); |
|
310 iMaintenance = CCmSqlDbMaintenance::NewL(); |
|
311 iConnection = CCmSqlConnection::NewL(); |
|
312 |
|
313 if( iMaintenance->InitConnection(*iConnection) ) |
|
314 { |
|
315 iMaintenance->CreateDbFile( *iConnection ); |
|
316 } |
|
317 if( !iConnection->Validate() ) |
|
318 { |
|
319 iMaintenance->CreateDb( *iConnection ); |
|
320 iMaintenance->CreateIndexes( *iConnection ); |
|
321 } |
|
322 } |
|
323 |
|
324 // End of file |
|
325 |