794 } |
794 } |
795 } |
795 } |
796 } |
796 } |
797 |
797 |
798 // ----------------------------------------------------------------------------- |
798 // ----------------------------------------------------------------------------- |
799 // ChspsThemeServerSession::DoCopyResourceFilesL |
|
800 // ----------------------------------------------------------------------------- |
|
801 TInt ChspsThemeServerSession::DoCopyResourceFilesL( |
|
802 ChspsODT& aAppODT, |
|
803 CFileMan& aFilemanager, |
|
804 const TInt aConfUid, |
|
805 const TDesC& aDestination ) |
|
806 { |
|
807 TInt error( KErrNone ); |
|
808 RPointerArray<ChspsResource> widgetResources; // Objects are not owned. |
|
809 CleanupClosePushL( widgetResources ); |
|
810 |
|
811 // Get resources that need to be copied. |
|
812 hspsServerUtil::GetValidResourcesL( aAppODT, |
|
813 aConfUid, |
|
814 Server().DeviceLanguage(), |
|
815 widgetResources ); |
|
816 |
|
817 // Copy the resources found |
|
818 for( TInt i = 0; ( i < widgetResources.Count() && !error ); i++ ) |
|
819 { |
|
820 ChspsResource* resource = widgetResources[i]; |
|
821 if( !resource ) |
|
822 { |
|
823 continue; |
|
824 } |
|
825 |
|
826 // Get relative path under the themes folder |
|
827 TPath relativePath; |
|
828 hspsServerUtil::GetRelativeResourcePath( |
|
829 resource->FileName(), |
|
830 relativePath ); |
|
831 |
|
832 // Strip language indicator from the relative path |
|
833 hspsServerUtil::GetLocaleIndependentResourcePath( |
|
834 resource->Language(), |
|
835 relativePath ); |
|
836 |
|
837 // Finalize target path |
|
838 TPath targetPath; |
|
839 targetPath.Copy( aDestination ); |
|
840 targetPath.Append( relativePath ); |
|
841 |
|
842 // Create missing target path and copy files when needed only |
|
843 error = hspsServerUtil::CopyResourceFileL( |
|
844 iFs, |
|
845 aFilemanager, |
|
846 targetPath, |
|
847 resource->FileName() ); |
|
848 if ( !error ) |
|
849 { |
|
850 #ifdef HSPS_LOG_ACTIVE |
|
851 if ( iLogBus ) |
|
852 { |
|
853 iLogBus->LogText( |
|
854 _L( "hspsServerUtil::DoCopyResourceFilesL(): - %S was copied" ), |
|
855 &targetPath |
|
856 ); |
|
857 } |
|
858 #endif |
|
859 } |
|
860 if ( error == KErrAlreadyExists ) |
|
861 { |
|
862 error = KErrNone; |
|
863 } |
|
864 |
|
865 } // copy loop |
|
866 |
|
867 widgetResources.Reset(); |
|
868 CleanupStack::PopAndDestroy( 1, &widgetResources ); |
|
869 |
|
870 return error; |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // ChspsThemeServerSession::CopyResourceFilesL |
799 // ChspsThemeServerSession::CopyResourceFilesL |
875 // (other items were commented in a header). |
800 // (other items were commented in a header). |
876 // ----------------------------------------------------------------------------- |
801 // ----------------------------------------------------------------------------- |
877 // |
802 // |
878 void ChspsThemeServerSession::CopyResourceFilesL(const RMessage2& aMessage) |
803 void ChspsThemeServerSession::CopyResourceFilesL(const RMessage2& aMessage) |
916 |
841 |
917 if( error == KErrNone ) |
842 if( error == KErrNone ) |
918 { |
843 { |
919 phaseCounter++; |
844 phaseCounter++; |
920 |
845 |
921 RArray<TInt> widgetArray; |
846 RArray<TInt> uidArray; |
922 CleanupClosePushL( widgetArray ); |
847 CleanupClosePushL( uidArray ); |
923 |
848 |
924 // Find unique configuration UIDs from the resource array |
849 // Find unique configuration UIDs from the resource array |
925 FindWidgetUidsL( *odt, widgetArray ); |
850 FindWidgetUidsL( *odt, uidArray ); |
926 |
851 |
927 CFileMan* fileManager = NULL; |
852 CFileMan* fileManager = NULL; |
928 fileManager = CFileMan::NewL( iFs ); |
853 fileManager = CFileMan::NewL( iFs ); |
929 CleanupStack::PushL( fileManager ); |
854 CleanupStack::PushL( fileManager ); |
930 |
855 |
931 // Loop widgets belonging to the root configuration |
856 // Loop widgets belonging to the root configuration |
932 const TInt uidCount = widgetArray.Count(); |
857 const TInt uidCount = uidArray.Count(); |
933 for( TInt i = 0; i < uidCount && !error; i++ ) |
858 for( TInt i = 0; i < uidCount && !error; i++ ) |
934 { |
859 { |
935 // Copy widget's resources to client's private folder |
860 // Copy widget's resources to client's private folder |
936 error = DoCopyResourceFilesL( |
861 error = hspsServerUtil::CopyResourceFilesL( |
937 *odt, |
862 *odt, |
938 *fileManager, |
863 iFs, |
939 widgetArray[i], |
864 *fileManager, |
940 destinationPath ); |
865 Server().DeviceLanguage(), |
|
866 uidArray[i], |
|
867 destinationPath ); |
941 } |
868 } |
942 |
869 |
943 widgetArray.Reset(); |
870 uidArray.Reset(); |
944 |
871 |
945 CleanupStack::PopAndDestroy( 2, &widgetArray ); // fileManager, widgetArray |
872 CleanupStack::PopAndDestroy( 2, &uidArray ); // fileManager, uidArray |
946 } // KErrNone |
873 } // KErrNone |
947 |
874 |
948 //Tidy-up |
875 //Tidy-up |
949 if ( odt ) |
876 if ( odt ) |
950 { |
877 { |