|
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: Implementaion of HSPS MhspsInstallationService interface defined |
|
15 * in hspsThemeManagement.h. For details, see the header file. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <bautils.h> |
|
21 #include <utf.h> |
|
22 #include <centralrepository.h> |
|
23 |
|
24 #include "hsps_builds_cfg.hrh" |
|
25 #include "hspsthememanagement.h" |
|
26 #include "hspsdefinitionrepository.h" |
|
27 #include "hspsodt.h" |
|
28 #include "hspsdefinitionengineinterface.h" |
|
29 #include "hspsdomdocument.h" |
|
30 #include "hspsresource.h" |
|
31 #include "hspsresult.h" |
|
32 #include "hspsthemeserver.h" |
|
33 #include "hspsinstallationhandler.h" |
|
34 #include "hspssecurityenforcer.h" |
|
35 #include "hspsuimanagererrorcodes.h" |
|
36 #include "hspsdomattribute.h" |
|
37 #include "hspsdomlist.h" |
|
38 #include "hspsdomdepthiterator.h" |
|
39 #include "hspsdomnode.h" |
|
40 #include "hspsconfiguration.h" |
|
41 #include "hspsmanifest.h" |
|
42 #include "hspsserverutil.h" |
|
43 #include "hspsfamilylistener.h" |
|
44 |
|
45 #ifdef HSPS_LOG_ACTIVE |
|
46 #include <hspsodtdump.h> |
|
47 #include <hspslogbus.h> |
|
48 #endif |
|
49 |
|
50 #ifdef _hsps_PERFORMANCE_TEST_ |
|
51 #include "hspstimemon.h" |
|
52 #endif |
|
53 |
|
54 _LIT8(KUnknownMimeType, "unknown"); |
|
55 |
|
56 _LIT8(KhspsDefinitionEngine, "hspsdefinitionengine"); |
|
57 |
|
58 _LIT(KPathDelim, "\\"); |
|
59 _LIT(KHsps, "\\hsps\\" ); |
|
60 _LIT(KXuikon, "xuikon\\" ); |
|
61 |
|
62 const TInt KMaxMediaTypeLength = 100; |
|
63 |
|
64 // ============================ MEMBER FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Callback function for removing repository lock if error occurs while repository is locked |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 LOCAL_C void UnlockRepository( TAny* aObject ) |
|
71 { |
|
72 ChspsDefinitionRepository* DefRep = reinterpret_cast<ChspsDefinitionRepository*>( aObject ); |
|
73 |
|
74 if (DefRep->Locked()) |
|
75 { |
|
76 DefRep->Unlock(); |
|
77 } |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // ChspsInstallationHandler::ChspsInstallationHandler() |
|
82 // C++ default constructor can NOT contain any code, that |
|
83 // might leave. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 ChspsInstallationHandler::ChspsInstallationHandler( ChspsThemeServer& aThemeServer ) |
|
87 : iThemeServer( aThemeServer ), |
|
88 iDefinitionRepository( aThemeServer.DefinitionRepository() ), |
|
89 iSecurityEnforcer( aThemeServer.SecurityEnforcer() ), |
|
90 iCentralRepository( aThemeServer.CentralRepository() ), |
|
91 iHeaderListCache( aThemeServer.HeaderListCache() ) |
|
92 { |
|
93 iPackageVerSupported = EFalse; |
|
94 iInstallationPhase = EhspsPhaseIdle; |
|
95 iConfigurationType = EhspsAppConfiguration; |
|
96 iThemeStatus = EhspsThemeStatusNone; |
|
97 iFileNotFound = EFalse; |
|
98 iLocalized = EFalse; |
|
99 iDefaultSpecificationSet = EFalse; |
|
100 iDefaultSpecification = ELangNone; |
|
101 iInstallationMode = EServiceHandler; |
|
102 iRomInstallation = EFalse; |
|
103 iInstallationType = EInstallationTypeNew; |
|
104 iFamilyMask = 0; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // ChspsInstallationHandler::NewL |
|
109 // Two-phased constructor. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 ChspsInstallationHandler* ChspsInstallationHandler::NewL( ChspsThemeServer& aThemeServer ) |
|
113 { |
|
114 ChspsInstallationHandler* h = ChspsInstallationHandler::NewLC( aThemeServer ); |
|
115 CleanupStack::Pop( h ); |
|
116 return ( h ); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // ChspsInstallationHandler::NewL |
|
121 // Two-phased constructor. |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 ChspsInstallationHandler* ChspsInstallationHandler::NewLC( ChspsThemeServer& aThemeServer ) |
|
125 { |
|
126 ChspsInstallationHandler* h = new (ELeave) ChspsInstallationHandler( aThemeServer ); |
|
127 CleanupStack::PushL( h ); |
|
128 h->ConstructL(); |
|
129 return ( h ); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // Destructor |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 ChspsInstallationHandler::~ChspsInstallationHandler() |
|
138 { |
|
139 iFsSession.Close(); |
|
140 delete iXmlParser; |
|
141 delete iOdt; |
|
142 delete iDtdFile; |
|
143 delete iHeaderData; |
|
144 delete iThemeFullName; |
|
145 delete iThemeShortName; |
|
146 delete iThemeVersion; |
|
147 delete iThemeDesc; |
|
148 delete iResourceTag; |
|
149 delete iPackageVersion; |
|
150 if ( iTempLocalizedResourceList ) |
|
151 { |
|
152 iTempLocalizedResourceList->ResetAndDestroy(); |
|
153 delete iTempLocalizedResourceList; |
|
154 } |
|
155 if( iResourceList ) |
|
156 { |
|
157 iResourceList->Reset(); // ODT has an ownership of the items |
|
158 delete iResourceList; |
|
159 } |
|
160 delete iContent; |
|
161 delete iXmlFile; |
|
162 delete iMediaType; |
|
163 delete iResource; |
|
164 delete iResult; |
|
165 |
|
166 if ( iDefEngine ) |
|
167 { |
|
168 delete iDefEngine; |
|
169 } |
|
170 |
|
171 REComSession::FinalClose(); |
|
172 |
|
173 } |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // ChspsInstallationHandler::ConstructL |
|
180 // Symbian 2nd phase constructor can leave. |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void ChspsInstallationHandler::ConstructL() |
|
184 { |
|
185 _LIT8(KMimeType, "text/xml"); |
|
186 MContentHandler* contentHandler = this; |
|
187 iXmlParser = Xml::CParser::NewL( KMimeType, *contentHandler ); |
|
188 |
|
189 iDefEngine = ChspsDefinitionEngineInterface::NewL(KhspsDefinitionEngine); |
|
190 |
|
191 iOdt = ChspsODT::NewL(); |
|
192 iResourceList = new( ELeave ) CArrayPtrSeg<ChspsResource>( KPathListGranularity ); |
|
193 iTempLocalizedResourceList = new( ELeave ) CArrayPtrSeg<ChspsResource>( KPathListGranularity ); |
|
194 User::LeaveIfError( iFsSession.Connect() ); |
|
195 iResult = ChspsResult::NewL(); |
|
196 |
|
197 iMultiInstanceFound = EFalse; |
|
198 |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // ChspsInstallationHandler::ServiceInstallThemeL |
|
203 // Starts the actual installation in ChspsInstallationHandler. |
|
204 // (other items were commented in a header). |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void ChspsInstallationHandler::ServiceInstallThemeL( const RMessage2& aMessage ) |
|
208 { |
|
209 // incoming arguments: TIpcArgs: &iResultData, &aManifestFileName, &aHeader |
|
210 iMessagePtr = aMessage; |
|
211 TBuf8<KMaxHeaderDataLength8> headerdata; |
|
212 |
|
213 iInstallationPhase = EhspsPhaseIdle; |
|
214 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
|
215 |
|
216 if ( !iDefinitionRepository.Locked() ) |
|
217 { |
|
218 // read name of the manifest file |
|
219 TBuf<KMaxHeaderDataLength8> manifestfilename; |
|
220 iMessagePtr.ReadL( 1, manifestfilename, 0 ); |
|
221 |
|
222 #ifdef HSPS_LOG_ACTIVE |
|
223 if( iLogBus ) |
|
224 { |
|
225 iLogBus->LogText( _L( "ChspsInstallationHandler::ServiceInstallThemeL() - Manifest file '%S'" ), |
|
226 &manifestfilename ); |
|
227 } |
|
228 #endif |
|
229 |
|
230 // install the manifest file |
|
231 ret = hspsInstallTheme( manifestfilename, headerdata ); |
|
232 |
|
233 // now there will be the time for query validity check |
|
234 if ( ret == EhspsInstallThemeSuccess ) |
|
235 { |
|
236 ret = EhspsInstallPhaseSuccess; |
|
237 } |
|
238 } |
|
239 else |
|
240 { |
|
241 iResult->ResetData(); |
|
242 iResult->iSystemError = KErrInUse; |
|
243 } |
|
244 |
|
245 CompleteRequestL(ret, headerdata); |
|
246 } |
|
247 |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // ChspsInstallationHandler::ServiceInstallNextPhaseL |
|
251 // Starts subsequent installation phases. |
|
252 // (other items were commented in a header). |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void ChspsInstallationHandler::ServiceInstallNextPhaseL( const RMessage2& aMessage ) |
|
256 { |
|
257 #ifdef HSPS_LOG_ACTIVE |
|
258 if( iLogBus ) |
|
259 { |
|
260 iLogBus->LogText( _L( "ChspsInstallationHandler::ServiceInstallNextPhaseL():" ) ); |
|
261 } |
|
262 #endif |
|
263 |
|
264 TBuf8<KMaxHeaderDataLength8> headerdata; |
|
265 iResult->ResetData(); |
|
266 iInstallationMode = EServiceHandler; |
|
267 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
|
268 // incoming arguments: TIpcArgs: &iResultData, &KNullDesC, &aHeaderData |
|
269 iMessagePtr = aMessage; |
|
270 |
|
271 // calling installation of next phase |
|
272 ret = hspsInstallNextPhaseL( headerdata ); |
|
273 CompleteRequestL( ret, headerdata ); |
|
274 } |
|
275 |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // ChspsInstallationHandler::InstallNextPhase() |
|
279 // Must be completed by EhspsInstallThemeSuccess, EhspsInstallPhaseSuccess or EhspsInstallThemeFailed |
|
280 // (other items were commented in a header). |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void ChspsInstallationHandler::hspsInstallNextPhaseL( |
|
284 TDes8& aHeaderData, |
|
285 TRequestStatus& aRequestStatus ) |
|
286 { |
|
287 ThspsServiceCompletedMessage ret = EhspsServiceNotSupported; |
|
288 iInstallationMode = EAsynchronousObject; |
|
289 iRequestStatus = &aRequestStatus; |
|
290 *iRequestStatus = KRequestPending; |
|
291 ret = hspsInstallNextPhaseL( aHeaderData ); |
|
292 CompleteRequestL( ret ); |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // ChspsInstallationHandler::ResetL() |
|
297 // ----------------------------------------------------------------------------- |
|
298 void ChspsInstallationHandler::ResetL() |
|
299 { |
|
300 iFamilyMask = 0; |
|
301 iInstallationPhase = EhspsPhaseInitialise; |
|
302 iThemeStatus = EhspsThemeStatusNone; |
|
303 iFileNotFound = EFalse; |
|
304 delete iMediaType; |
|
305 iMediaType = NULL; |
|
306 delete iThemeDesc; |
|
307 iThemeDesc = NULL; |
|
308 delete iResourceTag; |
|
309 iResourceTag = NULL; |
|
310 iLocalized = EFalse; |
|
311 iDefaultSpecificationSet = EFalse; |
|
312 iDefaultSpecification = ELangNone; |
|
313 if ( iOdt ) |
|
314 { |
|
315 delete iOdt; |
|
316 iOdt = NULL; |
|
317 iOdt = ChspsODT::NewL(); |
|
318 } |
|
319 |
|
320 delete iDtdFile; |
|
321 iDtdFile = NULL; |
|
322 |
|
323 delete iHeaderData; |
|
324 iHeaderData = NULL; |
|
325 if ( iDefEngine ) |
|
326 { |
|
327 delete iDefEngine; |
|
328 iDefEngine = NULL; |
|
329 iDefEngine = ChspsDefinitionEngineInterface::NewL(KhspsDefinitionEngine); |
|
330 } |
|
331 if ( iResourceList ) |
|
332 { |
|
333 iResourceList->Reset(); // ODT has an ownership of the items |
|
334 delete iResourceList; |
|
335 iResourceList = NULL; |
|
336 iResourceList = new( ELeave ) CArrayPtrSeg<ChspsResource>( KPathListGranularity ); |
|
337 } |
|
338 if ( iTempLocalizedResourceList ) |
|
339 { |
|
340 iTempLocalizedResourceList->ResetAndDestroy(); |
|
341 delete iTempLocalizedResourceList; |
|
342 iTempLocalizedResourceList = NULL; |
|
343 iTempLocalizedResourceList = new( ELeave ) CArrayPtrSeg<ChspsResource>( KPathListGranularity ); |
|
344 } |
|
345 iInstallationType = EInstallationTypeNew; |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // ChspsInstallationHandler::hspsInstallTheme() |
|
350 // From MhspsInstallationService |
|
351 // Must be completed by EhspsInstallThemeSuccess, EhspsInstallPhaseSuccess or EhspsInstallThemeFailed |
|
352 // (other items were commented in a header). |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 ThspsServiceCompletedMessage ChspsInstallationHandler::hspsInstallTheme( |
|
356 const TDesC& aManifestFileName, |
|
357 TDes8& aHeaderData) |
|
358 { |
|
359 // Assume that the installation fails |
|
360 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
|
361 iResult->iXuikonError = KErrManifestFileCorrupted; |
|
362 |
|
363 // Reset memeber variables |
|
364 TInt errorCode = KErrNone; |
|
365 TRAP( errorCode, ResetL() ); |
|
366 if ( !errorCode ) |
|
367 { |
|
368 // Get manifest file path |
|
369 iThemeFilePath.Set( TParsePtrC( aManifestFileName ).DriveAndPath() ); |
|
370 // Check if ROM installation is requested |
|
371 iRomInstallation = EFalse; |
|
372 TParse driveParser; |
|
373 driveParser.Set( iThemeFilePath, NULL, NULL ); |
|
374 TInt driveNumber; |
|
375 if ( RFs::CharToDrive( driveParser.Drive()[0], driveNumber ) == KErrNone ) |
|
376 { |
|
377 if ( driveNumber == EDriveZ ) |
|
378 { |
|
379 iRomInstallation = ETrue; |
|
380 } |
|
381 } |
|
382 |
|
383 #ifdef HSPS_LOG_ACTIVE |
|
384 if ( iLogBus ) |
|
385 { |
|
386 iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme() - *** Parsing a manifest file:" ) ); |
|
387 } |
|
388 #endif |
|
389 if( BaflUtils::FileExists( iFsSession, aManifestFileName ) ) |
|
390 { |
|
391 // Parse XML from the manifest file |
|
392 TRAP( errorCode, Xml::ParseL( *iXmlParser, iFsSession, aManifestFileName )); |
|
393 } |
|
394 else |
|
395 { |
|
396 #ifdef HSPS_LOG_ACTIVE |
|
397 if ( iLogBus ) |
|
398 { |
|
399 iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme() - Manifest was not found!" ) ); |
|
400 } |
|
401 #endif |
|
402 iFileNotFound = ETrue; |
|
403 errorCode = KErrNotFound; |
|
404 } |
|
405 } |
|
406 |
|
407 if ( !errorCode && !iFileNotFound ) |
|
408 { |
|
409 // The manifest file has been read at this point and following callbacks have been executed: |
|
410 // (unless the manifest was invalid): OnContent, OnStartElement, OnEndElement |
|
411 |
|
412 // Detect installation type. |
|
413 // Performance optimization: do not check if installing from rom. |
|
414 if( !iRomInstallation ) |
|
415 { |
|
416 // Check type of installation |
|
417 TBool instancesFound = EFalse; |
|
418 TRAP( errorCode, instancesFound = IsPluginUsedInAppConfsL() ); |
|
419 if( iThemeServer.PluginInHeaderCache( TUid::Uid( iThemeUid ) ) && instancesFound ) |
|
420 { |
|
421 // Plugin should be found from cache, update notifications are |
|
422 // sent only when plugins are used by one/more app configurations |
|
423 iInstallationType = EInstallationTypeUpdate; |
|
424 } |
|
425 else |
|
426 { |
|
427 iInstallationType = EInstallationTypeNew; |
|
428 } |
|
429 } |
|
430 if ( !errorCode ) |
|
431 { |
|
432 // Check the manifest |
|
433 TRAP( errorCode, ValidateL() ); |
|
434 } |
|
435 if ( !errorCode ) |
|
436 { |
|
437 // correct headerdata is in iHeaderData set by CheckHeaderL() |
|
438 aHeaderData = iHeaderData->Des(); |
|
439 |
|
440 ret = EhspsInstallThemeSuccess; |
|
441 |
|
442 // Set next phase |
|
443 iInstallationPhase = EhspsPhaseCleanup; |
|
444 |
|
445 // number of all resources to iResult |
|
446 iResult->iIntValue2 = 0; |
|
447 } |
|
448 } |
|
449 |
|
450 if ( errorCode ) |
|
451 { |
|
452 #ifdef HSPS_LOG_ACTIVE |
|
453 if( iLogBus ) |
|
454 { |
|
455 iLogBus->LogText( _L( "ChspsInstallationHandler::hspsInstallTheme(): - Installation failed with error code %d" ), |
|
456 errorCode ); |
|
457 } |
|
458 #endif |
|
459 } |
|
460 |
|
461 iResult->iSystemError = errorCode; |
|
462 return ret; |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // ChspsInstallationHandler::GetInterfacePath() |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 TFileName ChspsInstallationHandler::GetInterfacePath() |
|
470 { |
|
471 TFileName path; |
|
472 |
|
473 TParse pathParser; |
|
474 pathParser.Set( iThemeFilePath, NULL, NULL ); |
|
475 pathParser.PopDir(); // pop locale specific folder |
|
476 |
|
477 TPtrC parentFolder = pathParser.FullName().Mid( pathParser.FullName().Length() - KHsps().Length() ); |
|
478 if ( parentFolder.CompareF(KHsps) == 0 ) |
|
479 { |
|
480 pathParser.PopDir(); // pop "hsps" folder |
|
481 path.Copy( pathParser.FullName() ); |
|
482 path.Append( KXuikon ); |
|
483 } |
|
484 return path; |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // ChspsInstallationHandler::ValidateL() |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 void ChspsInstallationHandler::ValidateL() |
|
492 { |
|
493 TFileName interfacePath( GetInterfacePath() ); |
|
494 if ( interfacePath.Length() ) |
|
495 { |
|
496 // If name of the DTD file was specified in the manifest |
|
497 if ( iDtdFile ) |
|
498 { |
|
499 TParse pathParser; |
|
500 pathParser.Set( iThemeFilePath, NULL, NULL ); |
|
501 pathParser.PopDir(); // pop locale specific folder |
|
502 |
|
503 // Find locale specific DTD file |
|
504 AddHspsLocalesV2L( pathParser.FullName() ); |
|
505 } |
|
506 |
|
507 // Find Xuikon resources of each locale |
|
508 AddInterfaceResourcesV2L( interfacePath ); |
|
509 } |
|
510 else |
|
511 { |
|
512 // Find DTD files and locale specific resources from subdirectories under the installation path |
|
513 AddLocalesL( iThemeFilePath ); |
|
514 } |
|
515 |
|
516 // Validate input from the manifest |
|
517 CheckHeaderL(); |
|
518 |
|
519 if ( iSecurityEnforcer.CheckThemeLockingL( *iOdt ) ) |
|
520 { |
|
521 iResult->iXuikonError = KErrThemeStatusLocked; |
|
522 #ifdef HSPS_LOG_ACTIVE |
|
523 if( iLogBus ) |
|
524 { |
|
525 iLogBus->LogText( _L( "ChspsInstallationHandler::ValidateL(): - CheckThemeLockingL" ) ); |
|
526 } |
|
527 #endif |
|
528 User::Leave( KErrAccessDenied ); |
|
529 } |
|
530 |
|
531 #ifdef HSPS_LOG_ACTIVE |
|
532 // printing some debug-info |
|
533 TPtrC xmlfile = iXmlFile->Des(); |
|
534 if( iLogBus ) |
|
535 { |
|
536 iLogBus->LogText( _L( "ChspsInstallationHandler::ValidateL(): - iXmlFile = '%S'" ), |
|
537 &xmlfile ); |
|
538 |
|
539 iLogBus->LogText( _L( "ChspsInstallationHandler::ValidateL(): - resources included = %d" ), |
|
540 iResourceList->Count() ); |
|
541 } |
|
542 #endif |
|
543 } |
|
544 |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // Execution of specific installation phases and transitions in between. |
|
548 // Must be completed by EhspsInstallThemeSuccess, EhspsInstallPhaseSuccess or EhspsInstallThemeFailed |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 ThspsServiceCompletedMessage ChspsInstallationHandler::hspsInstallNextPhaseL( TDes8& aHeaderData ) |
|
552 { |
|
553 // Defaults |
|
554 ThspsServiceCompletedMessage ret = EhspsInstallPhaseSuccess; |
|
555 TInt errorCode = KErrNone; |
|
556 |
|
557 if ( !iDefinitionRepository.Locked() ) |
|
558 { |
|
559 iDefinitionRepository.Lock(); |
|
560 } |
|
561 |
|
562 //For unlocking repository in error cases |
|
563 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
564 |
|
565 switch ( iInstallationPhase ) |
|
566 { |
|
567 case EhspsPhaseIdle: |
|
568 { |
|
569 ret = EhspsServiceRequestError; |
|
570 } |
|
571 break; |
|
572 |
|
573 case EhspsPhaseCleanup: |
|
574 { |
|
575 if ( iOdt ) |
|
576 { |
|
577 // Remove existing/old files from the Plug-in Repository |
|
578 TRAP( errorCode, CleanupL( *iOdt ) ); |
|
579 } |
|
580 if ( errorCode ) |
|
581 { |
|
582 iResult->iSystemError = errorCode; |
|
583 iResult->iXuikonError = errorCode; |
|
584 CleanupStack::Pop(&iDefinitionRepository); |
|
585 return EhspsInstallThemeFailed; |
|
586 } |
|
587 else |
|
588 { |
|
589 iInstallationPhase = EhspsPhaseInstallSkeleton; |
|
590 } |
|
591 } |
|
592 break; |
|
593 |
|
594 case EhspsPhaseInstallSkeleton: |
|
595 { |
|
596 // Parses and stores DOM into the ODT being installed |
|
597 iResult->iIntValue2 = 0; |
|
598 TRAP( errorCode, InstallSkeletonL( ret ) ); |
|
599 if ( errorCode ) |
|
600 { |
|
601 ret = EhspsInstallThemeFailed; |
|
602 } |
|
603 else |
|
604 { |
|
605 iResult->iIntValue2 = 0; |
|
606 |
|
607 // Success - installation finished |
|
608 ret = EhspsInstallThemeSuccess; |
|
609 iInstallationPhase = EhspsPhaseIdle; |
|
610 } |
|
611 } |
|
612 break; |
|
613 |
|
614 default: |
|
615 { |
|
616 iResult->iSystemError = KErrNotReady; |
|
617 ret = EhspsServiceRequestError; |
|
618 } |
|
619 break; |
|
620 } // switch |
|
621 |
|
622 if ( iHeaderData ) |
|
623 { |
|
624 aHeaderData = iHeaderData->Des(); |
|
625 } |
|
626 else |
|
627 { |
|
628 aHeaderData = KNullDesC8; |
|
629 } |
|
630 |
|
631 CleanupStack::Pop(&iDefinitionRepository); |
|
632 return ret; |
|
633 } |
|
634 |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // ChspsInstallationHandler::hspsCancelInstallTheme() |
|
638 // Cancels the theme installation |
|
639 // (other items were commented in a header). |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 ThspsServiceCompletedMessage ChspsInstallationHandler::hspsCancelInstallTheme() |
|
643 { |
|
644 TRAP_IGNORE( CompleteRequestL( EhspsServiceRequestCanceled )); |
|
645 return EhspsServiceRequestCanceled; |
|
646 } |
|
647 |
|
648 |
|
649 // ----------------------------------------------------------------------------- |
|
650 // ChspsInstallationHandler::CheckAutoInstallationValidityL() |
|
651 // Returns EFalse if the user tries to install Licensee default theme |
|
652 // (other items were commented in a header). |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 TBool ChspsInstallationHandler::CheckAutoInstallationValidityL() |
|
656 { |
|
657 if ( iOdt->Flags() & EhspsThemeStatusLicenceeDefault ) |
|
658 { |
|
659 iResult->iXuikonError = KErrIllegalInstallation; |
|
660 return EFalse; |
|
661 } |
|
662 return ETrue; |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // ChspsInstallationHandler::SetLogBus() |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 #ifdef HSPS_LOG_ACTIVE |
|
670 void ChspsInstallationHandler::SetLogBus( ChspsLogBus* aLogBus ) |
|
671 { |
|
672 iLogBus = aLogBus; |
|
673 } |
|
674 #endif |
|
675 |
|
676 |
|
677 // ChspsInstallationHandler::InstallOdtL() |
|
678 // Installs DOM-document ODT and processes resource list |
|
679 // (other items were commented in a header). |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void ChspsInstallationHandler::InstallSkeletonL( ThspsServiceCompletedMessage& /*aReturnMsg*/ ) |
|
683 { |
|
684 #ifdef HSPS_LOG_ACTIVE |
|
685 if( iLogBus ) |
|
686 { |
|
687 iLogBus->LogText( _L( "hspsInstallationHandler::InstallSkeletonL(): - installing and localizing configuration" ) ); |
|
688 } |
|
689 #endif |
|
690 |
|
691 iOdt->SetOdtLanguage( ELangNone ); |
|
692 |
|
693 // Parse DOM |
|
694 ParseDocumentL( *iOdt ); |
|
695 |
|
696 // Save ODT itself as a resource |
|
697 SetODTAsResourceL( *iOdt ); |
|
698 |
|
699 // Add resources parsed from the manifest file into the new ODT instance, generate |
|
700 // target paths and update the iResourcesList array with the new paths |
|
701 User::LeaveIfError( iDefinitionRepository.SetResourceListL( *iOdt, *iResourceList ) ); |
|
702 |
|
703 // Update DOM's configuration node with attributes from the manifest |
|
704 hspsServerUtil::GenerateConfigurationAttributesL( *iOdt ); |
|
705 |
|
706 TBuf8<10> uid; |
|
707 _LIT8( KFormat8, "%X" ); |
|
708 _LIT8( KHexPrefix, "0x" ); |
|
709 uid.Append( KHexPrefix ); |
|
710 uid.AppendFormat( KFormat8, iOdt->ThemeUid() ); |
|
711 |
|
712 // Update configuration max child count |
|
713 if ( hspsServerUtil::FindNodeByTagL( |
|
714 KPluginsElement, |
|
715 *( iOdt->DomDocument().RootNode() ) ) ) |
|
716 { |
|
717 TPtrC8 maxChildCnt; |
|
718 // Plugins node found - Configuration can include child configurations |
|
719 TRAPD( err, hspsServerUtil::GetAttributeValueL( |
|
720 *iOdt, |
|
721 KConfigurationElement, |
|
722 KConfigurationAttrUid, |
|
723 uid, |
|
724 KConfigurationAttrMaxChild, |
|
725 maxChildCnt) ); |
|
726 if ( err ) |
|
727 { |
|
728 // Set default max child configuration count |
|
729 hspsServerUtil::SetAttributeValueL( |
|
730 *iOdt, |
|
731 KConfigurationElement, |
|
732 KConfigurationAttrUid, |
|
733 uid, |
|
734 KConfigurationAttrMaxChild, |
|
735 _L8( "6" ) ); |
|
736 } |
|
737 } |
|
738 else |
|
739 { |
|
740 // Configuration cannot indluce child configurations |
|
741 hspsServerUtil::SetAttributeValueL( |
|
742 *iOdt, |
|
743 KConfigurationElement, |
|
744 KConfigurationAttrUid, |
|
745 uid, |
|
746 KConfigurationAttrMaxChild, |
|
747 _L8( "0" ) ); |
|
748 } |
|
749 |
|
750 if ( iRomInstallation ) |
|
751 { |
|
752 // Update configuration state to KConfStateConfirmed |
|
753 hspsServerUtil::SetAttributeValueL( |
|
754 *iOdt, |
|
755 KConfigurationElement, |
|
756 KConfigurationAttrUid, |
|
757 uid, |
|
758 KConfigurationAttrState, |
|
759 KConfStateConfirmed |
|
760 ); |
|
761 } |
|
762 |
|
763 iOdt->SetOdtLanguage( ELangTest ); |
|
764 |
|
765 // Add a resouces node and its objects from the manifest into the DOM |
|
766 hspsServerUtil::GenerateObjectAttributesL( *iOdt ); |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 // Make localizations according to the active device language |
|
772 iThemeServer.LocalizeL( |
|
773 *iDefEngine, |
|
774 *iOdt ); |
|
775 |
|
776 // Store the ODT instance into the file system |
|
777 iDefinitionRepository.SetOdtL( *iOdt ); |
|
778 } |
|
779 |
|
780 // ----------------------------------------------------------------------------- |
|
781 // ChspsInstallationHandler::CheckHeaderL() |
|
782 // Checks the installed theme's header correctness |
|
783 // (other items were commented in a header). |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 void ChspsInstallationHandler::CheckHeaderL() |
|
787 { |
|
788 // Check whether the manifest is supported by the installer |
|
789 if ( !iPackageVerSupported ) |
|
790 { |
|
791 #ifdef HSPS_LOG_ACTIVE |
|
792 if( iLogBus ) |
|
793 { |
|
794 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - package version is not supported by the server!" ) ); |
|
795 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - Update plug-in configurations and try again" ) ); |
|
796 } |
|
797 #endif |
|
798 |
|
799 User::Leave( KErrNotSupported ); |
|
800 } |
|
801 else |
|
802 { |
|
803 // Store package version |
|
804 iOdt->SetPackageVersionL( *iPackageVersion ); |
|
805 } |
|
806 |
|
807 // Set the resolution family |
|
808 iOdt->SetFamily( iFamilyMask ); |
|
809 |
|
810 // Store root, provider and theme uid |
|
811 if ( iRootUid && iProviderUid && iThemeUid ) |
|
812 { |
|
813 iOdt->SetRootUid( iRootUid ); |
|
814 iOdt->SetProviderUid( iProviderUid ); |
|
815 iOdt->SetThemeUid( iThemeUid ); |
|
816 } |
|
817 else |
|
818 { |
|
819 #ifdef HSPS_LOG_ACTIVE |
|
820 if( iLogBus ) |
|
821 { |
|
822 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - Manifest file error, no UIDs" ) ); |
|
823 } |
|
824 #endif |
|
825 |
|
826 // If the content is empty, the file is supposedly wrong |
|
827 if( !iContent ) |
|
828 { |
|
829 iResult->iXuikonError = KErrWrongManifestFile; |
|
830 User::Leave( KErrNotFound ); |
|
831 } |
|
832 // something goes wrong... |
|
833 if( !iRootUid && !iProviderUid && !iThemeUid && |
|
834 !iThemeFullName && !iThemeShortName && !iThemeVersion ) |
|
835 { |
|
836 iResult->iXuikonError = KErrOtherXuikonError; |
|
837 User::Leave( KErrNotFound ); |
|
838 } |
|
839 if( !iRootUid ) |
|
840 { |
|
841 iResult->iXuikonError = KErrAppUidDefinitionMissing; |
|
842 User::Leave( KErrNotFound ); |
|
843 } |
|
844 if( !iProviderUid ) |
|
845 { |
|
846 iResult->iXuikonError = KErrProviderUidDefinitionMissing; |
|
847 User::Leave( KErrNotFound ); |
|
848 } |
|
849 if( !iThemeUid ) |
|
850 { |
|
851 iResult->iXuikonError = KErrThemeUidDefinitionMissing; |
|
852 User::Leave( KErrNotFound ); |
|
853 } |
|
854 User::Leave(KErrNotFound); |
|
855 } |
|
856 |
|
857 // Store name, short name and version |
|
858 HBufC* themeFullName = NULL; |
|
859 HBufC* themeShortName = NULL; |
|
860 HBufC* themeVersion = NULL; |
|
861 if ( iThemeFullName && iThemeShortName && iThemeVersion ) |
|
862 { |
|
863 themeFullName = HBufC::NewLC( iThemeFullName->Length() ); |
|
864 themeFullName->Des().Copy( *iThemeFullName ); |
|
865 themeShortName = HBufC::NewLC( iThemeShortName->Length() ); |
|
866 themeShortName->Des().Copy( *iThemeShortName ); |
|
867 themeVersion = HBufC::NewLC( iThemeVersion->Length() ); |
|
868 themeVersion->Des().Copy( *iThemeVersion ); |
|
869 } |
|
870 else |
|
871 { |
|
872 #ifdef HSPS_LOG_ACTIVE |
|
873 if( iLogBus ) |
|
874 { |
|
875 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - Manifest file error, no names" ) ); |
|
876 } |
|
877 #endif |
|
878 |
|
879 if( !iThemeFullName ) |
|
880 { |
|
881 iResult->iXuikonError = KErrThemeFullNameDefinitionMissing; |
|
882 User::Leave( KErrNotFound ); |
|
883 } |
|
884 if( !iThemeShortName ) |
|
885 { |
|
886 iResult->iXuikonError = KErrThemeShortDefinitionNameMissing; |
|
887 User::Leave( KErrNotFound ); |
|
888 } |
|
889 if( !iThemeVersion ) |
|
890 { |
|
891 iResult->iXuikonError = KErrThemeVersionDefinitionMissing; |
|
892 User::Leave( KErrNotFound ); |
|
893 } |
|
894 User::Leave(KErrNotFound); |
|
895 } |
|
896 iOdt->SetThemeFullNameL( themeFullName->Des() ); |
|
897 iOdt->SetThemeShortNameL( themeShortName->Des() ); |
|
898 iOdt->SetThemeVersionL( themeVersion->Des() ); |
|
899 if ( iThemeDesc ) |
|
900 { |
|
901 HBufC* buf = HBufC::NewLC( iThemeDesc->Length() ); |
|
902 buf->Des().Copy( iThemeDesc->Des() ); |
|
903 iOdt->SetDescriptionL( buf->Des() ); |
|
904 CleanupStack::PopAndDestroy( buf ); |
|
905 } |
|
906 iOdt->SetMultiInstance( iMultiInstance ); |
|
907 iMultiInstanceFound = EFalse; |
|
908 |
|
909 CleanupStack::PopAndDestroy( themeVersion ); |
|
910 CleanupStack::PopAndDestroy( themeShortName ); |
|
911 CleanupStack::PopAndDestroy( themeFullName ); |
|
912 |
|
913 iOdt->SetConfigurationType( iConfigurationType ); |
|
914 iOdt->SetFlags( iThemeStatus ); |
|
915 |
|
916 // If configuration file is missing |
|
917 if( !iXmlFile ) |
|
918 { |
|
919 #ifdef HSPS_LOG_ACTIVE |
|
920 if( iLogBus ) |
|
921 { |
|
922 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - XML was not declared!" ) ); |
|
923 } |
|
924 #endif |
|
925 iResult->iXuikonError = KErrXmlFileDefinitionMissing; |
|
926 User::Leave( KErrNotFound ); |
|
927 } |
|
928 |
|
929 // If name of the DTD file has been set |
|
930 if ( iDtdFile ) |
|
931 { |
|
932 // Expect localization for at least ELangTest (folder name "00") |
|
933 if ( !iDefaultSpecificationSet || iDefaultSpecification != ELangTest ) |
|
934 { |
|
935 iResult->iXuikonError = KErrDtdFileNotFound; |
|
936 #ifdef HSPS_LOG_ACTIVE |
|
937 if( iLogBus ) |
|
938 { |
|
939 iLogBus->LogText( _L( "ChspsInstallationHandler::CheckHeaderL(): - check localization!" ) ); |
|
940 } |
|
941 #endif |
|
942 User::Leave( KErrNotFound ); |
|
943 } |
|
944 } |
|
945 |
|
946 // all header-information is in place, now try to marshall it as a return of the service call |
|
947 iHeaderData = iOdt->MarshalHeaderL(); |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // ChspsInstallationHandler::ParseDocumentL |
|
952 // Parses the skeleton DOM with the help of Definition Engine |
|
953 // (other items were commented in a header). |
|
954 // ----------------------------------------------------------------------------- |
|
955 // |
|
956 void ChspsInstallationHandler::ParseDocumentL( ChspsODT& aOdt ) |
|
957 { |
|
958 TInt deferror = KErrNone; |
|
959 TInt errorCode = KErrNone; |
|
960 ChspsDefinitionEngineInterface::TError t_error; |
|
961 |
|
962 #ifdef _hsps_PERFORMANCE_TEST_ |
|
963 // service time prints |
|
964 _LIT( KStartTiming, "ChspsInstallationHandler::ParseDocumentL(): - calling iDefEngine->CreateDOM().."); |
|
965 TTime start_time = ChspsTimeMon::StartTiming( KStartTiming ); |
|
966 #endif |
|
967 |
|
968 t_error = iDefEngine->CreateDOM( iFsSession, *iXmlFile, aOdt ); |
|
969 |
|
970 deferror = t_error.iDefEngError + t_error.iSubComponentError; |
|
971 |
|
972 if (!deferror) |
|
973 { |
|
974 // get ODT information |
|
975 ChspsDomDocument& domDocument = aOdt.DomDocument(); |
|
976 TInt domNodeCount = domDocument.DomNodeCount(); |
|
977 // write the result |
|
978 iResult->iIntValue1 = 0; |
|
979 iResult->iIntValue2 = domNodeCount; |
|
980 |
|
981 #ifdef _hsps_PERFORMANCE_TEST_ |
|
982 // calculating service time |
|
983 _LIT( KStopTiming, "ChspsInstallationHandler::ParseDocumentL(): - Parsing success." ); |
|
984 ChspsTimeMon::StopTiming(start_time, KStopTiming ); |
|
985 #endif |
|
986 } |
|
987 else |
|
988 { |
|
989 errorCode = KErrCorrupt; |
|
990 iResult->iXuikonError = errorCode; |
|
991 |
|
992 iResult->iIntValue1 = t_error.iDefEngError; |
|
993 iResult->iIntValue2 = t_error.iSubComponentError; |
|
994 |
|
995 #ifdef HSPS_LOG_ACTIVE |
|
996 if( iLogBus ) |
|
997 { |
|
998 iLogBus->LogText( _L( "ChspsInstallationHandler::ParseDocumentL(): - TRAP returned %d" ), |
|
999 errorCode ); |
|
1000 iLogBus->LogText( _L( "ChspsInstallationHandler::ParseDocumentL(): - ChspsDefinition Engine::TError.iParserError: %d" ), |
|
1001 t_error.iDefEngError ); |
|
1002 iLogBus->LogText( _L( "ChspsInstallationHandler::ParseDocumentL(): - ChspsDefinition Engine::TError.iSubComponentError: %d" ), |
|
1003 t_error.iSubComponentError ); |
|
1004 } |
|
1005 #endif |
|
1006 } |
|
1007 |
|
1008 User::LeaveIfError(errorCode); |
|
1009 } |
|
1010 |
|
1011 // ----------------------------------------------------------------------------- |
|
1012 // ChspsInstallationHandler::AddResourceL() |
|
1013 // Adds parsed resource into a temporary resource list, from which the resources |
|
1014 // are applied to an ODT instance at later phase |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // |
|
1017 void ChspsInstallationHandler::AddResourceL( |
|
1018 CArrayPtrSeg<ChspsResource>& aArray, |
|
1019 const TPtrC aFilename, |
|
1020 const TLanguage aLanguage, |
|
1021 const ThspsResourceType aResourceType, |
|
1022 const TPtrC8 aMimetype, |
|
1023 const TPtrC8 aTag ) |
|
1024 { |
|
1025 TParsePtrC parsePtr( aFilename ); |
|
1026 |
|
1027 ChspsResource* r = ChspsResource::NewL(); |
|
1028 CleanupStack::PushL(r); |
|
1029 |
|
1030 r->SetLockingPolicy( EhspsUnlocked ); |
|
1031 if ( iThemeStatus & EhspsThemeStatusLicenceeDefault ) |
|
1032 { |
|
1033 r->SetLockingPolicy( EhspsLocked ); |
|
1034 } |
|
1035 r->SetResourceIdL( parsePtr.NameAndExt() ); |
|
1036 |
|
1037 // Common resources are parsed first - thus when the iLanguageSpecification is other than ELangNone, |
|
1038 // then we are parsing language specific resources |
|
1039 r->SetConfigurationUid( iThemeUid ); |
|
1040 r->SetLanguage( aLanguage ); |
|
1041 r->SetFileNameL( aFilename ); |
|
1042 r->SetResourceType( aResourceType ); |
|
1043 if ( aMimetype.Length() ) |
|
1044 { |
|
1045 r->SetMimeTypeL( TDataType( aMimetype ) ); |
|
1046 } |
|
1047 const TInt l = aTag.Length(); |
|
1048 if ( l ) |
|
1049 { |
|
1050 HBufC* buf = HBufC::NewLC( l ); |
|
1051 buf->Des().Copy( aTag ); |
|
1052 r->SetTagsL( *buf ); |
|
1053 CleanupStack::PopAndDestroy( buf ); |
|
1054 } |
|
1055 aArray.AppendL( r ); |
|
1056 |
|
1057 CleanupStack::Pop( r ); |
|
1058 } |
|
1059 |
|
1060 // ----------------------------------------------------------------------------- |
|
1061 // ChspsInstallationHandler::CleanupL() |
|
1062 // Executes cleaning of the target folder prior to the installation process |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // |
|
1065 void ChspsInstallationHandler::CleanupL( const ChspsODT& aOdt ) |
|
1066 { |
|
1067 #ifdef HSPS_LOG_ACTIVE |
|
1068 if( iLogBus ) |
|
1069 { |
|
1070 iLogBus->LogText( _L( "hspsInstallationHandler::CleanupL(): - removing previous installation" ) ); |
|
1071 } |
|
1072 #endif |
|
1073 |
|
1074 // Get ODT's relative path in Plug-in Repository without the drive information |
|
1075 HBufC* relativePath = HBufC::NewLC( KMaxFileName ); |
|
1076 TPtr ptr = relativePath->Des(); |
|
1077 iDefinitionRepository.GetODTPathL( aOdt, ptr ); |
|
1078 |
|
1079 // Strip file name and append path with a drive symbol |
|
1080 TParsePtr parser( ptr ); |
|
1081 parser.PopDir(); |
|
1082 TPtrC confPath = parser.Path(); |
|
1083 TPath file; |
|
1084 file.Format( _L("%S%S"), &KCDrive, &confPath ); |
|
1085 CleanupStack::PopAndDestroy( relativePath ); |
|
1086 |
|
1087 // If there was an existing configuration folder |
|
1088 if( BaflUtils::FileExists( iFsSession, file ) ) |
|
1089 { |
|
1090 // Remove the old configuration |
|
1091 CFileMan* fileMan = CFileMan::NewL( iFsSession ); |
|
1092 CleanupStack::PushL( fileMan ); |
|
1093 User::LeaveIfError( fileMan->RmDir( file ) ); |
|
1094 CleanupStack::PopAndDestroy( fileMan ); |
|
1095 } |
|
1096 |
|
1097 iThemeServer.UpdateHeaderListCache( |
|
1098 EhspsCacheRemoveHeader, |
|
1099 aOdt.RootUid(), |
|
1100 aOdt.ProviderUid(), |
|
1101 aOdt.ThemeUid() ); |
|
1102 } |
|
1103 |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // ChspsInstallationHandler::RollBackL() |
|
1107 // Rolls back the installation if it fails or is cancelled. Functionality depends |
|
1108 // on the state where the installation was. |
|
1109 // (other items were commented in a header). |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // |
|
1112 void ChspsInstallationHandler::RollBackL(ChspsODT& aOdt) |
|
1113 { |
|
1114 #ifdef HSPS_LOG_ACTIVE |
|
1115 if( iLogBus ) |
|
1116 { |
|
1117 iLogBus->LogText( _L( "hspsInstallationHandler::RollBackL(): - rolling back.." ) ); |
|
1118 } |
|
1119 #endif |
|
1120 |
|
1121 // then rolling back the installation in according to in which state it was before cancel |
|
1122 switch ( iInstallationPhase ) |
|
1123 { |
|
1124 case EhspsPhaseIdle: |
|
1125 case EhspsPhaseInitialise: |
|
1126 case EhspsPhaseCleanup: |
|
1127 break; |
|
1128 case EhspsPhaseInstallSkeleton: |
|
1129 { |
|
1130 iDefinitionRepository.RemoveThemeL( aOdt ); |
|
1131 iInstallationPhase = EhspsPhaseIdle; // roll-back is completed |
|
1132 } |
|
1133 break; |
|
1134 default: |
|
1135 break; |
|
1136 } |
|
1137 } |
|
1138 |
|
1139 |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 // ChspsInstallationHandler::CompleteRequestL() |
|
1142 // Completes client request |
|
1143 // (other items were commented in a header). |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // |
|
1146 void ChspsInstallationHandler::CompleteRequestL(const ThspsServiceCompletedMessage aReturnMessage, |
|
1147 const TDesC8& aHeaderData ) |
|
1148 { |
|
1149 TBool wasLocked( EFalse ); |
|
1150 |
|
1151 if( iDefinitionRepository.Locked() ) |
|
1152 { |
|
1153 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
1154 wasLocked = ETrue; |
|
1155 } |
|
1156 |
|
1157 // only EhspsInstallThemeSuccess and EhspsInstallPhaseSuccess quaranties valid header to be returned |
|
1158 TBool complete( ETrue ); |
|
1159 |
|
1160 switch( iInstallationMode ) |
|
1161 { |
|
1162 case EServiceHandler: |
|
1163 { |
|
1164 if( aReturnMessage == EhspsInstallThemeSuccess ) |
|
1165 { |
|
1166 // Activate the installed application configuration if EhspsThemeStatusMakeActive is set |
|
1167 if ( iThemeStatus & EhspsThemeStatusMakeActive ) |
|
1168 { |
|
1169 if ( iConfigurationType == EhspsAppConfiguration ) |
|
1170 { |
|
1171 ActivateThemeL(); |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 // lets try to delete temp files. Server will delete them only |
|
1176 // if there are not current resource holders |
|
1177 iInstallationPhase = EhspsPhaseIdle; |
|
1178 // write the result |
|
1179 iResult->iIntValue1 = 0; |
|
1180 iResult->iIntValue2 = 0; |
|
1181 |
|
1182 iDefinitionRepository.Unlock(); |
|
1183 |
|
1184 if ( !iDisableNotifications ) |
|
1185 { |
|
1186 // Inform server that a configuration was added or replaced and that the |
|
1187 // header cache should be updated (specific header to be added can be obtained |
|
1188 // from the uids) |
|
1189 |
|
1190 if( iInstallationType == EInstallationTypeNew ) |
|
1191 { |
|
1192 ThspsRepositoryInfo info( |
|
1193 ThspsRepositoryEvent( EhspsODTAdded ), |
|
1194 0, |
|
1195 0, |
|
1196 0, //=Any file |
|
1197 0, |
|
1198 iOdt->RootUid(), |
|
1199 iOdt->ProviderUid(), |
|
1200 iOdt->ThemeUid(),0,ETrue, |
|
1201 iOdt->ThemeFullName(), |
|
1202 (TLanguage)( iOdt->OdtLanguage() ) |
|
1203 ); |
|
1204 |
|
1205 iDefinitionRepository.RegisterNotification( info ); |
|
1206 } |
|
1207 else if( iInstallationType == EInstallationTypeUpdate ) |
|
1208 { |
|
1209 NotifyOdtUpdatedL(); |
|
1210 } |
|
1211 } |
|
1212 |
|
1213 #ifdef HSPS_LOG_ACTIVE |
|
1214 if( iLogBus ) |
|
1215 { |
|
1216 iLogBus->LogText( _L( "ChspsInstallationHandler::CompleteRequestL(): - configuration %d was successfully installed (EServiceHandler)" ), |
|
1217 iOdt->ThemeUid() ); |
|
1218 } |
|
1219 #endif |
|
1220 } |
|
1221 else if ( aReturnMessage == EhspsInstallPhaseSuccess ) |
|
1222 { |
|
1223 iResult->iIntValue1 = iInstallationPhase; |
|
1224 } |
|
1225 else if ( aReturnMessage == EhspsServiceRequestSheduled ) |
|
1226 { |
|
1227 complete = EFalse; |
|
1228 } |
|
1229 else if (aReturnMessage == EhspsServiceRequestCanceled) |
|
1230 { |
|
1231 iDefinitionRepository.Unlock(); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 // installation failed, resetting |
|
1236 // system error and xuikon error are writen in iResult when error was encountered |
|
1237 iInstallationPhase = EhspsPhaseIdle; |
|
1238 |
|
1239 if( !iMessagePtr.IsNull() ) |
|
1240 { |
|
1241 iMessagePtr.WriteL( 2, KNullDesC8, 0 ); |
|
1242 } |
|
1243 |
|
1244 RollBackL ( *iOdt ); |
|
1245 iDefinitionRepository.Unlock(); |
|
1246 } |
|
1247 |
|
1248 if( complete && !iMessagePtr.IsNull() ) |
|
1249 { |
|
1250 RDesWriteStream writeBuf( iResultData ); |
|
1251 iResult->ExternalizeL( writeBuf ); |
|
1252 writeBuf.Close(); |
|
1253 iMessagePtr.WriteL( 0, iResultData, 0 ); |
|
1254 iMessagePtr.WriteL( 2, aHeaderData, 0 ); |
|
1255 iMessagePtr.Complete( aReturnMessage ); |
|
1256 } |
|
1257 } |
|
1258 break; |
|
1259 |
|
1260 case EAsynchronousObject: |
|
1261 { |
|
1262 if( aReturnMessage == EhspsInstallThemeSuccess ) |
|
1263 { |
|
1264 |
|
1265 // Activate the installed application configuration if EhspsThemeStatusMakeActive is set |
|
1266 if( iThemeStatus & EhspsThemeStatusMakeActive ) |
|
1267 { |
|
1268 if ( iConfigurationType == EhspsAppConfiguration ) |
|
1269 { |
|
1270 ActivateThemeL(); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 // lets try to delete temp files. Server will delete them only if there are not |
|
1275 // current resource holders |
|
1276 iInstallationPhase = EhspsPhaseIdle; |
|
1277 iDefinitionRepository.Unlock(); |
|
1278 |
|
1279 if ( !iDisableNotifications ) |
|
1280 { |
|
1281 if( iInstallationType == EInstallationTypeNew ) |
|
1282 { |
|
1283 // Inform server there are files to be cleaned and cache has been updated |
|
1284 ThspsRepositoryInfo info( ThspsRepositoryEvent( EhspsODTAdded ), |
|
1285 0, |
|
1286 0, |
|
1287 0, //=Any file |
|
1288 0, |
|
1289 iOdt->RootUid(), |
|
1290 iOdt->ProviderUid(), |
|
1291 iOdt->ThemeUid(),0,ETrue, |
|
1292 iOdt->ThemeFullName(), |
|
1293 (TLanguage)( iOdt->OdtLanguage() ) ); |
|
1294 |
|
1295 iDefinitionRepository.RegisterNotification( info ); |
|
1296 } |
|
1297 else if( iInstallationType == EInstallationTypeUpdate ) |
|
1298 { |
|
1299 NotifyOdtUpdatedL(); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 #ifdef HSPS_LOG_ACTIVE |
|
1304 if( iLogBus ) |
|
1305 { |
|
1306 iLogBus->LogText( _L( "ChspsInstallationHandler::CompleteRequestL(): - configuration %d was successfully installed (EAsynchronousObject)" ), |
|
1307 iOdt->ThemeUid() ); |
|
1308 } |
|
1309 #endif |
|
1310 } |
|
1311 else if( aReturnMessage == EhspsInstallPhaseSuccess ) |
|
1312 { |
|
1313 iResult->iIntValue1 = iInstallationPhase; |
|
1314 } |
|
1315 else if( aReturnMessage == EhspsServiceRequestSheduled ) |
|
1316 { |
|
1317 complete = EFalse; |
|
1318 } |
|
1319 else |
|
1320 { |
|
1321 // installation failed, resetting |
|
1322 // system error and xuikon error are written in iResult when error was encountered |
|
1323 iInstallationPhase = EhspsPhaseIdle; |
|
1324 RollBackL ( *iOdt ); |
|
1325 iDefinitionRepository.Unlock(); |
|
1326 } |
|
1327 |
|
1328 if ( complete ) |
|
1329 { |
|
1330 User::RequestComplete( iRequestStatus, (TInt)aReturnMessage ); |
|
1331 } |
|
1332 } |
|
1333 break; |
|
1334 default: |
|
1335 { |
|
1336 if( wasLocked ) |
|
1337 { |
|
1338 CleanupStack::Pop( &iDefinitionRepository ); |
|
1339 } |
|
1340 |
|
1341 User::Leave( KErrCancel ); |
|
1342 } |
|
1343 break; |
|
1344 } |
|
1345 |
|
1346 if( wasLocked ) |
|
1347 { |
|
1348 CleanupStack::Pop( &iDefinitionRepository ); |
|
1349 } |
|
1350 } |
|
1351 |
|
1352 // ----------------------------------------------------------------------------- |
|
1353 // ChspsInstallationHandler::IsPluginUsedInAppConfsL |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // |
|
1356 TBool ChspsInstallationHandler::IsPluginUsedInAppConfsL() |
|
1357 { |
|
1358 TBool isUsed = EFalse; |
|
1359 |
|
1360 const TInt KArrayGranularity = 3; |
|
1361 CArrayPtrSeg<ChspsODT>* activeAppConfs = new ( ELeave ) CArrayPtrSeg<ChspsODT>( KArrayGranularity ); |
|
1362 CleanupStack::PushL( activeAppConfs ); |
|
1363 |
|
1364 // Retrieve active application configurations. These are not owned! |
|
1365 GetActiveAppConfsL( *activeAppConfs ); |
|
1366 |
|
1367 // Loop found headers |
|
1368 for( TInt i = 0; i < activeAppConfs->Count(); i++ ) |
|
1369 { |
|
1370 ChspsODT* const header = (*activeAppConfs)[i]; |
|
1371 if( header ) |
|
1372 { |
|
1373 // Clone header to avoid modification of original |
|
1374 ChspsODT* odt = header->CloneL(); |
|
1375 CleanupStack::PushL( odt ); |
|
1376 |
|
1377 // Get full ODT instance with DOM data |
|
1378 User::LeaveIfError( iDefinitionRepository.GetOdtL( *odt ) ); |
|
1379 |
|
1380 // Get all plugin instances with the configuration UID that was just installed |
|
1381 RArray<TInt> pluginIds; |
|
1382 CleanupClosePushL( pluginIds ); |
|
1383 hspsServerUtil::GetPluginIdsByUidL( |
|
1384 *odt, |
|
1385 TUid::Uid( iThemeUid ), |
|
1386 pluginIds ); |
|
1387 isUsed = ( pluginIds.Count() > 0 ); |
|
1388 CleanupStack::PopAndDestroy(); |
|
1389 |
|
1390 CleanupStack::PopAndDestroy( odt ); |
|
1391 |
|
1392 if ( isUsed ) |
|
1393 { |
|
1394 break; |
|
1395 } |
|
1396 } |
|
1397 } |
|
1398 |
|
1399 |
|
1400 |
|
1401 CleanupStack::PopAndDestroy( activeAppConfs ); |
|
1402 |
|
1403 return isUsed; |
|
1404 } |
|
1405 |
|
1406 // ----------------------------------------------------------------------------- |
|
1407 // ChspsInstallationHandler::NotifyOdtUpdatedL |
|
1408 // ----------------------------------------------------------------------------- |
|
1409 // |
|
1410 void ChspsInstallationHandler::NotifyOdtUpdatedL() |
|
1411 { |
|
1412 // Nothing to do if notifications disabled. |
|
1413 if( iDisableNotifications ) |
|
1414 { |
|
1415 return; |
|
1416 } |
|
1417 |
|
1418 // This method should only be called when type is update. |
|
1419 if( iInstallationType != EInstallationTypeUpdate ) |
|
1420 { |
|
1421 #ifdef HSPS_LOG_ACTIVE |
|
1422 if( iLogBus ) |
|
1423 { |
|
1424 iLogBus->LogText( _L( "ChspsInstallationHandler::NotifyOdtUpdatedL(): Error: Installation type is not update." ) ); |
|
1425 } |
|
1426 #endif |
|
1427 |
|
1428 return; |
|
1429 } |
|
1430 |
|
1431 // Sanity check. |
|
1432 if( !iOdt ) |
|
1433 { |
|
1434 #ifdef HSPS_LOG_ACTIVE |
|
1435 if( iLogBus ) |
|
1436 { |
|
1437 iLogBus->LogText( _L( "ChspsInstallationHandler::NotifyOdtUpdatedL(): Error: iOdt == NULL." ) ); |
|
1438 } |
|
1439 #endif |
|
1440 |
|
1441 return; |
|
1442 } |
|
1443 |
|
1444 const TInt KArrayGranularity = 2; |
|
1445 CArrayPtrSeg<ChspsODT>* activeAppConfs = new ( ELeave ) CArrayPtrSeg<ChspsODT>( KArrayGranularity ); |
|
1446 CleanupStack::PushL( activeAppConfs ); |
|
1447 |
|
1448 // Retrieve active application configurations. These are not owned! |
|
1449 GetActiveAppConfsL( *activeAppConfs ); |
|
1450 |
|
1451 // Notification list. |
|
1452 RArray<ThspsRepositoryInfo> notifications; |
|
1453 CleanupClosePushL( notifications ); |
|
1454 |
|
1455 // Construct notifications for every changed plugin id |
|
1456 // in every active application configuration. |
|
1457 for( TInt i = 0; i < activeAppConfs->Count(); i++ ) |
|
1458 { |
|
1459 ChspsODT* const activeODT = (*activeAppConfs)[i]; |
|
1460 |
|
1461 // Sanity check. |
|
1462 if( !activeODT ) |
|
1463 { |
|
1464 #ifdef HSPS_LOG_ACTIVE |
|
1465 if( iLogBus ) |
|
1466 { |
|
1467 iLogBus->LogText( _L( "ChspsInstallationHandler::NotifyOdtUpdatedL(): Error: active ODT list contains NULL." ) ); |
|
1468 } |
|
1469 #endif |
|
1470 |
|
1471 continue; |
|
1472 } |
|
1473 |
|
1474 // Clone activeOdt to avoid modification of original. |
|
1475 ChspsODT* fullODT = activeODT->CloneL(); |
|
1476 CleanupStack::PushL( fullODT ); |
|
1477 |
|
1478 User::LeaveIfError( iDefinitionRepository.GetOdtL( *fullODT ) ); |
|
1479 |
|
1480 RArray<TInt> pluginIds; |
|
1481 CleanupClosePushL( pluginIds ); |
|
1482 |
|
1483 // Get plugin ids. |
|
1484 hspsServerUtil::GetPluginIdsByUidL( *fullODT, |
|
1485 TUid::Uid( iOdt->ThemeUid() ), |
|
1486 pluginIds ); |
|
1487 |
|
1488 // Construct notifications. One for each plugin instance |
|
1489 // that is affected by update. |
|
1490 for( TInt j = 0; j < pluginIds.Count(); j++ ) |
|
1491 { |
|
1492 ThspsRepositoryInfo info( |
|
1493 ThspsRepositoryEvent( EhspsODTUpdated ), |
|
1494 fullODT->RootUid(), |
|
1495 fullODT->ThemeUid(), |
|
1496 0, //=Any file |
|
1497 0, |
|
1498 iOdt->RootUid(), |
|
1499 iOdt->ProviderUid(), |
|
1500 iOdt->ThemeUid(), |
|
1501 pluginIds[j], |
|
1502 EFalse, |
|
1503 KNullDesC(), |
|
1504 (TLanguage)( fullODT->OdtLanguage() ) ); |
|
1505 |
|
1506 notifications.Append( info ); |
|
1507 } |
|
1508 |
|
1509 CleanupStack::PopAndDestroy(); // pluginIds. |
|
1510 CleanupStack::PopAndDestroy( fullODT ); |
|
1511 fullODT = NULL; |
|
1512 |
|
1513 // Send applications notifications in one group. |
|
1514 for( TInt k = 0; k < notifications.Count(); k++ ) |
|
1515 { |
|
1516 // If last... |
|
1517 if( k == notifications.Count() - 1 ) |
|
1518 { |
|
1519 // ... Modify accordingly. |
|
1520 notifications[ k ].iLastNotification = ETrue; |
|
1521 } |
|
1522 |
|
1523 // Send. |
|
1524 iDefinitionRepository.RegisterNotification( notifications[ k ] ); |
|
1525 } |
|
1526 |
|
1527 // Clean notifications list. |
|
1528 notifications.Reset(); |
|
1529 } |
|
1530 |
|
1531 CleanupStack::PopAndDestroy(); // notifications. |
|
1532 CleanupStack::PopAndDestroy( activeAppConfs ); |
|
1533 activeAppConfs = NULL; |
|
1534 } |
|
1535 |
|
1536 // ----------------------------------------------------------------------------- |
|
1537 // ChspsInstallationHandler::GetActiveAppConfsL |
|
1538 // ----------------------------------------------------------------------------- |
|
1539 // |
|
1540 void ChspsInstallationHandler::GetActiveAppConfsL( CArrayPtrSeg<ChspsODT>& aActiveAppConfs ) |
|
1541 { |
|
1542 const TInt count = iHeaderListCache.Count(); |
|
1543 for( TInt i = 0; i < count; i++ ) |
|
1544 { |
|
1545 ChspsODT* header = iHeaderListCache.At( i ); |
|
1546 |
|
1547 if( header && header->ConfigurationType() == EhspsAppConfiguration ) |
|
1548 { |
|
1549 // Check if application configuration is active. |
|
1550 TInt tmp = 0; |
|
1551 if ( iCentralRepository.Get( header->RootUid(), tmp ) == KErrNone ) |
|
1552 { |
|
1553 if( tmp == header->ThemeUid() ) |
|
1554 { |
|
1555 // Active application configuration found. |
|
1556 aActiveAppConfs.AppendL( header ); |
|
1557 } |
|
1558 } |
|
1559 } |
|
1560 } |
|
1561 } |
|
1562 |
|
1563 // ----------------------------------------------------------------------------- |
|
1564 // Saves ODT itself as an resource |
|
1565 // ----------------------------------------------------------------------------- |
|
1566 // |
|
1567 void ChspsInstallationHandler::SetODTAsResourceL( ChspsODT& aOdt ) |
|
1568 { |
|
1569 TInt errorCode = KErrNone; |
|
1570 |
|
1571 ChspsResource* res = ChspsResource::NewL(); |
|
1572 CleanupStack::PushL( res ); |
|
1573 |
|
1574 ThspsLockingPolicy lockingPolicy = EhspsUnlocked; |
|
1575 if ( aOdt.Flags() & EhspsThemeStatusLicenceeDefault ) |
|
1576 { |
|
1577 lockingPolicy = EhspsLocked; |
|
1578 } |
|
1579 |
|
1580 // ODT-resource is handled as a cached resource |
|
1581 res->SetLockingPolicy( lockingPolicy ); |
|
1582 res->SetResourceType( EResourceODT ); |
|
1583 res->SetResourceIdL( aOdt.ThemeShortName() ); |
|
1584 //res->SetFileNameL( filepath ); will be set by the repository |
|
1585 res->SetMimeTypeL(TDataType( KUnknownMimeType )); |
|
1586 res->SetConfigurationUid( aOdt.ThemeUid() ); |
|
1587 |
|
1588 // Creates a path for given ODT |
|
1589 iDefinitionRepository.MakeODTPathL( aOdt, *res ); |
|
1590 |
|
1591 aOdt.AddResourceL( res ); |
|
1592 |
|
1593 CleanupStack::Pop(res); |
|
1594 |
|
1595 User::LeaveIfError( errorCode ); |
|
1596 } |
|
1597 |
|
1598 |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // ChspsInstallationHandler::ActivateThemeL() |
|
1601 // |
|
1602 // (other items were commented in a header). |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // |
|
1605 void ChspsInstallationHandler::ActivateThemeL() |
|
1606 { |
|
1607 const TUint32 fullMask = 0xFFFFFFFF; |
|
1608 RArray<TUint32> res; |
|
1609 CleanupClosePushL( res ); |
|
1610 |
|
1611 TInt errorCode = KErrNone; |
|
1612 iCentralRepository.FindL( iOdt->RootUid(), fullMask, res ); |
|
1613 if ( res.Count() == 0 ) |
|
1614 { |
|
1615 errorCode = iCentralRepository.Create( iOdt->RootUid(), iOdt->ThemeUid() ); |
|
1616 } |
|
1617 else |
|
1618 { |
|
1619 errorCode = iCentralRepository.Set( iOdt->RootUid(), iOdt->ThemeUid() ); |
|
1620 } |
|
1621 if ( !errorCode ) |
|
1622 { |
|
1623 TUint flags = iOdt->Flags(); |
|
1624 iOdt->SetFlags( flags | EhspsThemeStatusActive ); |
|
1625 |
|
1626 // If not processing ROM installations |
|
1627 if ( !iDisableNotifications ) |
|
1628 { |
|
1629 // inform for cache update to the repository so that everyone will know |
|
1630 // about the change |
|
1631 ThspsRepositoryInfo info( EhspsODTActivated ); |
|
1632 iDefinitionRepository.RegisterNotification( info ); |
|
1633 } |
|
1634 } |
|
1635 res.Close(); |
|
1636 CleanupStack::PopAndDestroy(); //res |
|
1637 } |
|
1638 |
|
1639 // ----------------------------------------------------------------------------- |
|
1640 // ChspsInstallationHandler::OnStartElementL |
|
1641 // Verifies that the installer is able to parse the manifest file, |
|
1642 // parses language specifications and resources |
|
1643 // ----------------------------------------------------------------------------- |
|
1644 // |
|
1645 void ChspsInstallationHandler::OnStartElementL( |
|
1646 const RTagInfo& aElement, |
|
1647 const RAttributeArray& aAttributes, |
|
1648 TInt /*aErrorCode*/) |
|
1649 { |
|
1650 TPtrC8 localName = aElement.LocalName().DesC(); |
|
1651 |
|
1652 if( iContent ) |
|
1653 { |
|
1654 delete iContent; |
|
1655 iContent = NULL; |
|
1656 } |
|
1657 |
|
1658 if ( localName == KPackage ) |
|
1659 { |
|
1660 // Check whether the version attribute is specified |
|
1661 TInt argCount = aAttributes.Count(); |
|
1662 if( argCount ) |
|
1663 { |
|
1664 for( TInt argIndex=0; argIndex < argCount; argIndex++ ) |
|
1665 { |
|
1666 const TDesC8& attName = aAttributes[argIndex].Attribute().LocalName().DesC(); |
|
1667 if ( attName.Compare(KPackageVersion) == 0 ) |
|
1668 { |
|
1669 delete iPackageVersion; |
|
1670 iPackageVersion = NULL; |
|
1671 iPackageVersion = HBufC::NewL( KMaxFileName ); |
|
1672 iPackageVersion->Des().Copy( aAttributes[argIndex].Value().DesC() ); |
|
1673 // Is manifest supported by this parser? |
|
1674 iPackageVerSupported = ETrue; //TODO temporarily enable till 0.3 to 1.0 changes have been integrated ( iPackageVersion->Des().Compare(KhspsSupportedManifestVersion) == 0); |
|
1675 break; |
|
1676 } |
|
1677 } |
|
1678 } |
|
1679 } |
|
1680 |
|
1681 else if ( localName == KLocalized ) |
|
1682 { |
|
1683 // From now on, we are parsing filenames of localized resources |
|
1684 iLocalized = ETrue; |
|
1685 } |
|
1686 |
|
1687 else if ( localName == KFileResource ) |
|
1688 { |
|
1689 if ( iMediaType ) |
|
1690 { |
|
1691 delete iMediaType; |
|
1692 iMediaType = NULL; |
|
1693 } |
|
1694 |
|
1695 // Get attributes of the resource element and store them for adding in ::OnEndElementL() |
|
1696 TInt attrCount( aAttributes.Count() ); |
|
1697 for( TInt i=0; i<attrCount; i++ ) |
|
1698 { |
|
1699 const TDesC8& attValueDes8 = aAttributes[i].Value().DesC(); |
|
1700 |
|
1701 // If mediatype attribute was found |
|
1702 if ( aAttributes[i].Attribute().LocalName().DesC() == KMediaType ) |
|
1703 { |
|
1704 TPtrC8 orginalPtr( aAttributes[i].Value().DesC() ); |
|
1705 TInt length = orginalPtr.Length(); |
|
1706 |
|
1707 // Length limit |
|
1708 if ( length > KMaxMediaTypeLength ) |
|
1709 { |
|
1710 length = KMaxMediaTypeLength; |
|
1711 |
|
1712 #ifdef HSPS_LOG_ACTIVE |
|
1713 if( iLogBus ) |
|
1714 { |
|
1715 iLogBus->LogText( _L( "ChspsInstallationHandler::OnStartElementL(): - mediatype was too long!" ) ); |
|
1716 } |
|
1717 #endif |
|
1718 } |
|
1719 |
|
1720 iMediaType = HBufC8::NewL( length ); |
|
1721 iMediaType->Des().Copy( orginalPtr.Left( length ) ); |
|
1722 } |
|
1723 else if ( aAttributes[i].Attribute().LocalName().DesC() == KTag ) |
|
1724 { |
|
1725 delete iResourceTag; |
|
1726 iResourceTag = NULL; |
|
1727 if ( attValueDes8.Length() ) |
|
1728 { |
|
1729 iResourceTag = attValueDes8.Left( KMaxTagsLength ).AllocL(); |
|
1730 } |
|
1731 } |
|
1732 |
|
1733 } // for |
|
1734 |
|
1735 } |
|
1736 |
|
1737 if ( !iMultiInstanceFound ) |
|
1738 { |
|
1739 iMultiInstance = KMultiInstanceDefaultValue; |
|
1740 } |
|
1741 } |
|
1742 |
|
1743 // ----------------------------------------------------------------------------- |
|
1744 // Parsing of the manifest elements. |
|
1745 // ----------------------------------------------------------------------------- |
|
1746 // |
|
1747 void ChspsInstallationHandler::OnEndElementL( const RTagInfo& aElement, TInt /*aErrorCode*/ ) |
|
1748 { |
|
1749 TPtrC8 localName = aElement.LocalName().DesC(); |
|
1750 |
|
1751 if ( localName == KFamily ) |
|
1752 { |
|
1753 #if defined(WINSCW) || defined(__WINS__) |
|
1754 const TPtrC8 familyPtr( iContent->Des() ); |
|
1755 iFamilyMask |= ChspsFamilyListener::GetFamilyType( familyPtr ); |
|
1756 #endif // defined(WINSCW) |
|
1757 } |
|
1758 else if ( localName == KConfigurationType ) |
|
1759 { |
|
1760 // Get configuration type from the manifest |
|
1761 if( *iContent == KManifestTypeApp ) |
|
1762 { |
|
1763 iConfigurationType = EhspsAppConfiguration; |
|
1764 } |
|
1765 else if ( *iContent == KManifestTypeView ) |
|
1766 { |
|
1767 iConfigurationType = EhspsViewConfiguration; |
|
1768 } |
|
1769 else if ( *iContent == KManifestTypeWidget ) |
|
1770 { |
|
1771 iConfigurationType = EhspsWidgetConfiguration; |
|
1772 } |
|
1773 else if( *iContent == KManifestTypeTemplate ) |
|
1774 { |
|
1775 iConfigurationType = EhspsTemplateConfiguration; |
|
1776 } |
|
1777 else |
|
1778 { |
|
1779 User::Leave( KErrNotSupported ); |
|
1780 } |
|
1781 } |
|
1782 else if ( localName == KInterfaceUid ) |
|
1783 { |
|
1784 if( iContent ) |
|
1785 { |
|
1786 // Delete extra whitespaces. |
|
1787 iContent->Des().TrimAll(); |
|
1788 |
|
1789 // Convert to Uint. |
|
1790 User::LeaveIfError( hspsServerUtil::HexString2Uint( *iContent, iRootUid ) ); |
|
1791 ApplyUidRangeTestsL( iRootUid ); |
|
1792 } |
|
1793 } |
|
1794 else if ( localName == KProviderUid ) |
|
1795 { |
|
1796 if( iContent ) |
|
1797 { |
|
1798 // Delete extra whitespaces. |
|
1799 iContent->Des().TrimAll(); |
|
1800 |
|
1801 // Convert to Uint. |
|
1802 User::LeaveIfError( hspsServerUtil::HexString2Uint( *iContent, iProviderUid ) ); |
|
1803 ApplyUidRangeTestsL( iProviderUid ); |
|
1804 } |
|
1805 } |
|
1806 else if ( localName == KThemeUid ) |
|
1807 { |
|
1808 if( iContent ) |
|
1809 { |
|
1810 // Delete extra whitespaces. |
|
1811 iContent->Des().TrimAll(); |
|
1812 |
|
1813 // Convert to Uint. |
|
1814 User::LeaveIfError( hspsServerUtil::HexString2Uint( *iContent, iThemeUid ) ); |
|
1815 ApplyUidRangeTestsL( iThemeUid ); |
|
1816 } |
|
1817 } |
|
1818 else if ( localName == KThemeStatus ) |
|
1819 { |
|
1820 if( *iContent == KStatusNone ) |
|
1821 { |
|
1822 iThemeStatus = iThemeStatus | EhspsThemeStatusNone; |
|
1823 } |
|
1824 else if( *iContent == KStatusLicenceeDefault ) |
|
1825 { |
|
1826 iThemeStatus = iThemeStatus | EhspsThemeStatusLicenceeDefault; |
|
1827 } |
|
1828 else if( *iContent == KStatusLicenceeRestorable ) |
|
1829 { |
|
1830 iThemeStatus = iThemeStatus | EhspsThemeStatusLicenceeRestorable; |
|
1831 iThemeStatus = iThemeStatus | EhspsThemeStatusLicenceeDefault; |
|
1832 } |
|
1833 else if( *iContent == KStatusOperatorDefault ) |
|
1834 { |
|
1835 iThemeStatus = iThemeStatus | EhspsThemeStatusOperatorDefault; |
|
1836 } |
|
1837 else if( *iContent == KStatusUserDefault ) |
|
1838 { |
|
1839 iThemeStatus = iThemeStatus | EhspsThemeStatusUserDefault; |
|
1840 } |
|
1841 else if( *iContent == KStatusMakeActive ) |
|
1842 { |
|
1843 iThemeStatus = iThemeStatus | EhspsThemeStatusMakeActive; |
|
1844 } |
|
1845 else if( *iContent == KStatusLocked ) |
|
1846 { |
|
1847 iThemeStatus = iThemeStatus | EhspsThemeStatusLocked; |
|
1848 } |
|
1849 } |
|
1850 else if ( localName == KThemeFullName ) |
|
1851 { |
|
1852 // Store value of the parsed "fullname" element |
|
1853 if ( iThemeFullName ) |
|
1854 { |
|
1855 delete iThemeFullName; |
|
1856 iThemeFullName = NULL; |
|
1857 } |
|
1858 iThemeFullName = HBufC::NewL( KMaxFileName ); |
|
1859 TInt contentLength = iContent->Des().Length(); |
|
1860 if ( contentLength > KMaxFileName ) |
|
1861 { |
|
1862 contentLength = KMaxFileName; |
|
1863 } |
|
1864 TPtr ptr( iThemeFullName->Des() ); |
|
1865 ptr.Copy( iContent->Des().Left(contentLength) ); |
|
1866 } |
|
1867 else if ( localName == KThemeShortName ) |
|
1868 { |
|
1869 delete iThemeShortName; |
|
1870 iThemeShortName = NULL; |
|
1871 iThemeShortName = HBufC8::NewL( KMaxFileName ); |
|
1872 TPtr8 themeShortNameDes( iThemeShortName->Des() ); |
|
1873 themeShortNameDes = *iContent; |
|
1874 } |
|
1875 else if ( localName == KThemeVersion ) |
|
1876 { |
|
1877 delete iThemeVersion; |
|
1878 iThemeVersion = NULL; |
|
1879 iThemeVersion = HBufC8::NewL( KMaxFileName ); |
|
1880 TPtr8 themeVersionDes( iThemeVersion->Des() ); |
|
1881 themeVersionDes = *iContent; |
|
1882 } |
|
1883 else if ( localName == KThemeDesc ) |
|
1884 { |
|
1885 if ( iContent ) |
|
1886 { |
|
1887 delete iThemeDesc; |
|
1888 iThemeDesc = NULL; |
|
1889 iThemeDesc = HBufC8::NewL( KMaxDescLength ); |
|
1890 TPtr8 descPtr8( iThemeDesc->Des() ); |
|
1891 descPtr8.Copy( (*iContent).Left( KMaxDescLength ) ); |
|
1892 } |
|
1893 } |
|
1894 else if ( localName == KFileLogo ) |
|
1895 { |
|
1896 if ( iContent ) |
|
1897 { |
|
1898 // Get possible file references and add them to the |
|
1899 // resource array with a logo tag |
|
1900 HBufC* result = NULL; |
|
1901 ParseIconDeclarationL( |
|
1902 *iContent, |
|
1903 KObjectAttrTagLogo, |
|
1904 result ); |
|
1905 if ( result ) |
|
1906 { |
|
1907 // Store logo declaration |
|
1908 CleanupStack::PushL( result ); |
|
1909 iOdt->SetLogoFileL( *result ); |
|
1910 CleanupStack::PopAndDestroy(); |
|
1911 } |
|
1912 } |
|
1913 } |
|
1914 else if ( localName == KFilePreview ) |
|
1915 { |
|
1916 if ( iContent ) |
|
1917 { |
|
1918 // Get possible file references and add them to the |
|
1919 // resource array with a preview tag |
|
1920 HBufC* result = NULL; |
|
1921 ParseIconDeclarationL( |
|
1922 *iContent, |
|
1923 KObjectAttrTagPreview, |
|
1924 result |
|
1925 ); |
|
1926 if ( result ) |
|
1927 { |
|
1928 // Store preview declaration |
|
1929 CleanupStack::PushL( result ); |
|
1930 iOdt->SetPreviewFileL( *result ); |
|
1931 CleanupStack::PopAndDestroy(); |
|
1932 } |
|
1933 } |
|
1934 } |
|
1935 else if ( localName == KFileXML ) |
|
1936 { |
|
1937 delete iXmlFile; |
|
1938 iXmlFile = NULL; |
|
1939 iXmlFile = HBufC::NewL( KMaxFileName ); |
|
1940 TPtr fileDes( iXmlFile->Des() ); |
|
1941 |
|
1942 fileDes.Copy( iThemeFilePath ); |
|
1943 HBufC* data = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *iContent ); |
|
1944 fileDes.Append( *data ); |
|
1945 delete data; |
|
1946 |
|
1947 if( !BaflUtils::FileExists( iFsSession, fileDes ) ) |
|
1948 { |
|
1949 #ifdef HSPS_LOG_ACTIVE |
|
1950 if( iLogBus ) |
|
1951 { |
|
1952 iLogBus->LogText( _L( "ChspsInstallationHandler::OnEndElementL(): - XML file does not exist '%S'" ), |
|
1953 &fileDes ); |
|
1954 } |
|
1955 #endif |
|
1956 |
|
1957 iFileNotFound = ETrue; |
|
1958 iResult->iXuikonError = KErrXmlFileNotFound; |
|
1959 } |
|
1960 } |
|
1961 else if ( localName == KFileDTD ) |
|
1962 { |
|
1963 // Parse name of the DTD files |
|
1964 if ( !iContent || iContent->Length() < 1 ) |
|
1965 { |
|
1966 User::Leave( KErrArgument ); |
|
1967 } |
|
1968 |
|
1969 if ( iDtdFile ) |
|
1970 { |
|
1971 delete iDtdFile; |
|
1972 iDtdFile = 0; |
|
1973 } |
|
1974 iDtdFile = HBufC::NewL( iContent->Length() ); |
|
1975 iDtdFile->Des().Copy( iContent->Des() ); |
|
1976 } |
|
1977 else if ( localName == KFileResource ) |
|
1978 { |
|
1979 // Following attributes are parsed in OnStartElement callback |
|
1980 TPtrC8 mediaPtr; |
|
1981 if ( iMediaType ) |
|
1982 { |
|
1983 mediaPtr.Set( iMediaType->Des() ); |
|
1984 } |
|
1985 TPtrC8 tagsPtr; |
|
1986 if ( iResourceTag ) |
|
1987 { |
|
1988 tagsPtr.Set( iResourceTag->Des() ); |
|
1989 } |
|
1990 |
|
1991 // Parse name of the resource file and make 8bit to 16bit conversion |
|
1992 HBufC* fileName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *iContent ); |
|
1993 if ( !fileName || fileName->Des().Length() < 1 ) |
|
1994 { |
|
1995 User::Leave( KErrArgument ); |
|
1996 } |
|
1997 CleanupStack::PushL( fileName ); |
|
1998 |
|
1999 // If parsing localized resources |
|
2000 if ( iLocalized ) |
|
2001 { |
|
2002 // Add locale specific resources into temp array |
|
2003 AddResourceL( |
|
2004 *iTempLocalizedResourceList, |
|
2005 *fileName, |
|
2006 ELangNone, |
|
2007 EResourceOther, |
|
2008 mediaPtr, |
|
2009 tagsPtr ); |
|
2010 } |
|
2011 else |
|
2012 { |
|
2013 // If Xuikon resource |
|
2014 TFileName interfacePath( GetInterfacePath() ); |
|
2015 HBufC* resourceFile = NULL; |
|
2016 if( interfacePath.Length() ) |
|
2017 { |
|
2018 _LIT(KSubFolder, "00\\"); |
|
2019 resourceFile = HBufC::NewLC( interfacePath.Length() + KSubFolder().Length() + fileName->Length() ); |
|
2020 resourceFile->Des().Copy( interfacePath ); |
|
2021 resourceFile->Des().Append( KSubFolder ); |
|
2022 resourceFile->Des().Append( *fileName ); |
|
2023 } |
|
2024 else |
|
2025 { |
|
2026 resourceFile = HBufC::NewLC( iThemeFilePath.Length() + fileName->Length() ); |
|
2027 resourceFile->Des().Copy( iThemeFilePath ); |
|
2028 resourceFile->Des().Append( *fileName ); |
|
2029 } |
|
2030 |
|
2031 // Validate the file |
|
2032 if( !BaflUtils::FileExists( iFsSession, *resourceFile ) ) |
|
2033 { |
|
2034 #ifdef HSPS_LOG_ACTIVE |
|
2035 TBuf8<KMaxFileName> name8; |
|
2036 name8.Copy( *resourceFile ); |
|
2037 if( iLogBus ) |
|
2038 { |
|
2039 iLogBus->LogText( _L8( "ChspsInstallationHandler::OnEndElementL(): - resource file does not exist '%S'" ), |
|
2040 &name8 ); |
|
2041 } |
|
2042 #endif |
|
2043 iFileNotFound = ETrue; |
|
2044 iResult->iXuikonError = KErrResourceFileNotFound; |
|
2045 } |
|
2046 |
|
2047 // Add common resources |
|
2048 AddResourceL( |
|
2049 *iResourceList, |
|
2050 *resourceFile, |
|
2051 ELangNone, |
|
2052 EResourceOther, |
|
2053 mediaPtr, |
|
2054 tagsPtr ); |
|
2055 |
|
2056 CleanupStack::PopAndDestroy( resourceFile ); |
|
2057 } |
|
2058 |
|
2059 CleanupStack::PopAndDestroy( fileName ); |
|
2060 |
|
2061 if ( iMediaType ) |
|
2062 { |
|
2063 delete iMediaType; |
|
2064 iMediaType = NULL; |
|
2065 } |
|
2066 if ( iResourceTag ) |
|
2067 { |
|
2068 delete iResourceTag; |
|
2069 iResourceTag = NULL; |
|
2070 } |
|
2071 } |
|
2072 else if ( localName == KMultiInstance) |
|
2073 { |
|
2074 iMultiInstanceFound = ETrue; |
|
2075 if( iContent ) |
|
2076 { |
|
2077 // Delete extra whitespaces. |
|
2078 iContent->Des().TrimAll(); |
|
2079 |
|
2080 // Convert to int |
|
2081 TLex8 lex( iContent->Des() ); |
|
2082 TInt err = lex.Val( iMultiInstance ); |
|
2083 // iContent is not a number - check for strings |
|
2084 if ( err != KErrNone ) |
|
2085 { |
|
2086 if ( iContent->CompareF( KMultiInstanceUnlimited ) |
|
2087 == KErrNone ) |
|
2088 { |
|
2089 iMultiInstance = KMultiInstanceUnlimitedValue; |
|
2090 } |
|
2091 else if ( iContent->CompareF( KMultiInstanceHidden ) == |
|
2092 KErrNone ) |
|
2093 { |
|
2094 iMultiInstance = KMultiInstanceHiddenValue; |
|
2095 } |
|
2096 else |
|
2097 { |
|
2098 User::Leave( KErrArgument ); |
|
2099 } |
|
2100 } |
|
2101 // iContent is a number - check whether it is valid |
|
2102 else |
|
2103 { |
|
2104 if ( ( iMultiInstance < KMultiInstanceMinimumCountValue ) || |
|
2105 ( iMultiInstance > KMultiInstanceMaximumCountValue ) ) |
|
2106 { |
|
2107 User::Leave( KErrArgument ); |
|
2108 } |
|
2109 } |
|
2110 } |
|
2111 } |
|
2112 } |
|
2113 |
|
2114 // ----------------------------------------------------------------------------- |
|
2115 // The needed memory for each element information is reserved here. |
|
2116 // ----------------------------------------------------------------------------- |
|
2117 // |
|
2118 void ChspsInstallationHandler::OnContentL(const TDesC8& aBytes, TInt aErrorCode) |
|
2119 { |
|
2120 if ( aErrorCode == KErrNone ) |
|
2121 { |
|
2122 if ( !iContent ) |
|
2123 { |
|
2124 iContent = HBufC8::NewL( aBytes.Size() ); |
|
2125 *iContent = aBytes; |
|
2126 } |
|
2127 else |
|
2128 { |
|
2129 iContent = iContent->ReAllocL( iContent->Size() + aBytes.Size() ); |
|
2130 TPtr8 c( iContent->Des() ); |
|
2131 c.Append( aBytes ); |
|
2132 } |
|
2133 } |
|
2134 |
|
2135 } |
|
2136 |
|
2137 // ----------------------------------------------------------------------------- |
|
2138 // Disables "configuration was installed" notifications |
|
2139 // ----------------------------------------------------------------------------- |
|
2140 // |
|
2141 void ChspsInstallationHandler::DisableNotifications() |
|
2142 { |
|
2143 iDisableNotifications = ETrue; |
|
2144 } |
|
2145 |
|
2146 // ----------------------------------------------------------------------------- |
|
2147 // Finds locale specific subdirectories and DTD resources and appends those |
|
2148 // into the resource array |
|
2149 // Should be executed prior to the CheckHeader method! |
|
2150 // ----------------------------------------------------------------------------- |
|
2151 // |
|
2152 void ChspsInstallationHandler::AddHspsLocalesV2L( |
|
2153 const TDesC& aPath ) |
|
2154 { |
|
2155 // Find all locale specific subfolders |
|
2156 TFindFile fileFinder( iFsSession ); |
|
2157 _LIT( KFilter, "*" ); |
|
2158 CDir* fileList( NULL ); |
|
2159 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
|
2160 if ( fileList ) |
|
2161 { |
|
2162 CleanupStack::PushL( fileList ); |
|
2163 TFileName localePath; |
|
2164 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
2165 { |
|
2166 const TEntry& entry = (*fileList)[i]; |
|
2167 if ( entry.IsDir() ) |
|
2168 { |
|
2169 TInt languageIndex = 0; |
|
2170 TLex lex( entry.iName ); |
|
2171 TInt error = lex.Val( languageIndex ); |
|
2172 |
|
2173 // See enumarations from e32lang.h |
|
2174 if( !error && languageIndex >= ELangTest ) |
|
2175 { |
|
2176 // If we found the first language specification |
|
2177 if ( !iDefaultSpecificationSet ) |
|
2178 { |
|
2179 // Assume this is the default language shown incase |
|
2180 // there is no locale for the active UI language |
|
2181 iDefaultSpecification = (TLanguage)languageIndex; |
|
2182 iDefaultSpecificationSet = ETrue; |
|
2183 } |
|
2184 |
|
2185 // Setup a path to the subdirectory |
|
2186 localePath.Copy( aPath ); |
|
2187 localePath.Append( entry.iName ); |
|
2188 localePath.Append( KPathDelim ); |
|
2189 |
|
2190 // Find localized resources |
|
2191 AddLocalizedResourcesDTDV2L( |
|
2192 localePath, |
|
2193 (TLanguage)languageIndex ); |
|
2194 } |
|
2195 } |
|
2196 |
|
2197 } |
|
2198 CleanupStack::PopAndDestroy( fileList ); |
|
2199 fileList = NULL; |
|
2200 } |
|
2201 |
|
2202 // If no DTD files were found |
|
2203 if ( iDefaultSpecification != ELangTest || !iDefaultSpecificationSet ) |
|
2204 { |
|
2205 #ifdef HSPS_LOG_ACTIVE |
|
2206 if( iLogBus ) |
|
2207 { |
|
2208 iLogBus->LogText( _L8( "ChspsInstallationHandler::AddHspsLocalesV2L(): - mandatory test locale is missing!" ) ); |
|
2209 } |
|
2210 #endif |
|
2211 // Halt installation, test language was not found |
|
2212 User::Leave( KErrNotFound ); |
|
2213 } |
|
2214 } |
|
2215 |
|
2216 // ----------------------------------------------------------------------------- |
|
2217 // Adds localized resources from the provided subdirectory |
|
2218 // ----------------------------------------------------------------------------- |
|
2219 // |
|
2220 void ChspsInstallationHandler::AddLocalizedResourcesDTDV2L( |
|
2221 const TDesC& aPath, |
|
2222 const TLanguage aLanguage ) |
|
2223 { |
|
2224 // Append path with the default name of DTD files |
|
2225 const TInt len = aPath.Length() + iDtdFile->Des().Length(); |
|
2226 HBufC* dtdPath = HBufC::NewLC( len ); |
|
2227 dtdPath->Des().Copy( aPath ); |
|
2228 dtdPath->Des().Append( *iDtdFile ); |
|
2229 |
|
2230 // Check whether the file exists |
|
2231 if( !BaflUtils::FileExists( iFsSession, *dtdPath ) ) |
|
2232 { |
|
2233 #ifdef HSPS_LOG_ACTIVE |
|
2234 if( iLogBus ) |
|
2235 { |
|
2236 iLogBus->LogText( _L( "ChspsInstallationHandler::AddLocalizedResourcesL(): - DTD file was not found '%S'" ), |
|
2237 &dtdPath ); |
|
2238 } |
|
2239 #endif |
|
2240 iFileNotFound = ETrue; |
|
2241 iResult->iXuikonError = KErrDtdFileNotFound; |
|
2242 User::Leave( KErrNotFound ); |
|
2243 } |
|
2244 |
|
2245 // Store locale specific DTD files into the resource array |
|
2246 TPtrC8 mediaType; |
|
2247 TPtrC8 tags; |
|
2248 AddResourceL( |
|
2249 *iResourceList, |
|
2250 *dtdPath, |
|
2251 aLanguage, |
|
2252 EResourceDTD, |
|
2253 mediaType, |
|
2254 tags ); |
|
2255 |
|
2256 CleanupStack::PopAndDestroy( dtdPath ); |
|
2257 } |
|
2258 |
|
2259 void ChspsInstallationHandler::AddInterfaceResourcesV2L( |
|
2260 const TDesC& aPath ) |
|
2261 { |
|
2262 // Find all locale specific subfolders |
|
2263 TFindFile fileFinder( iFsSession ); |
|
2264 _LIT( KFilter, "*" ); |
|
2265 CDir* fileList( NULL ); |
|
2266 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
|
2267 if ( fileList ) |
|
2268 { |
|
2269 CleanupStack::PushL( fileList ); |
|
2270 TFileName localePath; |
|
2271 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
2272 { |
|
2273 const TEntry& entry = (*fileList)[i]; |
|
2274 if ( entry.IsDir() ) |
|
2275 { |
|
2276 TInt languageIndex = 0; |
|
2277 TLex lex( entry.iName ); |
|
2278 TInt error = lex.Val( languageIndex ); |
|
2279 |
|
2280 // See enumarations from e32lang.h |
|
2281 if( !error && languageIndex >= ELangTest ) |
|
2282 { |
|
2283 // If we found the first language specification |
|
2284 if ( !iDefaultSpecificationSet ) |
|
2285 { |
|
2286 // Assume this is the default language shown incase |
|
2287 // there is no locale for the active UI language |
|
2288 iDefaultSpecification = (TLanguage)languageIndex; |
|
2289 iDefaultSpecificationSet = ETrue; |
|
2290 } |
|
2291 |
|
2292 // Setup a path to the subdirectory |
|
2293 localePath.Copy( aPath ); |
|
2294 localePath.Append( entry.iName ); |
|
2295 localePath.Append( KPathDelim ); |
|
2296 |
|
2297 // Find localized resources |
|
2298 AddLocalizedResourcesV2L( |
|
2299 localePath, |
|
2300 (TLanguage)languageIndex ); |
|
2301 } |
|
2302 } |
|
2303 |
|
2304 } |
|
2305 CleanupStack::PopAndDestroy( fileList ); |
|
2306 fileList = NULL; |
|
2307 } |
|
2308 |
|
2309 // If no DTD files were found |
|
2310 if ( iDefaultSpecification != ELangTest || !iDefaultSpecificationSet ) |
|
2311 { |
|
2312 // Halt installation, test language was not found |
|
2313 User::Leave( KErrNotFound ); |
|
2314 } |
|
2315 } |
|
2316 |
|
2317 void ChspsInstallationHandler::AddLocalizedResourcesV2L( |
|
2318 const TDesC& aPath, |
|
2319 const TLanguage aLanguage ) |
|
2320 { |
|
2321 TFindFile fileFinder( iFsSession ); |
|
2322 _LIT( KFilter, "*" ); |
|
2323 CDir* fileList( NULL ); |
|
2324 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
|
2325 if ( fileList ) |
|
2326 { |
|
2327 CleanupStack::PushL( fileList ); |
|
2328 |
|
2329 TFileName localePath; |
|
2330 ChspsResource* resource = NULL; |
|
2331 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
2332 { |
|
2333 const TEntry& entry = (*fileList)[i]; |
|
2334 if ( !entry.IsDir() ) |
|
2335 { |
|
2336 TParsePtrC parserPtr( entry.iName ); |
|
2337 TFileName modName = hspsServerUtil::GetFixedOdtName( entry.iName ); |
|
2338 |
|
2339 TBool addingOk = EFalse; |
|
2340 for( TInt resourceIndex=0; resourceIndex < iTempLocalizedResourceList->Count(); resourceIndex++ ) |
|
2341 { |
|
2342 resource = iTempLocalizedResourceList->At( resourceIndex ); |
|
2343 if( modName.CompareF( resource->FileName() ) == 0 ) |
|
2344 { |
|
2345 addingOk = ETrue; |
|
2346 break; |
|
2347 } |
|
2348 } |
|
2349 if ( addingOk ) |
|
2350 { |
|
2351 HBufC* resourcePath = HBufC::NewLC( aPath.Length() + entry.iName.Length() ); |
|
2352 resourcePath->Des().Copy( aPath ); |
|
2353 resourcePath->Des().Append( entry.iName ); |
|
2354 |
|
2355 TPtrC8 mimeType; |
|
2356 TPtrC8 tag; |
|
2357 |
|
2358 HBufC8* tagBuf8 = NULL; |
|
2359 if ( resource->Tags().Length() ) |
|
2360 { |
|
2361 tagBuf8 = HBufC8::NewLC( resource->Tags().Length() ); |
|
2362 tagBuf8->Des().Copy( resource->Tags() ); |
|
2363 tag.Set( tagBuf8->Des() ); |
|
2364 } |
|
2365 |
|
2366 // Add localized files into the resource array |
|
2367 AddResourceL( |
|
2368 *iResourceList, |
|
2369 *resourcePath, |
|
2370 aLanguage, |
|
2371 EResourceOther, |
|
2372 mimeType, |
|
2373 tag ); |
|
2374 |
|
2375 if ( tagBuf8 ) |
|
2376 { |
|
2377 CleanupStack::PopAndDestroy( tagBuf8 ); |
|
2378 } |
|
2379 CleanupStack::PopAndDestroy( resourcePath ); |
|
2380 } |
|
2381 } |
|
2382 } |
|
2383 |
|
2384 CleanupStack::PopAndDestroy( fileList ); |
|
2385 fileList = NULL; |
|
2386 } |
|
2387 } |
|
2388 |
|
2389 // ----------------------------------------------------------------------------- |
|
2390 // Finds locale specific subdirectories and resources and appends those |
|
2391 // into the resource array |
|
2392 // Should be executed prior to the CheckHeader method! |
|
2393 // ----------------------------------------------------------------------------- |
|
2394 // |
|
2395 void ChspsInstallationHandler::AddLocalesL( |
|
2396 const TDesC& aPath ) |
|
2397 { |
|
2398 // Find all locale specific subfolders |
|
2399 TFindFile fileFinder( iFsSession ); |
|
2400 _LIT( KFilter, "*" ); |
|
2401 CDir* fileList( NULL ); |
|
2402 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
|
2403 if ( fileList ) |
|
2404 { |
|
2405 CleanupStack::PushL( fileList ); |
|
2406 TFileName localePath; |
|
2407 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
2408 { |
|
2409 const TEntry& entry = (*fileList)[i]; |
|
2410 if ( entry.IsDir() ) |
|
2411 { |
|
2412 TInt languageIndex = 0; |
|
2413 TLex lex( entry.iName ); |
|
2414 TInt error = lex.Val( languageIndex ); |
|
2415 |
|
2416 // See enumarations from e32lang.h |
|
2417 if( !error && languageIndex >= ELangTest ) |
|
2418 { |
|
2419 // If we found the first language specification |
|
2420 if ( !iDefaultSpecificationSet ) |
|
2421 { |
|
2422 // Assume this is the default language shown incase |
|
2423 // there is no locale for the active UI language |
|
2424 iDefaultSpecification = (TLanguage)languageIndex; |
|
2425 iDefaultSpecificationSet = ETrue; |
|
2426 } |
|
2427 |
|
2428 // Setup a path to the subdirectory |
|
2429 localePath.Copy( aPath ); |
|
2430 localePath.Append( entry.iName ); |
|
2431 localePath.Append( KPathDelim ); |
|
2432 |
|
2433 // Find localized resources |
|
2434 AddLocalizedResourcesL( |
|
2435 localePath, |
|
2436 (TLanguage)languageIndex ); |
|
2437 } |
|
2438 } |
|
2439 |
|
2440 } |
|
2441 CleanupStack::PopAndDestroy( fileList ); |
|
2442 fileList = NULL; |
|
2443 } |
|
2444 |
|
2445 // If no DTD files were found |
|
2446 if ( iDefaultSpecification != ELangTest || !iDefaultSpecificationSet ) |
|
2447 { |
|
2448 // Halt installation, test language was not found |
|
2449 User::Leave( KErrNotFound ); |
|
2450 } |
|
2451 } |
|
2452 |
|
2453 // ----------------------------------------------------------------------------- |
|
2454 // Adds localized resources from the provided subdirectory |
|
2455 // ----------------------------------------------------------------------------- |
|
2456 // |
|
2457 void ChspsInstallationHandler::AddLocalizedResourcesL( |
|
2458 const TDesC& aPath, |
|
2459 const TLanguage aLanguage ) |
|
2460 { |
|
2461 // If FileDTD was declared |
|
2462 if ( iDtdFile && iDtdFile->Des().Length() ) |
|
2463 { |
|
2464 // Append path with the default name of DTD files |
|
2465 const TInt len = aPath.Length() + iDtdFile->Des().Length(); |
|
2466 HBufC* dtdPath = HBufC::NewLC( len ); |
|
2467 dtdPath->Des().Copy( aPath ); |
|
2468 dtdPath->Des().Append( *iDtdFile ); |
|
2469 |
|
2470 // Check whether the file exists |
|
2471 if( !BaflUtils::FileExists( iFsSession, *dtdPath ) ) |
|
2472 { |
|
2473 #ifdef HSPS_LOG_ACTIVE |
|
2474 if( iLogBus ) |
|
2475 { |
|
2476 iLogBus->LogText( _L( "ChspsInstallationHandler::AddLocalizedResourcesL(): - DTD file was not found '%S'" ), |
|
2477 &dtdPath ); |
|
2478 } |
|
2479 #endif |
|
2480 iFileNotFound = ETrue; |
|
2481 iResult->iXuikonError = KErrDtdFileNotFound; |
|
2482 User::Leave( KErrNotFound ); |
|
2483 } |
|
2484 |
|
2485 // Store locale specific DTD files into the resource array |
|
2486 TPtrC8 mediaType; |
|
2487 TPtrC8 tagsPtr; |
|
2488 AddResourceL( |
|
2489 *iResourceList, |
|
2490 *dtdPath, |
|
2491 aLanguage, |
|
2492 EResourceDTD, |
|
2493 mediaType, |
|
2494 tagsPtr ); |
|
2495 |
|
2496 CleanupStack::PopAndDestroy( dtdPath ); |
|
2497 } |
|
2498 |
|
2499 // Store locale specific resources if the "localization" element has been declared in XML definition |
|
2500 ChspsResource* resource = NULL; |
|
2501 for( TInt resourceIndex=0; resourceIndex < iTempLocalizedResourceList->Count(); resourceIndex++ ) |
|
2502 { |
|
2503 resource = iTempLocalizedResourceList->At( resourceIndex ); |
|
2504 |
|
2505 HBufC* resourcePath = HBufC::NewLC( aPath.Length() + resource->FileName().Length() ); |
|
2506 resourcePath->Des().Copy( aPath ); |
|
2507 resourcePath->Des().Append( resource->FileName() ); |
|
2508 |
|
2509 TDataType dataType( resource->MimeType() ); |
|
2510 TPtrC8 tagsPtr; |
|
2511 if ( iResourceTag ) |
|
2512 { |
|
2513 tagsPtr.Set( iResourceTag->Des() ); |
|
2514 } |
|
2515 |
|
2516 // Add localized files into the resource array |
|
2517 AddResourceL( |
|
2518 *iResourceList, |
|
2519 *resourcePath, |
|
2520 aLanguage, |
|
2521 EResourceOther, |
|
2522 dataType.Des8(), |
|
2523 tagsPtr |
|
2524 ); |
|
2525 |
|
2526 CleanupStack::PopAndDestroy( resourcePath ); |
|
2527 } |
|
2528 |
|
2529 } |
|
2530 |
|
2531 // ----------------------------------------------------------------------------- |
|
2532 // ChspsInstallationHandler::ApplyUidRangeTestsL |
|
2533 // ----------------------------------------------------------------------------- |
|
2534 // |
|
2535 void ChspsInstallationHandler::ApplyUidRangeTestsL( const TUint aUid ) |
|
2536 { |
|
2537 // Check for TUint to TInt conversion |
|
2538 const TInt intValue( aUid ); |
|
2539 if ( intValue < 1 ) |
|
2540 { |
|
2541 // Check UID ranges in the manifest file |
|
2542 #ifdef HSPS_LOG_ACTIVE |
|
2543 if( iLogBus ) |
|
2544 { |
|
2545 iLogBus->LogText( _L( "ChspsInstallationHandler::ApplyUidRangeTestsL() - Invalid UID value '%d'" ), aUid ); |
|
2546 } |
|
2547 #endif |
|
2548 User::Leave( KErrArgument ); |
|
2549 } |
|
2550 } |
|
2551 |
|
2552 |
|
2553 // ----------------------------------------------------------------------------- |
|
2554 // ChspsInstallationHandler::ParseIconDeclarationL |
|
2555 // ----------------------------------------------------------------------------- |
|
2556 // |
|
2557 void ChspsInstallationHandler::ParseIconDeclarationL( |
|
2558 HBufC8& aValue8, |
|
2559 const TDesC8& aTag, |
|
2560 HBufC*& aResultString ) |
|
2561 { |
|
2562 // 8bit > 16bit conversion |
|
2563 TInt size = KMaxFileName - iThemeFilePath.Length(); |
|
2564 aResultString = HBufC::NewLC( KMaxFileName ); |
|
2565 TPtr resultPtr( aResultString->Des() ); |
|
2566 resultPtr.Copy( aValue8.Des().Left( size ) ); |
|
2567 |
|
2568 // check whether skin/mif/uid declarations were used |
|
2569 TFileName filename; |
|
2570 if ( hspsServerUtil::IsFile( resultPtr, filename ) ) |
|
2571 { |
|
2572 // check whether the file reference is valid |
|
2573 TPath fullname; |
|
2574 fullname.Copy( iThemeFilePath ); |
|
2575 fullname.Append( filename ); |
|
2576 |
|
2577 if( !BaflUtils::FileExists( iFsSession, fullname ) ) |
|
2578 { |
|
2579 #ifdef HSPS_LOG_ACTIVE |
|
2580 if( iLogBus ) |
|
2581 { |
|
2582 iLogBus->LogText( |
|
2583 _L( "ChspsInstallationHandler::ParseIconDeclarationL(): - '%S' was not found " ), |
|
2584 &fullname ); |
|
2585 } |
|
2586 #endif |
|
2587 // User::Leave( KErrNotFound ); |
|
2588 } |
|
2589 else |
|
2590 { |
|
2591 // Store logo as a common resource file |
|
2592 TPtrC8 mediaType; |
|
2593 AddResourceL( |
|
2594 *iResourceList, |
|
2595 fullname, |
|
2596 ELangNone, |
|
2597 EResourceOther, |
|
2598 mediaType, |
|
2599 aTag ); |
|
2600 |
|
2601 // get offset of the filename |
|
2602 TInt nameOffset = resultPtr.FindF( (TPtrC)filename ); |
|
2603 if ( nameOffset >= 0 ) |
|
2604 { |
|
2605 // get relative path under the HSPS |
|
2606 if ( iRootUid < 1 || iProviderUid < 1 || iThemeUid < 1 || !iThemeVersion || iThemeVersion->Des().Length() < 1 ) |
|
2607 { |
|
2608 User::Leave( KErrArgument ); |
|
2609 } |
|
2610 // 8bit > 16bit |
|
2611 HBufC* verBuf = HBufC::NewLC( iThemeVersion->Des().Length() ); |
|
2612 verBuf->Des().Copy( *iThemeVersion ); |
|
2613 _LIT(KPathFormat, "%D\\%D\\%D\\%S\\sources\\"); |
|
2614 TFileName relativePath; |
|
2615 relativePath.Format( |
|
2616 KPathFormat, |
|
2617 iRootUid, |
|
2618 iProviderUid, |
|
2619 iThemeUid, |
|
2620 verBuf ); |
|
2621 if ( resultPtr.Length() + relativePath.Length() > KMaxFileName - 1 ) |
|
2622 { |
|
2623 User::Leave( KErrArgument ); |
|
2624 } |
|
2625 resultPtr.Insert( nameOffset, relativePath ); |
|
2626 CleanupStack::PopAndDestroy( verBuf ); |
|
2627 } |
|
2628 |
|
2629 } |
|
2630 |
|
2631 } // IsFile |
|
2632 |
|
2633 CleanupStack::Pop( aResultString ); |
|
2634 } |
|
2635 |
|
2636 // end of file |