114
|
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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <s32mem.h>
|
|
20 |
#include <liwgenericparam.h>
|
|
21 |
#include <escapeutils.h>
|
|
22 |
#include <badesca.h>
|
|
23 |
|
|
24 |
#include "cpliwmap.h"
|
|
25 |
#include "cpdebug.h"
|
|
26 |
#include "cpssqlcommands.h"
|
|
27 |
#include "ccontentmap.h"
|
|
28 |
#include "cpublisherregistrymap.h"
|
|
29 |
#include "cpsecuritypolicy.h"
|
|
30 |
|
|
31 |
using namespace LIW;
|
|
32 |
|
|
33 |
// ======== MEMBER FUNCTIONS ========
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
EXPORT_C CCPLiwMap* CCPLiwMap::NewL( RDesReadStream& aStream )
|
|
40 |
{
|
|
41 |
CLiwGenericParamList* list = CLiwGenericParamList::NewLC( aStream );
|
|
42 |
CCPLiwMap* map = CCPLiwMap::NewL( *list );
|
|
43 |
CleanupStack::PopAndDestroy( list );
|
|
44 |
return map;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
EXPORT_C CCPLiwMap* CCPLiwMap::NewL( const CLiwGenericParamList& aList )
|
|
52 |
{
|
|
53 |
CP_DEBUG( _L8("CCPLiwMap::NewL") );
|
|
54 |
const TLiwGenericParam* param = NULL;
|
|
55 |
TInt pos( 0 );
|
|
56 |
param = aList.FindFirst( pos, KType );
|
|
57 |
CCPLiwMap* map( NULL );
|
|
58 |
if( param && pos !=KErrNotFound )
|
|
59 |
{
|
|
60 |
if( IsTypePublisherL(param->Value()) )
|
|
61 |
{
|
|
62 |
map = CPublisherRegistryMap::NewLC();
|
|
63 |
}
|
|
64 |
else
|
|
65 |
{
|
|
66 |
map = CContentMap::NewLC();
|
|
67 |
}
|
|
68 |
map->SetL(aList);
|
|
69 |
CleanupStack::Pop(map);
|
|
70 |
}
|
|
71 |
else
|
|
72 |
{
|
|
73 |
User::Leave( KErrPathNotFound );
|
|
74 |
}
|
|
75 |
return map;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
EXPORT_C CCPLiwMap* CCPLiwMap::NewL( const CLiwMap& aMap )
|
|
83 |
{
|
|
84 |
CP_DEBUG( _L8("CCPLiwMap::NewL") );
|
|
85 |
TLiwVariant typeVariant;
|
|
86 |
typeVariant.PushL();
|
|
87 |
CCPLiwMap* map( NULL );
|
|
88 |
|
|
89 |
if (aMap.FindL(KType, typeVariant))
|
|
90 |
{
|
|
91 |
if( IsTypePublisherL(typeVariant) )
|
|
92 |
{
|
|
93 |
map = CPublisherRegistryMap::NewLC();
|
|
94 |
}
|
|
95 |
else
|
|
96 |
{
|
|
97 |
map = CContentMap::NewLC();
|
|
98 |
}
|
|
99 |
map->SetL(aMap);
|
|
100 |
CleanupStack::Pop(map);
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
User::Leave( KErrPathNotFound );
|
|
105 |
}
|
|
106 |
CleanupStack::PopAndDestroy(&typeVariant);
|
|
107 |
return map;
|
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
EXPORT_C HBufC8* CCPLiwMap::PackForServerLC() const
|
|
115 |
{
|
|
116 |
CP_DEBUG( _L8("CCPLiwMap::PackForServerLC") );
|
|
117 |
HBufC8* datadesc = HBufC8::NewLC( Size() );
|
|
118 |
TPtr8 ptr = datadesc->Des();
|
|
119 |
RDesWriteStream datastrm( ptr );
|
|
120 |
CleanupClosePushL(datastrm);
|
|
121 |
ExternalizeL(datastrm);
|
|
122 |
datastrm.CommitL();
|
|
123 |
CleanupStack::PopAndDestroy(&datastrm);
|
|
124 |
return datadesc;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
EXPORT_C void CCPLiwMap::Reset( ) const
|
|
132 |
{
|
|
133 |
iMap->Reset();
|
|
134 |
}
|
|
135 |
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CCPLiwMap::IsValidForAddL( ) const
|
|
141 |
{
|
|
142 |
CP_DEBUG( _L8("CCPLiwMap::IsValidForAddL") );
|
|
143 |
TInt err( KErrNone );
|
|
144 |
TInt32 id( 0 );
|
|
145 |
if( GetProperty( KId, id ) && ( id < 1 ) )
|
|
146 |
{
|
|
147 |
err = KErrArgument;
|
|
148 |
}
|
|
149 |
else if( !IsId() && PropertyExists( KId ) )
|
|
150 |
{
|
|
151 |
err = KErrBadName;
|
|
152 |
}
|
|
153 |
|
|
154 |
CheckIdentifiersL();
|
|
155 |
|
|
156 |
if( err == KErrNone && !IsId() && !( IsPublisherNameL()
|
|
157 |
&& IsContentTypeL() && IsContentIdL() ) )
|
|
158 |
{
|
|
159 |
err = KErrPathNotFound;
|
|
160 |
}
|
|
161 |
|
|
162 |
if( err != KErrNone )
|
|
163 |
{
|
|
164 |
User::Leave( err );
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
EXPORT_C void CCPLiwMap::IsValidForActionL( )const
|
|
173 |
{
|
|
174 |
CP_DEBUG( _L8("CCPLiwMap::IsValidForActionL") );
|
|
175 |
CCPLiwMap::IsValidForNotificationL();
|
|
176 |
if( !IsTriggerL() ) User::Leave( KErrPathNotFound );
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
EXPORT_C void CCPLiwMap::IsValidForNotificationL( ) const
|
|
184 |
{
|
|
185 |
CP_DEBUG( _L8("CCPLiwMap::IsValidForAddL") );
|
|
186 |
TInt err( KErrNone );
|
|
187 |
TInt32 id( 0 );
|
|
188 |
if( GetProperty( KId, id ) && ( id < 1 ) )
|
|
189 |
{
|
|
190 |
err = KErrArgument;
|
|
191 |
}
|
|
192 |
else if( !IsId() && PropertyExists( KId ) )
|
|
193 |
{
|
|
194 |
err = KErrBadName;
|
|
195 |
}
|
|
196 |
|
|
197 |
CheckIdentifiersL();
|
|
198 |
|
|
199 |
if( err == KErrNone && !IsId() && !IsPublisherNameL()
|
|
200 |
&& !IsContentTypeL() && !IsContentIdL() )
|
|
201 |
{
|
|
202 |
err = KErrPathNotFound;
|
|
203 |
}
|
|
204 |
|
|
205 |
if( err != KErrNone )
|
|
206 |
{
|
|
207 |
User::Leave( err );
|
|
208 |
}
|
|
209 |
}
|
|
210 |
|
|
211 |
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
EXPORT_C TBool CCPLiwMap::GetPropertyL( const TDesC8& aProperty ,
|
|
217 |
RBuf& aResult ) const
|
|
218 |
{
|
|
219 |
//change name
|
|
220 |
CP_DEBUG( _L8("CCPLiwMap::GetProperty - TPtrC") );
|
|
221 |
TBool result( EFalse );
|
|
222 |
TInt pos( 0 );
|
|
223 |
TPtrC result16( KNullDesC);
|
|
224 |
TPtrC8 result8( KNullDesC8);
|
|
225 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
|
|
226 |
if ( pos != KErrNotFound )
|
|
227 |
{
|
|
228 |
if( paramForValue->Value().Get( result16 ) )
|
|
229 |
{
|
|
230 |
aResult.CreateL( result16 );
|
|
231 |
result = ETrue;
|
|
232 |
}
|
|
233 |
else if( paramForValue->Value().Get( result8 ) )
|
|
234 |
{
|
|
235 |
aResult.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( result8 ) );
|
|
236 |
result = ETrue;
|
|
237 |
}
|
|
238 |
else
|
|
239 |
{
|
|
240 |
User::Leave( KErrBadName );
|
|
241 |
}
|
|
242 |
}
|
|
243 |
return result;
|
|
244 |
}
|
|
245 |
|
|
246 |
// ---------------------------------------------------------------------------
|
|
247 |
//
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
EXPORT_C TBool CCPLiwMap::GetPropertyL( const TDesC8& aProperty ,
|
|
251 |
RBuf8& aResult ) const
|
|
252 |
{
|
|
253 |
CP_DEBUG( _L8("CCPLiwMap::GetProperty - TPtrC8") );
|
|
254 |
TBool result( EFalse );
|
|
255 |
TInt pos( 0 );
|
|
256 |
TPtrC8 result8( KNullDesC8 );
|
|
257 |
TPtrC result16( KNullDesC );
|
|
258 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
|
|
259 |
if ( pos != KErrNotFound )
|
|
260 |
{
|
|
261 |
if( paramForValue->Value().Get( result8 ) )
|
|
262 |
{
|
|
263 |
aResult.CreateL( result8 );
|
|
264 |
result = ETrue;
|
|
265 |
}
|
|
266 |
else if( paramForValue->Value().Get( result16 ) )
|
|
267 |
{
|
|
268 |
aResult.Assign( EscapeUtils::ConvertFromUnicodeToUtf8L( result16 ) );
|
|
269 |
result = ETrue;
|
|
270 |
}
|
|
271 |
else
|
|
272 |
{
|
|
273 |
User::Leave( KErrBadName );
|
|
274 |
}
|
|
275 |
}
|
|
276 |
return result;
|
|
277 |
}
|
|
278 |
|
|
279 |
// ---------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
// ---------------------------------------------------------------------------
|
|
282 |
//
|
|
283 |
EXPORT_C TBool CCPLiwMap::GetProperty( const TDesC8& aProperty ,
|
|
284 |
TInt32& aResult ) const
|
|
285 |
{
|
|
286 |
CP_DEBUG( _L8("CCPLiwMap::GetProperty - TInt32") );
|
|
287 |
TBool result( EFalse );
|
|
288 |
TInt pos( 0 );
|
|
289 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
|
|
290 |
if ( pos != KErrNotFound )
|
|
291 |
{
|
|
292 |
if( paramForValue->Value().Get( aResult ) )
|
|
293 |
{
|
|
294 |
result = ETrue;
|
|
295 |
}
|
|
296 |
}
|
|
297 |
return result;
|
|
298 |
}
|
|
299 |
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
// ---------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
EXPORT_C CLiwDefaultList* CCPLiwMap::GetActionTriggersLC( ) const
|
|
305 |
{
|
|
306 |
CP_DEBUG( _L8("CCPLiwMap::GetActionTriggers") );
|
|
307 |
TInt pos( 0 );
|
|
308 |
CLiwDefaultList* list(NULL);
|
|
309 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos,
|
|
310 |
KActionTrigger );
|
|
311 |
if ( paramForValue )
|
|
312 |
{
|
|
313 |
if ( paramForValue->Value().TypeId() == EVariantTypeDesC8 )
|
|
314 |
{
|
|
315 |
list = CLiwDefaultList::NewLC();
|
|
316 |
list->AppendL(paramForValue->Value());
|
|
317 |
}
|
|
318 |
if ( paramForValue->Value().TypeId() == EVariantTypeDesC )
|
|
319 |
{
|
|
320 |
list = CLiwDefaultList::NewLC();
|
|
321 |
RBuf8 desc8;
|
|
322 |
desc8.CleanupClosePushL();
|
|
323 |
desc8.Assign( EscapeUtils::ConvertFromUnicodeToUtf8L(
|
|
324 |
paramForValue->Value().AsDes() ) );
|
|
325 |
list->AppendL(TLiwVariant(desc8));
|
|
326 |
CleanupStack::PopAndDestroy( &desc8 );
|
|
327 |
}
|
|
328 |
else if ( paramForValue->Value().TypeId() == EVariantTypeList )
|
|
329 |
{
|
|
330 |
list = CLiwDefaultList::NewLC();
|
|
331 |
const CLiwList* sourceList = paramForValue->Value().AsList();
|
|
332 |
TInt count = sourceList->Count();
|
|
333 |
for (TInt i = 0; i < count; i++)
|
|
334 |
{
|
|
335 |
TLiwVariant trigger;
|
|
336 |
trigger.PushL();
|
|
337 |
sourceList->AtL(i,trigger);
|
|
338 |
if (trigger.TypeId() == EVariantTypeDesC8)
|
|
339 |
{
|
|
340 |
list->AppendL(trigger);
|
|
341 |
}
|
|
342 |
else if (trigger.TypeId() == EVariantTypeDesC)
|
|
343 |
{
|
|
344 |
RBuf8 desc8;
|
|
345 |
desc8.CleanupClosePushL();
|
|
346 |
desc8.Assign( EscapeUtils::ConvertFromUnicodeToUtf8L(
|
|
347 |
trigger.AsDes() ) );
|
|
348 |
list->AppendL(TLiwVariant(desc8));
|
|
349 |
CleanupStack::PopAndDestroy( &desc8 );
|
|
350 |
}
|
|
351 |
CleanupStack::PopAndDestroy(&trigger);
|
|
352 |
}
|
|
353 |
}
|
|
354 |
}
|
|
355 |
return list;
|
|
356 |
}
|
|
357 |
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
//
|
|
362 |
EXPORT_C void CCPLiwMap::SetSecurityL( const RMessage2& aMessage )
|
|
363 |
{
|
|
364 |
delete iPolicy;
|
|
365 |
iPolicy = NULL;
|
|
366 |
iPolicy = CCPSecurityPolicy::NewL( aMessage );
|
|
367 |
}
|
|
368 |
|
|
369 |
// ---------------------------------------------------------------------------
|
|
370 |
//
|
|
371 |
// ---------------------------------------------------------------------------
|
|
372 |
//
|
|
373 |
CCPLiwMap::~CCPLiwMap()
|
|
374 |
{
|
|
375 |
delete iMap;
|
|
376 |
delete iPolicy;
|
|
377 |
}
|
|
378 |
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
// ---------------------------------------------------------------------------
|
|
382 |
//
|
|
383 |
CCPLiwMap::CCPLiwMap()
|
|
384 |
{
|
|
385 |
|
|
386 |
}
|
|
387 |
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
//
|
|
390 |
// ---------------------------------------------------------------------------
|
|
391 |
//
|
|
392 |
void CCPLiwMap::InsertL( const TDesC8& aKey, const TLiwVariant& aValue )
|
|
393 |
{
|
|
394 |
CP_DEBUG( _L8("CCPLiwMap::InsertL") );
|
|
395 |
Remove( aKey );
|
|
396 |
TLiwGenericParam mp;
|
|
397 |
mp.SetNameAndValueL( aKey, aValue );
|
|
398 |
iMap->AppendL( mp );
|
|
399 |
mp.Reset( );
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------------------------
|
|
403 |
//
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
TBool CCPLiwMap::FindL( const TDesC8& aKey, TLiwVariant& aValue ) const
|
|
407 |
{
|
|
408 |
CP_DEBUG( _L8("CCPLiwMap::FindL") );
|
|
409 |
TInt pos = 0;
|
|
410 |
TBool result(EFalse);
|
|
411 |
const TLiwGenericParam* tempParam = iMap->FindFirst( pos, aKey );
|
|
412 |
if ( tempParam )
|
|
413 |
{
|
|
414 |
aValue.SetL( tempParam->Value( ) );
|
|
415 |
result = ETrue;
|
|
416 |
}
|
|
417 |
return result;
|
|
418 |
}
|
|
419 |
|
|
420 |
// ---------------------------------------------------------------------------
|
|
421 |
//
|
|
422 |
// ---------------------------------------------------------------------------
|
|
423 |
//
|
|
424 |
TInt CCPLiwMap::Count() const
|
|
425 |
{
|
|
426 |
return iMap->Count( );
|
|
427 |
}
|
|
428 |
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
// ---------------------------------------------------------------------------
|
|
432 |
//
|
|
433 |
TBool CCPLiwMap::AtL( TInt aIndex, TDes8& aKey ) const
|
|
434 |
{
|
|
435 |
CP_DEBUG( _L8("CCPLiwMap::AtL") );
|
|
436 |
TBool result(EFalse);
|
|
437 |
if ( 0 <= aIndex && aIndex < iMap->Count( ) )
|
|
438 |
{
|
|
439 |
aKey = ((*iMap)[aIndex]).Name( );
|
|
440 |
result = ETrue;
|
|
441 |
}
|
|
442 |
return result;
|
|
443 |
}
|
|
444 |
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
// ---------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
void CCPLiwMap::Remove( const TDesC8& aKey )
|
|
450 |
{
|
|
451 |
CP_DEBUG( _L8("CCPLiwMap::Remove") );
|
|
452 |
TInt pos = 0;
|
|
453 |
iMap->FindFirst( pos, aKey );
|
|
454 |
if ( pos != KErrNotFound )
|
|
455 |
{
|
|
456 |
iMap->Remove( aKey );
|
|
457 |
}
|
|
458 |
}
|
|
459 |
|
|
460 |
// ---------------------------------------------------------------------------
|
|
461 |
//
|
|
462 |
// ---------------------------------------------------------------------------
|
|
463 |
//
|
|
464 |
TInt CCPLiwMap::Size() const
|
|
465 |
{
|
|
466 |
return iMap->Size( );
|
|
467 |
}
|
|
468 |
|
|
469 |
// ---------------------------------------------------------------------------
|
|
470 |
//
|
|
471 |
// ---------------------------------------------------------------------------
|
|
472 |
//
|
|
473 |
void CCPLiwMap::ExternalizeL( RWriteStream& aStream ) const
|
|
474 |
{
|
|
475 |
CP_DEBUG( _L8("CCPLiwMap::ExternalizeL") );
|
|
476 |
iMap->ExternalizeL( aStream );
|
|
477 |
}
|
|
478 |
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
// ---------------------------------------------------------------------------
|
|
482 |
//
|
|
483 |
void CCPLiwMap::FillChangeInfoMapL( RSqlStatement& aStmt,
|
|
484 |
CLiwDefaultMap* aMap )const
|
|
485 |
{
|
|
486 |
TInt idIndex = ColumnIndexL( aStmt, KColumnId );
|
|
487 |
TInt publisherIndex = ColumnIndexL( aStmt, KColumnPublisher );
|
|
488 |
TInt contentIndex = ColumnIndexL( aStmt, KColumnContent_type );
|
|
489 |
TInt content_idIndex = ColumnIndexL( aStmt, KColumnContent_id );
|
|
490 |
TInt acl_Index = ColumnIndexL( aStmt, KColumnAccessList );
|
|
491 |
|
|
492 |
TInt32 id = aStmt.ColumnInt( idIndex ) ;
|
|
493 |
TPtrC publisher;
|
|
494 |
User::LeaveIfError(aStmt.ColumnText( publisherIndex,publisher) );
|
|
495 |
TPtrC content_type;
|
|
496 |
User::LeaveIfError(aStmt.ColumnText( contentIndex,content_type ) );
|
|
497 |
TPtrC content_id;
|
|
498 |
User::LeaveIfError(aStmt.ColumnText( content_idIndex,content_id) );
|
|
499 |
aMap->InsertL( KId, TLiwVariant( id ) );
|
|
500 |
aMap->InsertL( KPublisherId, TLiwVariant( publisher ) );
|
|
501 |
aMap->InsertL( KContentType, TLiwVariant( content_type ) );
|
|
502 |
aMap->InsertL( KContentId, TLiwVariant( content_id ) );
|
|
503 |
aMap->InsertL( KOperation, TLiwVariant( KOperationDelete ) );
|
|
504 |
RBuf type;
|
|
505 |
type.CleanupClosePushL();
|
|
506 |
if( GetPropertyL( KType, type ) )
|
|
507 |
{
|
|
508 |
aMap->InsertL( KType , TLiwVariant( type ) );
|
|
509 |
}
|
|
510 |
CleanupStack::PopAndDestroy( &type );
|
|
511 |
}
|
|
512 |
|
|
513 |
|
|
514 |
// ---------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
// ---------------------------------------------------------------------------
|
|
517 |
//
|
|
518 |
void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList )
|
|
519 |
{
|
|
520 |
CP_DEBUG( _L8("CCPLiwMap::SetL") );
|
|
521 |
for ( TInt i = 0; i < aInParamList.Count( ); i++ )
|
|
522 |
{
|
|
523 |
const TLiwGenericParam& param = aInParamList[i];
|
|
524 |
ExtractParamL(param);
|
|
525 |
}
|
|
526 |
}
|
|
527 |
|
|
528 |
// ---------------------------------------------------------------------------
|
|
529 |
//
|
|
530 |
// ---------------------------------------------------------------------------
|
|
531 |
//
|
|
532 |
void CCPLiwMap::SetL( const CLiwMap& aMap )
|
|
533 |
{
|
|
534 |
CP_DEBUG( _L8("CCPLiwMap::SetL") );
|
|
535 |
for ( TInt i = 0; i < aMap.Count( ); i++ )
|
|
536 |
{
|
|
537 |
TBuf8<128> key;
|
|
538 |
aMap.AtL(i, key);
|
|
539 |
TLiwVariant value;
|
|
540 |
value.PushL();
|
|
541 |
aMap.FindL(key, value);
|
|
542 |
TLiwGenericParam param(key,value);
|
|
543 |
ExtractParamL(param);
|
|
544 |
CleanupStack::PopAndDestroy(&value);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
// ---------------------------------------------------------------------------
|
|
549 |
//
|
|
550 |
// ---------------------------------------------------------------------------
|
|
551 |
//
|
|
552 |
void CCPLiwMap::ExtractParamL(const TLiwGenericParam& aParam)
|
|
553 |
{
|
|
554 |
CP_DEBUG( _L8("CCPLiwMap::ExtractVariantL") );
|
|
555 |
if (aParam.Value().TypeId() == LIW::EVariantTypeMap)
|
|
556 |
{
|
|
557 |
const CLiwMap* map = aParam.Value().AsMap();
|
|
558 |
for (TInt i = 0; i < map->Count(); i++)
|
|
559 |
{
|
|
560 |
TBuf8<128> key;
|
|
561 |
map->AtL(i, key);
|
|
562 |
TLiwVariant value;
|
|
563 |
value.PushL();
|
|
564 |
map->FindL(key, value);
|
|
565 |
if (key == KOperation)
|
|
566 |
{
|
|
567 |
IsProperOperationL(value);
|
|
568 |
}
|
|
569 |
RBuf8 datadesc;
|
|
570 |
datadesc.CleanupClosePushL();
|
|
571 |
if (value.TypeId() == LIW::EVariantTypeMap)
|
|
572 |
{
|
|
573 |
const CLiwMap* internalMap = value.AsMap();
|
|
574 |
datadesc.CreateL(internalMap->Size());
|
|
575 |
RDesWriteStream datastrm(datadesc);
|
|
576 |
CleanupClosePushL(datastrm);
|
|
577 |
internalMap->ExternalizeL(datastrm);
|
|
578 |
datastrm.CommitL();
|
|
579 |
CleanupStack::PopAndDestroy(&datastrm);
|
|
580 |
value.Reset();
|
|
581 |
value.Set(datadesc);
|
|
582 |
}
|
|
583 |
TLiwGenericParam data(key, value);
|
|
584 |
iMap->AppendL(data);
|
|
585 |
CleanupStack::PopAndDestroy(&datadesc);
|
|
586 |
CleanupStack::PopAndDestroy(&value);
|
|
587 |
}
|
|
588 |
}
|
|
589 |
else
|
|
590 |
{
|
|
591 |
iMap->AppendL(aParam);
|
|
592 |
}
|
|
593 |
}
|
|
594 |
|
|
595 |
// ---------------------------------------------------------------------------
|
|
596 |
//
|
|
597 |
// ---------------------------------------------------------------------------
|
|
598 |
//
|
|
599 |
void CCPLiwMap::IsProperOperationL( const TLiwVariant& aValue ) const
|
|
600 |
{
|
|
601 |
CP_DEBUG( _L8("CContentMap::IsProperOperationL") );
|
|
602 |
TPtrC valDesc( KNullDesC );
|
|
603 |
TPtrC8 valDesc8( KNullDesC8 );
|
|
604 |
RBuf desc;
|
|
605 |
desc.CleanupClosePushL();
|
|
606 |
|
|
607 |
if( aValue.Get( valDesc ) == EFalse )
|
|
608 |
{
|
|
609 |
if( aValue.Get( valDesc8 ) != EFalse )
|
|
610 |
{
|
|
611 |
desc.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( valDesc8 ) );
|
|
612 |
valDesc.Set( desc );
|
|
613 |
}
|
|
614 |
else
|
|
615 |
{
|
|
616 |
User::Leave( KErrBadName );
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
TLex input( valDesc );
|
|
621 |
|
|
622 |
CDesC16Array* array = new (ELeave) CDesC16ArrayFlat(4);
|
|
623 |
CleanupStack::PushL( array );
|
|
624 |
|
|
625 |
TLexMark startMark;
|
|
626 |
input.Mark( startMark );
|
|
627 |
TBool notEmpty = EFalse;
|
|
628 |
while ( !input.Eos() )
|
|
629 |
{
|
|
630 |
if( input.Peek() == ':')
|
|
631 |
{
|
|
632 |
array->AppendL( input.MarkedToken( startMark ) );
|
|
633 |
input.Inc();
|
|
634 |
input.Mark( startMark );
|
|
635 |
}
|
|
636 |
input.Inc();
|
|
637 |
notEmpty = ETrue;
|
|
638 |
}
|
|
639 |
if ( notEmpty )
|
|
640 |
{
|
|
641 |
array->AppendL( input.MarkedToken( startMark ) );
|
|
642 |
}
|
|
643 |
|
|
644 |
for( TInt i= 0; i < array->MdcaCount(); i++ )
|
|
645 |
{
|
|
646 |
TPtrC operValue( array->MdcaPoint(i) );
|
|
647 |
|
|
648 |
if( operValue.Compare( KOperationAdd ) &&
|
|
649 |
operValue.Compare( KOperationUpdate ) &&
|
|
650 |
operValue.Compare( KOperationDelete ) &&
|
|
651 |
operValue.Compare( KOperationExecute ) )
|
|
652 |
{
|
|
653 |
User::Leave( KErrArgument );
|
|
654 |
}
|
|
655 |
}
|
|
656 |
CleanupStack::PopAndDestroy( array );
|
|
657 |
CleanupStack::PopAndDestroy( &desc );
|
|
658 |
}
|
|
659 |
|
|
660 |
|
|
661 |
// ---------------------------------------------------------------------------
|
|
662 |
//
|
|
663 |
// ---------------------------------------------------------------------------
|
|
664 |
//
|
|
665 |
void CCPLiwMap::AppendGetListFilterL( RBuf& aQuery, TUint& aFilter ) const
|
|
666 |
{
|
|
667 |
CP_DEBUG( _L8("CContentMap::AppendGetListFilterL") );
|
|
668 |
if( !IsGetListAllL( aFilter ) )
|
|
669 |
{
|
|
670 |
AppendFilterL( aQuery, aFilter );
|
|
671 |
}
|
|
672 |
}
|
|
673 |
|
|
674 |
// ---------------------------------------------------------------------------
|
|
675 |
//
|
|
676 |
// ---------------------------------------------------------------------------
|
|
677 |
//
|
|
678 |
void CCPLiwMap::AppendRemoveFilterL( RBuf& aQuery, TUint& aFilter ) const
|
|
679 |
{
|
|
680 |
CP_DEBUG( _L8("CContentMap::AppendRemoveFilterL") );
|
|
681 |
AppendFilterL( aQuery, aFilter );
|
|
682 |
}
|
|
683 |
// ---------------------------------------------------------------------------
|
|
684 |
//
|
|
685 |
// ---------------------------------------------------------------------------
|
|
686 |
//
|
|
687 |
void CCPLiwMap::AppendFilterL( RBuf& aQuery, TUint& aFilter ) const
|
|
688 |
{
|
|
689 |
CP_DEBUG( _L8("CContentMap::AppendFilterL") );
|
|
690 |
|
|
691 |
TBool nextFilter( EFalse );
|
|
692 |
|
|
693 |
RemoveAllAttributeL( aFilter ); //remove "all" attribute from publisher,
|
|
694 |
//cont_type or cont_id
|
|
695 |
|
|
696 |
aQuery.ReAllocL( aQuery.Length( ) + KWhere().Length( ) );
|
|
697 |
aQuery.Append( KWhere );
|
|
698 |
|
|
699 |
if( aFilter & EContentType )
|
|
700 |
{
|
|
701 |
aQuery.ReAllocL( aQuery.Length( ) + KSQLGetContentType().Length( ) );
|
|
702 |
aQuery.Append( KSQLGetContentType );
|
|
703 |
nextFilter = ETrue;
|
|
704 |
}
|
|
705 |
if( aFilter & EPublisher )
|
|
706 |
{
|
|
707 |
if( nextFilter )
|
|
708 |
{
|
|
709 |
aQuery.ReAllocL( aQuery.Length( ) + KAnd().Length( ) +
|
|
710 |
KSQLGetPublisher().Length( ) );
|
|
711 |
aQuery.Append( KAnd );
|
|
712 |
aQuery.Append( KSQLGetPublisher );
|
|
713 |
}
|
|
714 |
else
|
|
715 |
{
|
|
716 |
aQuery.ReAllocL( aQuery.Length( ) +
|
|
717 |
KSQLGetPublisher().Length( ) );
|
|
718 |
aQuery.Append( KSQLGetPublisher );
|
|
719 |
}
|
|
720 |
nextFilter = ETrue;
|
|
721 |
}
|
|
722 |
if( aFilter & EContentId )
|
|
723 |
{
|
|
724 |
if( nextFilter )
|
|
725 |
{
|
|
726 |
aQuery.ReAllocL( aQuery.Length( ) +
|
|
727 |
KAnd().Length( ) + KSQLGetContentId().Length( ) );
|
|
728 |
aQuery.Append( KAnd );
|
|
729 |
aQuery.Append( KSQLGetContentId );
|
|
730 |
}
|
|
731 |
else
|
|
732 |
{
|
|
733 |
aQuery.ReAllocL( aQuery.Length( ) + KSQLGetContentId().Length( ) );
|
|
734 |
aQuery.Append( KSQLGetContentId );
|
|
735 |
}
|
|
736 |
nextFilter = ETrue;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
|
|
740 |
// ---------------------------------------------------------------------------
|
|
741 |
//
|
|
742 |
// ---------------------------------------------------------------------------
|
|
743 |
//
|
|
744 |
void CCPLiwMap::PrepareStmtforAddL( RSqlDatabase aSqlDb,
|
|
745 |
RSqlStatement& aStmt, const TDesC& aQuery ) const
|
|
746 |
{
|
|
747 |
CP_DEBUG( _L8("CCPLiwMap::PrepareStmtforAddL") );
|
|
748 |
RBuf publisher;
|
|
749 |
publisher.CleanupClosePushL();
|
|
750 |
RBuf content_type;
|
|
751 |
content_type.CleanupClosePushL();
|
|
752 |
RBuf content_id;
|
|
753 |
content_id.CleanupClosePushL();
|
|
754 |
if ( GetPropertyL( KPublisherId, publisher )
|
|
755 |
&& GetPropertyL( KContentType, content_type )
|
|
756 |
&& GetPropertyL( KContentId, content_id ) )
|
|
757 |
{
|
|
758 |
User::LeaveIfError( aStmt.Prepare( aSqlDb, aQuery ) );
|
|
759 |
TInt publisherIndex = aStmt.ParameterIndex( KSQLPublisher );
|
|
760 |
TInt content_typeIndex = aStmt.ParameterIndex( KSQLContent_type );
|
|
761 |
TInt content_idIndex = aStmt.ParameterIndex( KSQLContent_id );
|
|
762 |
|
|
763 |
BindTextL( aStmt, publisherIndex, publisher );
|
|
764 |
BindTextL( aStmt, content_typeIndex, content_type );
|
|
765 |
BindTextL( aStmt, content_idIndex, content_id );
|
|
766 |
}
|
|
767 |
else
|
|
768 |
{
|
|
769 |
User::Leave( KErrArgument );
|
|
770 |
}
|
|
771 |
CleanupStack::PopAndDestroy( &content_id );
|
|
772 |
CleanupStack::PopAndDestroy( &content_type );
|
|
773 |
CleanupStack::PopAndDestroy( &publisher );
|
|
774 |
}
|
|
775 |
|
|
776 |
// ---------------------------------------------------------------------------
|
|
777 |
//
|
|
778 |
// ---------------------------------------------------------------------------
|
|
779 |
//
|
|
780 |
TUint CCPLiwMap::GetFilterL( )const
|
|
781 |
{
|
|
782 |
CP_DEBUG( _L8("CCPLiwMap::GetFilterL") );
|
|
783 |
TUint result (0);
|
|
784 |
if(IsPublisherNameL())
|
|
785 |
{
|
|
786 |
result |= EPublisher;
|
|
787 |
}
|
|
788 |
if(IsContentTypeL())
|
|
789 |
{
|
|
790 |
result |= EContentType;
|
|
791 |
}
|
|
792 |
if(IsContentIdL())
|
|
793 |
{
|
|
794 |
result |= EContentId;
|
|
795 |
}
|
|
796 |
if(IsFlag())
|
|
797 |
{
|
|
798 |
result |= EFlag;
|
|
799 |
}
|
|
800 |
return result;
|
|
801 |
}
|
|
802 |
|
|
803 |
// ---------------------------------------------------------------------------
|
|
804 |
//
|
|
805 |
// ---------------------------------------------------------------------------
|
|
806 |
//
|
|
807 |
CCPLiwMap::TCPSortOrder CCPLiwMap::GetSortL() const
|
|
808 |
{
|
|
809 |
CP_DEBUG( _L8("CCPLiwMap::GetSortL") );
|
|
810 |
TCPSortOrder result(ECPRecent);
|
|
811 |
RBuf sort;
|
|
812 |
sort.CleanupClosePushL();
|
|
813 |
if ( GetPropertyL( KSortOrder, sort ) )
|
|
814 |
{
|
|
815 |
if ( !sort.Compare( KSortRecent ) )
|
|
816 |
{
|
|
817 |
result = ECPRecent;
|
|
818 |
}
|
|
819 |
else if ( !sort.Compare( KSortPublisher ) )
|
|
820 |
{
|
|
821 |
result = ECPPublisher;
|
|
822 |
}
|
|
823 |
else if ( !sort.Compare( KSortContentType ) )
|
|
824 |
{
|
|
825 |
result = ECPContent;
|
|
826 |
}
|
|
827 |
else if ( !sort.Compare( KSortContentId ) )
|
|
828 |
{
|
|
829 |
result = ECPContentId;
|
|
830 |
}
|
|
831 |
}
|
|
832 |
CleanupStack::PopAndDestroy( &sort );
|
|
833 |
return result;
|
|
834 |
}
|
|
835 |
|
|
836 |
// ---------------------------------------------------------------------------
|
|
837 |
//
|
|
838 |
// ---------------------------------------------------------------------------
|
|
839 |
//
|
|
840 |
TBool CCPLiwMap::IsPublisherNameL() const
|
|
841 |
{
|
|
842 |
return IsPropertyValidL( KPublisherId );
|
|
843 |
}
|
|
844 |
|
|
845 |
// ---------------------------------------------------------------------------
|
|
846 |
//
|
|
847 |
// ---------------------------------------------------------------------------
|
|
848 |
//
|
|
849 |
TBool CCPLiwMap::IsContentTypeL() const
|
|
850 |
{
|
|
851 |
return IsPropertyValidL( KContentType );
|
|
852 |
}
|
|
853 |
|
|
854 |
// ---------------------------------------------------------------------------
|
|
855 |
//
|
|
856 |
// ---------------------------------------------------------------------------
|
|
857 |
//
|
|
858 |
TBool CCPLiwMap::IsContentIdL() const
|
|
859 |
{
|
|
860 |
return IsPropertyValidL( KContentId );
|
|
861 |
}
|
|
862 |
|
|
863 |
// ---------------------------------------------------------------------------
|
|
864 |
//
|
|
865 |
// ---------------------------------------------------------------------------
|
|
866 |
//
|
|
867 |
TBool CCPLiwMap::IsTriggerL( ) const
|
|
868 |
{
|
|
869 |
TBool result(EFalse);
|
|
870 |
TInt pos( 0 );
|
|
871 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos,
|
|
872 |
KActionTrigger );
|
|
873 |
if ( pos != KErrNotFound )
|
|
874 |
{
|
|
875 |
result = ETrue;
|
|
876 |
LIW::TVariantTypeId variantType = paramForValue->Value().TypeId();
|
|
877 |
if ( variantType != EVariantTypeDesC &&
|
|
878 |
variantType != EVariantTypeDesC8 &&
|
|
879 |
variantType != EVariantTypeList )
|
|
880 |
{
|
|
881 |
User::Leave( KErrBadName );
|
|
882 |
}
|
|
883 |
}
|
|
884 |
return result;
|
|
885 |
}
|
|
886 |
|
|
887 |
// ---------------------------------------------------------------------------
|
|
888 |
//
|
|
889 |
// ---------------------------------------------------------------------------
|
|
890 |
//
|
|
891 |
TBool CCPLiwMap::IsFlag( ) const
|
|
892 |
{
|
|
893 |
TInt32 buffer( 0 );
|
|
894 |
return GetProperty( KFlag, buffer );
|
|
895 |
}
|
|
896 |
|
|
897 |
// ---------------------------------------------------------------------------
|
|
898 |
//
|
|
899 |
// ---------------------------------------------------------------------------
|
|
900 |
//
|
|
901 |
TBool CCPLiwMap::IsId() const
|
|
902 |
{
|
|
903 |
TInt32 id( 0);
|
|
904 |
return GetProperty( KId, id );
|
|
905 |
}
|
|
906 |
|
|
907 |
// ---------------------------------------------------------------------------
|
|
908 |
//
|
|
909 |
// ---------------------------------------------------------------------------
|
|
910 |
//
|
|
911 |
TBool CCPLiwMap::PropertyExists( const TDesC8& aProperty ) const
|
|
912 |
{
|
|
913 |
TBool result( EFalse );
|
|
914 |
TInt pos( 0 );
|
|
915 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
|
|
916 |
if ( pos != KErrNotFound )
|
|
917 |
{
|
|
918 |
result = ETrue;
|
|
919 |
}
|
|
920 |
return result;
|
|
921 |
}
|
|
922 |
|
|
923 |
|
|
924 |
// ---------------------------------------------------------------------------
|
|
925 |
//
|
|
926 |
// ---------------------------------------------------------------------------
|
|
927 |
//
|
|
928 |
TUint CCPLiwMap::GetListL( RSqlDatabase aSqlDb, const TDesC& aQuery,
|
|
929 |
CLiwGenericParamList* aList, RArray<TInt32>& aItemsToDelete ) const
|
|
930 |
{
|
|
931 |
CP_DEBUG( _L8("CCPLiwMap::GetListL") );
|
|
932 |
RBuf sqlquery;
|
|
933 |
sqlquery.CleanupClosePushL();
|
|
934 |
sqlquery.CreateL( aQuery );
|
|
935 |
TInt32 id( 0);
|
|
936 |
if ( GetProperty( KId, id ) )
|
|
937 |
{
|
|
938 |
ConstructSelectIdL( sqlquery );
|
|
939 |
}
|
|
940 |
else
|
|
941 |
{
|
|
942 |
ConstructGetListSelectL( sqlquery );
|
|
943 |
}
|
|
944 |
RSqlStatement stmt;
|
|
945 |
CleanupClosePushL( stmt );
|
|
946 |
User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
|
|
947 |
BindValueL( sqlquery, stmt );
|
|
948 |
SaveQueryResultsL( stmt, *aList, aItemsToDelete );
|
|
949 |
CleanupStack::PopAndDestroy( &stmt ) ;
|
|
950 |
CleanupStack::PopAndDestroy( &sqlquery );
|
|
951 |
return aList->Count( );
|
|
952 |
}
|
|
953 |
|
|
954 |
// ---------------------------------------------------------------------------
|
|
955 |
//
|
|
956 |
// ---------------------------------------------------------------------------
|
|
957 |
//
|
|
958 |
void CCPLiwMap::RemoveL( RSqlDatabase aSqlDb, const TDesC& aQuery ) const
|
|
959 |
{
|
|
960 |
CP_DEBUG( _L8("CCPLiwMap::RemoveL") );
|
|
961 |
RBuf sqlquery;
|
|
962 |
sqlquery.CleanupClosePushL();
|
|
963 |
sqlquery.CreateL( aQuery );
|
|
964 |
TInt32 id( 0);
|
|
965 |
if ( GetProperty( KId, id ) )
|
|
966 |
{
|
|
967 |
ConstructSelectIdL( sqlquery );
|
|
968 |
}
|
|
969 |
else
|
|
970 |
{
|
|
971 |
ConstructRemoveSelectL( sqlquery, EFalse );
|
|
972 |
}
|
|
973 |
|
|
974 |
RSqlStatement stmt;
|
|
975 |
CleanupClosePushL( stmt );
|
|
976 |
User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
|
|
977 |
|
|
978 |
BindValueL( sqlquery, stmt );
|
|
979 |
if ( stmt.Exec( ) <= 0 )
|
|
980 |
{
|
|
981 |
User::Leave( KErrNotFound );
|
|
982 |
}
|
|
983 |
CleanupStack::PopAndDestroy( &stmt ) ;
|
|
984 |
CleanupStack::PopAndDestroy( &sqlquery );
|
|
985 |
}
|
|
986 |
// ---------------------------------------------------------------------------
|
|
987 |
//
|
|
988 |
// ---------------------------------------------------------------------------
|
|
989 |
//
|
|
990 |
void CCPLiwMap::FetchIdsL( TInt32 aId, const TDesC& aQuery,
|
|
991 |
CLiwDefaultMap* aMap, RSqlDatabase aSqlDb ) const
|
|
992 |
{
|
|
993 |
CP_DEBUG( _L8("CCPLiwMap::FetchIdsL") );
|
|
994 |
RSqlStatement stmt;
|
|
995 |
CleanupClosePushL( stmt );
|
|
996 |
//prepare statment for "Get Ids" (Publisher, ContentType,ContentId)
|
|
997 |
User::LeaveIfError( stmt.Prepare( aSqlDb, aQuery ) );
|
|
998 |
TInt idIndex = stmt.ParameterIndex( KSQLId );
|
|
999 |
User::LeaveIfError( stmt.BindInt( idIndex, aId ) );
|
|
1000 |
|
|
1001 |
TInt publisherIndex = ColumnIndexL( stmt, KColumnPublisher );
|
|
1002 |
TInt contentTypeIndex = ColumnIndexL( stmt, KColumnContent_type );
|
|
1003 |
TInt contentIdIndex = ColumnIndexL( stmt, KColumnContent_id );
|
|
1004 |
TInt acl_Index = ColumnIndexL( stmt, KColumnAccessList );
|
|
1005 |
|
|
1006 |
if ( stmt.Next( ) == KSqlAtRow )
|
|
1007 |
{
|
|
1008 |
if( iPolicy )
|
|
1009 |
{
|
|
1010 |
TPtrC8 acl;
|
|
1011 |
User::LeaveIfError( stmt.ColumnBinary( acl_Index, acl ) );
|
|
1012 |
if( !iPolicy->CheckSecurityL( acl , CCPSecurityPolicy::EWrite ) )
|
|
1013 |
{
|
|
1014 |
User::Leave( KErrPermissionDenied );
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
TPtrC publisher;
|
|
1018 |
User::LeaveIfError( stmt.ColumnText( publisherIndex, publisher ) );
|
|
1019 |
TPtrC content_type;
|
|
1020 |
User::LeaveIfError( stmt.ColumnText( contentTypeIndex, content_type ) );
|
|
1021 |
TPtrC content_id;
|
|
1022 |
User::LeaveIfError( stmt.ColumnText( contentIdIndex, content_id ) );
|
|
1023 |
aMap->InsertL( KId, TLiwVariant( aId ) );
|
|
1024 |
aMap->InsertL( KPublisherId, TLiwVariant( publisher ) );
|
|
1025 |
aMap->InsertL( KContentType, TLiwVariant( content_type ) );
|
|
1026 |
aMap->InsertL( KContentId, TLiwVariant( content_id ) );
|
|
1027 |
aMap->InsertL( KOperation, TLiwVariant( KOperationUpdate ) );
|
|
1028 |
}
|
|
1029 |
CleanupStack::PopAndDestroy( &stmt ) ;
|
|
1030 |
}
|
|
1031 |
|
|
1032 |
// ---------------------------------------------------------------------------
|
|
1033 |
//
|
|
1034 |
// ---------------------------------------------------------------------------
|
|
1035 |
//
|
|
1036 |
void CCPLiwMap::FetchIdL( RSqlDatabase aSqlDb, const TDesC& aQuery,
|
|
1037 |
TInt32& aId ) const
|
|
1038 |
{
|
|
1039 |
CP_DEBUG( _L8("CCPLiwMap::FetchIdL") );
|
|
1040 |
aId = 0;
|
|
1041 |
RSqlStatement stmt;
|
|
1042 |
CleanupClosePushL( stmt );
|
|
1043 |
PrepareStmtforAddL( aSqlDb, stmt, aQuery );
|
|
1044 |
TInt idIndex = ColumnIndexL( stmt, KColumnId );
|
|
1045 |
if ( stmt.Next( ) == KSqlAtRow )
|
|
1046 |
{
|
|
1047 |
aId = stmt.ColumnInt( idIndex );
|
|
1048 |
}
|
|
1049 |
CleanupStack::PopAndDestroy( &stmt ) ;
|
|
1050 |
}
|
|
1051 |
|
|
1052 |
// ---------------------------------------------------------------------------
|
|
1053 |
//
|
|
1054 |
// ---------------------------------------------------------------------------
|
|
1055 |
//
|
|
1056 |
void CCPLiwMap::GetIdsOfRemovedEntriesL( RSqlDatabase aSqlDb,
|
|
1057 |
const TDesC& aQuery, CLiwDefaultList* aList ) const
|
|
1058 |
{
|
|
1059 |
CP_DEBUG( _L8("CCPLiwMap::GetIdsOfRemovedEntriesL") );
|
|
1060 |
RBuf sqlquery;
|
|
1061 |
sqlquery.CleanupClosePushL();
|
|
1062 |
sqlquery.CreateL( aQuery );
|
|
1063 |
TInt32 id( 0);
|
|
1064 |
if ( GetProperty( KId, id ) )
|
|
1065 |
{
|
|
1066 |
ConstructSelectIdL( sqlquery );
|
|
1067 |
}
|
|
1068 |
else
|
|
1069 |
{
|
|
1070 |
ConstructRemoveSelectL( sqlquery );
|
|
1071 |
}
|
|
1072 |
RSqlStatement stmt;
|
|
1073 |
CleanupClosePushL( stmt );
|
|
1074 |
User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
|
|
1075 |
BindValueL( sqlquery, stmt );
|
|
1076 |
SaveQueryResultsIdsL( stmt, aList );
|
|
1077 |
if( aList && aList->Count()==0 )
|
|
1078 |
{
|
|
1079 |
User::Leave( KErrNotFound );
|
|
1080 |
}
|
|
1081 |
CleanupStack::PopAndDestroy( &stmt ) ;
|
|
1082 |
CleanupStack::PopAndDestroy( &sqlquery );
|
|
1083 |
}
|
|
1084 |
|
|
1085 |
// ---------------------------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
// ---------------------------------------------------------------------------
|
|
1088 |
//
|
|
1089 |
void CCPLiwMap::SaveQueryResultsIdsL( RSqlStatement& aStmt,
|
|
1090 |
CLiwDefaultList* aList ) const
|
|
1091 |
{
|
|
1092 |
CP_DEBUG( _L8("CCPLiwMap::SaveQueryResultsIdsL") );
|
|
1093 |
TInt acl_Index = ColumnIndexL( aStmt, KColumnAccessList );
|
|
1094 |
|
|
1095 |
while ( aStmt.Next( ) == KSqlAtRow )
|
|
1096 |
{
|
|
1097 |
if( iPolicy )
|
|
1098 |
{
|
|
1099 |
TPtrC8 acl;
|
|
1100 |
User::LeaveIfError( aStmt.ColumnBinary( acl_Index, acl ) );
|
|
1101 |
if ( !iPolicy->CheckSecurityL( acl ,
|
|
1102 |
CCPSecurityPolicy::EDelete ) )
|
|
1103 |
{
|
|
1104 |
User::Leave( KErrPermissionDenied );
|
|
1105 |
}
|
|
1106 |
}
|
|
1107 |
if ( aList )
|
|
1108 |
{
|
|
1109 |
CLiwDefaultMap* targetMap = CLiwDefaultMap::NewLC( );
|
|
1110 |
FillChangeInfoMapL( aStmt, targetMap );
|
|
1111 |
aList->AppendL( TLiwVariant( targetMap ) );
|
|
1112 |
CleanupStack::PopAndDestroy( targetMap );
|
|
1113 |
}
|
|
1114 |
}
|
|
1115 |
}
|
|
1116 |
|
|
1117 |
// ---------------------------------------------------------------------------
|
|
1118 |
//
|
|
1119 |
// ---------------------------------------------------------------------------
|
|
1120 |
//
|
|
1121 |
void CCPLiwMap::ConstructSelectIdL( RBuf& aQuery ) const
|
|
1122 |
{
|
|
1123 |
aQuery.ReAllocL( aQuery.Length( ) + KSQLGetId().Length( ) +
|
|
1124 |
KWhere().Length() );
|
|
1125 |
aQuery.Append( KWhere );
|
|
1126 |
aQuery.Append( KSQLGetId );
|
|
1127 |
}
|
|
1128 |
|
|
1129 |
// ---------------------------------------------------------------------------
|
|
1130 |
//
|
|
1131 |
// ---------------------------------------------------------------------------
|
|
1132 |
//
|
|
1133 |
void CCPLiwMap::ConstructGetListSelectL( RBuf& aQuery, TBool aGet ) const
|
|
1134 |
{
|
|
1135 |
TUint filter = GetFilterL( );
|
|
1136 |
AppendGetListFilterL( aQuery, filter );
|
|
1137 |
if ( aGet )
|
|
1138 |
{
|
|
1139 |
AppendSortL( aQuery, GetSortL( ) );
|
|
1140 |
}
|
|
1141 |
}
|
|
1142 |
|
|
1143 |
// ---------------------------------------------------------------------------
|
|
1144 |
//
|
|
1145 |
// ---------------------------------------------------------------------------
|
|
1146 |
//
|
|
1147 |
void CCPLiwMap::ConstructRemoveSelectL( RBuf& aQuery, TBool aGet ) const
|
|
1148 |
{
|
|
1149 |
TUint filter = GetFilterL( );
|
|
1150 |
AppendRemoveFilterL( aQuery, filter );
|
|
1151 |
if ( aGet )
|
|
1152 |
{
|
|
1153 |
AppendSortL( aQuery, GetSortL( ) );
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
|
|
1157 |
// ---------------------------------------------------------------------------
|
|
1158 |
//
|
|
1159 |
// ---------------------------------------------------------------------------
|
|
1160 |
//
|
|
1161 |
void CCPLiwMap::BindValueL( const RBuf& aQuery, RSqlStatement& aStmt ) const
|
|
1162 |
{
|
|
1163 |
CP_DEBUG( _L8("CCPLiwMap::BindValueL") );
|
|
1164 |
if ( aQuery.Find( KSQLGetPublisher ) != KErrNotFound )
|
|
1165 |
{
|
|
1166 |
TInt param = aStmt.ParameterIndex( KSQLPublisher );
|
|
1167 |
RBuf publisher;
|
|
1168 |
publisher.CleanupClosePushL();
|
|
1169 |
User::LeaveIfError( GetPropertyL( KPublisherId, publisher ));
|
|
1170 |
BindTextL( aStmt, param, publisher );
|
|
1171 |
CleanupStack::PopAndDestroy( &publisher );
|
|
1172 |
}
|
|
1173 |
if ( aQuery.Find( KSQLGetContentType ) != KErrNotFound )
|
|
1174 |
{
|
|
1175 |
TInt param = aStmt.ParameterIndex( KSQLContent_type );
|
|
1176 |
RBuf content_type;
|
|
1177 |
content_type.CleanupClosePushL();
|
|
1178 |
User::LeaveIfError( GetPropertyL( KContentType, content_type ));
|
|
1179 |
BindTextL( aStmt, param, content_type );
|
|
1180 |
CleanupStack::PopAndDestroy( &content_type );
|
|
1181 |
}
|
|
1182 |
if ( aQuery.Find( KSQLGetContentId ) != KErrNotFound )
|
|
1183 |
{
|
|
1184 |
TInt param = aStmt.ParameterIndex( KSQLContent_id );
|
|
1185 |
RBuf content_id;
|
|
1186 |
content_id.CleanupClosePushL();
|
|
1187 |
User::LeaveIfError( GetPropertyL( KContentId, content_id ));
|
|
1188 |
BindTextL( aStmt, param, content_id );
|
|
1189 |
CleanupStack::PopAndDestroy( &content_id );
|
|
1190 |
}
|
|
1191 |
if ( aQuery.Find( KSQLGetId ) != KErrNotFound )
|
|
1192 |
{
|
|
1193 |
TInt param = aStmt.ParameterIndex( KSQLId );
|
|
1194 |
TInt32 id( 0);
|
|
1195 |
User::LeaveIfError( GetProperty( KId, id ));
|
|
1196 |
BindIntL( aStmt, param, id );
|
|
1197 |
}
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
// ---------------------------------------------------------------------------
|
|
1201 |
//
|
|
1202 |
// ---------------------------------------------------------------------------
|
|
1203 |
//
|
|
1204 |
TBool CCPLiwMap::IsGetListAllL( TUint aFilter ) const
|
|
1205 |
{
|
|
1206 |
TBool result( EFalse );
|
|
1207 |
if ( !( aFilter & EContentType ) &&
|
|
1208 |
!( aFilter & EContentId ) &&
|
|
1209 |
!( aFilter & EPublisher ) )
|
|
1210 |
{
|
|
1211 |
result = ETrue;
|
|
1212 |
}
|
|
1213 |
else if ( ( aFilter & EContentType ) &&
|
|
1214 |
( aFilter & EContentId ) &&
|
|
1215 |
( aFilter & EPublisher ) )
|
|
1216 |
{
|
|
1217 |
RBuf publisher;
|
|
1218 |
publisher.CleanupClosePushL();
|
|
1219 |
RBuf content_type;
|
|
1220 |
content_type.CleanupClosePushL();
|
|
1221 |
RBuf content_id;
|
|
1222 |
content_id.CleanupClosePushL();
|
|
1223 |
GetPropertyL( KPublisherId, publisher );
|
|
1224 |
GetPropertyL( KContentType, content_type );
|
|
1225 |
GetPropertyL( KContentId, content_id );
|
|
1226 |
|
|
1227 |
if( ( publisher == KAll ) &&
|
|
1228 |
( content_type == KAll ) &&
|
|
1229 |
( content_id == KAll) )
|
|
1230 |
{
|
|
1231 |
result = ETrue;
|
|
1232 |
}
|
|
1233 |
CleanupStack::PopAndDestroy( &content_id );
|
|
1234 |
CleanupStack::PopAndDestroy( &content_type );
|
|
1235 |
CleanupStack::PopAndDestroy( &publisher );
|
|
1236 |
}
|
|
1237 |
return result;
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
// ---------------------------------------------------------------------------
|
|
1241 |
//
|
|
1242 |
// ---------------------------------------------------------------------------
|
|
1243 |
//
|
|
1244 |
void CCPLiwMap::RemoveAllAttributeL( TUint& aFilter ) const
|
|
1245 |
{
|
|
1246 |
RBuf publisher;
|
|
1247 |
publisher.CleanupClosePushL();
|
|
1248 |
RBuf content_type;
|
|
1249 |
content_type.CleanupClosePushL();
|
|
1250 |
RBuf content_id;
|
|
1251 |
content_id.CleanupClosePushL();
|
|
1252 |
GetPropertyL( KPublisherId, publisher );
|
|
1253 |
GetPropertyL( KContentType, content_type );
|
|
1254 |
GetPropertyL( KContentId, content_id );
|
|
1255 |
|
|
1256 |
if( publisher == KAll )
|
|
1257 |
{
|
|
1258 |
iMap->Remove( KPublisherId );
|
|
1259 |
aFilter = aFilter & ~EPublisher;
|
|
1260 |
}
|
|
1261 |
if( content_type == KAll )
|
|
1262 |
{
|
|
1263 |
iMap->Remove( KContentType );
|
|
1264 |
aFilter = aFilter & ~EContentType;
|
|
1265 |
}
|
|
1266 |
if( content_id == KAll )
|
|
1267 |
{
|
|
1268 |
iMap->Remove( KContentId );
|
|
1269 |
aFilter = aFilter & ~EContentId;
|
|
1270 |
}
|
|
1271 |
|
|
1272 |
CleanupStack::PopAndDestroy( &content_id );
|
|
1273 |
CleanupStack::PopAndDestroy( &content_type );
|
|
1274 |
CleanupStack::PopAndDestroy( &publisher );
|
|
1275 |
|
|
1276 |
}
|
|
1277 |
|
|
1278 |
// ---------------------------------------------------------------------------
|
|
1279 |
//
|
|
1280 |
// ---------------------------------------------------------------------------
|
|
1281 |
//
|
|
1282 |
void CCPLiwMap::ConstructL()
|
|
1283 |
{
|
|
1284 |
iMap = CLiwGenericParamList::NewL( );
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
// ---------------------------------------------------------------------------
|
|
1288 |
//
|
|
1289 |
// ---------------------------------------------------------------------------
|
|
1290 |
//
|
|
1291 |
TBool CCPLiwMap::IsTypePublisherL( const TLiwVariant& aVariant )
|
|
1292 |
{
|
|
1293 |
TBool result (EFalse);
|
|
1294 |
RBuf typeBuf;
|
|
1295 |
typeBuf.CleanupClosePushL();
|
|
1296 |
TPtrC type( KNullDesC );
|
|
1297 |
if( !aVariant.Get( type ) )
|
|
1298 |
{
|
|
1299 |
TPtrC8 type8( KNullDesC8 );
|
|
1300 |
if( !aVariant.Get( type8 ) )
|
|
1301 |
{
|
|
1302 |
User::Leave( KErrBadName );
|
|
1303 |
}
|
|
1304 |
typeBuf.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( type8 ) );
|
|
1305 |
}
|
|
1306 |
else
|
|
1307 |
{
|
|
1308 |
typeBuf.CreateL( type );
|
|
1309 |
}
|
|
1310 |
if( typeBuf.Find( KCpData () ) != KErrNotFound )
|
|
1311 |
{
|
|
1312 |
result = EFalse;
|
|
1313 |
}
|
|
1314 |
else if ( typeBuf.Find( KPublisher () ) != KErrNotFound )
|
|
1315 |
{
|
|
1316 |
result = ETrue;
|
|
1317 |
}
|
|
1318 |
else
|
|
1319 |
{
|
|
1320 |
User::Leave( KErrArgument );
|
|
1321 |
}
|
|
1322 |
CleanupStack::PopAndDestroy( &typeBuf );
|
|
1323 |
return result;
|
|
1324 |
}
|
|
1325 |
|
|
1326 |
|
|
1327 |
// ---------------------------------------------------------------------------
|
|
1328 |
//
|
|
1329 |
// ---------------------------------------------------------------------------
|
|
1330 |
//
|
|
1331 |
void CCPLiwMap::CheckIdentifiersL() const
|
|
1332 |
{
|
|
1333 |
IsPublisherNameL();
|
|
1334 |
IsContentTypeL();
|
|
1335 |
IsContentIdL();
|
|
1336 |
}
|
|
1337 |
|
|
1338 |
// ---------------------------------------------------------------------------
|
|
1339 |
//
|
|
1340 |
// ---------------------------------------------------------------------------
|
|
1341 |
//
|
|
1342 |
void CCPLiwMap::BindTextL(RSqlStatement& aStmt, TInt aParameterIndex,
|
|
1343 |
const TDesC& aParameterText) const
|
|
1344 |
{
|
|
1345 |
User::LeaveIfError( aParameterIndex );
|
|
1346 |
User::LeaveIfError( aStmt.BindText( aParameterIndex, aParameterText ) );
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
// ---------------------------------------------------------------------------
|
|
1350 |
//
|
|
1351 |
// ---------------------------------------------------------------------------
|
|
1352 |
//
|
|
1353 |
void CCPLiwMap::BindBinaryL(RSqlStatement& aStmt, TInt aParameterIndex,
|
|
1354 |
const TDesC8& aParameterData) const
|
|
1355 |
{
|
|
1356 |
User::LeaveIfError(aParameterIndex);
|
|
1357 |
User::LeaveIfError(aStmt.BindBinary(aParameterIndex, aParameterData));
|
|
1358 |
}
|
|
1359 |
|
|
1360 |
// ---------------------------------------------------------------------------
|
|
1361 |
//
|
|
1362 |
// ---------------------------------------------------------------------------
|
|
1363 |
//
|
|
1364 |
void CCPLiwMap::BindInt64L(RSqlStatement& aStmt, TInt aParameterIndex,
|
|
1365 |
TInt64 aParameterValue) const
|
|
1366 |
{
|
|
1367 |
User::LeaveIfError(aParameterIndex);
|
|
1368 |
User::LeaveIfError(aStmt.BindInt64(aParameterIndex, aParameterValue));
|
|
1369 |
}
|
|
1370 |
|
|
1371 |
// ---------------------------------------------------------------------------
|
|
1372 |
//
|
|
1373 |
// ---------------------------------------------------------------------------
|
|
1374 |
//
|
|
1375 |
void CCPLiwMap::BindIntL(RSqlStatement& aStmt, TInt aParameterIndex,
|
|
1376 |
TInt aParameterValue) const
|
|
1377 |
{
|
|
1378 |
User::LeaveIfError(aParameterIndex);
|
|
1379 |
User::LeaveIfError(aStmt.BindInt(aParameterIndex, aParameterValue));
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
// ---------------------------------------------------------------------------
|
|
1383 |
//
|
|
1384 |
// ---------------------------------------------------------------------------
|
|
1385 |
//
|
|
1386 |
TInt CCPLiwMap::ColumnIndexL(RSqlStatement& aStmt, const TDesC& aColumnName )
|
|
1387 |
const
|
|
1388 |
{
|
|
1389 |
TInt ret( aStmt.ColumnIndex( aColumnName ) );
|
|
1390 |
User::LeaveIfError( ret );
|
|
1391 |
return ret;
|
|
1392 |
}
|
|
1393 |
|
|
1394 |
// ---------------------------------------------------------------------------
|
|
1395 |
//
|
|
1396 |
// ---------------------------------------------------------------------------
|
|
1397 |
//
|
|
1398 |
TBool CCPLiwMap::IsPropertyValidL( const TDesC8& aProperty ) const
|
|
1399 |
{
|
|
1400 |
CP_DEBUG( _L8("CCPLiwMap::IsPropertyValidL") );
|
|
1401 |
TBool found( EFalse );
|
|
1402 |
TInt pos( 0 );
|
|
1403 |
const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
|
|
1404 |
if ( pos != KErrNotFound )
|
|
1405 |
{
|
|
1406 |
found = ETrue;
|
|
1407 |
TInt length(0);
|
|
1408 |
if( paramForValue->Value().TypeId() == EVariantTypeDesC )
|
|
1409 |
{
|
|
1410 |
length = paramForValue->Value().AsDes().Length();
|
|
1411 |
}
|
|
1412 |
else if ( paramForValue->Value().TypeId() == EVariantTypeDesC8 )
|
|
1413 |
{
|
|
1414 |
length = paramForValue->Value().AsData().Length();
|
|
1415 |
}
|
|
1416 |
else
|
|
1417 |
{
|
|
1418 |
User::Leave( KErrBadName );
|
|
1419 |
}
|
|
1420 |
|
|
1421 |
if ( length == 0 )
|
|
1422 |
{
|
|
1423 |
User::Leave( KErrArgument );
|
|
1424 |
}
|
|
1425 |
}
|
|
1426 |
return found;
|
|
1427 |
}
|
|
1428 |
|