contentstorage/casrv/caappscanner/src/casrvappscanner.cpp
changeset 66 32469d7d46ff
parent 61 8e5041d13c84
child 73 4bc7b118b3df
equal deleted inserted replaced
61:8e5041d13c84 66:32469d7d46ff
    18 #include <e32property.h>
    18 #include <e32property.h>
    19 #include <bautils.h>
    19 #include <bautils.h>
    20 #include <swi/sisregistrysession.h>
    20 #include <swi/sisregistrysession.h>
    21 #include <swi/sisregistryentry.h>
    21 #include <swi/sisregistryentry.h>
    22 #include <swi/sisregistrypackage.h>
    22 #include <swi/sisregistrypackage.h>
       
    23 #include <WidgetRegistryClient.h>
    23 
    24 
    24 #include "cadef.h"
    25 #include "cadef.h"
    25 #include "casrvappscanner.h"
    26 #include "casrvappscanner.h"
    26 #include "cautils.h"
    27 #include "cautils.h"
    27 #include "casrvmmchistory.h"
    28 #include "casrvmmchistory.h"
    30 #include "cainnerquery.h"
    31 #include "cainnerquery.h"
    31 #include "cainnerentry.h"
    32 #include "cainnerentry.h"
    32 #include "caarraycleanup.inl"
    33 #include "caarraycleanup.inl"
    33 #include "castorageproxy.h"
    34 #include "castorageproxy.h"
    34 
    35 
       
    36 
       
    37 
    35 // ==================== LOCAL FUNCTIONS ====================
    38 // ==================== LOCAL FUNCTIONS ====================
    36 
    39 
    37 /**
    40 /**
    38  * Identity function to search in an array of CCaInnerEntry.
    41  * Identity function to search in an array of CCaInnerEntry.
    39  * Identity is the ID.
    42  * Identity is the ID.
   133 
   136 
   134     User::LeaveIfError( iApaLsSession.Connect() );
   137     User::LeaveIfError( iApaLsSession.Connect() );
   135     User::LeaveIfError( iApaLsSession.GetAllApps() ); // This is async.
   138     User::LeaveIfError( iApaLsSession.GetAllApps() ); // This is async.
   136     iApaLsSession.RegisterListPopulationCompleteObserver( iStatus );
   139     iApaLsSession.RegisterListPopulationCompleteObserver( iStatus );
   137     iCollectionDownloadId = 0;
   140     iCollectionDownloadId = 0;
       
   141     iAllCollectionId = 0;
   138     SetActive();
   142     SetActive();
   139     }
   143     }
   140 
   144 
   141 // ---------------------------------------------------------
   145 // ---------------------------------------------------------
   142 // CCaSrvAppScanner::RunL
   146 // CCaSrvAppScanner::RunL
   146     {
   150     {
   147     User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL.
   151     User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL.
   148     // AppArc app scan complete, we have the app list.
   152     // AppArc app scan complete, we have the app list.
   149     UpdateApplicationEntriesL();
   153     UpdateApplicationEntriesL();
   150     InstallationNotifyL();
   154     InstallationNotifyL();
       
   155     MakeNotEmptyCollectionsVisibleL();
   151     }
   156     }
   152 
   157 
   153 // ---------------------------------------------------------
   158 // ---------------------------------------------------------
   154 // CCaSrvAppScanner::DoCancel
   159 // CCaSrvAppScanner::DoCancel
   155 // ---------------------------------------------------------
   160 // ---------------------------------------------------------
   219     TBool toUpdate = HandleMmcAttrUpdateL( aEntry, aMmcId );
   224     TBool toUpdate = HandleMmcAttrUpdateL( aEntry, aMmcId );
   220     toUpdate = HandleHiddenFlagUpdateL( aEntry ) || toUpdate;
   225     toUpdate = HandleHiddenFlagUpdateL( aEntry ) || toUpdate;
   221     toUpdate = HandleMissingFlagUpdate( aEntry ) || toUpdate;
   226     toUpdate = HandleMissingFlagUpdate( aEntry ) || toUpdate;
   222     toUpdate = HandleLockDeleteFlagUpdateL( aEntry ) || toUpdate;
   227     toUpdate = HandleLockDeleteFlagUpdateL( aEntry ) || toUpdate;
   223     toUpdate = SetApaAppInfoL( aEntry ) || toUpdate;
   228     toUpdate = SetApaAppInfoL( aEntry ) || toUpdate;
   224        
   229 
   225     if( iInstalledPackages.Find( aEntry->GetUid() ) != KErrNotFound )
   230     if( iInstalledPackages.Find( aEntry->GetUid() ) != KErrNotFound )
   226         {
   231         {
   227         AddEntryToDownloadedCollectionL( aEntry->GetId() );
   232         AddEntryToDownloadedCollectionL( aEntry->GetId() );
   228         toUpdate = HandleUsedFlagUpdateL( aEntry ) || toUpdate;
   233         toUpdate = HandleUsedFlagUpdateL( aEntry ) || toUpdate;
   229         }
   234         }
   230     if( toUpdate )
   235     if( toUpdate )
   231         {
   236         {
   232         //update app in storage
   237         //update app in storage
   233         iCaStorageProxy.AddL( aEntry );
   238         iCaStorageProxy.AddL( aEntry );
   234         RemoveFromInstalledPackages( aEntry->GetUid() );
   239         RemoveFromInstalledPackages( aEntry->GetUid() );
       
   240         AddEntryToPredefinedCollectionL( aEntry, ETrue );
   235         }
   241         }
   236     }
   242     }
   237 // ---------------------------------------------------------
   243 // ---------------------------------------------------------
   238 // CCaSrvAppScanner::HandleHiddenFlagUpdateL
   244 // CCaSrvAppScanner::HandleHiddenFlagUpdateL
   239 // ---------------------------------------------------------
   245 // ---------------------------------------------------------
   273 //
   279 //
   274 TBool CCaSrvAppScanner::HandleMmcAttrUpdateL(
   280 TBool CCaSrvAppScanner::HandleMmcAttrUpdateL(
   275         CCaInnerEntry* aItem, TUint aMmcId )
   281         CCaInnerEntry* aItem, TUint aMmcId )
   276     {
   282     {
   277     TBool toUpdate( ETrue );
   283     TBool toUpdate( ETrue );
   278     if( IsInMmc( TUid::Uid( aItem->GetUid() ) ) )
   284     if( IsInMmcL( TUid::Uid( aItem->GetUid() ) ) )
   279         {
   285         {
   280         //app is instaled on mmc - KCaAttrMmcId attribute update
   286         //app is instaled on mmc - KCaAttrMmcId attribute update
   281         TBuf<KUidChars> uidString;
   287         TBuf<KUidChars> uidString;
   282         uidString.Format( KHexFormat, aMmcId );
   288         uidString.Format( KHexFormat, aMmcId );
   283         aItem->AddAttributeL( KCaAttrMmcId, uidString );
   289         aItem->AddAttributeL( KCaAttrMmcId, uidString );
   284         }
   290         }
   285     else if ( IsInMassStorage( TUid::Uid( aItem->GetUid() ) ) )
   291     else if ( IsInMassStorageL( TUid::Uid( aItem->GetUid() ) ) )
   286         {
   292         {
   287         //its app installed on mass storage, we need to leave it
   293         //its app installed on mass storage, we need to leave it
   288         //in case of connecting usb in mass storage mode
   294         //in case of connecting usb in mass storage mode
   289         aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage );
   295         aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage );
   290         }
   296         }
   360 //
   366 //
   361 TBool CCaSrvAppScanner::HandleLockDeleteFlagUpdateL( CCaInnerEntry* aItem )
   367 TBool CCaSrvAppScanner::HandleLockDeleteFlagUpdateL( CCaInnerEntry* aItem )
   362     {
   368     {
   363     TBool toChange( EFalse );
   369     TBool toChange( EFalse );
   364     TBool isVisible = ( ( aItem->GetFlags() & EVisible ) != 0 );
   370     TBool isVisible = ( ( aItem->GetFlags() & EVisible ) != 0 );
   365     if( isVisible && IsInRom( aItem->GetUid() ) )
   371     if( isVisible && IsInRomL( aItem->GetUid() ) )
   366         {
   372         {
   367         if( ( aItem->GetFlags() & ERemovable ) != 0 )
   373         if( ( aItem->GetFlags() & ERemovable ) != 0 )
   368             {
   374             {
   369             aItem->SetFlags( aItem->GetFlags() & ~ERemovable );
   375             aItem->SetFlags( aItem->GetFlags() & ~ERemovable );
   370             toChange = ETrue;
   376             toChange = ETrue;
   439     {
   445     {
   440     CCaInnerEntry* appEntry = CCaInnerEntry::NewLC();
   446     CCaInnerEntry* appEntry = CCaInnerEntry::NewLC();
   441     appEntry->SetUid( KHsAppUid.iUid );
   447     appEntry->SetUid( KHsAppUid.iUid );
   442     TInt index = aArray.Find(
   448     TInt index = aArray.Find(
   443             appEntry, TIdentityRelation<CCaInnerEntry>( UidMatch ) );
   449             appEntry, TIdentityRelation<CCaInnerEntry>( UidMatch ) );
   444     
   450 
   445     if ( index != KErrNotFound )
   451     if ( index != KErrNotFound )
   446         { // hs app already in storage - ensure it is hidden and remove from resultArray
   452         { // hs app already in storage - ensure it is hidden and remove from resultArray
   447         if ( ( aArray[index]->GetFlags() & EVisible ) != 0 )
   453         if ( ( aArray[index]->GetFlags() & EVisible ) != 0 )
   448             {
   454             {
   449             aArray[index]->SetFlags( aArray[index]->GetFlags() & ~EVisible);
   455             aArray[index]->SetFlags( aArray[index]->GetFlags() & ~EVisible);
   450             iCaStorageProxy.AddL( aArray[index] );
   456             iCaStorageProxy.AddL( aArray[index] );
   451             }        
   457             }
   452         delete aArray[index];
   458         delete aArray[index];
   453         aArray.Remove( index );        
   459         aArray.Remove( index );
   454         }
   460         }
   455     else
   461     else
   456         { // if not found add as not visible to the storage
   462         { // if not found add as not visible to the storage
   457         appEntry->SetEntryTypeNameL( KCaTypeApp );
   463         appEntry->SetEntryTypeNameL( KCaTypeApp );
   458         appEntry->SetFlags( 0 ); 
   464         appEntry->SetFlags( 0 );
   459         appEntry->SetRole( EItemEntryRole );
   465         appEntry->SetRole( EItemEntryRole );
   460         SetApaAppInfoL( appEntry );
   466         SetApaAppInfoL( appEntry );
   461         iCaStorageProxy.AddL( appEntry );
   467         iCaStorageProxy.AddL( appEntry );
   462         }
   468         }
   463     CleanupStack::PopAndDestroy( appEntry );
   469     CleanupStack::PopAndDestroy( appEntry );
   468 // CCaSrvAppScanner::GetApaItemsL
   474 // CCaSrvAppScanner::GetApaItemsL
   469 // ---------------------------------------------------------
   475 // ---------------------------------------------------------
   470 //
   476 //
   471 void CCaSrvAppScanner::GetApaItemsL( RArray<TCaAppAtributes>& aArray )
   477 void CCaSrvAppScanner::GetApaItemsL( RArray<TCaAppAtributes>& aArray )
   472     {
   478     {
   473     TApaAppInfo appInfo;
   479     TApaAppInfo* appInfo = new(ELeave) TApaAppInfo();
       
   480     CleanupStack::PushL(appInfo);
   474     TApaAppCapabilityBuf appCap;
   481     TApaAppCapabilityBuf appCap;
   475 
   482 
   476     User::LeaveIfError( iApaLsSession.GetAllApps( 0 ) );
   483     User::LeaveIfError( iApaLsSession.GetAllApps( 0 ) );
   477     // for every application get uid, hidden and missing attribute
   484     // for every application get uid, hidden and missing attribute
   478     // and add to aArray.
   485     // and add to aArray.
   479     while( KErrNone == iApaLsSession.GetNextApp( appInfo ) )
   486     while( KErrNone == iApaLsSession.GetNextApp( *appInfo ) )
   480         {
   487         {
   481         User::LeaveIfError( iApaLsSession.GetAppCapability(
   488         User::LeaveIfError( iApaLsSession.GetAppCapability(
   482                 appCap, appInfo.iUid ) );
   489                 appCap, appInfo->iUid ) );
   483         // "Hidden" status according to AppArc.
   490         // "Hidden" status according to AppArc.
   484         if( !appCap().iAppIsHidden )
   491         if( !appCap().iAppIsHidden )
   485             {
   492             {
   486             TCaAppAtributes appAtributes( appInfo.iUid.iUid );
   493             TCaAppAtributes appAtributes( appInfo->iUid.iUid );
   487             aArray.AppendL( appAtributes );
   494             aArray.AppendL( appAtributes );
   488             }
   495             }
   489         }
   496         }
       
   497     CleanupStack::PopAndDestroy(appInfo);
   490     }
   498     }
   491 
   499 
   492 // ---------------------------------------------------------
   500 // ---------------------------------------------------------
   493 // CCaSrvAppScanner::GetMcsItemsL
   501 // CCaSrvAppScanner::GetMcsItemsL
   494 // ---------------------------------------------------------
   502 // ---------------------------------------------------------
   532         }
   540         }
   533     return iCollectionDownloadId;
   541     return iCollectionDownloadId;
   534     }
   542     }
   535 
   543 
   536 // ---------------------------------------------------------
   544 // ---------------------------------------------------------
       
   545 // CCaSrvAppScanner::GetAllCollectionIdL
       
   546 // ---------------------------------------------------------
       
   547 //
       
   548 TInt CCaSrvAppScanner::GetAllCollectionIdL()
       
   549     {
       
   550     if( iAllCollectionId == 0 )
       
   551         {
       
   552         CCaInnerQuery *getAllCollectionIdQuery = CCaInnerQuery::NewLC();
       
   553         CDesC16ArrayFlat *typenameArray = new(ELeave) CDesC16ArrayFlat(
       
   554                 KDefaultGranularity );
       
   555         CleanupStack::PushL( typenameArray );
       
   556         typenameArray->AppendL( KCaTypeMenuCollections );
       
   557         getAllCollectionIdQuery->SetEntryTypeNames( typenameArray );
       
   558         CleanupStack::Pop( typenameArray );
       
   559         
       
   560         RArray<TInt> idArray;
       
   561         CleanupClosePushL( idArray );
       
   562         iCaStorageProxy.GetEntriesIdsL( getAllCollectionIdQuery,
       
   563                 idArray );
       
   564         if( idArray.Count() )
       
   565             {
       
   566             iAllCollectionId = idArray[0];
       
   567             }
       
   568         CleanupStack::PopAndDestroy( &idArray );
       
   569         CleanupStack::PopAndDestroy( getAllCollectionIdQuery );
       
   570         }
       
   571     return iAllCollectionId;
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------
   537 // CCaSrvAppScanner::GetMcsItemsL
   575 // CCaSrvAppScanner::GetMcsItemsL
   538 // ---------------------------------------------------------
   576 // ---------------------------------------------------------
   539 //
   577 //
   540 void CCaSrvAppScanner::GetCaAppEntriesL( TInt aUid,
   578 void CCaSrvAppScanner::GetCaAppEntriesL( TInt aUid,
   541         RPointerArray<CCaInnerEntry>& aArray )
   579         RPointerArray<CCaInnerEntry>& aArray )
   650 // ---------------------------------------------------------
   688 // ---------------------------------------------------------
   651 //
   689 //
   652 void CCaSrvAppScanner::AddEntryToDownloadedCollectionL( TInt aEntryId )
   690 void CCaSrvAppScanner::AddEntryToDownloadedCollectionL( TInt aEntryId )
   653     {
   691     {
   654     TCaOperationParams params = { TCaOperationParams::EPrepend, GetCollectionDownloadIdL(), 0 // not used
   692     TCaOperationParams params = { TCaOperationParams::EPrepend, GetCollectionDownloadIdL(), 0 // not used
   655     		};
   693             };
   656 
   694 
   657     RArray<TInt> entryIds;
   695     RArray<TInt> entryIds;
   658     CleanupClosePushL( entryIds );
   696     CleanupClosePushL( entryIds );
   659     entryIds.AppendL( aEntryId );
   697     entryIds.AppendL( aEntryId );
   660     iCaStorageProxy.OrganizeL( entryIds, params );
   698     iCaStorageProxy.OrganizeL( entryIds, params );
   661 
   699 
   662     CleanupStack::PopAndDestroy( &entryIds );
   700     CleanupStack::PopAndDestroy( &entryIds );
   663     }
   701     }
   664 
   702 
   665 // ---------------------------------------------------------
   703 // ---------------------------------------------------------
       
   704 // CCaSrvAppScanner::AddEntryToPredefinedCollectionL
       
   705 // ---------------------------------------------------------
       
   706 //
       
   707 void CCaSrvAppScanner::AddEntryToPredefinedCollectionL(
       
   708         CCaInnerEntry* aEntry, TBool aUpdate )
       
   709     {
       
   710     TApaAppCapabilityBuf capability;
       
   711     User::LeaveIfError( iApaLsSession.GetAppCapability( capability,
       
   712             TUid::Uid( aEntry->GetUid() ) ) );
       
   713 
       
   714     if( capability().iGroupName.Length() )
       
   715         {
       
   716         // appgroup_name is defined for this app. Find or create folder.
       
   717         CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
       
   718         innerQuery->SetRole( CCaInnerQuery::Group );          
       
   719         innerQuery->AddAttributeL( KCaAppGroupName,
       
   720                 capability().iGroupName );
       
   721         
       
   722         // get entries by attributes
       
   723         RPointerArray<CCaInnerEntry> resultArrayItems;
       
   724         CleanupResetAndDestroyPushL( resultArrayItems );
       
   725         iCaStorageProxy.GetEntriesL( innerQuery, resultArrayItems );
       
   726 
       
   727         RArray<TInt> entryIds;
       
   728         CleanupClosePushL( entryIds );
       
   729         TInt entryId = aEntry->GetId();
       
   730         entryIds.AppendL( entryId );
       
   731         TCaOperationParams organizeParams;
       
   732         organizeParams.iBeforeEntryId = 0;
       
   733         
       
   734         if( resultArrayItems.Count() )
       
   735             {
       
   736             // collection with appgroup_name exist - add entry 
       
   737             // to this collection
       
   738             organizeParams.iGroupId = resultArrayItems[0]->GetId();
       
   739             }
       
   740         else
       
   741             {
       
   742             // create new collection
       
   743             TInt predefinedCollectionId = CreatePredefinedCollectionL(
       
   744                     capability().iGroupName );
       
   745             
       
   746             organizeParams.iGroupId = predefinedCollectionId;
       
   747 
       
   748             // add new collection to all collection   
       
   749             AddCollectionToAllCollectionL( predefinedCollectionId );
       
   750             
       
   751             if( aUpdate )
       
   752                 {
       
   753                 organizeParams.iOperationType = TCaOperationParams::EAppend;
       
   754                 iCaStorageProxy.OrganizeL( entryIds, organizeParams );
       
   755                 }
       
   756             }
       
   757         
       
   758         if( !aUpdate )
       
   759             {
       
   760             organizeParams.iOperationType = TCaOperationParams::EAppend;
       
   761             iCaStorageProxy.OrganizeL( entryIds, organizeParams );
       
   762             }
       
   763         
       
   764         CleanupStack::PopAndDestroy( &entryIds );
       
   765         CleanupStack::PopAndDestroy( &resultArrayItems );
       
   766         CleanupStack::PopAndDestroy( innerQuery );
       
   767         } 
       
   768     }
       
   769 
       
   770 // ---------------------------------------------------------
       
   771 // CCaSrvAppScanner::CreatePredefinedCollectionL
       
   772 // ---------------------------------------------------------
       
   773 //
       
   774 TInt CCaSrvAppScanner::CreatePredefinedCollectionL( const TDesC& aGroupName )
       
   775     {
       
   776     CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
       
   777     innerEntry->SetTextL( aGroupName );
       
   778     innerEntry->SetEntryTypeNameL( KCaTypeCollection );
       
   779     innerEntry->SetRole( CCaInnerQuery::Group );
       
   780     innerEntry->AddAttributeL( KCaAppGroupName, aGroupName );
       
   781     innerEntry->SetFlags( EVisible );
       
   782     innerEntry->SetFlags( innerEntry->GetFlags() | ERemovable );
       
   783     _LIT( KCollectionIconFileName, "qtg_large_applications_user");
       
   784     innerEntry->SetIconDataL( KCollectionIconFileName,
       
   785             KNullDesC, KNullDesC );
       
   786     iCaStorageProxy.AddL( innerEntry );
       
   787     // Get new collection Id
       
   788     TInt newCollectionId = innerEntry->GetId();
       
   789     CleanupStack::PopAndDestroy( innerEntry );
       
   790     
       
   791     return newCollectionId;
       
   792     }
       
   793 
       
   794 // ---------------------------------------------------------
       
   795 // CCaSrvAppScanner::AddCollectionToAllCollectionL
       
   796 // ---------------------------------------------------------
       
   797 //
       
   798 void CCaSrvAppScanner::AddCollectionToAllCollectionL( TInt aCollectionId )
       
   799     {
       
   800     RArray<TInt> entryIds;
       
   801     CleanupClosePushL( entryIds );
       
   802     entryIds.AppendL( aCollectionId );
       
   803     
       
   804     TCaOperationParams organizeParams;
       
   805     organizeParams.iBeforeEntryId = 0;
       
   806     organizeParams.iOperationType = TCaOperationParams::EAppend;
       
   807     organizeParams.iGroupId = GetAllCollectionIdL();
       
   808     iCaStorageProxy.OrganizeL( entryIds, organizeParams );
       
   809     CleanupStack::PopAndDestroy( &entryIds );
       
   810     }
       
   811 
       
   812 
       
   813 
       
   814 // ---------------------------------------------------------
   666 // CCaSrvAppScanner::RemoveToDownloadedCollectionL
   815 // CCaSrvAppScanner::RemoveToDownloadedCollectionL
   667 // ---------------------------------------------------------
   816 // ---------------------------------------------------------
   668 //
   817 //
   669 void CCaSrvAppScanner::RemoveEntryFromDownloadedL( TInt aEntryId )
   818 void CCaSrvAppScanner::RemoveEntryFromDownloadedL( TInt aEntryId )
   670     {
   819     {
   671     TCaOperationParams params = { TCaOperationParams::ERemove, GetCollectionDownloadIdL(), 0 // not used
   820     TCaOperationParams params = { TCaOperationParams::ERemove, GetCollectionDownloadIdL(), 0 // not used
   672     		};
   821             };
   673 
   822 
   674     RArray<TInt> entryIds;
   823     RArray<TInt> entryIds;
   675     CleanupClosePushL( entryIds );
   824     CleanupClosePushL( entryIds );
   676     entryIds.AppendL( aEntryId );
   825     entryIds.AppendL( aEntryId );
   677     iCaStorageProxy.OrganizeL( entryIds, params );
   826     iCaStorageProxy.OrganizeL( entryIds, params );
   711     SetApaAppInfoL( appEntry );
   860     SetApaAppInfoL( appEntry );
   712     HandleLockDeleteFlagUpdateL( appEntry );
   861     HandleLockDeleteFlagUpdateL( appEntry );
   713     HandleMmcAttrUpdateL( appEntry, aCurrentMmcId );
   862     HandleMmcAttrUpdateL( appEntry, aCurrentMmcId );
   714 
   863 
   715     iCaStorageProxy.AddL( appEntry );
   864     iCaStorageProxy.AddL( appEntry );
       
   865     
       
   866     AddEntryToPredefinedCollectionL( appEntry );
       
   867     
   716     if( iInstalledPackages.Find( aUid ) != KErrNotFound )
   868     if( iInstalledPackages.Find( aUid ) != KErrNotFound )
   717         {
   869         {
   718         AddEntryToDownloadedCollectionL( appEntry->GetId() );
   870         AddEntryToDownloadedCollectionL( appEntry->GetId() );
   719         }
   871         }
   720     RemoveFromInstalledPackages( aUid );
   872     RemoveFromInstalledPackages( aUid );
   757             aEntry->SetTextL( info.iCaption );
   909             aEntry->SetTextL( info.iCaption );
   758             aEntry->AddAttributeL( KCaAttrLongName, info.iCaption );
   910             aEntry->AddAttributeL( KCaAttrLongName, info.iCaption );
   759             changed = ETrue;
   911             changed = ETrue;
   760             }
   912             }
   761         CleanupStack::PopAndDestroy( &attrVal );
   913         CleanupStack::PopAndDestroy( &attrVal );
       
   914         // check if its java app and add attr for entrys
       
   915         TUid appTypeUid;
       
   916         if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info.iUid ) )
       
   917             {
       
   918             if( appTypeUid == KMidletApplicationTypeUid )
       
   919                 {
       
   920                 aEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueJava );
       
   921                 aEntry->AddAttributeL( KCaAttrAppSettingsPlugin, KCaAttrJavaAppSettingsPluginValue );
       
   922                 }
       
   923             else if (appTypeUid == KCWRTApplicationTypeUid) 
       
   924                 {
       
   925                 aEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueCWRT );
       
   926                 aEntry->AddAttributeL( KCaAttrAppWidgetUri, KCaAttrAppWidgetUriCWRTValue );
       
   927                 // web id should be taken from SCR when supported
       
   928                 RWidgetRegistryClientSession wrtSession;
       
   929                 CleanupClosePushL(wrtSession);
       
   930                 User::LeaveIfError( wrtSession.Connect());
       
   931                 TFileName bundleId;
       
   932                 wrtSession.GetWidgetBundleId(info.iUid, bundleId);
       
   933                 aEntry->AddAttributeL( KCaAttrAppWidgetParamWebAppId, bundleId );
       
   934                 CleanupStack::PopAndDestroy(&wrtSession);
       
   935                 }
       
   936             }
   762         }
   937         }
   763     return changed;
   938     return changed;
   764     }
   939     }
   765 
   940 
   766 // ---------------------------------------------------------
   941 // ---------------------------------------------------------
   792                 {
   967                 {
   793                 AddObjectFlagL( aCaEntries[i], EMissing );
   968                 AddObjectFlagL( aCaEntries[i], EMissing );
   794                 }
   969                 }
   795             else
   970             else
   796                 {
   971                 {
   797                 RemoveAppL( aCaEntries[i] );
   972                 //RemoveAppL( aCaEntries[i] );
       
   973                 AddObjectFlagL( aCaEntries[i], EMissing );
   798                 }
   974                 }
   799             }
   975             }
   800         else
   976         else
   801             {
   977             {
   802             RemoveAppL( aCaEntries[i] );
   978             AddObjectFlagL( aCaEntries[i], EMissing );
   803             }
   979             }
   804         CleanupStack::PopAndDestroy( &attrVal );
   980         CleanupStack::PopAndDestroy( &attrVal );
   805         }
   981         }
   806     }
   982     }
   807 
   983 
   896         }
  1072         }
   897     return EFalse;
  1073     return EFalse;
   898     }
  1074     }
   899 
  1075 
   900 // ---------------------------------------------------------
  1076 // ---------------------------------------------------------
   901 // CCaSrvAppScanner::IsAppInDrive
  1077 // CCaSrvAppScanner::IsAppInDriveL
   902 // ---------------------------------------------------------
  1078 // ---------------------------------------------------------
   903 //
  1079 //
   904 TBool CCaSrvAppScanner::IsAppInDrive(
  1080 TBool CCaSrvAppScanner::IsAppInDriveL(
   905         const TUid aUid,
  1081         const TUid aUid,
   906         const DriveInfo::TDefaultDrives& aDefaultDrive ) const
  1082         const DriveInfo::TDefaultDrives& aDefaultDrive ) const
   907     {
  1083     {
   908     TBool ret( EFalse );
  1084     TBool ret( EFalse );
   909     TApaAppInfo info;
  1085     TApaAppInfo* appInfo = new( ELeave ) TApaAppInfo();
   910     TInt err = iApaLsSession.GetAppInfo( info, aUid );
  1086     TInt err = iApaLsSession.GetAppInfo( *appInfo, aUid );
   911     if( !err && IsFileInDrive( info.iFullName, aDefaultDrive ) )
  1087     if( !err && IsFileInDrive( appInfo->iFullName, aDefaultDrive ) )
   912         {
  1088         {
   913         ret = ETrue;
  1089         ret = ETrue;
   914         }
  1090         }
       
  1091     delete appInfo;
   915     return ret;
  1092     return ret;
   916     }
  1093     }
   917 
  1094 
   918 // ---------------------------------------------------------
  1095 // ---------------------------------------------------------
   919 // CCaSrvAppScanner::IsInMmc
  1096 // CCaSrvAppScanner::IsInMmcL
   920 // ---------------------------------------------------------
  1097 // ---------------------------------------------------------
   921 //
  1098 //
   922 TBool CCaSrvAppScanner::IsInMmc( const TUid aUid ) const
  1099 TBool CCaSrvAppScanner::IsInMmcL( const TUid aUid ) const
   923     {
  1100     {
   924     return IsAppInDrive( aUid, DriveInfo::EDefaultRemovableMassStorage );
  1101     return IsAppInDriveL( aUid, DriveInfo::EDefaultRemovableMassStorage );
   925     }
  1102     }
   926 
  1103 
   927 // ---------------------------------------------------------
  1104 // ---------------------------------------------------------
   928 // CCaSrvAppScanner::IsInMassStorage
  1105 // CCaSrvAppScanner::IsInMassStorageL
   929 // ---------------------------------------------------------
  1106 // ---------------------------------------------------------
   930 //
  1107 //
   931 TBool CCaSrvAppScanner::IsInMassStorage( const TUid aUid ) const
  1108 TBool CCaSrvAppScanner::IsInMassStorageL( const TUid aUid ) const
   932     {
  1109     {
   933     return IsAppInDrive( aUid, DriveInfo::EDefaultMassStorage );
  1110     return IsAppInDriveL( aUid, DriveInfo::EDefaultMassStorage );
   934     }
  1111     }
   935 
  1112 
   936 // ---------------------------------------------------------
  1113 // ---------------------------------------------------------
   937 // CCaSrvAppScanner::IsInRom
  1114 // CCaSrvAppScanner::IsInRomL
   938 // ---------------------------------------------------------
  1115 // ---------------------------------------------------------
   939 //
  1116 //
   940 TBool CCaSrvAppScanner::IsInRom( TInt aUid )
  1117 TBool CCaSrvAppScanner::IsInRomL( TInt aUid )
   941     {
  1118     {
   942     return IsAppInDrive( TUid::Uid( aUid ), DriveInfo::EDefaultRom );
  1119     return IsAppInDriveL( TUid::Uid( aUid ), DriveInfo::EDefaultRom );
   943     }
  1120     }
   944 
  1121 
   945 // ---------------------------------------------------------
  1122 // ---------------------------------------------------------
   946 // CCaSrvAppScanner::IsDriveInUse
  1123 // CCaSrvAppScanner::IsDriveInUse
   947 // ---------------------------------------------------------
  1124 // ---------------------------------------------------------
   964         }
  1141         }
   965 
  1142 
   966     return inUse;
  1143     return inUse;
   967     }
  1144     }
   968 
  1145 
       
  1146 void CCaSrvAppScanner::MakeNotEmptyCollectionsVisibleL()
       
  1147     {
       
  1148     RPointerArray<CCaInnerEntry> resultArray;
       
  1149     CleanupResetAndDestroyPushL( resultArray );
       
  1150     CCaInnerQuery* hiddenCollectionsQuery = CCaInnerQuery::NewLC();
       
  1151     CDesC16ArrayFlat* entryType = new ( ELeave ) CDesC16ArrayFlat(
       
  1152             KGranularityOne );
       
  1153     CleanupStack::PushL( entryType );
       
  1154     entryType->AppendL( KCaTypeCollection );
       
  1155     hiddenCollectionsQuery->SetEntryTypeNames( entryType );
       
  1156     hiddenCollectionsQuery->SetFlagsOff( EVisible );
       
  1157     iCaStorageProxy.GetEntriesL( hiddenCollectionsQuery, resultArray );
       
  1158     CleanupStack::Pop( entryType );
       
  1159     CleanupStack::PopAndDestroy( hiddenCollectionsQuery );
       
  1160     if( resultArray.Count() )
       
  1161         {
       
  1162         for( TInt i=0; i<resultArray.Count(); i++ )
       
  1163             {
       
  1164             // for any not visible collection
       
  1165             MakeCollectionVisibleIfHasVisibleEntryL( resultArray[i] );
       
  1166             }
       
  1167         }
       
  1168     CleanupStack::PopAndDestroy( &resultArray );
       
  1169    }
       
  1170 
       
  1171 void CCaSrvAppScanner::MakeCollectionVisibleIfHasVisibleEntryL(
       
  1172         CCaInnerEntry* aEntry )
       
  1173     {
       
  1174     RPointerArray<CCaInnerEntry> resultEntriesArray;
       
  1175     CleanupResetAndDestroyPushL( resultEntriesArray );
       
  1176     CCaInnerQuery* visibleEntriesQuery = CCaInnerQuery::NewLC();
       
  1177     visibleEntriesQuery->SetParentId( aEntry->GetId() );
       
  1178     visibleEntriesQuery->SetFlagsOn( EVisible );
       
  1179     visibleEntriesQuery->SetFlagsOff( EMissing );
       
  1180     iCaStorageProxy.GetEntriesL( visibleEntriesQuery, resultEntriesArray );
       
  1181     if( resultEntriesArray.Count() )
       
  1182         {
       
  1183         // set collection visible if hidden
       
  1184         if( HandleHiddenFlagUpdateL( aEntry ) )
       
  1185             {
       
  1186             // update here this collection
       
  1187             iCaStorageProxy.AddL( aEntry, ETrue );
       
  1188             }
       
  1189         }
       
  1190     CleanupStack::PopAndDestroy( visibleEntriesQuery );
       
  1191     CleanupStack::PopAndDestroy( &resultEntriesArray );
       
  1192     }
       
  1193 
   969 // ==================== MEMBER FUNCTIONS ====================
  1194 // ==================== MEMBER FUNCTIONS ====================
   970 
  1195 
   971 // ---------------------------------------------------------
  1196 // ---------------------------------------------------------
   972 // TAppAtributes::TAppAtributes
  1197 // TAppAtributes::TAppAtributes
   973 // ---------------------------------------------------------
  1198 // ---------------------------------------------------------