coreapplicationuis/rfsplugins/FormatterRFSPlugin/src/selectiveformatter.cpp
changeset 65 8a530a83576a
parent 0 2e3d3ce01487
equal deleted inserted replaced
56:11a052f4b02e 65:8a530a83576a
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <f32file.h>
    19 #include <f32file.h>
       
    20 #include <swi/sisregistrysession.h>
       
    21 #include <swi/sisregistryentry.h>
       
    22 #include <swi/sisregistrypackage.h>
    20 
    23 
    21 #include "dirstackentry.h"
    24 #include "dirstackentry.h"
    22 #include "selectiveformatter.h"
    25 #include "selectiveformatter.h"
    23 #include "formatterrfsplugincommon.h"
    26 #include "formatterrfsplugincommon.h"
    24 #include "rfsfileman.h"
    27 #include "rfsfileman.h"
    25 #include "trace.h"
    28 #include "trace.h"
    26 
    29 
       
    30 _LIT(KZDrive,"z");
    27 // ================= MEMBER FUNCTIONS =======================
    31 // ================= MEMBER FUNCTIONS =======================
    28 
    32 
    29 // ---------------------------------------------------------------------------
    33 // ---------------------------------------------------------------------------
    30 // CSelectiveFormatter::NewL
    34 // CSelectiveFormatter::NewL
    31 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
   122         {
   126         {
   123         ReadExcludeListL( aExcludeListFile );
   127         ReadExcludeListL( aExcludeListFile );
   124         }
   128         }
   125     // Handle app specific files
   129     // Handle app specific files
   126     HandleAppExcludeListsL();
   130     HandleAppExcludeListsL();
       
   131     
       
   132     // Handle NR-Applications
       
   133     //HandleNrExcludeListsL();
   127     
   134     
   128     if( !iValidExcludeListFound )
   135     if( !iValidExcludeListFound )
   129         {
   136         {
   130         User::Leave( KErrInvalidExcList );
   137         User::Leave( KErrInvalidExcList );
   131         }
   138         }
   327             }
   334             }
   328         CleanupStack::PopAndDestroy( dir );
   335         CleanupStack::PopAndDestroy( dir );
   329         dir = NULL;
   336         dir = NULL;
   330         }
   337         }
   331     }
   338     }
       
   339 
       
   340 // ---------------------------------------------------------------------------
       
   341 // CSelectiveFormatter::HandleNrExcludeListsL
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 void CSelectiveFormatter::HandleNrExcludeListsL()
       
   345     {
       
   346     INFO( "CSelectiveFormatter::HandleNrExcludeListsL() START ");
       
   347     
       
   348     Swi::RSisRegistrySession session;
       
   349     CleanupClosePushL(session);
       
   350     User::LeaveIfError(session.Connect());
       
   351     
       
   352     INFO( "In CSelectiveFormatter::HandleNrExcludeListsL() RSisRegistrySession::Connect() established");
       
   353     // Get the installed application UIDs
       
   354     RArray<TUid> uids;
       
   355     CleanupClosePushL(uids);
       
   356     session.InstalledUidsL(uids);
       
   357     TInt uidcount = uids.Count(); 
       
   358     
       
   359     Swi::RSisRegistryEntry regEntry;
       
   360     Swi::RSisRegistryEntry augmentForRegEntry;
       
   361     CleanupClosePushL(regEntry);
       
   362     CleanupClosePushL(augmentForRegEntry);
       
   363     
       
   364     // Array of registry files i.e., .reg and .ctl for the installed apps
       
   365     RPointerArray<HBufC> registryFiles;
       
   366     
       
   367     // Array of registry files i.e., .reg and .ctl for the augmented apps
       
   368     RPointerArray<HBufC> augmentedRegistryFiles;
       
   369     
       
   370     // Array of files installed through package.
       
   371     RPointerArray<HBufC> nonRemovableFiles;
       
   372     
       
   373     // Array of augmented files installed through package.
       
   374     RPointerArray<HBufC> nonRemovableAugmentedFiles;
       
   375     
       
   376     CleanupResetAndDestroyPushL(registryFiles);
       
   377     CleanupResetAndDestroyPushL(augmentedRegistryFiles);
       
   378     CleanupResetAndDestroyPushL(nonRemovableFiles);
       
   379     CleanupResetAndDestroyPushL(nonRemovableAugmentedFiles);
       
   380     
       
   381     TInt count;
       
   382     
       
   383     //Array of augmented packages
       
   384     RPointerArray<Swi::CSisRegistryPackage> augmentationPackages;
       
   385     CleanupResetAndDestroyPushL(augmentationPackages);
       
   386         
       
   387     for ( TInt iter=0; iter<uidcount; iter++)
       
   388      {
       
   389      User::LeaveIfError(regEntry.Open(session,uids[iter]));
       
   390      if(EFalse == regEntry.RemovableL())
       
   391          {
       
   392          INFO( "In CSelectiveFormatter::HandleNrExcludeListsL() get the nonRemovable and registry files");
       
   393          
       
   394          regEntry.FilesL(nonRemovableFiles);
       
   395          regEntry.RegistryFilesL(registryFiles);
       
   396          TInt fileCount = nonRemovableFiles.Count(); 
       
   397          for (TInt nonRemovableFilesCount=fileCount-1; nonRemovableFilesCount>=0;nonRemovableFilesCount--)
       
   398              {
       
   399              TPtr nrFileName(nonRemovableFiles[nonRemovableFilesCount]->Des());
       
   400              if(nrFileName.Left(1) == KZDrive )
       
   401                  {
       
   402                  delete nonRemovableFiles[nonRemovableFilesCount];
       
   403                  nonRemovableFiles.Remove(nonRemovableFilesCount);
       
   404                  }
       
   405              }
       
   406          // Look for augmentations.
       
   407          if(regEntry.IsAugmentationL())
       
   408              {
       
   409              regEntry.AugmentationsL(augmentationPackages);
       
   410              count = regEntry.AugmentationsNumberL();
       
   411              for (TInt augPkgCount=0; augPkgCount < count; ++augPkgCount)
       
   412                  {
       
   413                  User::LeaveIfError(augmentForRegEntry.OpenL(session,*augmentationPackages[augPkgCount]));
       
   414                  if(EFalse == augmentForRegEntry.RemovableL())
       
   415                      {
       
   416                      INFO( "In CSelectiveFormatter::HandleNrExcludeListsL() get the augmented nonRemovable and registry files");
       
   417                      augmentForRegEntry.FilesL(nonRemovableAugmentedFiles);
       
   418                      augmentForRegEntry.RegistryFilesL(augmentedRegistryFiles);
       
   419                      }
       
   420                  augmentForRegEntry.Close();
       
   421                  }
       
   422              }
       
   423          }
       
   424      AppendNrlisttoExcludeListL(nonRemovableFiles);
       
   425      nonRemovableFiles.ResetAndDestroy();
       
   426      regEntry.Close();
       
   427      }
       
   428     INFO( "In CSelectiveFormatter::HandleNrExcludeListsL() append the list of files to the excludelist ");
       
   429     
       
   430     AppendNrlisttoExcludeListL(nonRemovableAugmentedFiles);
       
   431     AppendNrlisttoExcludeListL(augmentedRegistryFiles);
       
   432     AppendNrlisttoExcludeListL(registryFiles);
       
   433     
       
   434     CleanupStack::PopAndDestroy(9,&session);
       
   435     INFO( "CSelectiveFormatter::HandleNrExcludeListsL() End");
       
   436     }
       
   437 
       
   438 // ---------------------------------------------------------------------------
       
   439 // CSelectiveFormatter::HandleNrExcludeListsL
       
   440 // ---------------------------------------------------------------------------
       
   441 //
       
   442 
       
   443 void CSelectiveFormatter::AppendNrlisttoExcludeListL(RPointerArray<HBufC> &aFileNameArr)
       
   444     {
       
   445     INFO( "CSelectiveFormatter::AppendNrlisttoExcludeListL() START ");
       
   446     TInt size = aFileNameArr.Count();
       
   447     CExcludeListEntry* entry;
       
   448     TInt err;
       
   449     for ( TInt i=0; i < size; i++)
       
   450         {
       
   451         entry = CExcludeListEntry::NewL( aFileNameArr[i]->Des() );
       
   452         err = iExcludeList.InsertInOrder( entry, CExcludeListEntry::Compare ); // take ownership
       
   453         if( err != KErrNone )
       
   454             {
       
   455             delete entry; // delete entry if ownership not transferred
       
   456             
       
   457             if( err != KErrAlreadyExists )
       
   458                 {
       
   459                 INFO_1( "CSelectiveFormatter::AppendNrlisttoExcludeListL() leaves with error code %d",err);
       
   460                 User::Leave( err );
       
   461                 }
       
   462             }            
       
   463         }
       
   464     INFO( "CSelectiveFormatter::AppendNrlisttoExcludeListL() END ");
       
   465     }