|
1 /* |
|
2 * Copyright (c) 2007-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: Implementation file for CAknLocalSkinInstance |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aknlocalskinlib.h" |
|
20 #include <AknsSrvDescriptorFileLayout.h> |
|
21 #include <AknsConstants.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <AknsImageAttributeData.h> |
|
24 #include <AknsSrvVariant.hrh> |
|
25 |
|
26 #include <caf/content.h> |
|
27 #include <DRMHelper.h> |
|
28 #include <caf/rightsmanager.h> |
|
29 |
|
30 #include <centralrepository.h> |
|
31 #include <AknLayoutDef.h> |
|
32 // CenRep keys. |
|
33 #include <AvkonInternalCRKeys.h> // KAknLayoutId |
|
34 #include <AknSkinsInternalCRKeys.h> // KPslnActiveSkinUid, ... |
|
35 |
|
36 #include <versioninfo.h> |
|
37 using namespace ContentAccess; |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 // Max of 32 effects per queue and 64 params per effect should be enough |
|
43 static const TInt KAknsSrvMaxEffectCount = 0x20; |
|
44 static const TInt KAknsSrvMaxEffectParamCount = 0x40; |
|
45 |
|
46 // There are nine images in one frame. |
|
47 const TInt KAknsSrvFrameIconCount = 9; |
|
48 |
|
49 _LIT(KAknsSrvScalableRomBmpLocation,":\\resource\\skins\\"); |
|
50 _LIT(KAknsSrvScalableRomBmpOldLocation, ":\\private\\10207114\\import\\"); |
|
51 _LIT(KAknsSrvPathEndSeparator, "\\"); |
|
52 |
|
53 _LIT(KDefaultSkinFilename, "Z:\\private\\10207114\\import\\101f84b9\\series60skin.skn"); |
|
54 |
|
55 |
|
56 class CSkinFilename : public CBase |
|
57 { |
|
58 HBufC* iFilename; |
|
59 TInt iId; |
|
60 }; |
|
61 |
|
62 |
|
63 TInt Int32(TUint8* dataPtr,TUint32 aOffset) |
|
64 { |
|
65 return *((TInt*)(dataPtr+aOffset)); |
|
66 } |
|
67 |
|
68 TUint Uint32(TUint8* dataPtr,TUint32 aOffset) |
|
69 { |
|
70 return *((TUint32*)(dataPtr+aOffset)); |
|
71 } |
|
72 |
|
73 |
|
74 TInt16 Int16(TUint8* dataPtr, TUint32 aOffset) |
|
75 { |
|
76 return *((TInt16*)(dataPtr+aOffset)); |
|
77 } |
|
78 |
|
79 TUint16 Uint16(TUint8* dataPtr, TUint32 aOffset) |
|
80 { |
|
81 return *((TUint16*)(dataPtr+aOffset)); |
|
82 } |
|
83 |
|
84 |
|
85 TInt8 Int8(TUint8* dataPtr, TUint32 aOffset) |
|
86 { |
|
87 return *((TInt8*)(dataPtr+aOffset)); |
|
88 } |
|
89 |
|
90 TUint8 Uint8(TUint8* dataPtr, TUint32 aOffset) |
|
91 { |
|
92 return *((TUint8*)(dataPtr+aOffset)); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // Constructor. |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CAknLocalSkinInstance* CAknLocalSkinInstance::NewL( |
|
101 const RFs& aFileSystem, const RAknsSrvSession& aSkinSrv) |
|
102 { |
|
103 CAknLocalSkinInstance* self = |
|
104 new (ELeave) CAknLocalSkinInstance(aFileSystem, aSkinSrv); |
|
105 |
|
106 VersionInfo::TPlatformVersion platformVersion; |
|
107 TRAPD( err,VersionInfo::GetVersion( platformVersion ) ); |
|
108 if ( !err ) |
|
109 { |
|
110 self->iPlatformMajor = platformVersion.iMajorVersion; |
|
111 self->iPlatformMinor = platformVersion.iMinorVersion; |
|
112 } |
|
113 else |
|
114 { |
|
115 self->iPlatformMajor = 0; |
|
116 self->iPlatformMinor = 0; |
|
117 } |
|
118 return self; |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // Apply the local skin. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C void CAknLocalSkinInstance::ApplyL( |
|
126 const TDesC& aFilename, RArray<TAknsItemID>& aItemsToOverride) |
|
127 { |
|
128 iOverriddenItems.Reset(); |
|
129 iNoColors = EFalse; |
|
130 iColorsFound = EFalse; |
|
131 |
|
132 iItemsToOVerride = aItemsToOverride; |
|
133 iInitialCount = iItemsToOVerride.Count(); |
|
134 |
|
135 |
|
136 TRAPD(err,DoApplyL(aFilename)); |
|
137 |
|
138 User::LeaveIfError(err); |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // Start Apply procedure. |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CAknLocalSkinInstance::DoApplyL(const TDesC& aFilename) |
|
148 { |
|
149 |
|
150 |
|
151 ProcessSkinFileL( KDefaultSkinFilename , ETrue ); |
|
152 //-------------------------- |
|
153 |
|
154 MAknsSkinInstance* si = AknsUtils::SkinInstance(); |
|
155 si->SetChangeEventsEnabled( EFalse ); |
|
156 si->RemoveLocalItemDefs(); |
|
157 TInt count = 0; |
|
158 |
|
159 // force scalable elements to NULL if they are not found from the skin |
|
160 CAknsEffectQueueItemDef* override = NULL; |
|
161 if (iInitialCount != iItemsToOVerride.Count()) |
|
162 { |
|
163 for (count = 0; count < iItemsToOVerride.Count(); count++) |
|
164 { |
|
165 TAknsItemID id = iItemsToOVerride[count]; |
|
166 if ( IsScalableItem( id ) && !AlreadyOverrideElement(id) ) |
|
167 { |
|
168 override = CAknsEffectQueueItemDef::NewL(id); |
|
169 override->SetReference(KAknsIIDNone); |
|
170 si->SetLocalItemDefL( override ); // ownership is transferred |
|
171 count--; |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 // and read the rest of the remaining elements from the default skin |
|
177 |
|
178 ProcessSkinFileL( aFilename , EFalse ); |
|
179 |
|
180 //-------------------------- |
|
181 for (count = 0; count < iOverriddenItems.Count(); count++) |
|
182 { |
|
183 si->SetLocalItemDefL( (CAknsItemDef*)iOverriddenItems.operator[](count)); |
|
184 } |
|
185 |
|
186 TAknsItemID id; |
|
187 for (count = 0; count < iItemsToOVerride.Count(); count++) |
|
188 { |
|
189 id = iItemsToOVerride[count]; |
|
190 if( !AlreadyOverrideElement(id) ) |
|
191 { |
|
192 override = CAknsEffectQueueItemDef::NewL(id); |
|
193 override->SetReference(KAknsIIDNone); |
|
194 si->SetLocalItemDefL( override ); // ownership is transferred |
|
195 } |
|
196 } |
|
197 |
|
198 // and finally disable all highlight animations.... |
|
199 override = CAknsEffectQueueItemDef::NewL(KAknsIIDQsnAnimGrid); |
|
200 override->SetReference(KAknsIIDNone); |
|
201 si->SetLocalItemDefL( override ); |
|
202 |
|
203 override = CAknsEffectQueueItemDef::NewL(KAknsIIDQsnAnimList); |
|
204 override->SetReference(KAknsIIDNone); |
|
205 si->SetLocalItemDefL( override ); |
|
206 |
|
207 override = CAknsEffectQueueItemDef::NewL(KAknsIIDQsnAnimSetOptFoc); |
|
208 override->SetReference(KAknsIIDNone); |
|
209 si->SetLocalItemDefL( override ); |
|
210 |
|
211 si->SetChangeEventsEnabled( ETrue ); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // Destructor. |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 EXPORT_C CAknLocalSkinInstance::~CAknLocalSkinInstance() |
|
219 { |
|
220 delete iSknBuffer; |
|
221 delete iDefaultSknBuffer; |
|
222 delete iBitmapPath; |
|
223 delete iBitmapFilename; |
|
224 iOverriddenItems.Close(); |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // C++ constructor. |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 CAknLocalSkinInstance::CAknLocalSkinInstance( |
|
232 const RFs& aFileSystem, const RAknsSrvSession& aSkinSrv) |
|
233 : iFs(aFileSystem), iSkinSrv(aSkinSrv) |
|
234 { |
|
235 RetrieveAHMirroringState(); |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // Start processing the skin chunks. |
|
240 // |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TInt CAknLocalSkinInstance::ProcessChunksL( TUint32 aOffset, TUint32 aChunkCount ) |
|
244 { |
|
245 |
|
246 TInt offset = aOffset; |
|
247 TUint16 chunktype = 65535; |
|
248 for (TUint32 count = 0; count < aChunkCount; count++) |
|
249 { |
|
250 TInt32 chunksize = Int32( |
|
251 iDataPtr, offset+EAknsSrvDFOCommonLength ); |
|
252 chunktype = Uint16( |
|
253 iDataPtr, offset+EAknsSrvDFOCommonType ); |
|
254 |
|
255 // filename chunk |
|
256 if (chunktype == EAknsSkinDescFilename) |
|
257 { |
|
258 offset+=HandleFilenameChunkL(offset); |
|
259 } |
|
260 // class chunk |
|
261 else if (chunktype == EAknsSkinDescSkinDescClass) |
|
262 { |
|
263 offset+=HandleClassChunkL(offset); |
|
264 } |
|
265 // release restriction chunk (2.6) |
|
266 else if( chunktype == EAknsSkinDescRelease26 ) |
|
267 { |
|
268 offset+=Handle26RelRestrictionChunkL(offset); |
|
269 } |
|
270 // release restriction chunk (generic) |
|
271 else if( chunktype == EAknsSkinDescReleaseGeneric ) |
|
272 { |
|
273 offset+=HandleGenericRelRestrictionChunkL(offset); |
|
274 } |
|
275 else if (chunktype == EAknsSkinDescLanguage) // language restriction chunk |
|
276 { |
|
277 offset+=HandleLangRestrictionChunkL(offset); |
|
278 } |
|
279 else |
|
280 { |
|
281 // chunk not supported/not used, proceed.... |
|
282 offset+=chunksize; |
|
283 } |
|
284 if( Uint8(iDataPtr,offset-1) != 0xf5 ) |
|
285 { |
|
286 User::Leave(KErrCorrupt); |
|
287 } |
|
288 } |
|
289 return offset; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // Handle filename chunk. |
|
294 // |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 TInt CAknLocalSkinInstance::HandleFilenameChunkL(TUint32 aOffset) |
|
298 { |
|
299 // todo: figure out a way to get the filename by other means than hardcoding..... |
|
300 |
|
301 TUint32 size = Int32(iDataPtr, EAknsSrvDFOCommonLength+aOffset); |
|
302 TUint8* filenamechunk = (iDataPtr+aOffset); |
|
303 if (iBitmapFilename) |
|
304 { |
|
305 return size; |
|
306 } |
|
307 |
|
308 TUint16 filenamelen = *((TUint16*)(filenamechunk+EAknsSrvDFOFilenameLen)); |
|
309 iBitmapFilename = HBufC16::NewL(filenamelen+100); |
|
310 iBitmapFilename->Des().Append(*iBitmapPath); |
|
311 TUint8* fn = new TUint8[filenamelen * 2]; |
|
312 memcpy ( fn,( filenamechunk+EAknsSrvDFOFilenameFilename ),filenamelen * 2 ); |
|
313 TPtr16 filenamePtr( (TUint16*)(fn),filenamelen,filenamelen ); |
|
314 |
|
315 iBitmapFilename->Des().Append(KAknsSrvPathEndSeparator); |
|
316 iBitmapFilename->Des().Append(filenamePtr); |
|
317 iBitmapFilename->Des().Replace(iBitmapFilename->Length()-3, 3 ,_L("mif")); |
|
318 |
|
319 TUint att = 0; |
|
320 if (iFs.Att(*iBitmapFilename,att)) |
|
321 { |
|
322 iBitmapFilename->Des().Zero(); |
|
323 iBitmapFilename->Des().Append((*iBitmapPath)[0]); |
|
324 iBitmapFilename->Des().Append(KAknsSrvScalableRomBmpOldLocation); |
|
325 iBitmapFilename->Des().AppendNumFixedWidthUC( iPkg.iNumber, EHex, 8 ); |
|
326 |
|
327 if( !iPkg.IsUid() ) |
|
328 { |
|
329 iBitmapFilename->Des().AppendNumFixedWidthUC( iPkg.iTimestamp, EHex, 8 ); |
|
330 } |
|
331 iBitmapFilename->Des().Append(KAknsSrvPathEndSeparator); |
|
332 iBitmapFilename->Des().Append(filenamePtr); |
|
333 } |
|
334 delete[] fn; |
|
335 return size; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // Handle class chunk. |
|
340 // |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 TInt CAknLocalSkinInstance::HandleClassChunkL(TUint32 aOffset) |
|
344 { |
|
345 TUint32 size = Int32( |
|
346 iDataPtr, aOffset+EAknsSrvDFOCommonLength); |
|
347 |
|
348 TInt fileoffset = aOffset; |
|
349 TInt32 chunklen = Int32( iDataPtr, |
|
350 fileoffset+EAknsSrvDFOCommonLength ); |
|
351 TInt16 chunktype = Uint16( iDataPtr, |
|
352 fileoffset+EAknsSrvDFOCommonType ); |
|
353 TInt32 chunkcount = Int32( iDataPtr, |
|
354 fileoffset+EAknsSrvDFOClassChunksN ); |
|
355 fileoffset += EAknsSrvDFOClassContent; |
|
356 |
|
357 for (TInt count = 0;count < chunkcount;count++) |
|
358 { |
|
359 chunklen = Int32( iDataPtr, |
|
360 fileoffset+EAknsSrvDFOCommonLength ); |
|
361 chunktype = Uint16( iDataPtr, |
|
362 fileoffset+EAknsSrvDFOCommonType ); |
|
363 |
|
364 switch(chunktype) |
|
365 { |
|
366 |
|
367 case EAknsSkinDescSkinDescBmpItemDef: |
|
368 DoOverrideBitmapDefinitionL( fileoffset ); |
|
369 break; |
|
370 |
|
371 case EAknsSkinDescSkinDescColorTblItemDef: |
|
372 DoOverrideColorTableDefinitionL( fileoffset ); |
|
373 break; |
|
374 |
|
375 case EAknsSkinDescSkinDescImgTblItemDef: |
|
376 DoOverrideImageTableDefinitionL( fileoffset); |
|
377 break; |
|
378 |
|
379 case EAknsSkinDescSkinDescImgBmpAnim: |
|
380 break; |
|
381 |
|
382 case EAknsSkinDescSkinDescStringItemDef: |
|
383 break; |
|
384 |
|
385 case EAknsSkinDescEffectQueue: |
|
386 DoOverrideEffectQueueL(fileoffset); |
|
387 break; |
|
388 |
|
389 case EAknsSkinDescAnimation: |
|
390 break; |
|
391 |
|
392 default: |
|
393 break; |
|
394 |
|
395 } |
|
396 |
|
397 fileoffset+=chunklen; |
|
398 if( Uint8( iDataPtr, fileoffset-1 ) != 0xf5 ) |
|
399 { |
|
400 User::Leave( KErrCorrupt ); |
|
401 } |
|
402 } |
|
403 |
|
404 return size; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // Override effect queue. |
|
409 // |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 void CAknLocalSkinInstance::DoOverrideEffectQueueL(TUint32 aOffset) |
|
413 { |
|
414 TInt32 major = Int32( iDataPtr, aOffset+EAknsSrvDFOEffectQueueMajor ); |
|
415 TInt32 minor = Int32( iDataPtr, aOffset+EAknsSrvDFOEffectQueueMinor ); |
|
416 TAknsItemID id; |
|
417 id.Set(major,minor); |
|
418 if (!OverrideElement(id)) |
|
419 { |
|
420 return; |
|
421 } |
|
422 |
|
423 TInt32 refmajor = Int32( iDataPtr, aOffset+EAknsSrvDFOEffectQueueRefMajor ); |
|
424 TInt32 refminor = Int32( iDataPtr, aOffset+EAknsSrvDFOEffectQueueRefMinor ); |
|
425 TUint8 inputlayerindex = Uint8( iDataPtr, aOffset + EAknsSrvDFOEffectQueueInputLayerIndex); |
|
426 TUint8 inputlayermode = Uint8( iDataPtr, aOffset + EAknsSrvDFOEffectQueueInputLayerMode); |
|
427 TUint8 outputlayerindex = Uint8( iDataPtr, aOffset + EAknsSrvDFOEffectQueueOutputLayerIndex); |
|
428 TUint8 outputlayermode = Uint8( iDataPtr, aOffset + EAknsSrvDFOEffectQueueOutputLayerMode); |
|
429 |
|
430 TUint16 effectcount = Uint16( iDataPtr, aOffset + EAknsSrvDFOEffectQueueEffectCount); |
|
431 |
|
432 if( inputlayermode > 0x08 || |
|
433 outputlayermode > 0x08 || |
|
434 effectcount > KAknsSrvMaxEffectCount ) |
|
435 { |
|
436 User::Leave(KErrCorrupt); |
|
437 } |
|
438 |
|
439 CAknsEffectQueueItemDef* queue = CAknsEffectQueueItemDef::NewL(id); |
|
440 CleanupStack::PushL(queue); |
|
441 UpdateOverriddenItem(queue); |
|
442 CleanupStack::Pop(queue); |
|
443 |
|
444 if (refmajor && refminor) |
|
445 { |
|
446 TAknsItemID ref; |
|
447 ref.Set(refmajor, refminor); |
|
448 return; |
|
449 } |
|
450 |
|
451 // process all effect chunks inside |
|
452 TUint32 eqBase = EAknsSrvDFOEffectQueueEffects; |
|
453 // process all effect chunks inside |
|
454 DoOverrideEffectCommandsL( aOffset, eqBase, queue, effectcount ); |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // Override effect commands. |
|
459 // |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 TUint32 CAknLocalSkinInstance::DoOverrideEffectCommandsL( |
|
463 const TUint aOffset, TUint32& aBase, |
|
464 CAknsEffectQueueItemDef* aEffectQueue, const TUint16 aEffectCount ) |
|
465 { |
|
466 TUint32 totalSize = 0; |
|
467 for( TInt i = 0; i < aEffectCount; i++) |
|
468 { |
|
469 TInt32 effectuid = Int32( iDataPtr, aOffset+aBase + 8 ); |
|
470 TUint8 inAindex = Uint8( iDataPtr, aOffset+ aBase+ 12); |
|
471 TUint8 inAmode = Uint8( iDataPtr, aOffset+ aBase+ 13); |
|
472 TUint8 inBindex = Uint8( iDataPtr, aOffset+ aBase+ 14); |
|
473 TUint8 inBmode = Uint8( iDataPtr, aOffset+ aBase+ 15); |
|
474 TUint8 outIndex = Uint8( iDataPtr, aOffset+ aBase+ 16); |
|
475 TUint8 outMode = Uint8( iDataPtr, aOffset+ aBase+ 17); |
|
476 |
|
477 // Check that at least some values are meaningful |
|
478 if (inAmode > 0x08 || inBmode > 0x08 || outMode > 0x08 ) |
|
479 { |
|
480 User::Leave(KErrCorrupt); |
|
481 } |
|
482 |
|
483 TUint16 paramcount = Uint16( iDataPtr, aOffset+ aBase+ 18); |
|
484 if (paramcount > KAknsSrvMaxEffectParamCount) |
|
485 { |
|
486 User::Leave(KErrCorrupt); |
|
487 } |
|
488 aBase+=20; |
|
489 |
|
490 // process all parameters inside single effect |
|
491 TUid uid; |
|
492 uid.iUid = effectuid; |
|
493 CAknsEffectItemDef* effect = CAknsEffectItemDef::NewL(); |
|
494 CleanupStack::PushL(effect); |
|
495 effect->SetEffectUid(uid); |
|
496 effect->SetLayerIndexesAndModes( |
|
497 inAindex, inAmode, |
|
498 inBindex, inBmode, |
|
499 outIndex, outMode ); |
|
500 aEffectQueue->AddEffectL(effect); |
|
501 CleanupStack::Pop( effect ); |
|
502 |
|
503 TUint32 totalparamsize = |
|
504 DoOverrideParamsL( aOffset, aBase, effect, paramcount ); |
|
505 aBase+=1; |
|
506 } |
|
507 |
|
508 return totalSize; |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // Override effect parameters. |
|
513 // |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 TUint32 CAknLocalSkinInstance::DoOverrideParamsL(const TUint aOffset, TUint32& aEqBase, |
|
517 CAknsEffectItemDef* aEffect, const TUint16 aParamCount ) |
|
518 { |
|
519 TUint32 totalparamsize = 0; // total size of all parameters |
|
520 for( TInt i = 0; i < aParamCount; i++ ) |
|
521 { |
|
522 TUint16 totalparamlen = Uint16( iDataPtr, aOffset + aEqBase); |
|
523 TUint32 datasize = totalparamlen-4; //ParamLength(TUint16)-Reserved(TUint8)-ParamType(TUint8) |
|
524 |
|
525 // lets assume that one effect cannot be larger than 32kb (should be more than enough) |
|
526 if (datasize >= 0x8000) |
|
527 { |
|
528 User::Leave(KErrCorrupt); |
|
529 } |
|
530 TUint8 ptype = Uint8(iDataPtr,aOffset+aEqBase+3); |
|
531 |
|
532 CAknsEffectParamDef* paramdef = CAknsEffectParamDef::NewL(); |
|
533 CleanupStack::PushL(paramdef); |
|
534 paramdef->SetType(ptype); |
|
535 |
|
536 TUint16 paramnamelen = *((TUint16*)(iDataPtr+aOffset+aEqBase+4)); |
|
537 if (paramnamelen) |
|
538 { |
|
539 HBufC* name = HBufC::NewL(paramnamelen); |
|
540 CleanupStack::PushL(name); |
|
541 TPtr nam(name->Des()); |
|
542 nam.SetLength(paramnamelen); |
|
543 TUint8* ptr = (unsigned char*)nam.Ptr(); |
|
544 Mem::Copy(ptr,iDataPtr+aOffset+aEqBase+4+2, paramnamelen*2); |
|
545 paramdef->SetNameL(*name); |
|
546 CleanupStack::PopAndDestroy( name ); |
|
547 } |
|
548 |
|
549 if (ptype == 2) // graphics param |
|
550 { |
|
551 TUint32 bmpindex = Uint32(iDataPtr,aOffset+aEqBase+4+2+paramnamelen*2); |
|
552 TUint32 maskindex = Uint32(iDataPtr, aOffset+aEqBase+4+6+paramnamelen*2); |
|
553 paramdef->SetValueL(*iBitmapFilename, |
|
554 bmpindex, maskindex); |
|
555 |
|
556 } |
|
557 else // string or int param or namedref (similar to int, used in animations) |
|
558 { |
|
559 TUint32 value = Uint32(iDataPtr,aOffset+aEqBase+4+2+paramnamelen*2); |
|
560 paramdef->SetValue(value); |
|
561 } |
|
562 aEffect->AddParameterL(paramdef); |
|
563 CleanupStack::Pop( paramdef ); |
|
564 |
|
565 aEqBase += totalparamlen; |
|
566 totalparamsize+=totalparamlen; |
|
567 } |
|
568 |
|
569 return totalparamsize; |
|
570 } |
|
571 |
|
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // Override color table definitions. |
|
575 // |
|
576 // ----------------------------------------------------------------------------- |
|
577 // |
|
578 void CAknLocalSkinInstance::DoOverrideColorTableDefinitionL( TUint32 aOffset ) |
|
579 { |
|
580 if (iNoColors) |
|
581 { |
|
582 return; |
|
583 } |
|
584 TInt32 major = Int32( iDataPtr, |
|
585 aOffset+EAknsSrvDFOColorTableMajor ); |
|
586 TInt32 minor = Int32( iDataPtr, |
|
587 aOffset+EAknsSrvDFOColorTableMinor ); |
|
588 TInt colorCount = (Uint16( iDataPtr, |
|
589 aOffset+EAknsSrvDFOColorTableColorsN))&0xff; |
|
590 |
|
591 |
|
592 TAknsImageAttributeData attributedata; |
|
593 TInt attributes = 0; |
|
594 TInt alignment = 0; |
|
595 TInt coordX = 0; |
|
596 TInt coordY = 0; |
|
597 TInt sizeW = 0; |
|
598 TInt sizeH = 0; |
|
599 |
|
600 // Image attributes |
|
601 TInt attributeBaseOffset = |
|
602 aOffset+EAknsSrvDFOColorTableColorIndex0+ |
|
603 colorCount*EAknsSrvDFOColorTableColorSize; |
|
604 ReadAttributeChunkL( attributeBaseOffset, |
|
605 attributes, alignment, |
|
606 coordX, coordY, |
|
607 sizeW, sizeH ); |
|
608 |
|
609 // Set only attributes - others are not relevant for color tables. |
|
610 attributedata.iAttributes = (TAknsImageAttribute)attributes; |
|
611 |
|
612 TAknsItemID id; |
|
613 id.Set( major, minor ); |
|
614 CAknsColorTableItemDef* colorDef = CAknsColorTableItemDef::NewL(id); |
|
615 CleanupStack::PushL(colorDef); |
|
616 |
|
617 TAknsColorTableEntry* colors = new TAknsColorTableEntry[colorCount]; |
|
618 CleanupArrayDeletePushL(colors); |
|
619 |
|
620 for( TInt i=0; i<colorCount; i++ ) |
|
621 { |
|
622 TInt16 index = Uint16( iDataPtr, |
|
623 aOffset+EAknsSrvDFOColorTableColorIndex0 + |
|
624 (i*EAknsSrvDFOColorTableColorSize) ); |
|
625 TInt32 rgb = Int32( iDataPtr, |
|
626 aOffset+EAknsSrvDFOColorTableColorRgb0 + |
|
627 (i*EAknsSrvDFOColorTableColorSize) ); |
|
628 |
|
629 colors[i].iIndex = index; |
|
630 colors[i].iRgb = rgb; |
|
631 } |
|
632 // colors are owned by the itemdef |
|
633 colorDef->SetColorsL(colorCount, colors); |
|
634 colorDef->SetAttributesL(attributedata); |
|
635 CleanupStack::PopAndDestroy( colors ); |
|
636 |
|
637 UpdateOverriddenItem(colorDef); |
|
638 CleanupStack::Pop( colorDef ); |
|
639 iColorsFound = ETrue; |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // Override elements. |
|
644 // |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 TBool CAknLocalSkinInstance::OverrideElement(const TAknsItemID& aId) |
|
648 { |
|
649 TInt index = iItemsToOVerride.FindInOrder(aId, TAknsItemID::LinearOrder ); |
|
650 if (index == KErrNotFound) |
|
651 { |
|
652 return EFalse; |
|
653 } |
|
654 else |
|
655 { |
|
656 return ETrue; |
|
657 } |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 // |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 TBool CAknLocalSkinInstance::AlreadyOverrideElement(const TAknsItemID& aId) |
|
666 { |
|
667 TInt count = iOverriddenItems.Count(); |
|
668 for( int i=0 ; i < count ; i++ ) |
|
669 { |
|
670 CAknsItemDef *item = static_cast< CAknsItemDef* >( iOverriddenItems[i] ); |
|
671 if( item && item->ID() == aId ) |
|
672 { |
|
673 return ETrue; |
|
674 } |
|
675 } |
|
676 |
|
677 return EFalse; |
|
678 } |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // Override bitmap definitions. |
|
685 // |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 void CAknLocalSkinInstance::DoOverrideBitmapDefinitionL(TUint32 aOffset) |
|
689 { |
|
690 TInt32 major = Int32( iDataPtr, |
|
691 aOffset+EAknsSrvDFOBitmapMajor ); |
|
692 TInt32 minor = Int32( iDataPtr, |
|
693 aOffset+EAknsSrvDFOBitmapMinor ); |
|
694 TInt32 bmpIndex = Int32( iDataPtr, |
|
695 aOffset+EAknsSrvDFOBitmapBitmapIndex ); |
|
696 TInt32 maskBmpIndex = Int32( iDataPtr, |
|
697 aOffset+EAknsSrvDFOBitmapMaskIndex ); |
|
698 |
|
699 TAknsItemID id; |
|
700 id.Set(major, minor); |
|
701 |
|
702 if( maskBmpIndex == KErrNotFound ) |
|
703 { |
|
704 CAknsBitmapItemDef* bmpdef = CAknsBitmapItemDef::NewL(id); |
|
705 bmpdef->SetFilenameL(*iBitmapFilename); |
|
706 bmpdef->SetIndex(bmpIndex); |
|
707 UpdateOverriddenItem(bmpdef); |
|
708 } |
|
709 else |
|
710 { |
|
711 CAknsMaskedBitmapItemDef* maskeddef = CAknsMaskedBitmapItemDef::NewL(id); |
|
712 maskeddef->SetFilenameL(*iBitmapFilename); |
|
713 maskeddef->SetIndex(bmpIndex); |
|
714 maskeddef->SetMaskIndex(maskBmpIndex); |
|
715 UpdateOverriddenItem(maskeddef); |
|
716 } |
|
717 |
|
718 } |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // Read attribute chunks. |
|
722 // |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CAknLocalSkinInstance::ReadAttributeChunkL( const TUint aOffset, |
|
726 TInt& aAttributes, TInt& aAlignment, |
|
727 TInt& aCoordX, TInt& aCoordY, TInt& aSizeW, TInt& aSizeH ) |
|
728 { |
|
729 TUint16 version = Uint16( iDataPtr, |
|
730 aOffset + EAknsSrvDFOCommonVersion ); |
|
731 |
|
732 TUint16 alignAttr = Uint16( iDataPtr, |
|
733 aOffset + EAknsSrvDFOAttributesAttributeFlags ); |
|
734 TInt16 imageCoordX = Uint16( iDataPtr, |
|
735 aOffset + EAknsSrvDFOAttributesCoordX ); |
|
736 TInt16 imageCoordY = Uint16( iDataPtr, |
|
737 aOffset + EAknsSrvDFOAttributesCoordY ); |
|
738 TInt16 imageSizeW = Uint16( iDataPtr, |
|
739 aOffset + EAknsSrvDFOAttributesSizeW ); |
|
740 TInt16 imageSizeH = Uint16( iDataPtr, |
|
741 aOffset + EAknsSrvDFOAttributesSizeH ); |
|
742 |
|
743 aAttributes = alignAttr&0xff; |
|
744 aAlignment = (alignAttr&0xff00)>>8; |
|
745 aCoordX = imageCoordX; |
|
746 aCoordY = imageCoordY; |
|
747 aSizeW = imageSizeW; |
|
748 aSizeH = imageSizeH; |
|
749 |
|
750 if( version >= 2 ) |
|
751 { |
|
752 TInt extAttr = Uint16( iDataPtr, |
|
753 aOffset + EAknsSrvDFOAttributesExtAttributeFlags ); |
|
754 extAttr = extAttr << 8; |
|
755 aAttributes |= extAttr; |
|
756 } |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // Override image table definitions. |
|
761 // |
|
762 // ----------------------------------------------------------------------------- |
|
763 // |
|
764 void CAknLocalSkinInstance::DoOverrideImageTableDefinitionL( TUint32 aOffset) |
|
765 { |
|
766 TInt32 major = Int32( iDataPtr, |
|
767 aOffset+EAknsSrvDFOImageTableMajor ); |
|
768 TInt32 minor = Int32( iDataPtr, |
|
769 aOffset+EAknsSrvDFOImageTableMinor ); |
|
770 TInt imageCount = (Uint16( iDataPtr, |
|
771 aOffset+EAknsSrvDFOImageTableImagesN))&0xff; |
|
772 |
|
773 TAknsItemID id; |
|
774 id.Set(major, minor); |
|
775 if (!OverrideElement(id)) |
|
776 { |
|
777 return; |
|
778 } |
|
779 |
|
780 TAknsImageAttributeData attributedata; |
|
781 TInt attributes = 0; |
|
782 TInt alignment = 0; |
|
783 TInt coordX = 0; |
|
784 TInt coordY = 0; |
|
785 TInt sizeW = 0; |
|
786 TInt sizeH = 0; |
|
787 |
|
788 // Image attributes |
|
789 TInt attributeBaseOffset = |
|
790 aOffset+EAknsSrvDFOImageTableImageMajor0+ |
|
791 imageCount*EAknsSrvDFOImageTableImageSize; |
|
792 ReadAttributeChunkL( attributeBaseOffset, |
|
793 attributes, alignment, |
|
794 coordX, coordY, |
|
795 sizeW, sizeH ); |
|
796 |
|
797 attributedata.iCoords = TPoint(coordX, coordY); |
|
798 |
|
799 attributedata.iSize = TSize(sizeW, sizeH); |
|
800 |
|
801 attributedata.iAlignment = (TAknsImageAlignment)alignment; |
|
802 |
|
803 if( imageCount == KAknsSrvFrameIconCount ) |
|
804 { |
|
805 attributes^= EAknsImageAttributeTile; |
|
806 attributes|= EAknsImageAttributeStretch; |
|
807 attributes|= EAknsImageAttributeNBC; |
|
808 } |
|
809 |
|
810 attributedata.iAttributes = (TAknsImageAttribute)attributes; |
|
811 |
|
812 CAknsImageTableItemDef* tabledef = CAknsImageTableItemDef::NewL(id); |
|
813 CleanupStack::PushL(tabledef); |
|
814 tabledef->SetAttributesL(attributedata); |
|
815 TAknsItemID* items = new (ELeave)TAknsItemID[imageCount]; |
|
816 CleanupArrayDeletePushL(items); |
|
817 |
|
818 for( TInt i=0; i<imageCount; i++ ) |
|
819 { |
|
820 TInt32 imgMajor = Int32( iDataPtr, |
|
821 aOffset+EAknsSrvDFOImageTableImageMajor0 + |
|
822 (i*EAknsSrvDFOImageTableImageSize) ); |
|
823 TInt32 imgMinor = Int32( iDataPtr, |
|
824 aOffset+EAknsSrvDFOImageTableImageMinor0 + |
|
825 (i*EAknsSrvDFOImageTableImageSize) ); |
|
826 |
|
827 items[i].iMajor = imgMajor; |
|
828 items[i].iMinor = imgMinor; |
|
829 } |
|
830 tabledef->SetImagesL(imageCount, items); |
|
831 CleanupStack::PopAndDestroy( items ); |
|
832 UpdateOverriddenItem(tabledef); |
|
833 CleanupStack::Pop( tabledef ); |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // Handle generic release restriction chunk. |
|
838 // |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 TInt CAknLocalSkinInstance::HandleGenericRelRestrictionChunkL( |
|
842 TUint32 aFileOffset) |
|
843 { |
|
844 TUint32 size = Int32( iDataPtr, |
|
845 aFileOffset+EAknsSrvDFOReleaseGenericLength); |
|
846 TInt32 numberofchunks = Int32( iDataPtr, |
|
847 aFileOffset+EAknsSrvDFOReleaseGenericChunksN ); |
|
848 TInt platformMajor = Uint8( iDataPtr, |
|
849 aFileOffset+EAknsSrvDFOReleaseGenericPlatformMajor ); |
|
850 TInt platformMinor = Uint8( iDataPtr, |
|
851 aFileOffset+EAknsSrvDFOReleaseGenericPlatformMinor ); |
|
852 |
|
853 // Process the chunk only if restriction is met |
|
854 if( (platformMajor<iPlatformMajor) || |
|
855 ((platformMajor==iPlatformMajor)&& |
|
856 (platformMinor<=iPlatformMinor)) ) |
|
857 { |
|
858 ProcessChunksL( aFileOffset+EAknsSrvDFOReleaseGenericContent, |
|
859 numberofchunks ); |
|
860 } |
|
861 |
|
862 return size; |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // Handle release 2.6 restriction chunk. |
|
867 // |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 TInt CAknLocalSkinInstance::Handle26RelRestrictionChunkL( |
|
871 TUint32 aFileOffset ) |
|
872 { |
|
873 TUint32 size = Int32( iDataPtr, |
|
874 aFileOffset+EAknsSrvDFORelease26Length); |
|
875 TInt32 numberofchunks = Int32( iDataPtr, |
|
876 aFileOffset+EAknsSrvDFORelease26ChunksN ); |
|
877 |
|
878 // Process always (we are guaranteed to be at lease 2.8>2.6) |
|
879 ProcessChunksL( aFileOffset+EAknsSrvDFORelease26Content, |
|
880 numberofchunks ); |
|
881 return size; |
|
882 } |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // Check if skin item is scalable item. |
|
889 // |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 TBool CAknLocalSkinInstance::IsScalableItem(const TAknsItemID& aId) |
|
893 { |
|
894 if ( aId.iMajor == EAknsMajorSkin && |
|
895 aId.iMinor >= EAknsMinorQsnBgScreen && |
|
896 aId.iMinor <= EAknsMinorQsnBgAreaMainSmall ) |
|
897 { |
|
898 return ETrue; |
|
899 } |
|
900 return EFalse; |
|
901 } |
|
902 |
|
903 // ----------------------------------------------------------------------------- |
|
904 // CAknLocalSkinInstance::IsDrmProtectedL |
|
905 // ----------------------------------------------------------------------------- |
|
906 // |
|
907 TBool CAknLocalSkinInstance::IsDrmProtectedL(RFile &aFile) |
|
908 { |
|
909 TBool isProtected(EFalse); |
|
910 TInt value = KErrNone; |
|
911 |
|
912 CContent* content = CContent::NewLC( aFile ); |
|
913 User::LeaveIfError( content->GetAttribute( EIsProtected, value ) ); |
|
914 if ( value ) |
|
915 { |
|
916 isProtected = ETrue; |
|
917 } |
|
918 CleanupStack::PopAndDestroy( content ); |
|
919 return isProtected; |
|
920 } |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // CAknLocalSkinInstance::ReadFromProtectedFileL |
|
924 // ----------------------------------------------------------------------------- |
|
925 // |
|
926 void CAknLocalSkinInstance::ReadFromProtectedFileL(TDes8 &aDes, RFile &aFile) |
|
927 { |
|
928 CContent* content = CContent::NewLC( aFile ); |
|
929 CData* data = content->OpenContentL( |
|
930 ContentAccess::EView, ContentAccess::EContentShareReadOnly); |
|
931 CleanupStack::PushL( data ); |
|
932 |
|
933 TInt size = 0; |
|
934 TInt position = 0; |
|
935 data->DataSizeL(size); |
|
936 User::LeaveIfError( data->Seek(ESeekStart, position) ); |
|
937 User::LeaveIfError( data->Read(aDes, size) ); |
|
938 |
|
939 CleanupStack::PopAndDestroy( 2 ); // content, |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CAknLocalSkinInstance::GetRightsDetailsL |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 TInt CAknLocalSkinInstance::GetRightsDetailsL(RFile &aFile) |
|
947 { |
|
948 // If protection is indicated, by default set it on. |
|
949 TInt protectionType = EAknsSrvProtected; |
|
950 |
|
951 TBool expired = EFalse; |
|
952 TBool sendAllowed = EFalse; //not needed |
|
953 CDRMHelperRightsConstraints* playDrmHlpCons = NULL; |
|
954 CDRMHelperRightsConstraints* dispDrmHlpCons = NULL; |
|
955 CDRMHelperRightsConstraints* execDrmHlpCons = NULL; |
|
956 CDRMHelperRightsConstraints* printDrmHlpCons = NULL; |
|
957 |
|
958 TRAPD( drmErr, iDrmHelper->GetRightsDetailsL( |
|
959 aFile, ContentAccess::EView, expired, sendAllowed, |
|
960 playDrmHlpCons, dispDrmHlpCons, execDrmHlpCons, printDrmHlpCons ) ); |
|
961 // DrmHelper leaves if the content is protected, but there are rights. |
|
962 if ( drmErr == KErrCANoRights ) |
|
963 { |
|
964 protectionType = EAknsSrvNoRights; // not allowed to preview |
|
965 } |
|
966 else if ( drmErr == KErrArgument ) |
|
967 { |
|
968 protectionType = EAknsSrvNoProtection; // not DRM protected |
|
969 } |
|
970 // Delete not needed constraints. |
|
971 delete printDrmHlpCons; |
|
972 delete execDrmHlpCons; |
|
973 delete playDrmHlpCons; |
|
974 CleanupStack::PushL( dispDrmHlpCons ); |
|
975 // Check expiration. If expired and no rights => expired. |
|
976 if ( expired && !dispDrmHlpCons ) |
|
977 { |
|
978 protectionType = EAknsSrvExpiredRights; // not allowed to preview |
|
979 } |
|
980 // If expired, but there are rights => future rights. |
|
981 if ( expired && dispDrmHlpCons ) |
|
982 { |
|
983 protectionType = EAknsSrvFutureRights; // not allowed to preview |
|
984 } |
|
985 if ( dispDrmHlpCons ) |
|
986 { |
|
987 TUint32 counter = 0; |
|
988 TUint32 origCounter = 0; |
|
989 TRAP( drmErr, dispDrmHlpCons->GetCountersL( counter, origCounter ) ); |
|
990 // No counters |
|
991 if ( drmErr == KErrNotFound ) |
|
992 { |
|
993 protectionType = EAknsSrvProtected; // allowed to preview |
|
994 } |
|
995 else |
|
996 { |
|
997 protectionType = EAknsSrvCountBased; // not allowed to preview |
|
998 } |
|
999 } |
|
1000 CleanupStack::PopAndDestroy( dispDrmHlpCons ); |
|
1001 |
|
1002 return protectionType; |
|
1003 } |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // Read arabic/hebrew mirroring state. |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 void CAknLocalSkinInstance::RetrieveAHMirroringState() |
|
1010 { |
|
1011 CRepository *avkonRepository = NULL; |
|
1012 TRAPD( cenrepErr,avkonRepository = CRepository::NewL(KCRUidAvkon) ); |
|
1013 if( cenrepErr != KErrNone ) |
|
1014 { |
|
1015 iAHMirroringActive = EFalse; |
|
1016 return; |
|
1017 } |
|
1018 |
|
1019 CleanupStack::PushL( avkonRepository ); |
|
1020 |
|
1021 TInt value = 0; |
|
1022 TInt errorCode = avkonRepository->Get( KAknLayoutId , value ); |
|
1023 if( errorCode != KErrNone ) |
|
1024 { |
|
1025 value = 0; |
|
1026 } |
|
1027 if( value == EAknLayoutIdABRW ) |
|
1028 { |
|
1029 iAHMirroringActive = ETrue; |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 iAHMirroringActive = EFalse; |
|
1034 } |
|
1035 |
|
1036 CleanupStack::PopAndDestroy( avkonRepository ); |
|
1037 } |
|
1038 |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // Load skin item from skin file. |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CAknLocalSkinInstance::ProcessSkinFileL( const TDesC& aFilename, TBool aIsDefaultSkin ) |
|
1045 { |
|
1046 TInt filehandle = 0; |
|
1047 |
|
1048 if( !aIsDefaultSkin || !iDefaultSknBuffer ) |
|
1049 { |
|
1050 TInt fshandle = iSkinSrv.OpenBitmapFile( aFilename, filehandle); |
|
1051 if (fshandle <=0 || filehandle == 0) |
|
1052 { |
|
1053 User::Leave(fshandle); |
|
1054 } |
|
1055 |
|
1056 RFile file; |
|
1057 TInt fileSize = 0; |
|
1058 |
|
1059 CleanupClosePushL(file); |
|
1060 User::LeaveIfError(file.AdoptFromServer(fshandle, filehandle)); |
|
1061 User::LeaveIfError(file.Size(fileSize)); |
|
1062 |
|
1063 TPtr8 *pptr = 0; |
|
1064 if(aIsDefaultSkin) |
|
1065 { |
|
1066 iDefaultSknBuffer = HBufC8::NewL(fileSize); |
|
1067 pptr = new TPtr8( iDefaultSknBuffer->Des() ); |
|
1068 CleanupStack::PushL(pptr); |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 iSknBuffer = HBufC8::NewL(fileSize); |
|
1073 pptr = new TPtr8( iSknBuffer->Des() ); |
|
1074 CleanupStack::PushL(pptr); |
|
1075 } |
|
1076 |
|
1077 |
|
1078 TBool drmProtected = IsDrmProtectedL(file); |
|
1079 if ( drmProtected ) |
|
1080 { |
|
1081 if (!iDrmHelper) |
|
1082 { |
|
1083 iDrmHelper = CDRMHelper::NewL(); |
|
1084 } |
|
1085 |
|
1086 TInt protectionType = GetRightsDetailsL(file); |
|
1087 |
|
1088 if (protectionType == EAknsSrvProtected) |
|
1089 { |
|
1090 // local skinning is permitted but drm rights |
|
1091 // must be consumed first |
|
1092 // consume start |
|
1093 iDrmHelper->ConsumeFile2( file, EInstall, CDRMHelper::EStart ); |
|
1094 |
|
1095 // reading content from drm protected file!!!! |
|
1096 // DoApplyL probably needs to be changed |
|
1097 TRAPD(err,ReadFromProtectedFileL(*pptr,file)); |
|
1098 |
|
1099 iDrmHelper->ConsumeFile2( file, EInstall, CDRMHelper::EFinish ); |
|
1100 |
|
1101 User::LeaveIfError(err); |
|
1102 } |
|
1103 else if(protectionType == EAknsSrvNoProtection) |
|
1104 { |
|
1105 drmProtected = EFalse; |
|
1106 } |
|
1107 else // local skinning is not permitted |
|
1108 { |
|
1109 User::Leave(EAknsSrvProtected); |
|
1110 } |
|
1111 } |
|
1112 else |
|
1113 { |
|
1114 User::LeaveIfError(file.Read(*pptr,fileSize)); |
|
1115 } |
|
1116 CleanupStack::Pop(pptr); |
|
1117 delete pptr; |
|
1118 CleanupStack::PopAndDestroy(); // file |
|
1119 } |
|
1120 |
|
1121 |
|
1122 if(aIsDefaultSkin) |
|
1123 { |
|
1124 iDataPtr = (TUint8*)iDefaultSknBuffer->Ptr(); |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 iDataPtr = (TUint8*)iSknBuffer->Ptr(); |
|
1129 } |
|
1130 |
|
1131 TUint masterChunkSize = Int32( |
|
1132 iDataPtr, EAknsSrvDFOCommonLength ); |
|
1133 TUint masterChunkType = Uint16( |
|
1134 iDataPtr, EAknsSrvDFOCommonType ); |
|
1135 TInt32 numberofchunks = Int32( |
|
1136 iDataPtr, EAknsSrvDFOSkinChunksN ); |
|
1137 |
|
1138 if( masterChunkType != EAknsSkinDescSkinDesc ) |
|
1139 { |
|
1140 User::Leave( KErrCorrupt ); |
|
1141 } |
|
1142 TInt32 pid1 = Int32(iDataPtr,EAknsSrvDFOSkinSkinPID1); |
|
1143 TInt32 pid2 = Int32(iDataPtr,EAknsSrvDFOSkinSkinPID2); |
|
1144 |
|
1145 iPkg.Set(pid2, pid1); |
|
1146 |
|
1147 //2 for the driveletter and end separator |
|
1148 TInt pathsize = KAknsSrvScalableRomBmpLocation().Length()+8+2; |
|
1149 if (!iPkg.IsUid()) |
|
1150 { |
|
1151 pathsize+=8; |
|
1152 } |
|
1153 |
|
1154 |
|
1155 iBitmapPath = HBufC16::NewL(pathsize); |
|
1156 iBitmapPath->Des().Append(aFilename[0]); |
|
1157 iBitmapPath->Des().Append(KAknsSrvScalableRomBmpLocation); |
|
1158 iBitmapPath->Des().AppendNumFixedWidthUC( iPkg.iNumber, EHex, 8 ); |
|
1159 |
|
1160 if( !iPkg.IsUid() ) |
|
1161 { |
|
1162 iBitmapPath->Des().AppendNumFixedWidthUC( iPkg.iTimestamp, EHex, 8 ); |
|
1163 } |
|
1164 |
|
1165 ProcessChunksL(EAknsSrvDFOSkinContent , numberofchunks ); |
|
1166 if( Uint8(iDataPtr,masterChunkSize-1) != 0xf5 ) |
|
1167 { |
|
1168 User::Leave( KErrCorrupt ); |
|
1169 } |
|
1170 |
|
1171 |
|
1172 delete iSknBuffer; |
|
1173 iSknBuffer = NULL; |
|
1174 delete iBitmapPath; |
|
1175 iBitmapPath = NULL; |
|
1176 delete iBitmapFilename; |
|
1177 iBitmapFilename = NULL; |
|
1178 } |
|
1179 |
|
1180 |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // Override local skin item. |
|
1183 // ----------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CAknLocalSkinInstance::UpdateOverriddenItem(const CAknsItemDef* aItemDef) |
|
1186 { |
|
1187 if( !aItemDef ) |
|
1188 { |
|
1189 return; |
|
1190 } |
|
1191 |
|
1192 TInt count = iOverriddenItems.Count(); |
|
1193 for( int i=0 ; i < count ; i++ ) |
|
1194 { |
|
1195 CAknsItemDef *item = static_cast< CAknsItemDef* >( iOverriddenItems[i] ); |
|
1196 if( item && item->ID() == aItemDef->ID() ) |
|
1197 { |
|
1198 iOverriddenItems.Remove( i ); |
|
1199 delete item; |
|
1200 break; |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 iOverriddenItems.Append(aItemDef); |
|
1205 } |
|
1206 |
|
1207 |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 // Handles language restriction chunk.. |
|
1210 // ----------------------------------------------------------------------------- |
|
1211 // |
|
1212 TInt CAknLocalSkinInstance::HandleLangRestrictionChunkL(TUint32 aFileOffset) |
|
1213 { |
|
1214 TUint32 size = Int32( iDataPtr, |
|
1215 aFileOffset+EAknsSrvDFOCommonLength); |
|
1216 |
|
1217 TUint16 generalRestr = Uint16( iDataPtr, |
|
1218 aFileOffset+EAknsSrvDFOLanguageGenRestr); |
|
1219 |
|
1220 TUint16 langRestr = Uint16( iDataPtr, |
|
1221 aFileOffset+EAknsSrvDFOLanguageLangRestr); |
|
1222 |
|
1223 TInt32 numberofchunks = Int32( iDataPtr, |
|
1224 aFileOffset+EAknsSrvDFOLanguageLanguageN ); |
|
1225 |
|
1226 if( (generalRestr == 0) || |
|
1227 (generalRestr == 1 && !iAHMirroringActive) || |
|
1228 (generalRestr == 2 && iAHMirroringActive) ) |
|
1229 { |
|
1230 if ((langRestr == 0) || |
|
1231 (langRestr && langRestr == User::Language())) |
|
1232 { |
|
1233 // Set the restriction parameters before processing |
|
1234 // the chunks inside it |
|
1235 ProcessChunksL( aFileOffset+EAknsSrvDFOLanguageContent, |
|
1236 numberofchunks ); |
|
1237 } |
|
1238 } |
|
1239 return size; |
|
1240 } |
|
1241 // End of file |