18 |
18 |
19 #include <s32mem.h> |
19 #include <s32mem.h> |
20 #include <liwgenericparam.h> |
20 #include <liwgenericparam.h> |
21 #include <escapeutils.h> |
21 #include <escapeutils.h> |
22 #include <badesca.h> |
22 #include <badesca.h> |
23 #include <aiwvarianttype.hrh> |
|
24 |
23 |
25 #include "cpliwmap.h" |
24 #include "cpliwmap.h" |
26 #include "cpdebug.h" |
25 #include "cpdebug.h" |
27 #include "cpssqlcommands.h" |
26 #include "cpssqlcommands.h" |
28 #include "ccontentmap.h" |
27 #include "ccontentmap.h" |
29 #include "cpublisherregistrymap.h" |
28 #include "cpublisherregistrymap.h" |
30 #include "cpsecuritypolicy.h" |
29 #include "cpsecuritypolicy.h" |
31 |
30 |
|
31 using namespace LIW; |
|
32 |
32 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
33 |
34 |
34 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
35 // |
36 // |
36 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
54 TInt pos( 0 ); |
55 TInt pos( 0 ); |
55 param = aList.FindFirst( pos, KType ); |
56 param = aList.FindFirst( pos, KType ); |
56 CCPLiwMap* map( NULL ); |
57 CCPLiwMap* map( NULL ); |
57 if( param && pos !=KErrNotFound ) |
58 if( param && pos !=KErrNotFound ) |
58 { |
59 { |
59 RBuf typeBuf; |
60 if( IsTypePublisherL(param->Value()) ) |
60 typeBuf.CleanupClosePushL(); |
61 { |
61 TPtrC type( KNullDesC ); |
62 map = CPublisherRegistryMap::NewLC(); |
62 if( !param->Value().Get( type ) ) |
63 } |
63 { |
64 else |
64 TPtrC8 type8( KNullDesC8 ); |
|
65 if( !param->Value().Get( type8 ) ) |
|
66 { |
|
67 User::Leave( KErrBadName ); |
|
68 } |
|
69 typeBuf.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( type8 ) ); |
|
70 } |
|
71 else |
|
72 { |
|
73 typeBuf.CreateL( type ); |
|
74 } |
|
75 if( typeBuf.Find( KCpData () ) != KErrNotFound ) |
|
76 { |
65 { |
77 map = CContentMap::NewLC(); |
66 map = CContentMap::NewLC(); |
78 } |
67 } |
79 else if ( typeBuf.Find( KPublisher () ) != KErrNotFound ) |
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) ) |
80 { |
92 { |
81 map = CPublisherRegistryMap::NewLC(); |
93 map = CPublisherRegistryMap::NewLC(); |
82 } |
94 } |
83 else User::Leave( KErrArgument ); |
95 else |
84 map->SetL( aList ); |
96 { |
85 CleanupStack::Pop( map ); |
97 map = CContentMap::NewLC(); |
86 CleanupStack::PopAndDestroy( &typeBuf ); |
98 } |
|
99 map->SetL(aMap); |
|
100 CleanupStack::Pop(map); |
87 } |
101 } |
88 else |
102 else |
89 { |
103 { |
90 User::Leave( KErrPathNotFound ); |
104 User::Leave( KErrPathNotFound ); |
91 } |
105 } |
|
106 CleanupStack::PopAndDestroy(&typeVariant); |
92 return map; |
107 return map; |
93 } |
108 } |
94 |
109 |
95 // --------------------------------------------------------------------------- |
110 // --------------------------------------------------------------------------- |
96 // |
111 // |
97 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
98 // |
113 // |
99 EXPORT_C HBufC8* CCPLiwMap::PackForServerLC() const |
114 EXPORT_C HBufC8* CCPLiwMap::PackForServerLC() const |
280 } |
295 } |
281 } |
296 } |
282 return result; |
297 return result; |
283 } |
298 } |
284 |
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 } |
285 |
357 |
286 // --------------------------------------------------------------------------- |
358 // --------------------------------------------------------------------------- |
287 // |
359 // |
288 // --------------------------------------------------------------------------- |
360 // --------------------------------------------------------------------------- |
289 // |
361 // |
443 // |
515 // |
444 // --------------------------------------------------------------------------- |
516 // --------------------------------------------------------------------------- |
445 // |
517 // |
446 void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList ) |
518 void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList ) |
447 { |
519 { |
448 |
|
449 CP_DEBUG( _L8("CCPLiwMap::SetL") ); |
520 CP_DEBUG( _L8("CCPLiwMap::SetL") ); |
450 for ( TInt i = 0; i < aInParamList.Count( ); i++ ) |
521 for ( TInt i = 0; i < aInParamList.Count( ); i++ ) |
451 { |
522 { |
452 const TLiwGenericParam& param = aInParamList[i]; |
523 const TLiwGenericParam& param = aInParamList[i]; |
453 if ( param.Value().TypeId( ) == LIW::EVariantTypeMap ) |
524 ExtractParamL(param); |
454 { |
525 } |
455 const CLiwMap* map = param.Value().AsMap( ); |
526 } |
456 for ( TInt i = 0; i <map->Count( ); i++ ) |
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) |
457 { |
566 { |
458 TBuf8<128> key; |
567 IsProperOperationL(value); |
459 map->AtL( i, key ); |
|
460 TLiwVariant value; |
|
461 value.PushL( ); |
|
462 map->FindL( key, value ); |
|
463 if ( key == KOperation ) |
|
464 { |
|
465 IsProperOperationL( value ); |
|
466 } |
|
467 RBuf8 datadesc; |
|
468 datadesc.CleanupClosePushL(); |
|
469 if ( value.TypeId( ) == LIW::EVariantTypeMap ) |
|
470 { |
|
471 const CLiwMap* internalMap = value.AsMap( ); |
|
472 datadesc.CreateL( internalMap->Size( ) ); |
|
473 RDesWriteStream datastrm(datadesc); |
|
474 CleanupClosePushL( datastrm ); |
|
475 internalMap->ExternalizeL( datastrm ); |
|
476 datastrm.CommitL( ); |
|
477 CleanupStack::PopAndDestroy( &datastrm ); |
|
478 value.Reset( ); |
|
479 value.Set( datadesc ); |
|
480 } |
|
481 TLiwGenericParam data( key, value); |
|
482 iMap->AppendL( data ); |
|
483 CleanupStack::PopAndDestroy( &datadesc ); |
|
484 CleanupStack::PopAndDestroy( &value ); |
|
485 } |
568 } |
486 } |
569 RBuf8 datadesc; |
487 else |
570 datadesc.CleanupClosePushL(); |
488 { |
571 if (value.TypeId() == LIW::EVariantTypeMap) |
489 iMap->AppendL( param ); |
572 { |
490 } |
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); |
491 } |
592 } |
492 } |
593 } |
493 |
594 |
494 // --------------------------------------------------------------------------- |
595 // --------------------------------------------------------------------------- |
495 // |
596 // |
763 // |
864 // |
764 // --------------------------------------------------------------------------- |
865 // --------------------------------------------------------------------------- |
765 // |
866 // |
766 TBool CCPLiwMap::IsTriggerL( ) const |
867 TBool CCPLiwMap::IsTriggerL( ) const |
767 { |
868 { |
768 TBool result( EFalse ); |
869 TBool result(EFalse); |
769 RBuf8 buffer; |
870 TInt pos( 0 ); |
770 buffer.CleanupClosePushL(); |
871 const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, |
771 result = GetPropertyL( KActionTrigger, buffer ); |
872 KActionTrigger ); |
772 CleanupStack::PopAndDestroy( &buffer ); |
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 } |
773 return result; |
884 return result; |
774 } |
885 } |
775 |
886 |
776 // --------------------------------------------------------------------------- |
887 // --------------------------------------------------------------------------- |
777 // |
888 // |
1175 |
1286 |
1176 // --------------------------------------------------------------------------- |
1287 // --------------------------------------------------------------------------- |
1177 // |
1288 // |
1178 // --------------------------------------------------------------------------- |
1289 // --------------------------------------------------------------------------- |
1179 // |
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 // |
1180 void CCPLiwMap::CheckIdentifiersL() const |
1331 void CCPLiwMap::CheckIdentifiersL() const |
1181 { |
1332 { |
1182 IsPublisherNameL(); |
1333 IsPublisherNameL(); |
1183 IsContentTypeL(); |
1334 IsContentTypeL(); |
1184 IsContentIdL(); |
1335 IsContentIdL(); |