85
|
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: CCASqlQuery implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <sqldb.h>
|
|
19 |
#include "casqlquery.h"
|
|
20 |
#include "casqlcommands.h"
|
|
21 |
#include "cainnerquery.h"
|
|
22 |
#include "caentryattribute.h"
|
|
23 |
#include "casqlquerycreator.h"
|
|
24 |
#include "caoperationparams.h"
|
|
25 |
#include "cadef.h"
|
|
26 |
#include "calocalizationentry.h"
|
|
27 |
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
//
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CCaSqlQuery::CCaSqlQuery( RSqlDatabase& aSql ) :
|
|
33 |
iSqlDb( aSql )
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CCaSqlQuery::~CCaSqlQuery()
|
|
42 |
{
|
|
43 |
iStatement.Close();
|
|
44 |
iQuery.Close();
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CCaSqlQuery* CCaSqlQuery::NewLC( RSqlDatabase& aSql )
|
|
52 |
{
|
|
53 |
CCaSqlQuery* self = new ( ELeave ) CCaSqlQuery( aSql );
|
|
54 |
CleanupStack::PushL( self );
|
|
55 |
self->ConstructL();
|
|
56 |
return self;
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CCaSqlQuery* CCaSqlQuery::NewL( RSqlDatabase& aSql )
|
|
64 |
{
|
|
65 |
CCaSqlQuery* self = CCaSqlQuery::NewLC( aSql );
|
|
66 |
CleanupStack::Pop( self );
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
void CCaSqlQuery::ConstructL()
|
|
75 |
{
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CCaSqlQuery::PrepareL()
|
|
83 |
{
|
|
84 |
User::LeaveIfError( iStatement.Prepare( iSqlDb, iQuery ) );
|
|
85 |
}
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CCaSqlQuery::CloseStatement()
|
|
91 |
{
|
|
92 |
iStatement.Close();
|
|
93 |
}
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CCaSqlQuery::ResetStatement()
|
|
99 |
{
|
|
100 |
iStatement.Reset();
|
|
101 |
}
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CCaSqlQuery::BindValuesForAddL( const CCaInnerEntry* aEntry )
|
|
107 |
{
|
|
108 |
switch ( Type() )
|
|
109 |
{
|
|
110 |
case EEntryTable: // = 1
|
|
111 |
{
|
|
112 |
BindValuesForAddEntryL( aEntry );
|
|
113 |
break;
|
|
114 |
}
|
|
115 |
case EIconTable:
|
|
116 |
{
|
|
117 |
BindValuesForAddIconL( aEntry );
|
|
118 |
break;
|
|
119 |
}
|
|
120 |
case EAttributeTable:
|
|
121 |
{
|
|
122 |
break;
|
|
123 |
}
|
|
124 |
default:
|
|
125 |
User::Leave( KErrNotSupported );
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CCaSqlQuery::BindValuesForAddEntryL( const CCaInnerEntry* aEntry )
|
|
134 |
{
|
|
135 |
if( iQuery.Find( KSQLEnText ) != KErrNotFound )
|
|
136 |
{
|
|
137 |
BindTextL( iStatement.ParameterIndex( KSQLEnText ),
|
|
138 |
aEntry->GetText() );
|
|
139 |
}
|
|
140 |
if( iQuery.Find( KSQLEnDescription )!= KErrNotFound )
|
|
141 |
{
|
|
142 |
BindTextL( iStatement.ParameterIndex( KSQLEnDescription ),
|
|
143 |
aEntry->GetDescription() );
|
|
144 |
}
|
|
145 |
if( iQuery.Find( KSQLEnRole ) != KErrNotFound )
|
|
146 |
{
|
|
147 |
BindIntL( iStatement.ParameterIndex( KSQLEnRole ),
|
|
148 |
aEntry->GetRole() );
|
|
149 |
}
|
|
150 |
if( iQuery.Find( KSQLEnTypeName ) != KErrNotFound )
|
|
151 |
{
|
|
152 |
BindTextL( iStatement.ParameterIndex( KSQLEnTypeName ),
|
|
153 |
aEntry->GetEntryTypeName() );
|
|
154 |
}
|
|
155 |
if( iQuery.Find( KSQLEnIdIcon ) != KErrNotFound )
|
|
156 |
{
|
|
157 |
BindIntL( iStatement.ParameterIndex( KSQLEnIdIcon ),
|
|
158 |
aEntry->GetIconId() );
|
|
159 |
}
|
|
160 |
if( iQuery.Find( KSQLEnCreationTime ) != KErrNotFound )
|
|
161 |
{
|
|
162 |
TTime currentTime( 0 );
|
|
163 |
currentTime.UniversalTime();
|
|
164 |
BindInt64L( iStatement.ParameterIndex( KSQLEnCreationTime ),
|
|
165 |
currentTime.Int64() );
|
|
166 |
}
|
|
167 |
if( iQuery.Find( KSQLEnUid ) != KErrNotFound )
|
|
168 |
{
|
|
169 |
BindIntL( iStatement.ParameterIndex( KSQLEnUid ),
|
|
170 |
aEntry->GetUid() );
|
|
171 |
}
|
|
172 |
if( iQuery.Find( KSQLEnFlags )!= KErrNotFound )
|
|
173 |
{
|
|
174 |
BindIntL( iStatement.ParameterIndex( KSQLEnFlags ),
|
|
175 |
aEntry->GetFlags() );
|
|
176 |
}
|
|
177 |
if( iQuery.Find( KSQLEntryId ) != KErrNotFound )
|
|
178 |
{
|
|
179 |
BindIntL( iStatement.ParameterIndex( KSQLEntryId ),
|
|
180 |
aEntry->GetId() );
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CCaSqlQuery::BindValuesForAddIconL( const CCaInnerEntry* aEntry )
|
|
189 |
{
|
|
190 |
BindValuesForGetIconL( aEntry );
|
|
191 |
}
|
|
192 |
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
void CCaSqlQuery::BindValuesForAddAttributeL( const CCaInnerEntry* aEntry,
|
|
198 |
const CCaEntryAttribute* aAttr )
|
|
199 |
{
|
|
200 |
if( iQuery.Find( KSQLAttrEntryID ) != KErrNotFound )
|
|
201 |
{
|
|
202 |
BindIntL(iStatement.ParameterIndex( KSQLAttrEntryID ),
|
|
203 |
aEntry->GetId() );
|
|
204 |
}
|
|
205 |
if( iQuery.Find( KSQLAttrName ) != KErrNotFound )
|
|
206 |
{
|
|
207 |
BindTextL( iStatement.ParameterIndex( KSQLAttrName ),
|
|
208 |
aAttr->Name() );
|
|
209 |
}
|
|
210 |
if( iQuery.Find( KSQLAttrValue ) != KErrNotFound )
|
|
211 |
{
|
|
212 |
BindTextL( iStatement.ParameterIndex( KSQLAttrValue ),
|
|
213 |
aAttr->Value() );
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
void CCaSqlQuery::BindValuesForOrganizeL( const RArray<TInt>& aEntryIds,
|
|
222 |
TCaOperationParams& aParams, const TInt aEntryId )
|
|
223 |
{
|
|
224 |
if( aEntryIds.Count() > 0 )
|
|
225 |
{
|
|
226 |
BindIdsL( aEntryIds, KSQLEntryId );
|
|
227 |
}
|
|
228 |
if( iQuery.Find( KSQLGEIdGroup ) != KErrNotFound )
|
|
229 |
{
|
|
230 |
BindIntL( iStatement.ParameterIndex( KSQLGEIdGroup ),
|
|
231 |
aParams.iGroupId );
|
|
232 |
}
|
|
233 |
if( iQuery.Find( KSQLEntryIdBefore ) != KErrNotFound )
|
|
234 |
{
|
|
235 |
BindIntL( iStatement.ParameterIndex( KSQLEntryIdBefore ),
|
|
236 |
aParams.iBeforeEntryId );
|
|
237 |
}
|
|
238 |
if( iQuery.Find( KSQLGEEntryId ) != KErrNotFound )
|
|
239 |
{
|
|
240 |
BindIntL( iStatement.ParameterIndex( KSQLGEEntryId ), aEntryId );
|
|
241 |
}
|
|
242 |
if( iQuery.Find( KSQLShiftThreshold ) != KErrNotFound )
|
|
243 |
{
|
|
244 |
BindIntL( iStatement.ParameterIndex( KSQLShiftThreshold ),
|
|
245 |
aEntryIds.Count() );
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
void CCaSqlQuery::BindValuesForLaunchL( const TInt aEntryId,
|
|
254 |
const TInt64 aLaunchTime )
|
|
255 |
{
|
|
256 |
if( iQuery.Find( KSQLLaLaunchEntryId ) != KErrNotFound )
|
|
257 |
{
|
|
258 |
BindIntL( iStatement.ParameterIndex(
|
|
259 |
KSQLLaLaunchEntryId ), aEntryId );
|
|
260 |
}
|
|
261 |
if( iQuery.Find( KSQLLaLaunchTime ) != KErrNotFound )
|
|
262 |
{
|
|
263 |
BindInt64L( iStatement.ParameterIndex(
|
|
264 |
KSQLLaLaunchTime ), aLaunchTime );
|
|
265 |
}
|
|
266 |
if( iQuery.Find( KSQLEnFlags ) != KErrNotFound )
|
|
267 |
{
|
|
268 |
BindIntL( iStatement.ParameterIndex( KSQLEnFlags ), EUsed );
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
// ---------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
void CCaSqlQuery::BindValuesForRemoveL( const TInt aEntryId,
|
|
277 |
const TInt aIconId )
|
|
278 |
{
|
|
279 |
if( iQuery.Find( KSQLEntryId )!= KErrNotFound )
|
|
280 |
{
|
|
281 |
BindIntL( iStatement.ParameterIndex( KSQLEntryId ), aEntryId );
|
|
282 |
}
|
|
283 |
if( iQuery.Find( KSQLIconId )!= KErrNotFound )
|
|
284 |
{
|
|
285 |
BindIntL( iStatement.ParameterIndex( KSQLIconId ), aIconId );
|
|
286 |
}
|
|
287 |
}
|
|
288 |
|
|
289 |
// ---------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
void CCaSqlQuery::BindValuesForCustomSortL( const TInt aGroupId, const TInt aEntryId,
|
|
294 |
const TInt aNewPostion )
|
|
295 |
{
|
|
296 |
if( iQuery.Find( KSQLGEIdGroup )!= KErrNotFound )
|
|
297 |
{
|
|
298 |
BindIntL( iStatement.ParameterIndex( KSQLGEIdGroup ), aGroupId );
|
|
299 |
}
|
|
300 |
if( iQuery.Find( KSQLGEEntryId )!= KErrNotFound )
|
|
301 |
{
|
|
302 |
BindIntL( iStatement.ParameterIndex( KSQLGEEntryId ), aEntryId );
|
|
303 |
}
|
|
304 |
if( iQuery.Find( KSQLGEPosition )!= KErrNotFound )
|
|
305 |
{
|
|
306 |
BindIntL( iStatement.ParameterIndex( KSQLGEPosition ), aNewPostion );
|
|
307 |
}
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
//
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
void CCaSqlQuery::BindTextL( TInt aParameterIndex,
|
|
315 |
const TDesC& aParameterValue )
|
|
316 |
{
|
|
317 |
User::LeaveIfError( iStatement.BindText( aParameterIndex,
|
|
318 |
aParameterValue ) );
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
// ---------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CCaSqlQuery::BindIntL( TInt aParameterIndex,
|
|
326 |
TInt aParameterValue )
|
|
327 |
{
|
|
328 |
User::LeaveIfError( aParameterIndex );
|
|
329 |
User::LeaveIfError( iStatement.BindInt( aParameterIndex,
|
|
330 |
aParameterValue ) );
|
|
331 |
}
|
|
332 |
|
|
333 |
// ---------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
// ---------------------------------------------------------------------------
|
|
336 |
//
|
|
337 |
void CCaSqlQuery::BindInt64L( TInt aParameterIndex,
|
|
338 |
TInt64 aParameterValue )
|
|
339 |
{
|
|
340 |
User::LeaveIfError( aParameterIndex );
|
|
341 |
User::LeaveIfError( iStatement.BindInt64( aParameterIndex,
|
|
342 |
aParameterValue ) );
|
|
343 |
}
|
|
344 |
|
|
345 |
// ---------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
// ---------------------------------------------------------------------------
|
|
348 |
//
|
|
349 |
void CCaSqlQuery::SetQueryL( const TDesC& aQuery )
|
|
350 |
{
|
|
351 |
iQuery.Close();
|
|
352 |
iQuery.CreateL( aQuery );
|
|
353 |
}
|
|
354 |
|
|
355 |
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
void CCaSqlQuery::BindValuesForLocalizeL( CCaLocalizationEntry& aLocalization )
|
|
361 |
{
|
|
362 |
if( iQuery.Find( KSQLLocRowId ) != KErrNotFound )
|
|
363 |
{
|
|
364 |
BindIntL( iStatement.ParameterIndex(
|
|
365 |
KSQLLocRowId ), aLocalization.GetRowId() );
|
|
366 |
}
|
|
367 |
if( iQuery.Find( KSQLLocTable ) != KErrNotFound )
|
|
368 |
{
|
|
369 |
BindTextL(iStatement.ParameterIndex( KSQLLocTable ),
|
|
370 |
aLocalization.GetTableName() );
|
|
371 |
}
|
|
372 |
if( iQuery.Find( KSQLLocAttribute ) != KErrNotFound )
|
|
373 |
{
|
|
374 |
BindTextL(iStatement.ParameterIndex( KSQLLocAttribute ),
|
|
375 |
aLocalization.GetAttributeName() );
|
|
376 |
}
|
|
377 |
if( iQuery.Find( KSQLLocString ) != KErrNotFound )
|
|
378 |
{
|
|
379 |
BindTextL(iStatement.ParameterIndex( KSQLLocString ),
|
|
380 |
aLocalization.GetLocalizedString() );
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
void CCaSqlQuery::BindValuesForPropertyL( const TDesC& aProperty )
|
|
389 |
{
|
|
390 |
if( iQuery.Find( KSQLDbProperty ) != KErrNotFound )
|
|
391 |
{
|
|
392 |
BindTextL( iStatement.ParameterIndex(
|
|
393 |
KSQLDbProperty ), aProperty );
|
|
394 |
}
|
|
395 |
}
|
|
396 |
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
//
|
|
399 |
// ---------------------------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CCaSqlQuery::BindValuesForPropertyUpdateL( const TDesC& aProperty, const TDesC& aPropertyValue )
|
|
402 |
{
|
|
403 |
BindValuesForPropertyL( aProperty );
|
|
404 |
|
|
405 |
if( iQuery.Find( KSQLDbValue ) != KErrNotFound )
|
|
406 |
{
|
|
407 |
BindTextL( iStatement.ParameterIndex(
|
|
408 |
KSQLDbValue ), aPropertyValue );
|
|
409 |
}
|
|
410 |
}
|
|
411 |
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
//
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
//
|
94
|
416 |
void CCaSqlQuery::BindValuesForGetLocalizationEntryL(
|
|
417 |
const CCaLocalizationEntry& aLocalization)
|
|
418 |
{
|
|
419 |
BindIntL( iStatement.ParameterIndex( KSQLLocRowId ),
|
|
420 |
aLocalization.GetRowId() );
|
|
421 |
BindTextL( iStatement.ParameterIndex( KSQLLocTable ),
|
|
422 |
aLocalization.GetTableName() );
|
|
423 |
BindTextL( iStatement.ParameterIndex( KSQLLocAttribute ),
|
|
424 |
aLocalization.GetAttributeName() );
|
|
425 |
}
|
|
426 |
|
|
427 |
// ---------------------------------------------------------------------------
|
|
428 |
//
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
void CCaSqlQuery::BindValuesForLocalizationEntryL(
|
|
432 |
const CCaLocalizationEntry& aLocalization)
|
|
433 |
{
|
|
434 |
BindIntL( iStatement.ParameterIndex( KSQLLocRowId ),
|
|
435 |
aLocalization.GetRowId() );
|
|
436 |
BindTextL( iStatement.ParameterIndex( KSQLLocTable ),
|
|
437 |
aLocalization.GetTableName() );
|
|
438 |
BindTextL( iStatement.ParameterIndex( KSQLLocAttribute ),
|
|
439 |
aLocalization.GetAttributeName() );
|
|
440 |
BindTextL( iStatement.ParameterIndex( KSQLLocQmFilename ),
|
|
441 |
aLocalization.GetQmFilename() );
|
|
442 |
BindTextL( iStatement.ParameterIndex( KSQLLocString ),
|
|
443 |
aLocalization.GetStringId() );
|
|
444 |
}
|
|
445 |
|
|
446 |
|
|
447 |
// ---------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
// ---------------------------------------------------------------------------
|
|
450 |
//
|
85
|
451 |
void CCaSqlQuery::BindValuesForGetEntriesL( const CCaInnerQuery* aQuery )
|
|
452 |
{
|
|
453 |
if( aQuery->GetIds().Count() > 0 )
|
|
454 |
{
|
|
455 |
BindIdsL( aQuery->GetIds(), KSQLEntryId );
|
|
456 |
}
|
|
457 |
else
|
|
458 |
{
|
|
459 |
if( aQuery->GetFlagsOn() != 0 && iQuery.Find( KSQLFlagsOn )
|
|
460 |
!= KErrNotFound )
|
|
461 |
{
|
|
462 |
BindIntL( iStatement.ParameterIndex( KSQLFlagsOn ),
|
|
463 |
aQuery->GetFlagsOn() );
|
|
464 |
}
|
|
465 |
if( aQuery->GetFlagsOff() != 0 && iQuery.Find( KSQLFlagsOff )
|
|
466 |
!= KErrNotFound )
|
|
467 |
{
|
|
468 |
BindIntL( iStatement.ParameterIndex( KSQLFlagsOff ),
|
|
469 |
aQuery->GetFlagsOff() );
|
|
470 |
}
|
|
471 |
if( aQuery->GetRole() != -1 && iQuery.Find( KSQLEnRole )
|
|
472 |
!= KErrNotFound )
|
|
473 |
{
|
|
474 |
BindIntL( iStatement.ParameterIndex( KSQLEnRole ),
|
|
475 |
aQuery->GetRole() );
|
|
476 |
}
|
|
477 |
if( aQuery->GetParentId() != -1 && iQuery.Find( KSQLGEIdGroup )
|
|
478 |
!= KErrNotFound )
|
|
479 |
{
|
|
480 |
BindIntL( iStatement.ParameterIndex( KSQLGEIdGroup ),
|
|
481 |
aQuery->GetParentId() );
|
|
482 |
}
|
99
|
483 |
if( aQuery->GetChildId() != -1 && iQuery.Find( KSQLGEEntryId )
|
|
484 |
!= KErrNotFound )
|
|
485 |
{
|
|
486 |
BindIntL( iStatement.ParameterIndex( KSQLGEEntryId ),
|
|
487 |
aQuery->GetChildId() );
|
|
488 |
}
|
85
|
489 |
if( aQuery->GetUid() != 0 && iQuery.Find( KSQLEnUid )
|
|
490 |
!= KErrNotFound )
|
|
491 |
{
|
|
492 |
BindIntL( iStatement.ParameterIndex( KSQLEnUid ),
|
|
493 |
aQuery->GetUid() );
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
// ---------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
void CCaSqlQuery::BindValuesForGetEntriesL( const CCaInnerEntry* aEntry )
|
|
503 |
{
|
|
504 |
if( iQuery.Find( KSQLEntryId ) != KErrNotFound )
|
|
505 |
{
|
|
506 |
BindIntL(iStatement.ParameterIndex( KSQLEntryId ),
|
|
507 |
aEntry->GetId() );
|
|
508 |
}
|
|
509 |
if( iQuery.Find( KSQLEnText) != KErrNotFound )
|
|
510 |
{
|
|
511 |
BindTextL(iStatement.ParameterIndex( KSQLEnText ),
|
|
512 |
aEntry->GetText() );
|
|
513 |
}
|
|
514 |
if( iQuery.Find( KSQLEnDescription ) != KErrNotFound )
|
|
515 |
{
|
|
516 |
BindTextL(iStatement.ParameterIndex( KSQLEnDescription ),
|
|
517 |
aEntry->GetDescription() );
|
|
518 |
}
|
|
519 |
if( iQuery.Find( KSQLEnRole ) != KErrNotFound )
|
|
520 |
{
|
|
521 |
BindIntL( iStatement.ParameterIndex( KSQLEnRole ),
|
|
522 |
aEntry->GetRole() );
|
|
523 |
}
|
|
524 |
if( iQuery.Find( KSQLEnTypeName ) != KErrNotFound )
|
|
525 |
{
|
|
526 |
BindTextL( iStatement.ParameterIndex( KSQLEnTypeName ),
|
|
527 |
aEntry->GetEntryTypeName() );
|
|
528 |
}
|
|
529 |
if( iQuery.Find( KSQLEnIdIcon ) != KErrNotFound )
|
|
530 |
{
|
|
531 |
BindIntL( iStatement.ParameterIndex( KSQLEnIdIcon ),
|
|
532 |
aEntry->GetIconId() );
|
|
533 |
}
|
|
534 |
if( iQuery.Find( KSQLEnUid ) != KErrNotFound )
|
|
535 |
{
|
|
536 |
BindIntL( iStatement.ParameterIndex(KSQLEnUid), aEntry->GetUid() );
|
|
537 |
}
|
|
538 |
if( iQuery.Find( KSQLEnFlags ) != KErrNotFound )
|
|
539 |
{
|
|
540 |
BindIntL( iStatement.ParameterIndex( KSQLEnFlags ),
|
|
541 |
aEntry->GetFlags() );
|
|
542 |
}
|
|
543 |
}
|
|
544 |
// ---------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
// ---------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CCaSqlQuery::BindValuesForGetIconL( const CCaInnerEntry* aEntry )
|
|
549 |
{
|
|
550 |
if( iQuery.Find( KSQLIconId ) != KErrNotFound )
|
|
551 |
{
|
|
552 |
BindIntL(iStatement.ParameterIndex( KSQLIconId ),
|
92
|
553 |
aEntry->Icon()->Id() );
|
85
|
554 |
}
|
|
555 |
if( iQuery.Find( KSQLIcFileName ) != KErrNotFound )
|
|
556 |
{
|
|
557 |
BindTextL( iStatement.ParameterIndex( KSQLIcFileName ),
|
92
|
558 |
aEntry->Icon()->FileName() );
|
85
|
559 |
}
|
88
|
560 |
if( iQuery.Find( KSQLIcSkinId ) != KErrNotFound )
|
85
|
561 |
{
|
88
|
562 |
BindTextL( iStatement.ParameterIndex( KSQLIcSkinId ),
|
92
|
563 |
aEntry->Icon()->SkinId() );
|
85
|
564 |
}
|
88
|
565 |
if( iQuery.Find( KSQLIcAppId ) != KErrNotFound )
|
85
|
566 |
{
|
88
|
567 |
BindTextL( iStatement.ParameterIndex( KSQLIcAppId ),
|
92
|
568 |
aEntry->Icon()->ApplicationId() );
|
85
|
569 |
}
|
|
570 |
}
|
|
571 |
|
|
572 |
// ---------------------------------------------------------------------------
|
|
573 |
//
|
|
574 |
// ---------------------------------------------------------------------------
|
|
575 |
//
|
|
576 |
void CCaSqlQuery::BindEntryIdsL(
|
|
577 |
const RPointerArray<CCaInnerEntry>& aEntryArray )
|
|
578 |
{
|
|
579 |
RArray<TInt> entryIdArray;
|
|
580 |
CleanupClosePushL( entryIdArray );
|
|
581 |
|
|
582 |
for( TInt i = 0; i < aEntryArray.Count(); i++ )
|
|
583 |
{
|
|
584 |
entryIdArray.AppendL( aEntryArray[i]->GetId() );
|
|
585 |
}
|
|
586 |
BindIdsL( entryIdArray, KSQLEntryId );
|
|
587 |
CleanupStack::PopAndDestroy( &entryIdArray );
|
|
588 |
}
|
|
589 |
|
|
590 |
// ---------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
// ---------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
void CCaSqlQuery::BindIdsL( const RArray<TInt>& aEntryIdArray,
|
|
595 |
const TDesC& aColName )
|
|
596 |
{
|
|
597 |
RBuf bindKey;
|
|
598 |
bindKey.CleanupClosePushL();
|
|
599 |
bindKey.CreateL( aColName.Length() + KMaxIntNumLength );
|
|
600 |
for( TInt i = 0; i < aEntryIdArray.Count() ; i++ )
|
|
601 |
{
|
|
602 |
bindKey.Copy( KNullDesC );
|
|
603 |
bindKey.Append( aColName );
|
|
604 |
bindKey.AppendNum( i );
|
|
605 |
if( iQuery.Find( bindKey ) != KErrNotFound )
|
|
606 |
{
|
|
607 |
BindIntL( iStatement.ParameterIndex( bindKey ),
|
|
608 |
aEntryIdArray[i] );
|
|
609 |
}
|
|
610 |
}
|
|
611 |
CleanupStack::PopAndDestroy( &bindKey );
|
|
612 |
}
|
|
613 |
|
|
614 |
// ---------------------------------------------------------------------------
|
|
615 |
//
|
|
616 |
// ---------------------------------------------------------------------------
|
|
617 |
//
|
|
618 |
void CCaSqlQuery::BindEntryIdL( const TInt& aEntryId )
|
|
619 |
{
|
|
620 |
if( iQuery.Find( KSQLEntryId ) != KErrNotFound )
|
|
621 |
{
|
|
622 |
BindIntL( iStatement.ParameterIndex( KSQLEntryId ), aEntryId );
|
|
623 |
}
|
|
624 |
}
|
|
625 |
|
|
626 |
// ---------------------------------------------------------------------------
|
|
627 |
// CCaSqlQuery::BindValuesForRemoveFromLocalizationL( const TInt aEntryId )
|
|
628 |
// ---------------------------------------------------------------------------
|
|
629 |
//
|
|
630 |
void CCaSqlQuery::BindValuesForRemoveFromLocalizationL( const TInt aEntryId )
|
|
631 |
{
|
|
632 |
if( iQuery.Find( KSQLLocRowId ) != KErrNotFound )
|
|
633 |
{
|
|
634 |
BindIntL( iStatement.ParameterIndex( KSQLLocRowId ), aEntryId );
|
|
635 |
}
|
|
636 |
}
|
|
637 |
|
|
638 |
// ---------------------------------------------------------------------------
|
|
639 |
//
|
|
640 |
// ---------------------------------------------------------------------------
|
|
641 |
//
|
|
642 |
TInt CCaSqlQuery::ExecuteL()
|
|
643 |
{
|
|
644 |
User::LeaveIfError( iStatement.Exec() );
|
|
645 |
TSqlScalarFullSelectQuery id_query( iSqlDb );
|
|
646 |
return id_query.SelectIntL( KSQLGetLastInsertId );
|
|
647 |
}
|
|
648 |
|
|
649 |
// ---------------------------------------------------------------------------
|
|
650 |
//
|
|
651 |
// ---------------------------------------------------------------------------
|
|
652 |
//
|
94
|
653 |
TBool CCaSqlQuery::ExecuteEntryPresentL( )
|
|
654 |
{
|
|
655 |
if( iStatement.Next() == KSqlAtRow )
|
|
656 |
{
|
|
657 |
return ETrue;
|
|
658 |
}
|
|
659 |
return EFalse;
|
|
660 |
}
|
|
661 |
|
|
662 |
// ---------------------------------------------------------------------------
|
|
663 |
//
|
|
664 |
// ---------------------------------------------------------------------------
|
|
665 |
//
|
85
|
666 |
TInt CCaSqlQuery::ExecuteL( TInt& aId )
|
|
667 |
{
|
|
668 |
if( iStatement.Next() == KSqlAtRow )
|
|
669 |
{
|
|
670 |
aId = iStatement.ColumnInt( ColumnIndexL( iStatement,
|
|
671 |
KColumnSingleData ) );
|
|
672 |
return 1;
|
|
673 |
}
|
|
674 |
return 0;
|
|
675 |
}
|
|
676 |
|
|
677 |
// ---------------------------------------------------------------------------
|
|
678 |
//
|
|
679 |
// ---------------------------------------------------------------------------
|
|
680 |
//
|
|
681 |
TInt CCaSqlQuery::ExecuteL( TInt64& aId )
|
|
682 |
{
|
|
683 |
if( iStatement.Next() == KSqlAtRow )
|
|
684 |
{
|
|
685 |
aId = iStatement.ColumnInt64(ColumnIndexL( iStatement,
|
|
686 |
KColumnSingleData ) );
|
|
687 |
return 1;
|
|
688 |
}
|
|
689 |
return 0;
|
|
690 |
}
|
|
691 |
|
|
692 |
// ---------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
// ---------------------------------------------------------------------------
|
|
695 |
//
|
|
696 |
TInt CCaSqlQuery::ExecuteL( RPointerArray<CCaInnerEntry>& result,
|
|
697 |
TQueryResultType aResultType )
|
|
698 |
{
|
|
699 |
TInt rowCount( 0 );
|
|
700 |
if( aResultType==CCaSqlQuery::EEntry )
|
|
701 |
{
|
|
702 |
rowCount = ExecuteEntryL( result );
|
|
703 |
}
|
|
704 |
else // aResultType==CCaSqlQuery::EAttribute
|
|
705 |
{
|
|
706 |
rowCount = ExecuteAttributeL( result );
|
|
707 |
}
|
|
708 |
return rowCount;
|
|
709 |
}
|
|
710 |
|
|
711 |
// ---------------------------------------------------------------------------
|
|
712 |
//
|
|
713 |
// ---------------------------------------------------------------------------
|
|
714 |
//
|
|
715 |
TInt CCaSqlQuery::ExecuteEntryL(
|
|
716 |
RPointerArray<CCaInnerEntry>& aResultInput )
|
|
717 |
{
|
|
718 |
TInt rowCount(0);
|
|
719 |
while( iStatement.Next() == KSqlAtRow )
|
|
720 |
{
|
89
|
721 |
TInt entryId = iStatement.ColumnInt(
|
|
722 |
ColumnIndexL( iStatement, KColumnEntryId ) );
|
|
723 |
TInt role = iStatement.ColumnInt(
|
|
724 |
ColumnIndexL( iStatement, KColumnEnRole ) );
|
|
725 |
TInt32 uid = iStatement.ColumnInt(
|
|
726 |
ColumnIndexL( iStatement, KColumnEnUid ) );
|
|
727 |
TUint flags = iStatement.ColumnInt(
|
|
728 |
ColumnIndexL( iStatement, KColumnEnFlags ) );
|
|
729 |
TInt idIcon = iStatement.ColumnInt(
|
|
730 |
ColumnIndexL( iStatement, KColumnEnIdIcon ) );
|
88
|
731 |
|
85
|
732 |
TPtrC text;
|
|
733 |
User::LeaveIfError( iStatement. ColumnText( ColumnIndexL(
|
|
734 |
iStatement, KColumnEnText ), text ) );
|
|
735 |
TPtrC description;
|
|
736 |
User::LeaveIfError( iStatement.
|
|
737 |
ColumnText( ColumnIndexL( iStatement, KColumnEnDescription ),
|
|
738 |
description) );
|
|
739 |
TPtrC typeName;
|
|
740 |
User::LeaveIfError( iStatement.ColumnText(
|
|
741 |
ColumnIndexL(iStatement, KColumnEnTypeName ), typeName) );
|
88
|
742 |
|
85
|
743 |
TPtrC iconFilename;
|
|
744 |
User::LeaveIfError( iStatement.ColumnText( ColumnIndexL(
|
|
745 |
iStatement, KColumnIcFileName ), iconFilename ) );
|
|
746 |
|
88
|
747 |
TPtrC iconSkinId;
|
|
748 |
User::LeaveIfError( iStatement.ColumnText( ColumnIndexL(
|
|
749 |
iStatement, KColumnIcSkinId ), iconSkinId ) );
|
|
750 |
|
|
751 |
TPtrC iconApplicationId;
|
|
752 |
User::LeaveIfError( iStatement.ColumnText( ColumnIndexL(
|
|
753 |
iStatement, KColumnIcAppId ), iconApplicationId ) );
|
|
754 |
|
85
|
755 |
CCaInnerEntry* result = CCaInnerEntry::NewLC();
|
|
756 |
result->SetId( entryId );
|
|
757 |
result->SetRole( role );
|
88
|
758 |
result->SetIconDataL(
|
|
759 |
iconFilename, iconSkinId, iconApplicationId );
|
85
|
760 |
result->SetIconId( idIcon );
|
|
761 |
result->SetFlags( flags );
|
|
762 |
result->SetUid( uid );
|
|
763 |
result->SetTextL( text );
|
|
764 |
result->SetDescriptionL( description );
|
|
765 |
result->SetEntryTypeNameL( typeName );
|
|
766 |
|
|
767 |
aResultInput.AppendL( result );
|
|
768 |
CleanupStack::Pop( result );
|
|
769 |
rowCount++;
|
|
770 |
}//while
|
|
771 |
|
|
772 |
return rowCount;
|
|
773 |
}
|
|
774 |
|
|
775 |
// ---------------------------------------------------------------------------
|
|
776 |
//
|
|
777 |
// ---------------------------------------------------------------------------
|
|
778 |
//
|
|
779 |
TInt CCaSqlQuery::ExecuteLocalizationsL(
|
|
780 |
RPointerArray<CCaLocalizationEntry>& aResultInput )
|
|
781 |
{
|
|
782 |
TInt rowCount(0);
|
|
783 |
while( iStatement.Next() == KSqlAtRow )
|
|
784 |
{
|
|
785 |
TInt locTextId = iStatement.ColumnInt(
|
|
786 |
ColumnIndexL( iStatement, KColumnLocTextId )
|
|
787 |
);
|
|
788 |
|
|
789 |
TInt rowId = iStatement.ColumnInt(
|
|
790 |
ColumnIndexL( iStatement, KColumnLocRowId )
|
|
791 |
);
|
|
792 |
|
|
793 |
TPtrC tableName;
|
|
794 |
User::LeaveIfError(
|
|
795 |
iStatement.ColumnText(
|
|
796 |
ColumnIndexL( iStatement, KColumnLocTableName ),
|
|
797 |
tableName )
|
|
798 |
);
|
|
799 |
|
94
|
800 |
TPtrC qmFilename;
|
|
801 |
User::LeaveIfError(
|
|
802 |
iStatement.ColumnText(
|
|
803 |
ColumnIndexL( iStatement, KColumnQmFile ),
|
|
804 |
qmFilename )
|
|
805 |
);
|
|
806 |
|
85
|
807 |
TPtrC attribute;
|
|
808 |
User::LeaveIfError(
|
|
809 |
iStatement.ColumnText(
|
|
810 |
ColumnIndexL( iStatement, KColumnLocAttrName ),
|
|
811 |
attribute )
|
|
812 |
);
|
|
813 |
|
|
814 |
TPtrC stringId;
|
|
815 |
User::LeaveIfError(
|
|
816 |
iStatement.ColumnText(
|
|
817 |
ColumnIndexL( iStatement, KColumnLocStringId ),
|
|
818 |
stringId )
|
|
819 |
);
|
|
820 |
|
|
821 |
CCaLocalizationEntry* result = CCaLocalizationEntry::NewLC( );
|
|
822 |
result->SetTextId( locTextId );
|
|
823 |
result->SetAttributeNameL( attribute );
|
|
824 |
result->SetStringIdL( stringId );
|
|
825 |
result->SetRowId( rowId );
|
|
826 |
result->SetTableNameL( tableName );
|
94
|
827 |
result->SetQmFilenameL( qmFilename );
|
85
|
828 |
|
|
829 |
aResultInput.AppendL( result );
|
|
830 |
CleanupStack::Pop( result );
|
|
831 |
rowCount++;
|
|
832 |
}//while
|
|
833 |
|
|
834 |
return rowCount;
|
|
835 |
}
|
|
836 |
|
|
837 |
// ---------------------------------------------------------------------------
|
|
838 |
//
|
|
839 |
// ---------------------------------------------------------------------------
|
|
840 |
//
|
|
841 |
TInt CCaSqlQuery::ExecutePropertyL( TDes& aPropertyValue )
|
|
842 |
{
|
|
843 |
TInt rowCount(0);
|
|
844 |
while( iStatement.Next() == KSqlAtRow )
|
|
845 |
{
|
|
846 |
TPtrC propertyValue;
|
|
847 |
User::LeaveIfError( iStatement. ColumnText(
|
|
848 |
ColumnIndexL( iStatement, KColumnDbValue ), propertyValue ) );
|
|
849 |
|
|
850 |
aPropertyValue.Copy( propertyValue );
|
|
851 |
|
|
852 |
rowCount++;
|
|
853 |
}//while
|
|
854 |
|
|
855 |
return rowCount;
|
|
856 |
}
|
|
857 |
|
|
858 |
// ---------------------------------------------------------------------------
|
|
859 |
//
|
|
860 |
// ---------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
TInt CCaSqlQuery::ExecuteAttributeL(
|
|
863 |
RPointerArray<CCaInnerEntry>& aEntryArray )
|
|
864 |
{
|
|
865 |
TInt rowCount( 0 );
|
|
866 |
while( iStatement.Next() == KSqlAtRow )
|
|
867 |
{
|
|
868 |
TInt idEntry = iStatement.ColumnInt(
|
|
869 |
ColumnIndexL( iStatement, KColumnAttrEntryID ) );
|
|
870 |
TPtrC name;
|
|
871 |
User::LeaveIfError(iStatement.ColumnText(
|
|
872 |
ColumnIndexL( iStatement, KColumnAttrName), name ) );
|
|
873 |
TPtrC value;
|
|
874 |
User::LeaveIfError(iStatement.ColumnText(
|
|
875 |
ColumnIndexL( iStatement, KColumnAttrValue), value ) );
|
|
876 |
for( TInt i = 0; i < aEntryArray.Count(); i++ )
|
|
877 |
{
|
|
878 |
if( idEntry == aEntryArray[i]->GetId() )
|
|
879 |
{
|
|
880 |
aEntryArray[i]->AddAttributeL( name, value );
|
|
881 |
}
|
|
882 |
}
|
|
883 |
rowCount++;
|
|
884 |
}
|
|
885 |
return rowCount;
|
|
886 |
}
|
|
887 |
|
|
888 |
// ---------------------------------------------------------------------------
|
|
889 |
//
|
|
890 |
// ---------------------------------------------------------------------------
|
|
891 |
//
|
|
892 |
TInt CCaSqlQuery::ExecuteL( RArray<TInt>& aResultIdArray,
|
|
893 |
TTableType aType )
|
|
894 |
{
|
|
895 |
TInt rowCount( 0 );
|
|
896 |
TPtrC columnId;
|
|
897 |
if( aType == CCaSqlQuery::EEntryTable )
|
|
898 |
{
|
|
899 |
columnId.Set( KColumnEntryId );
|
|
900 |
}
|
|
901 |
else // aType==CCaSqlQuery::EGroupTable
|
|
902 |
{
|
|
903 |
columnId.Set( KColumnGEIdGroup );
|
|
904 |
}
|
|
905 |
while( iStatement.Next() == KSqlAtRow )
|
|
906 |
{
|
|
907 |
aResultIdArray.AppendL( iStatement.ColumnInt( ColumnIndexL(
|
|
908 |
iStatement, columnId ) ) );
|
|
909 |
rowCount++;
|
|
910 |
}
|
|
911 |
return rowCount;
|
|
912 |
}
|
|
913 |
|
|
914 |
// ---------------------------------------------------------------------------
|
|
915 |
//
|
|
916 |
// ---------------------------------------------------------------------------
|
|
917 |
//
|
92
|
918 |
TInt CCaSqlQuery::ExecuteL( CCaInnerIconDescription* aInnerIconDescription )
|
85
|
919 |
{
|
|
920 |
TInt columnCount( 0 );
|
92
|
921 |
|
|
922 |
RBuf description;
|
|
923 |
description.CleanupClosePushL();
|
|
924 |
description.CreateL(KMaxFileName);
|
|
925 |
|
85
|
926 |
while( iStatement.Next() == KSqlAtRow )
|
|
927 |
{
|
92
|
928 |
aInnerIconDescription->SetId( iStatement.ColumnInt(
|
|
929 |
ColumnIndexL( iStatement, KColumnIconId ) ) );
|
85
|
930 |
User::LeaveIfError(iStatement.ColumnText(
|
|
931 |
ColumnIndexL( iStatement, KColumnIcFileName),
|
92
|
932 |
description));
|
|
933 |
aInnerIconDescription->SetFileNameL(description);
|
|
934 |
|
88
|
935 |
User::LeaveIfError(iStatement.ColumnText(
|
|
936 |
ColumnIndexL( iStatement, KColumnIcSkinId),
|
92
|
937 |
description));
|
|
938 |
aInnerIconDescription->SetSkinIdL(description);
|
|
939 |
|
88
|
940 |
User::LeaveIfError(iStatement.ColumnText(
|
|
941 |
ColumnIndexL( iStatement, KColumnIcAppId),
|
92
|
942 |
description));
|
|
943 |
aInnerIconDescription->SetApplicationIdL(description);
|
|
944 |
|
85
|
945 |
columnCount++;
|
|
946 |
}
|
92
|
947 |
CleanupStack::PopAndDestroy(&description);
|
85
|
948 |
return columnCount;
|
|
949 |
}
|
|
950 |
|
|
951 |
// ---------------------------------------------------------------------------
|
|
952 |
//
|
|
953 |
// ---------------------------------------------------------------------------
|
|
954 |
//
|
|
955 |
TInt CCaSqlQuery::ColumnIndexL( RSqlStatement& aStmt,
|
|
956 |
const TDesC& aColumnName ) const
|
|
957 |
{
|
|
958 |
TInt ret( aStmt.ColumnIndex( aColumnName ) );
|
|
959 |
User::LeaveIfError( ret );
|
|
960 |
return ret;
|
|
961 |
}
|
|
962 |
|