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 sourceList->AtL(i,trigger); |
|
337 if (trigger.TypeId() == EVariantTypeDesC8) |
|
338 { |
|
339 list->AppendL(trigger); |
|
340 } |
|
341 else if (trigger.TypeId() == EVariantTypeDesC) |
|
342 { |
|
343 RBuf8 desc8; |
|
344 desc8.CleanupClosePushL(); |
|
345 desc8.Assign( EscapeUtils::ConvertFromUnicodeToUtf8L( |
|
346 trigger.AsDes() ) ); |
|
347 list->AppendL(TLiwVariant(desc8)); |
|
348 CleanupStack::PopAndDestroy( &desc8 ); |
|
349 } |
|
350 } |
|
351 } |
|
352 } |
|
353 return list; |
|
354 } |
285 |
355 |
286 // --------------------------------------------------------------------------- |
356 // --------------------------------------------------------------------------- |
287 // |
357 // |
288 // --------------------------------------------------------------------------- |
358 // --------------------------------------------------------------------------- |
289 // |
359 // |
443 // |
513 // |
444 // --------------------------------------------------------------------------- |
514 // --------------------------------------------------------------------------- |
445 // |
515 // |
446 void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList ) |
516 void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList ) |
447 { |
517 { |
448 |
|
449 CP_DEBUG( _L8("CCPLiwMap::SetL") ); |
518 CP_DEBUG( _L8("CCPLiwMap::SetL") ); |
450 for ( TInt i = 0; i < aInParamList.Count( ); i++ ) |
519 for ( TInt i = 0; i < aInParamList.Count( ); i++ ) |
451 { |
520 { |
452 const TLiwGenericParam& param = aInParamList[i]; |
521 const TLiwGenericParam& param = aInParamList[i]; |
453 if ( param.Value().TypeId( ) == LIW::EVariantTypeMap ) |
522 ExtractParamL(param); |
454 { |
523 } |
455 const CLiwMap* map = param.Value().AsMap( ); |
524 } |
456 for ( TInt i = 0; i <map->Count( ); i++ ) |
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 void CCPLiwMap::SetL( const CLiwMap& aMap ) |
|
531 { |
|
532 CP_DEBUG( _L8("CCPLiwMap::SetL") ); |
|
533 for ( TInt i = 0; i < aMap.Count( ); i++ ) |
|
534 { |
|
535 TBuf8<128> key; |
|
536 aMap.AtL(i, key); |
|
537 TLiwVariant value; |
|
538 value.PushL(); |
|
539 aMap.FindL(key, value); |
|
540 TLiwGenericParam param(key,value); |
|
541 ExtractParamL(param); |
|
542 CleanupStack::PopAndDestroy(&value); |
|
543 } |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 void CCPLiwMap::ExtractParamL(const TLiwGenericParam& aParam) |
|
551 { |
|
552 CP_DEBUG( _L8("CCPLiwMap::ExtractVariantL") ); |
|
553 if (aParam.Value().TypeId() == LIW::EVariantTypeMap) |
|
554 { |
|
555 const CLiwMap* map = aParam.Value().AsMap(); |
|
556 for (TInt i = 0; i < map->Count(); i++) |
|
557 { |
|
558 TBuf8<128> key; |
|
559 map->AtL(i, key); |
|
560 TLiwVariant value; |
|
561 value.PushL(); |
|
562 map->FindL(key, value); |
|
563 if (key == KOperation) |
457 { |
564 { |
458 TBuf8<128> key; |
565 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 } |
566 } |
486 } |
567 RBuf8 datadesc; |
487 else |
568 datadesc.CleanupClosePushL(); |
488 { |
569 if (value.TypeId() == LIW::EVariantTypeMap) |
489 iMap->AppendL( param ); |
570 { |
490 } |
571 const CLiwMap* internalMap = value.AsMap(); |
|
572 datadesc.CreateL(internalMap->Size()); |
|
573 RDesWriteStream datastrm(datadesc); |
|
574 CleanupClosePushL(datastrm); |
|
575 internalMap->ExternalizeL(datastrm); |
|
576 datastrm.CommitL(); |
|
577 CleanupStack::PopAndDestroy(&datastrm); |
|
578 value.Reset(); |
|
579 value.Set(datadesc); |
|
580 } |
|
581 TLiwGenericParam data(key, value); |
|
582 iMap->AppendL(data); |
|
583 CleanupStack::PopAndDestroy(&datadesc); |
|
584 CleanupStack::PopAndDestroy(&value); |
|
585 } |
|
586 } |
|
587 else |
|
588 { |
|
589 iMap->AppendL(aParam); |
491 } |
590 } |
492 } |
591 } |
493 |
592 |
494 // --------------------------------------------------------------------------- |
593 // --------------------------------------------------------------------------- |
495 // |
594 // |
763 // |
862 // |
764 // --------------------------------------------------------------------------- |
863 // --------------------------------------------------------------------------- |
765 // |
864 // |
766 TBool CCPLiwMap::IsTriggerL( ) const |
865 TBool CCPLiwMap::IsTriggerL( ) const |
767 { |
866 { |
768 TBool result( EFalse ); |
867 TBool result(EFalse); |
769 RBuf8 buffer; |
868 TInt pos( 0 ); |
770 buffer.CleanupClosePushL(); |
869 const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, |
771 result = GetPropertyL( KActionTrigger, buffer ); |
870 KActionTrigger ); |
772 CleanupStack::PopAndDestroy( &buffer ); |
871 if ( pos != KErrNotFound ) |
|
872 { |
|
873 result = ETrue; |
|
874 LIW::TVariantTypeId variantType = paramForValue->Value().TypeId(); |
|
875 if ( variantType != EVariantTypeDesC && |
|
876 variantType != EVariantTypeDesC8 && |
|
877 variantType != EVariantTypeList ) |
|
878 { |
|
879 User::Leave( KErrBadName ); |
|
880 } |
|
881 } |
773 return result; |
882 return result; |
774 } |
883 } |
775 |
884 |
776 // --------------------------------------------------------------------------- |
885 // --------------------------------------------------------------------------- |
777 // |
886 // |
1175 |
1284 |
1176 // --------------------------------------------------------------------------- |
1285 // --------------------------------------------------------------------------- |
1177 // |
1286 // |
1178 // --------------------------------------------------------------------------- |
1287 // --------------------------------------------------------------------------- |
1179 // |
1288 // |
|
1289 TBool CCPLiwMap::IsTypePublisherL( const TLiwVariant& aVariant ) |
|
1290 { |
|
1291 TBool result (EFalse); |
|
1292 RBuf typeBuf; |
|
1293 typeBuf.CleanupClosePushL(); |
|
1294 TPtrC type( KNullDesC ); |
|
1295 if( !aVariant.Get( type ) ) |
|
1296 { |
|
1297 TPtrC8 type8( KNullDesC8 ); |
|
1298 if( !aVariant.Get( type8 ) ) |
|
1299 { |
|
1300 User::Leave( KErrBadName ); |
|
1301 } |
|
1302 typeBuf.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( type8 ) ); |
|
1303 } |
|
1304 else |
|
1305 { |
|
1306 typeBuf.CreateL( type ); |
|
1307 } |
|
1308 if( typeBuf.Find( KCpData () ) != KErrNotFound ) |
|
1309 { |
|
1310 result = EFalse; |
|
1311 } |
|
1312 else if ( typeBuf.Find( KPublisher () ) != KErrNotFound ) |
|
1313 { |
|
1314 result = ETrue; |
|
1315 } |
|
1316 else |
|
1317 { |
|
1318 User::Leave( KErrArgument ); |
|
1319 } |
|
1320 CleanupStack::PopAndDestroy( &typeBuf ); |
|
1321 return result; |
|
1322 } |
|
1323 |
|
1324 |
|
1325 // --------------------------------------------------------------------------- |
|
1326 // |
|
1327 // --------------------------------------------------------------------------- |
|
1328 // |
1180 void CCPLiwMap::CheckIdentifiersL() const |
1329 void CCPLiwMap::CheckIdentifiersL() const |
1181 { |
1330 { |
1182 IsPublisherNameL(); |
1331 IsPublisherNameL(); |
1183 IsContentTypeL(); |
1332 IsContentTypeL(); |
1184 IsContentIdL(); |
1333 IsContentIdL(); |