diff -r 502e5d91ad42 -r 15e4dd19031c homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp --- a/homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp Mon Mar 15 12:41:53 2010 +0200 +++ b/homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp Wed Mar 31 22:04:35 2010 +0300 @@ -91,14 +91,15 @@ ChspsThemeServer& aThemeServer, const TUint aSecureId ): CTimer(EPriorityLow), - iLanguage ( aThemeServer.DeviceLanguage() ), iThemeServer( aThemeServer ), iSecureId( aSecureId ), iCentralRepository( aThemeServer.CentralRepository() ), iDefinitionRepository( aThemeServer.DefinitionRepository() ), iSecurityEnforcer( aThemeServer.SecurityEnforcer() ), iHeaderListCache( aThemeServer.HeaderListCache() ), - iFileMan( NULL ) + iServerSession( NULL ), + iFileMan( NULL ), + iMaintainLogoResources( EFalse ) { iDeliveryCount = 0; iSubscription = EFalse; @@ -194,11 +195,11 @@ } iSearchMask = ChspsODT::NewL(); iSearchMask->UnMarshalHeaderL(searchMaskData); - - // check the device language - iLanguage = iThemeServer.DeviceLanguage(); - iSearchMask->SetOdtLanguage( (TInt)iLanguage ); - + + iMaintainLogoResources = EFalse; + TPckg intPkg( iMaintainLogoResources ); + messagePtr.ReadL(3, intPkg ); + // now there is a subscription iSubscription = ETrue; // fetch the header list from repository @@ -242,9 +243,6 @@ // is there headers to delivere left if (iHeaderDataList->Count() > iDeliveryCount) { - // Handle copying of logo icon resources - CopyIconsToHomescreenL( aMessage.SecureId().iId ); - // at least one header on the list TPtr8 bufPtr( iHeaderDataList->At(iDeliveryCount)->Des() ); iMessagePtr.WriteL(2, bufPtr, 0); @@ -262,82 +260,6 @@ } } -// ----------------------------------------------------------------------------- -// ChspsMaintenanceHandler::CopyIconsToHomescreenL -// ----------------------------------------------------------------------------- -// -void ChspsMaintenanceHandler::CopyIconsToHomescreenL( - const TUint aAppUid ) - { - HBufC8* headerData = iHeaderDataList->At(iDeliveryCount); - ChspsODT* header = ChspsODT::UnMarshalHeaderLC( headerData->Des() ); - if ( iServerSession && header ) - { - if( header->LogoFile().Length() ) - { - // If a file reference was found from the logo declaration - TFileName filename; - if ( hspsServerUtil::IsFile( header->LogoFile(), filename ) ) - { - if ( !iFileMan ) - { - iFileMan = CFileMan::NewL( iServerSession->FileSystem() ); - } - - // Get client's private directory: - // We should use some common directory if there are more than one SAPI clients, - // for now we can copy files to AI3's private folder - _LIT( KPrivatePath, "c:\\private\\%X\\"); - TPath privatePath; - privatePath.Format( KPrivatePath, aAppUid ); - - // Append private path to the logo file reference - TInt offset = header->LogoFile().FindF( filename ); - if ( offset >= 0 ) - { - // Insert private path prior to the file reference - HBufC* logoBuf = HBufC::NewLC( - privatePath.Length() + header->LogoFile().Length() ); - logoBuf->Des().Copy( header->LogoFile() ); - logoBuf->Des().Insert( offset, privatePath ); - header->SetLogoFileL( logoBuf->Des() ); - CleanupStack::PopAndDestroy( logoBuf ); - - // Replace the serialized header descriptor - HBufC8* newHeaderData = header->MarshalHeaderL(); - CleanupStack::PushL( newHeaderData ); - iHeaderDataList->InsertL( - iDeliveryCount, - newHeaderData ); - CleanupStack::Pop( newHeaderData ); - delete headerData; - headerData = 0; - iHeaderDataList->Delete( iDeliveryCount + 1 ); - } - - // Set target directory for file copying - TPath targetPath; - targetPath.Copy( privatePath ); - targetPath.Append( filename ); - - // Set source directory for file copying - TFileName sourceFile; - _LIT( KThemesFolder, "themes\\" ); - iServerSession->FileSystem().SessionPath( sourceFile ); - sourceFile.Append( KThemesFolder ); - sourceFile.Append( filename ); - - // Create the target path and copy files when required - hspsServerUtil::CopyResourceFileL( - iServerSession->FileSystem(), - *iFileMan, - targetPath, - sourceFile ); - } - } - } - CleanupStack::PopAndDestroy( header ); - } // ----------------------------------------------------------------------------- // ChspsMaintenanceHandler::SetServerSession @@ -1859,14 +1781,20 @@ { TBool isView = EFalse; - ChspsDomNode* confNode = - (ChspsDomNode*)aPluginNode.ChildNodes().FindByName( KConfigurationElement ); + ChspsDomNode* confNode = static_cast( + aPluginNode.ChildNodes().FindByName( KConfigurationElement )); + if( confNode ) { - ChspsDomAttribute* typeAttr = - (ChspsDomAttribute*)confNode->AttributeList().FindByName( KConfigurationAttrType ); - isView = ( typeAttr->Value().CompareF( KConfTypeView ) == 0 ); + ChspsDomAttribute* typeAttr = static_cast( + confNode->AttributeList().FindByName( KConfigurationAttrType )); + + if( typeAttr ) + { + isView = ( typeAttr->Value().CompareF( KConfTypeView ) == 0 ); + } } + return isView; } @@ -3841,8 +3769,10 @@ // (other items were commented in a header). // ----------------------------------------------------------------------------- // -ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders(const ChspsODT& /*aSearchMask*/, - CArrayPtrFlat& /*aHeaderList*/) +ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders( + const ChspsODT& /*aSearchMask*/, + const TBool /*aCopyLogos*/, + CArrayPtrFlat& /*aHeaderList*/) { return EhspsServiceNotSupported; } @@ -4052,6 +3982,18 @@ { After(KHeaderListUpdatePollingTimeSpan); } + + else if( aRepositoryInfo.iEventType & EhspsODTAdded + || aRepositoryInfo.iEventType & EhspsODTUpdated ) + { + // If a widget has been installed or updated + if( iServerSession ) + { + // Make sure all logos are copied when user retrieves the list + iServerSession->SetIconFileCopyRequired( ETrue ); + } + } + return EFalse; } @@ -4315,37 +4257,78 @@ void ChspsMaintenanceHandler::GetHeaderListL( CArrayPtrSeg& aHeaderDataList, const ChspsODT& aSearchMask ) - { - HBufC8* headerBuf = aSearchMask.MarshalHeaderL(); - if ( !headerBuf ) - { - User::Leave(KErrGeneral); - } - CleanupStack::PushL( headerBuf ); - ChspsODT* searchOdt = ChspsODT::UnMarshalHeaderLC( *headerBuf ); - + { // Reset search results aHeaderDataList.ResetAndDestroy(); + + if( !iFileMan ) + { + iFileMan = CFileMan::NewL( iServerSession->FileSystem() ); + } for ( TInt i = 0; i < iHeaderListCache.Count(); i++ ) { ChspsODT* header = iHeaderListCache.At( i ); - // Check whether the header matches the search criteria - if ( FilterHeader( *searchOdt, *header ) ) + // Check whether the header matches the search criteria (family etc) + if ( FilterHeader( aSearchMask, *header ) ) { - // Append to the search results - HBufC8* data = header->MarshalHeaderL(); + + // Update file paths into the existing logo declarations + if( header->LogoFile().Length() && + iMaintainLogoResources && + ( header->ConfigurationType() == EhspsWidgetConfiguration || + header->ConfigurationType() == EhspsTemplateConfiguration ) ) + { + + RBuf targetFile; + CleanupClosePushL( targetFile ); + targetFile.CreateL( KMaxFileName ); + + RBuf sourceFile; + CleanupClosePushL( sourceFile ); + sourceFile.CreateL( KMaxFileName ); + + RBuf newDeclaration; + CleanupClosePushL( newDeclaration ); + newDeclaration.CreateL( header->LogoFile().Length() + KMaxFileName ); + + // Find location of the logo file and location where it shold be copied + hspsServerUtil::PopulateLogoPathsL( + header->LogoFile(), + iSecureId, + targetFile, + sourceFile, + newDeclaration ); + + if( targetFile.Length() + && sourceFile.Length() + && newDeclaration.Length() ) + { + // Update private path information to the logo declaration + header->SetLogoFileL( newDeclaration ); + + hspsServerUtil::CopyResourceFileL( + iServerSession->FileSystem(), + *iFileMan, + targetFile, + sourceFile ); + } + + CleanupStack::PopAndDestroy( 3, &targetFile ); // targetFile, sourceFile, newDeclaration + } + + // Convert the header to a descriptor + HBufC8* data = header->MarshalHeaderL(); if ( data ) { + // Append to the search results CleanupStack::PushL( data ); aHeaderDataList.AppendL( data ); CleanupStack::Pop( data ); } } - } - - CleanupStack::PopAndDestroy( 2, headerBuf ); // searchOdt, headerBuf + } } // ----------------------------------------------------------------------------- @@ -4555,7 +4538,7 @@ ) && ( - ( aMask.ConfigurationType() && aMask.ConfigurationType() == aHeader.ConfigurationType() ) + ( aMask.ConfigurationType() && ( aHeader.ConfigurationType() == aMask.ConfigurationType() ) ) || ( !aMask.ConfigurationType() ) ) @@ -4723,10 +4706,7 @@ // Get active root configuration for the client application ChspsODT* appODT = ChspsODT::NewL(); - CleanupStack::PushL( appODT ); - iThemeServer.GetActivateAppConfigurationL( - params.appUid, - *appODT ); + CleanupStack::PushL( appODT ); #ifdef HSPS_LOG_ACTIVE if( iLogBus ) @@ -4741,12 +4721,20 @@ TInt err = KErrNone; if ( !params.restoreAll ) { - // Remove all widgets from the active view - err = RestoreActiveViewL( *appODT ); - } + // reinstall all widgets + TRAP( err, iThemeServer.InstallWidgetsL(); + iThemeServer.InstallUDAWidgetsL() ); + + // Force updating of the header cache + iThemeServer.UpdateHeaderListCacheL(); + } + + iThemeServer.GetActivateAppConfigurationL( + params.appUid, + *appODT ); // As a backup, if restoration of the active view fails, - // or if all views but the locked view should be removed + // or if all views but the locked view should be removedc if ( err || params.restoreAll ) { // Remove all views but the locked one and reset active view