appinstaller/AppMngr2/src/appmngr2model.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-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".
   131 
   131 
   132 // ---------------------------------------------------------------------------
   132 // ---------------------------------------------------------------------------
   133 // CAppMngr2Model::PackageInfo()
   133 // CAppMngr2Model::PackageInfo()
   134 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
   135 //
   135 //
   136 CAppMngr2PackageInfo& CAppMngr2Model::PackageInfo( TInt aIndex ) const 
   136 CAppMngr2PackageInfo& CAppMngr2Model::PackageInfo( TInt aIndex ) const
   137     {
   137     {
   138     return *( reinterpret_cast< CAppMngr2PackageInfo* >( iInstallationFiles->At( aIndex ) ) );
   138     return *( reinterpret_cast< CAppMngr2PackageInfo* >( iInstallationFiles->At( aIndex ) ) );
   139     }
   139     }
   140 
   140 
   141 // ---------------------------------------------------------------------------
   141 // ---------------------------------------------------------------------------
   143 // ---------------------------------------------------------------------------
   143 // ---------------------------------------------------------------------------
   144 //
   144 //
   145 void CAppMngr2Model::LoadIconsL( CAknIconArray& aIconArray )
   145 void CAppMngr2Model::LoadIconsL( CAknIconArray& aIconArray )
   146     {
   146     {
   147     LoadDefaultIconsL( aIconArray );
   147     LoadDefaultIconsL( aIconArray );
   148     
   148 
   149     TInt pluginCount = iPlugins.Count();
   149     TInt pluginCount = iPlugins.Count();
   150     for( TInt index = 0; index < pluginCount; index++ )
   150     for( TInt index = 0; index < pluginCount; index++ )
   151         {
   151         {
   152         iPlugins[ index ]->LoadIconsL( aIconArray );
   152         iPlugins[ index ]->LoadIconsL( aIconArray );
   153         }
   153         }
   177 // ---------------------------------------------------------------------------
   177 // ---------------------------------------------------------------------------
   178 //
   178 //
   179 void CAppMngr2Model::HandleCommandL( CAppMngr2InfoBase& aInfo, TInt aCommand )
   179 void CAppMngr2Model::HandleCommandL( CAppMngr2InfoBase& aInfo, TInt aCommand )
   180     {
   180     {
   181     FLOG( "CAppMngr2Model::HandleCommandL( %d ), IsActive() = %d", aCommand, IsActive() );
   181     FLOG( "CAppMngr2Model::HandleCommandL( %d ), IsActive() = %d", aCommand, IsActive() );
   182     
   182 
   183     if( !IsActive() )
   183     if( !IsActive() )
   184         {
   184         {
   185         // About to start plugin specific command. Note that when the command completes
   185         // About to start plugin specific command. Note that when the command completes
   186         // we need to call CAppMngr2InfoBase::CommandComplete() function. For this (and
   186         // we need to call CAppMngr2InfoBase::CommandComplete() function. For this (and
   187         // to indicate that there is a plugin specific command on-going) we take the
   187         // to indicate that there is a plugin specific command on-going) we take the
   202             }
   202             }
   203 
   203 
   204         iActiveItem = &aInfo;
   204         iActiveItem = &aInfo;
   205         iActiveCommand = aCommand;
   205         iActiveCommand = aCommand;
   206         FLOG( "CAppMngr2Model::HandleCommandL, iActiveItem = 0x%08x '%S'",
   206         FLOG( "CAppMngr2Model::HandleCommandL, iActiveItem = 0x%08x '%S'",
   207                 iActiveItem, &( iActiveItem->Name() ) ); 
   207                 iActiveItem, &( iActiveItem->Name() ) );
   208         TRAPD( err, iActiveItem->HandleCommandL( aCommand, iStatus ) );
   208         TRAPD( err, iActiveItem->HandleCommandL( aCommand, iStatus ) );
   209         FLOG( "CAppMngr2Model::HandleCommandL, command started, err = %d", err );
   209         FLOG( "CAppMngr2Model::HandleCommandL, command started, err = %d", err );
   210         SetActive();
   210         SetActive();
   211         if( err )
   211         if( err )
   212             {
   212             {
   224 // CAppMngr2Model::StartFetchingInstallationFilesL()
   224 // CAppMngr2Model::StartFetchingInstallationFilesL()
   225 // ---------------------------------------------------------------------------
   225 // ---------------------------------------------------------------------------
   226 //
   226 //
   227 void CAppMngr2Model::StartFetchingInstallationFilesL()
   227 void CAppMngr2Model::StartFetchingInstallationFilesL()
   228     {
   228     {
   229     FLOG( "CAppMngr2Model::StartFetchingInstallationFilesL" );
   229     FLOG( "CAppMngr2Model::StartFetchingInstallationFilesL, fetching %d",
   230     FLOG_PERF_START( FetchInstallationFiles )
   230             iFetchingInstallationFiles );
   231     
   231     if( !iFetchingInstallationFiles )
   232     // Installation files cache must be enabled until scanner has completed.
   232         {
   233     // This ensures that scanner has time to call GetInstallationFilesL() for
   233         FLOG_PERF_START( FetchInstallationFiles )
   234     // each plugin and for each directory before the first call completes.
   234         iFetchingInstallationFiles = ETrue;
   235     // If the first call completes before scanner has made all these requets,
   235 
   236     // cache will be turned off and partial results are displayed.
   236         // Installation files cache must be enabled until scanner has completed.
   237     iInstallationFiles->IncrementCacheUseStartingNewRoundL();
   237         // This ensures that scanner has time to call GetInstallationFilesL() for
   238 
   238         // each plugin and for each directory before the first call completes.
   239     iScanner->StartScanningL();
   239         // If the first call completes before scanner has made all these requets,
       
   240         // cache will be turned off and partial results are displayed.
       
   241         iInstallationFiles->IncrementCacheUseStartingNewRoundL();
       
   242 
       
   243         iScanner->StartScanningL();
       
   244         }
   240     }
   245     }
   241 
   246 
   242 // ---------------------------------------------------------------------------
   247 // ---------------------------------------------------------------------------
   243 // CAppMngr2Model::StartFetchingInstalledAppsL()
   248 // CAppMngr2Model::StartFetchingInstalledAppsL()
   244 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   245 //
   250 //
   246 void CAppMngr2Model::StartFetchingInstalledAppsL()
   251 void CAppMngr2Model::StartFetchingInstalledAppsL()
   247     {
   252     {
   248     FLOG( "CAppMngr2Model::StartFetchingInstalledAppsL" );
   253     FLOG( "CAppMngr2Model::StartFetchingInstalledAppsL, fetching %d",
   249     FLOG_PERF_START( FetchInstalledApps )
   254             iFetchingInstalledApps );
   250 
   255     if( !iFetchingInstalledApps )
   251     // Additional cache increment to ensure that iInstalledApps cache is
   256         {
   252     // used until GetInstalledAppsL() function is called for each plugin.
   257         FLOG_PERF_START( FetchInstalledApps )
   253     // Without this, the fastest plugin might get it's list complete before
   258         iFetchingInstalledApps = ETrue;
   254     // other IncrementCacheUseL() calls and iInstalledApps would display
   259 
   255     // partial list.
   260         // Additional cache increment to ensure that iInstalledApps cache is
   256     iInstalledApps->IncrementCacheUseStartingNewRoundL();
   261         // used until GetInstalledAppsL() function is called for each plugin.
   257     
   262         // Without this, the fastest plugin might get it's list complete before
   258     TInt pluginCount = iPlugins.Count();
   263         // other IncrementCacheUseL() calls and iInstalledApps would display
   259     for( TInt pluginIndex = 0; pluginIndex < pluginCount; pluginIndex++ )
   264         // partial list.
   260         {
   265         iInstalledApps->IncrementCacheUseStartingNewRoundL();
   261         CAppMngr2AppInfoMaker* appInfoMaker = CAppMngr2AppInfoMaker::NewLC(
   266 
   262                 iPlugins[ pluginIndex ]->Runtime(), *this, iFs );
   267         TInt pluginCount = iPlugins.Count();
   263         
   268         for( TInt pluginIndex = 0; pluginIndex < pluginCount; pluginIndex++ )
   264         TRAPD( err, appInfoMaker->StartGettingInstalledAppsL() );
   269             {
   265         FLOG( "CAppMngr2Model::StartFetchingInstalledAppsL, plugin 0x%08x, err = %d",
   270             CAppMngr2AppInfoMaker* appInfoMaker = CAppMngr2AppInfoMaker::NewLC(
   266                 iPlugins[ pluginIndex ]->Runtime().RuntimeUid().iUid, err );
   271                     iPlugins[ pluginIndex ]->Runtime(), *this, iFs );
   267         if( err == KErrNone )
   272 
   268             {
   273             TRAPD( err, appInfoMaker->StartGettingInstalledAppsL() );
   269             iInfoMakers.AppendL( appInfoMaker );
   274             FLOG( "CAppMngr2Model::StartFetchingInstalledAppsL, plugin 0x%08x, err = %d",
   270             CleanupStack::Pop( appInfoMaker );
   275                     iPlugins[ pluginIndex ]->Runtime().RuntimeUid().iUid, err );
   271             iInstalledApps->IncrementCacheUseL();
   276             if( err == KErrNone )
   272             }
   277                 {
   273         else
   278                 iInfoMakers.AppendL( appInfoMaker );
   274             {
   279                 CleanupStack::Pop( appInfoMaker );
   275             CleanupStack::PopAndDestroy( appInfoMaker );
   280                 iInstalledApps->IncrementCacheUseL();
   276             }
   281                 }
   277         }
   282             else
   278 
   283                 {
   279     // All GetInstalledAppsL() requests have been issued
   284                 CleanupStack::PopAndDestroy( appInfoMaker );
   280     iInstalledApps->DecrementCacheUse();
   285                 }
       
   286             }
       
   287 
       
   288         // All GetInstalledAppsL() requests have been issued
       
   289         iInstalledApps->DecrementCacheUse();
       
   290         }
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------------------------
       
   294 // CAppMngr2Model::IsUninstall()
       
   295 // ---------------------------------------------------------------------------
       
   296 //
       
   297 TBool CAppMngr2Model::IsUninstall()
       
   298     {       
       
   299     if ( iActiveCommand == EAppMngr2CmdUninstall )
       
   300         {
       
   301         FLOG( "CAppMngr2Model::IsUninstall: ETrue" );
       
   302         return ETrue;
       
   303         }   
       
   304     FLOG( "CAppMngr2Model::IsUninstall: EFalse" );
       
   305     return EFalse;    
   281     }
   306     }
   282 
   307 
   283 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   284 // CAppMngr2Model::DoCancel()
   309 // CAppMngr2Model::DoCancel()
   285 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   286 //
   311 //
   287 void CAppMngr2Model::DoCancel()
   312 void CAppMngr2Model::DoCancel()
   288     {
   313     {
   289     FLOG( "CAppMngr2Model::DoCancel, iActiveItem = 0x%08x", iActiveItem );
   314     FLOG( "CAppMngr2Model::DoCancel, iActiveItem = 0x%08x", iActiveItem );
   290     
   315 
   291     if( iActiveItem )
   316     if( iActiveItem )
   292         {
   317         {
   293         iActiveItem->CancelCommand();
   318         iActiveItem->CancelCommand();
   294         iActiveItem = NULL;
   319         iActiveItem = NULL;
   295         if( !iClosing )
   320         if( !iClosing )
   322         iInstalledApps->EnableRefreshNotificationsL();
   347         iInstalledApps->EnableRefreshNotificationsL();
   323         iInstallationFiles->EnableRefreshNotificationsL();
   348         iInstallationFiles->EnableRefreshNotificationsL();
   324 
   349 
   325         // Leave on error. This displays error note (if error notes are enabled).
   350         // Leave on error. This displays error note (if error notes are enabled).
   326         User::LeaveIfError( err );
   351         User::LeaveIfError( err );
   327         
   352 
   328         // If the command is EAppMngr2CmdUninstall or EAppMngr2CmdRemove, and it
   353         // If the command is EAppMngr2CmdUninstall or EAppMngr2CmdRemove, and it
   329         // completed without errors, then we remove the current item immediatelty
   354         // completed without errors, then we remove the current item immediatelty
   330         // from the displayed list. Otherwise it may take quite long time until
   355         // from the displayed list. Otherwise it may take quite long time until
   331         // the item is removed from the UI, and in worst case it may not be removed
   356         // the item is removed from the UI, and in worst case it may not be removed
   332         // at all.
   357         // at all.
   353 // ---------------------------------------------------------------------------
   378 // ---------------------------------------------------------------------------
   354 //
   379 //
   355 void CAppMngr2Model::RefreshInstalledApps()
   380 void CAppMngr2Model::RefreshInstalledApps()
   356     {
   381     {
   357     FLOG( "CAppMngr2Model::RefreshInstalledApps" );
   382     FLOG( "CAppMngr2Model::RefreshInstalledApps" );
   358     
   383 
   359     TRAP_IGNORE( StartFetchingInstalledAppsL() );
   384     TRAP_IGNORE( StartFetchingInstalledAppsL() );
   360     }
   385     }
   361 
   386 
   362 // ---------------------------------------------------------------------------
   387 // ---------------------------------------------------------------------------
   363 // CAppMngr2Model::RefreshInstallationFiles()
   388 // CAppMngr2Model::RefreshInstallationFiles()
   375 // ---------------------------------------------------------------------------
   400 // ---------------------------------------------------------------------------
   376 //
   401 //
   377 void CAppMngr2Model::ScanningResultL( RPointerArray<CAppMngr2RecognizedFile>& aResult )
   402 void CAppMngr2Model::ScanningResultL( RPointerArray<CAppMngr2RecognizedFile>& aResult )
   378     {
   403     {
   379     FLOG( "CAppMngr2Model::ScanningResultL, begin: aResult.Count() = %d", aResult.Count() );
   404     FLOG( "CAppMngr2Model::ScanningResultL, begin: aResult.Count() = %d", aResult.Count() );
   380     
   405 
   381     // Split recognition result array into smaller (plugin specific) arrays. Plugin
   406     // Split recognition result array into smaller (plugin specific) arrays. Plugin
   382     // specific arrays are maintained by CAppMngr2PackageInfoMaker objects, so one
   407     // specific arrays are maintained by CAppMngr2PackageInfoMaker objects, so one
   383     // CAppMngr2PackageInfoMaker object is needed for each plugin that has recognized
   408     // CAppMngr2PackageInfoMaker object is needed for each plugin that has recognized
   384     // files.
   409     // files.
   385     TInt pluginCount = iPlugins.Count();
   410     TInt pluginCount = iPlugins.Count();
   422 // ---------------------------------------------------------------------------
   447 // ---------------------------------------------------------------------------
   423 //
   448 //
   424 void CAppMngr2Model::ScanningComplete()
   449 void CAppMngr2Model::ScanningComplete()
   425     {
   450     {
   426     FLOG( "CAppMngr2Model::ScanningComplete" );
   451     FLOG( "CAppMngr2Model::ScanningComplete" );
   427     
   452 
   428     iInstallationFiles->DecrementCacheUse();
   453     iInstallationFiles->DecrementCacheUse();
   429     }
   454     }
   430 
   455 
   431 // ---------------------------------------------------------------------------
   456 // ---------------------------------------------------------------------------
   432 // CAppMngr2Model::DirectoryChangedL()
   457 // CAppMngr2Model::DirectoryChangedL()
   433 // ---------------------------------------------------------------------------
   458 // ---------------------------------------------------------------------------
   434 //
   459 //
   435 void CAppMngr2Model::DirectoryChangedL( const TDesC& /*aChangedDir*/ )
   460 void CAppMngr2Model::DirectoryChangedL( const TDesC& /*aChangedDir*/ )
   436     {
   461     {
   437     FLOG( "CAppMngr2Model::DirectoryChangedL" );
   462     FLOG( "CAppMngr2Model::DirectoryChangedL" );
   438     
   463 
   439     // This might be improved by scanning the changed directory only. Model
   464     // This might be improved by scanning the changed directory only. Model
   440     // could record which items are got from which directory, so that it could
   465     // could record which items are got from which directory, so that it could
   441     // remove those items that were created from the changed directory and
   466     // remove those items that were created from the changed directory and
   442     // re-scan only the changed directory. Scanner should also support
   467     // re-scan only the changed directory. Scanner should also support
   443     // scanning one directory only. Now, we just scan all again.
   468     // scanning one directory only. Now, we just scan all again.
   449 // ---------------------------------------------------------------------------
   474 // ---------------------------------------------------------------------------
   450 //
   475 //
   451 void CAppMngr2Model::HandleAppListEvent( TInt /*aEvent*/ )
   476 void CAppMngr2Model::HandleAppListEvent( TInt /*aEvent*/ )
   452     {
   477     {
   453     FLOG( "CAppMngr2Model::HandleAppListEvent" );
   478     FLOG( "CAppMngr2Model::HandleAppListEvent" );
   454     
   479 
   455     TRAP_IGNORE( StartFetchingInstalledAppsL() );
   480     TRAP_IGNORE( StartFetchingInstalledAppsL() );
   456     }
   481     }
   457 
   482 
   458 // ---------------------------------------------------------------------------
   483 // ---------------------------------------------------------------------------
   459 // CAppMngr2Model::NewAppsCreatedL()
   484 // CAppMngr2Model::NewAppsCreatedL()
   462 void CAppMngr2Model::NewAppsCreatedL( const CAppMngr2InfoMaker& aMaker,
   487 void CAppMngr2Model::NewAppsCreatedL( const CAppMngr2InfoMaker& aMaker,
   463         RPointerArray<CAppMngr2AppInfo>& aAppInfos )
   488         RPointerArray<CAppMngr2AppInfo>& aAppInfos )
   464     {
   489     {
   465     FLOG( "CAppMngr2Model::NewAppsCreatedL, plugin 0x%08x: packageCount = %d",
   490     FLOG( "CAppMngr2Model::NewAppsCreatedL, plugin 0x%08x: packageCount = %d",
   466             aMaker.RuntimeUid().iUid, aAppInfos.Count() );
   491             aMaker.RuntimeUid().iUid, aAppInfos.Count() );
   467     
   492 
   468     iInstalledApps->AddItemsInOrderL( aAppInfos );
   493     iInstalledApps->AddItemsInOrderL( aAppInfos );
   469     iInstalledApps->DecrementCacheUse();
   494     iInstalledApps->DecrementCacheUse();
   470     CloseInfoMaker( aMaker );
   495     CloseInfoMaker( aMaker );
   471     }
   496     }
   472 
   497 
   481         TInt /*aError*/ )
   506         TInt /*aError*/ )
   482 #endif
   507 #endif
   483     {
   508     {
   484     FLOG( "CAppMngr2Model::ErrorInCreatingAppsL, plugin 0x%08x: error = %d",
   509     FLOG( "CAppMngr2Model::ErrorInCreatingAppsL, plugin 0x%08x: error = %d",
   485             aMaker.RuntimeUid().iUid, aError );
   510             aMaker.RuntimeUid().iUid, aError );
   486     
   511 
   487     iInstalledApps->DecrementCacheUse();
   512     iInstalledApps->DecrementCacheUse();
   488     CloseInfoMaker( aMaker );
   513     CloseInfoMaker( aMaker );
   489     }
   514     }
   490 
   515 
   491 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
   495 void CAppMngr2Model::NewPackagesCreatedL( const CAppMngr2InfoMaker& aMaker,
   520 void CAppMngr2Model::NewPackagesCreatedL( const CAppMngr2InfoMaker& aMaker,
   496             RPointerArray<CAppMngr2PackageInfo>& aPackageInfos )
   521             RPointerArray<CAppMngr2PackageInfo>& aPackageInfos )
   497     {
   522     {
   498     FLOG( "CAppMngr2Model::NewPackagesCreatedL, plugin 0x%08x: packageCount = %d",
   523     FLOG( "CAppMngr2Model::NewPackagesCreatedL, plugin 0x%08x: packageCount = %d",
   499             aMaker.RuntimeUid().iUid, aPackageInfos.Count() );
   524             aMaker.RuntimeUid().iUid, aPackageInfos.Count() );
   500     
   525 
   501     iInstallationFiles->AddItemsInOrderL( aPackageInfos );
   526     iInstallationFiles->AddItemsInOrderL( aPackageInfos );
   502     iInstallationFiles->DecrementCacheUse();
   527     iInstallationFiles->DecrementCacheUse();
   503     CloseInfoMaker( aMaker );
   528     CloseInfoMaker( aMaker );
   504     }
   529     }
   505 
   530 
   514         TInt /*aError*/ )
   539         TInt /*aError*/ )
   515 #endif
   540 #endif
   516     {
   541     {
   517     FLOG( "CAppMngr2Model::ErrorInCreatingPackagesL, plugin 0x%08x: error = %d",
   542     FLOG( "CAppMngr2Model::ErrorInCreatingPackagesL, plugin 0x%08x: error = %d",
   518             aMaker.RuntimeUid().iUid, aError );
   543             aMaker.RuntimeUid().iUid, aError );
   519     
   544 
   520     iInstallationFiles->DecrementCacheUse();
   545     iInstallationFiles->DecrementCacheUse();
   521     CloseInfoMaker( aMaker );
   546     CloseInfoMaker( aMaker );
   522     }
   547     }
   523 
   548 
   524 // ---------------------------------------------------------------------------
   549 // ---------------------------------------------------------------------------
   526 // ---------------------------------------------------------------------------
   551 // ---------------------------------------------------------------------------
   527 //
   552 //
   528 void CAppMngr2Model::ArrayContentChanged( CAppMngr2InfoArray* aArray,
   553 void CAppMngr2Model::ArrayContentChanged( CAppMngr2InfoArray* aArray,
   529         TInt aMoreRefreshesExpected )
   554         TInt aMoreRefreshesExpected )
   530     {
   555     {
       
   556     FLOG( "CAppMngr2Model::ArrayContentChanged, more = %d", aMoreRefreshesExpected );
   531     if( aArray == iInstalledApps )
   557     if( aArray == iInstalledApps )
   532         {
   558         {
   533         FLOG_PERF_STOP( FetchInstalledApps )
   559         FLOG_PERF_STOP( FetchInstalledApps )
   534         FLOG_PERF_PRINT( FetchInstalledApps )
   560         FLOG_PERF_PRINT( FetchInstalledApps )
   535         iObs.InstalledAppsChanged( aMoreRefreshesExpected );
   561         iObs.InstalledAppsChanged( aMoreRefreshesExpected );
       
   562         if( !aMoreRefreshesExpected )
       
   563             {
       
   564             FLOG( "CAppMngr2Model::ArrayContentChanged: StartFetchingInstalledAppsL done" );
       
   565             iFetchingInstalledApps = EFalse;
       
   566             }
   536         }
   567         }
   537     if( aArray == iInstallationFiles )
   568     if( aArray == iInstallationFiles )
   538         {
   569         {
   539         FLOG_PERF_STOP( FetchInstallationFiles )
   570         FLOG_PERF_STOP( FetchInstallationFiles )
   540         FLOG_PERF_PRINT( FetchInstallationFiles )
   571         FLOG_PERF_PRINT( FetchInstallationFiles )
   541         iObs.InstallationFilesChanged( aMoreRefreshesExpected );
   572         iObs.InstallationFilesChanged( aMoreRefreshesExpected );
       
   573         if( !aMoreRefreshesExpected )
       
   574             {
       
   575             FLOG( "CAppMngr2Model::ArrayContentChanged: StartFetchingInstallationFilesL done" );
       
   576             iFetchingInstallationFiles = EFalse;
       
   577             }
   542         }
   578         }
   543     }
   579     }
   544 
   580 
   545 // ---------------------------------------------------------------------------
   581 // ---------------------------------------------------------------------------
   546 // CAppMngr2Model::CAppMngr2Model()
   582 // CAppMngr2Model::CAppMngr2Model()
   561     FLOG( "CAppMngr2Model::ConstructL" );
   597     FLOG( "CAppMngr2Model::ConstructL" );
   562     iClosing = EFalse;
   598     iClosing = EFalse;
   563 
   599 
   564     iInstalledApps = CAppMngr2AppInfoArray::NewL( *this );
   600     iInstalledApps = CAppMngr2AppInfoArray::NewL( *this );
   565     iInstallationFiles = CAppMngr2PackageInfoArray::NewL( *this );
   601     iInstallationFiles = CAppMngr2PackageInfoArray::NewL( *this );
   566     
   602 
   567     FLOG_PERF_STATIC_BEGIN( LoadPluginsL )
   603     FLOG_PERF_STATIC_BEGIN( LoadPluginsL )
   568     LoadPluginsL();
   604     LoadPluginsL();
   569     FLOG_PERF_STATIC_END( LoadPluginsL )
   605     FLOG_PERF_STATIC_END( LoadPluginsL )
   570     FLOG_PERF_STATIC_BEGIN( CreateScannerL )
   606     FLOG_PERF_STATIC_BEGIN( CreateScannerL )
   571     CreateScannerL();
   607     CreateScannerL();
   583 // ---------------------------------------------------------------------------
   619 // ---------------------------------------------------------------------------
   584 //
   620 //
   585 void CAppMngr2Model::LoadDefaultIconsL( CAknIconArray& aIconArray )
   621 void CAppMngr2Model::LoadDefaultIconsL( CAknIconArray& aIconArray )
   586     {
   622     {
   587     FLOG( "CAppMngr2Model::LoadDefaultIconsL" );
   623     FLOG( "CAppMngr2Model::LoadDefaultIconsL" );
   588     
   624 
   589     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
   625     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
   590     HBufC* bitmapFile = TAppMngr2DriveUtils::FullBitmapFileNameLC( KAppMngr2BitmapFile, iFs );
   626     HBufC* bitmapFile = TAppMngr2DriveUtils::FullBitmapFileNameLC( KAppMngr2BitmapFile, iFs );
   591     CFbsBitmap* bitmap = NULL;
   627     CFbsBitmap* bitmap = NULL;
   592     CFbsBitmap* mask = NULL;
   628     CFbsBitmap* mask = NULL;
   593     CGulIcon* icon = NULL;
   629     CGulIcon* icon = NULL;
   594     
   630 
   595     // Note that icons can be graphically-skinned (icon graphic defined in theme)
   631     // Note that icons can be graphically-skinned (icon graphic defined in theme)
   596     // or color-skinned (icon colors change depending on background color defined
   632     // or color-skinned (icon colors change depending on background color defined
   597     // in theme). Normal icons are graphically-skinned and indicator icons are
   633     // in theme). Normal icons are graphically-skinned and indicator icons are
   598     // color-skinned. AknsUtils::CreateGulIconL() creates graphically-skinned icons,
   634     // color-skinned. AknsUtils::CreateGulIconL() creates graphically-skinned icons,
   599     // and AknsUtils::CreateColorIconL() creates color-skinned icons. Hence both
   635     // and AknsUtils::CreateColorIconL() creates color-skinned icons. Hence both
   600     // of these functions are used below.
   636     // of these functions are used below.
   601 
   637 
   602     // Icon 0: EAppMngr2IconIndex_QgnIndiAmInstMmcAdd
   638     // Icon 0: EAppMngr2IconIndex_QgnIndiAmInstMmcAdd
   603     // Indicator icon for items stored/installed in memory card
   639     // Indicator icon for items stored/installed in memory card
   604     AknsUtils::CreateColorIconLC( skinInstance, 
   640     AknsUtils::CreateColorIconLC( skinInstance,
   605             KAknsIIDQgnIndiMmcAdd, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13,
   641             KAknsIIDQgnIndiMmcAdd, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13,
   606             bitmap, mask, *bitmapFile, 
   642             bitmap, mask, *bitmapFile,
   607             EMbmAppmngr2Qgn_indi_mmc_add,
   643             EMbmAppmngr2Qgn_indi_mmc_add,
   608             EMbmAppmngr2Qgn_indi_mmc_add_mask,
   644             EMbmAppmngr2Qgn_indi_mmc_add_mask,
   609             KRgbBlack );
   645             KRgbBlack );
   610     icon = CGulIcon::NewL( bitmap, mask );
   646     icon = CGulIcon::NewL( bitmap, mask );
   611     icon->SetBitmapsOwnedExternally( EFalse );
   647     icon->SetBitmapsOwnedExternally( EFalse );
   614     aIconArray.AppendL( icon );
   650     aIconArray.AppendL( icon );
   615     CleanupStack::Pop( icon );
   651     CleanupStack::Pop( icon );
   616 
   652 
   617     // Icon 1: EAppMngr2IconIndex_QgnIndiFmgrMsAdd
   653     // Icon 1: EAppMngr2IconIndex_QgnIndiFmgrMsAdd
   618     // Indicator icon for items stored/installed in mass memory
   654     // Indicator icon for items stored/installed in mass memory
   619     AknsUtils::CreateColorIconLC( skinInstance, 
   655     AknsUtils::CreateColorIconLC( skinInstance,
   620             KAknsIIDQgnIndiFmgrMsAdd, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13,
   656             KAknsIIDQgnIndiFmgrMsAdd, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13,
   621             bitmap, mask, *bitmapFile, 
   657             bitmap, mask, *bitmapFile,
   622             EMbmAppmngr2Qgn_indi_fmgr_ms_add,
   658             EMbmAppmngr2Qgn_indi_fmgr_ms_add,
   623             EMbmAppmngr2Qgn_indi_fmgr_ms_add_mask,
   659             EMbmAppmngr2Qgn_indi_fmgr_ms_add_mask,
   624             KRgbBlack );
   660             KRgbBlack );
   625     icon = CGulIcon::NewL( bitmap, mask );
   661     icon = CGulIcon::NewL( bitmap, mask );
   626     icon->SetBitmapsOwnedExternally( EFalse );
   662     icon->SetBitmapsOwnedExternally( EFalse );
   631 
   667 
   632     // Icon 2: EAppMngr2IconIndex_QgnPropUnknown
   668     // Icon 2: EAppMngr2IconIndex_QgnPropUnknown
   633     // List icon for items that are not known
   669     // List icon for items that are not known
   634     icon = AknsUtils::CreateGulIconL( skinInstance,
   670     icon = AknsUtils::CreateGulIconL( skinInstance,
   635             KAknsIIDQgnPropUnknown, *bitmapFile,
   671             KAknsIIDQgnPropUnknown, *bitmapFile,
   636             EMbmAppmngr2Qgn_prop_unknown, 
   672             EMbmAppmngr2Qgn_prop_unknown,
   637             EMbmAppmngr2Qgn_prop_unknown_mask );
   673             EMbmAppmngr2Qgn_prop_unknown_mask );
   638     CleanupStack::PushL( icon );
   674     CleanupStack::PushL( icon );
   639     aIconArray.AppendL( icon );
   675     aIconArray.AppendL( icon );
   640     CleanupStack::Pop( icon );
   676     CleanupStack::Pop( icon );
   641 
   677 
   642     CleanupStack::PopAndDestroy( bitmapFile );
   678     CleanupStack::PopAndDestroy( bitmapFile );
   643     
   679 
   644     // Additionally some unknown indicator icon could be defined.
   680     // Additionally some unknown indicator icon could be defined.
   645     // Now, if some plugin gives incorrect index fox indicator icon,
   681     // Now, if some plugin gives incorrect index fox indicator icon,
   646     // then no indicator icon is displayed.
   682     // then no indicator icon is displayed.
   647     }
   683     }
   648 
   684 
   651 // ---------------------------------------------------------------------------
   687 // ---------------------------------------------------------------------------
   652 //
   688 //
   653 void CAppMngr2Model::LoadPluginsL()
   689 void CAppMngr2Model::LoadPluginsL()
   654     {
   690     {
   655     FLOG( "CAppMngr2Model::LoadPluginsL" );
   691     FLOG( "CAppMngr2Model::LoadPluginsL" );
   656     
   692 
   657     RImplInfoPtrArray implInfoArray;
   693     RImplInfoPtrArray implInfoArray;
   658     CleanupResetAndDestroyPushL( implInfoArray  );
   694     CleanupResetAndDestroyPushL( implInfoArray  );
   659     REComSession::ListImplementationsL( KAppMngr2PluginInterface, implInfoArray );
   695     REComSession::ListImplementationsL( KAppMngr2PluginInterface, implInfoArray );
   660 
   696 
   661     CAppMngr2PluginHolder* pluginHolder = NULL;
   697     CAppMngr2PluginHolder* pluginHolder = NULL;
   745                 iScanner->AddDirectoryL( dirName );
   781                 iScanner->AddDirectoryL( dirName );
   746                 }
   782                 }
   747             }
   783             }
   748         CleanupStack::PopAndDestroy( &dirsToScan );
   784         CleanupStack::PopAndDestroy( &dirsToScan );
   749         }
   785         }
   750     
   786 
   751     // KSWInstallerPackageFolder directory if defined in CenRep
   787     // KSWInstallerPackageFolder directory if defined in CenRep
   752     CRepository* cenrep = CRepository::NewLC( KCRUidSWInstallerLV );
   788     CRepository* cenrep = CRepository::NewLC( KCRUidSWInstallerLV );
   753     err = cenrep->Get( KSWInstallerPackageFolder, path );
   789     err = cenrep->Get( KSWInstallerPackageFolder, path );
   754     CleanupStack::PopAndDestroy( cenrep );
   790     CleanupStack::PopAndDestroy( cenrep );
   755     if( err == KErrNone )
   791     if( err == KErrNone )
   778                             TChar driveLetter;
   814                             TChar driveLetter;
   779                             if( RFs::DriveToChar( driveNumber, driveLetter ) == KErrNone )
   815                             if( RFs::DriveToChar( driveNumber, driveLetter ) == KErrNone )
   780                                 {
   816                                 {
   781                                 TFileName fullPath;
   817                                 TFileName fullPath;
   782                                 fullPath.Format( KDriveSpec, static_cast<TUint>( driveLetter ) );
   818                                 fullPath.Format( KDriveSpec, static_cast<TUint>( driveLetter ) );
   783                                 fullPath.Append( path ); 
   819                                 fullPath.Append( path );
   784                                 iScanner->AddDirectoryL( fullPath );
   820                                 iScanner->AddDirectoryL( fullPath );
   785                                 }
   821                                 }
   786                             }
   822                             }
   787                         }
   823                         }
   788                     }
   824                     }
   807 // ---------------------------------------------------------------------------
   843 // ---------------------------------------------------------------------------
   808 //
   844 //
   809 void CAppMngr2Model::FetchDataTypesL()
   845 void CAppMngr2Model::FetchDataTypesL()
   810     {
   846     {
   811     FLOG( "CAppMngr2Model::FetchDataTypesL" );
   847     FLOG( "CAppMngr2Model::FetchDataTypesL" );
   812     
   848 
   813     TInt pluginCount = iPlugins.Count();
   849     TInt pluginCount = iPlugins.Count();
   814     for( TInt pluginIndex = 0; pluginIndex < pluginCount; pluginIndex++ )
   850     for( TInt pluginIndex = 0; pluginIndex < pluginCount; pluginIndex++ )
   815         {
   851         {
   816         FLOG( "CAppMngr2Model::FetchDataTypesL: pluginIndex = %d", pluginIndex );
   852         FLOG( "CAppMngr2Model::FetchDataTypesL: pluginIndex = %d", pluginIndex );
   817         TRAP_IGNORE( iPlugins[ pluginIndex ]->FetchDataTypesL() );
   853         TRAP_IGNORE( iPlugins[ pluginIndex ]->FetchDataTypesL() );
   825 void CAppMngr2Model::CloseInfoMaker( const CAppMngr2InfoMaker& aMaker )
   861 void CAppMngr2Model::CloseInfoMaker( const CAppMngr2InfoMaker& aMaker )
   826     {
   862     {
   827     const CAppMngr2InfoMaker* makerToClose = &aMaker;
   863     const CAppMngr2InfoMaker* makerToClose = &aMaker;
   828     for( TInt index = iInfoMakers.Count() - 1; index >= 0; index-- )
   864     for( TInt index = iInfoMakers.Count() - 1; index >= 0; index-- )
   829         {
   865         {
   830         CAppMngr2InfoMaker* maker = iInfoMakers[ index ]; 
   866         CAppMngr2InfoMaker* maker = iInfoMakers[ index ];
   831         if( maker == makerToClose )
   867         if( maker == makerToClose )
   832             {
   868             {
   833             iInfoMakers.Remove( index );
   869             iInfoMakers.Remove( index );
   834             delete maker;
   870             delete maker;
   835             break;
   871             break;