contentstorage/casrv/caappscanner/src/casrvappscanner.cpp
changeset 102 8b8b34fa9751
parent 99 7aaf39b772ac
child 119 50e220be30d1
equal deleted inserted replaced
100:0920c6a9b6c8 102:8b8b34fa9751
    32 
    32 
    33 #include "caarraycleanup.inl"
    33 #include "caarraycleanup.inl"
    34 
    34 
    35 using namespace Usif;
    35 using namespace Usif;
    36 
    36 
       
    37 
       
    38 
    37 // ==================== LOCAL FUNCTIONS ====================
    39 // ==================== LOCAL FUNCTIONS ====================
    38 
    40 
    39 /**
    41 /**
    40  * Identity function to search in an array of CCaInnerEntry.
    42  * Identity function to search in an array of CCaInnerEntry.
    41  * Identity is the ID.
    43  * Identity is the ID.
    67 // ---------------------------------------------------------
    69 // ---------------------------------------------------------
    68 //
    70 //
    69 // ---------------------------------------------------------
    71 // ---------------------------------------------------------
    70 //
    72 //
    71 CCaSrvAppScanner* CCaSrvAppScanner::NewL( CCaStorageProxy& aCaStorageProxy,
    73 CCaSrvAppScanner* CCaSrvAppScanner::NewL( CCaStorageProxy& aCaStorageProxy,
       
    74         Usif::RSoftwareComponentRegistry& aSoftwareRegistry,
    72         CCaSrvEngUtils& aUtils )
    75         CCaSrvEngUtils& aUtils )
    73     {
    76     {
    74     CCaSrvAppScanner* scanner = new ( ELeave ) CCaSrvAppScanner(
    77     CCaSrvAppScanner* scanner = new ( ELeave ) CCaSrvAppScanner(
    75             aCaStorageProxy, aUtils );
    78             aCaStorageProxy, aSoftwareRegistry, aUtils );
    76     CleanupStack::PushL( scanner );
    79     CleanupStack::PushL( scanner );
    77     scanner->ConstructL();
    80     scanner->ConstructL();
    78     CleanupStack::Pop( scanner );
    81     CleanupStack::Pop( scanner );
    79     return scanner;
    82     return scanner;
    80     }
    83     }
    84 // ---------------------------------------------------------
    87 // ---------------------------------------------------------
    85 //
    88 //
    86 CCaSrvAppScanner::~CCaSrvAppScanner()
    89 CCaSrvAppScanner::~CCaSrvAppScanner()
    87     {
    90     {
    88     Cancel();
    91     Cancel();
    89     iSoftwareRegistry.Close();
       
    90     iApaLsSession.Close();
    92     iApaLsSession.Close();
    91     delete iMmcHistory;
    93     delete iMmcHistory;
    92     iFs.Close();
    94     iFs.Close();
    93     }
    95     }
    94 
    96 
    95 // ---------------------------------------------------------
    97 // ---------------------------------------------------------
    96 //
    98 //
    97 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
    98 //
   100 //
    99 CCaSrvAppScanner::CCaSrvAppScanner( CCaStorageProxy& aCaStorageProxy,
   101 CCaSrvAppScanner::CCaSrvAppScanner( CCaStorageProxy& aCaStorageProxy,
       
   102         Usif::RSoftwareComponentRegistry& aSoftwareRegistry,
   100         CCaSrvEngUtils& aUtils ) :
   103         CCaSrvEngUtils& aUtils ) :
   101     CActive( CActive::EPriorityStandard ),
   104     CActive( CActive::EPriorityStandard ),
   102     iCaStorageProxy( aCaStorageProxy ), iSrvEngUtils( aUtils )
   105     iCaStorageProxy( aCaStorageProxy ),
       
   106     iSoftwareRegistry(aSoftwareRegistry), iSrvEngUtils( aUtils )
   103     {
   107     {
   104     CActiveScheduler::Add( this );
   108     CActiveScheduler::Add( this );
   105     }
   109     }
   106 
   110 
   107 // ---------------------------------------------------------
   111 // ---------------------------------------------------------
   124         }
   128         }
   125     iMmcHistory = CCaSrvMmcHistory::NewL();
   129     iMmcHistory = CCaSrvMmcHistory::NewL();
   126     iMmcHistory->LoadL( iFs, KCaMmcHistoryFname() );
   130     iMmcHistory->LoadL( iFs, KCaMmcHistoryFname() );
   127 
   131 
   128     User::LeaveIfError( iApaLsSession.Connect() );
   132     User::LeaveIfError( iApaLsSession.Connect() );
   129     User::LeaveIfError( iSoftwareRegistry.Connect() );
       
   130     iApaLsSession.SetNotify( EFalse, iStatus );
   133     iApaLsSession.SetNotify( EFalse, iStatus );
   131     iCollectionDownloadId = 0;
   134     iCollectionDownloadId = 0;
   132     iAllCollectionId = 0;
   135     iAllCollectionId = 0;
   133 
   136 
   134     UpdateApplicationEntriesL();
   137     UpdateApplicationEntriesL();
   162 			TInt id;
   165 			TInt id;
   163 			if( !resultArray.Count() )
   166 			if( !resultArray.Count() )
   164 				{
   167 				{
   165                 id = AddAppEntryL(
   168                 id = AddAppEntryL(
   166                         updatedAppsInfo[i].iAppUid.iUid, UpdateMmcHistoryL() );
   169                         updatedAppsInfo[i].iAppUid.iUid, UpdateMmcHistoryL() );
       
   170                 AddEntryToDownloadedCollectionL( id );
   167 				}
   171 				}
   168 			else
   172 			else
   169 			    {
   173 			    {
   170                 ASSERT( resultArray.Count() == 1 );
   174                 ASSERT( resultArray.Count() == 1 );
   171                 id = resultArray[0]->GetId();
   175                 id = resultArray[0]->GetId();
   172                 UpdateAppEntryL( resultArray[0], UpdateMmcHistoryL(), ETrue );
   176                 UpdateAppEntryL( resultArray[0], UpdateMmcHistoryL(), ETrue );
   173                 AddEntryToPredefinedCollectionL( resultArray[0], ETrue );
   177                 }
   174 			    }
       
   175             AddEntryToDownloadedCollectionL( id );
       
   176             MakeNotEmptyCollectionsVisibleL();
   178             MakeNotEmptyCollectionsVisibleL();
   177 			}
   179 			}
   178 		else if( action == TApaAppUpdateInfo::EAppNotPresent )
   180 		else if( action == TApaAppUpdateInfo::EAppNotPresent )
   179 			{
   181 			{
   180 			HandleMissingItemsL( resultArray );
   182 			HandleMissingItemsL( resultArray );
   253 // ---------------------------------------------------------
   255 // ---------------------------------------------------------
   254 //
   256 //
   255 // ---------------------------------------------------------
   257 // ---------------------------------------------------------
   256 //
   258 //
   257 void CCaSrvAppScanner::UpdateAppEntryL(
   259 void CCaSrvAppScanner::UpdateAppEntryL(
   258         CCaInnerEntry* aEntry, TUint aMmcId, TBool aAlwaysUpdate  )
   260         CCaInnerEntry* aEntry, TUint aMmcId, TBool aAlwaysUpdate )
   259     {
   261     {
   260     TBool toUpdate = HandleMmcAttrUpdateL( aEntry, aMmcId );
   262     TBool missingFlagChanged = HandleMissingFlagsUpdate( aEntry );
   261     TBool missingVisibleFlagChanged =
   263     TBool visibleFlagChanged = HandleVisibleFlagUpdate( aEntry );
   262         HandleMissingVisibleFlagsUpdate( aEntry );
   264 
   263     toUpdate = missingVisibleFlagChanged || toUpdate;
   265 
   264     toUpdate = HandleRemovableVisibleFlagsUpdateL( aEntry ) || toUpdate;
   266     // To handle case with mmc card. When mmc attritube is updated then
       
   267     // used flag should be change. When aplication is update but
       
   268     // it is not appear then this flag should be change too.
       
   269     if( aAlwaysUpdate && !missingFlagChanged )
       
   270         {
       
   271         HandleUsedFlagUpdate( aEntry );
       
   272         }
       
   273     TBool toUpdate = missingFlagChanged || visibleFlagChanged;
   265     toUpdate = SetApaAppInfoL( aEntry ) || toUpdate;
   274     toUpdate = SetApaAppInfoL( aEntry ) || toUpdate;
       
   275     toUpdate = HandleRemovableFlagAndMmcAttrUpdateL( aEntry, aMmcId ) || toUpdate;
   266     toUpdate = RemoveUninstallFlagL( aEntry ) || toUpdate;
   276     toUpdate = RemoveUninstallFlagL( aEntry ) || toUpdate;
   267 
   277 
   268     if( toUpdate || aAlwaysUpdate )
   278     if( toUpdate || aAlwaysUpdate )
   269         {
   279         {
   270         //update app in storage
   280         //update app in storage
   271         HandleUsedFlagUpdate( aEntry );
       
   272         TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
   281         TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
   273         if( missingVisibleFlagChanged )
   282         if( missingFlagChanged || visibleFlagChanged )
   274             {
   283             {
   275             itemAppearanceChange = EItemAppeared;
   284             itemAppearanceChange = EItemAppeared;
   276             }
   285             }
       
   286         if( !missingFlagChanged )
       
   287             {
       
   288             AddEntryToPredefinedCollectionL( aEntry, ETrue );
       
   289             if ( aEntry->GetFlags() & ERemovable )
       
   290                 {
       
   291                 AddEntryToDownloadedCollectionL( aEntry->GetId() );
       
   292                 }
       
   293             }
   277         iCaStorageProxy.AddL( aEntry, EFalse, itemAppearanceChange );
   294         iCaStorageProxy.AddL( aEntry, EFalse, itemAppearanceChange );
   278         }
   295         }
   279     }
   296     }
   280 
   297 
   281 // ---------------------------------------------------------
   298 // ---------------------------------------------------------
   282 //
   299 //
   283 // ---------------------------------------------------------
   300 // ---------------------------------------------------------
   284 //
   301 //
   285 TBool CCaSrvAppScanner::HandleMmcAttrUpdateL(
   302 TBool CCaSrvAppScanner::HandleMmcAttrUpdateL(
       
   303         const Usif::CComponentEntry* aEntry,
   286         CCaInnerEntry* aItem, TUint aMmcId )
   304         CCaInnerEntry* aItem, TUint aMmcId )
   287     {
   305     {
   288     TBool toUpdate( ETrue );
   306     TBool toChange( EFalse );
   289     if( IsInMmcL( TUid::Uid( aItem->GetUid() ) ) )
   307     if( aEntry && aEntry->IsRemovable() )
   290         {
   308         {
   291         //app is instaled on mmc - KCaAttrMmcId attribute update
   309         TChar currentDriveLetter;
   292         RBuf uidString;
   310         if ( aEntry->SoftwareType().Compare(KCaAttrAppTypeValueNative()) != 0 )
   293         uidString.CleanupClosePushL();
   311             {
   294         uidString.CreateL(KUidChars);
   312             TDriveList driveList = aEntry->InstalledDrives();
   295         uidString.Format( KHexFormat, aMmcId );
   313             for ( TInt driveNr=EDriveY; driveNr >= EDriveA; driveNr-- )
   296         aItem->AddAttributeL( KCaAttrMmcId, uidString );
   314                 {
   297         CleanupStack::PopAndDestroy( &uidString );
   315                 if ( driveList[driveNr] )
   298         }
   316                     {
   299     else if ( IsInMassStorageL( TUid::Uid( aItem->GetUid() ) ) )
   317                     User::LeaveIfError( iFs.DriveToChar( driveNr,
   300         {
   318                             currentDriveLetter ) );
   301         //its app installed on mass storage, we need to leave it
   319                     }
   302         //in case of connecting usb in mass storage mode
   320                 }
   303         aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage );
   321             }
       
   322         else
       
   323             {
       
   324             TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo();
       
   325             if( !iApaLsSession.GetAppInfo( *appInfo,
       
   326                     TUid::Uid( aItem->GetUid() ) ) )
       
   327                 {
       
   328                 currentDriveLetter = appInfo->iFullName[0];
       
   329                 }
       
   330             }
       
   331 
       
   332         if( IsCharInDrive( currentDriveLetter,
       
   333                 DriveInfo::EDefaultRemovableMassStorage ) )
       
   334             {
       
   335             //app is instaled on mmc - KCaAttrMmcId attribute update
       
   336             RBuf uidString;
       
   337             uidString.CleanupClosePushL();
       
   338             uidString.CreateL( KUidChars );
       
   339             uidString.Format( KHexFormat, aMmcId );
       
   340             toChange = AddAttributeL( aItem, KCaAttrMmcId, uidString );
       
   341             CleanupStack::PopAndDestroy( &uidString );
       
   342             }
       
   343         else if ( IsCharInDrive( currentDriveLetter, DriveInfo::EDefaultMassStorage ) )
       
   344             {
       
   345             //its app installed on mass storage, we need to leave it
       
   346             //in case of connecting usb in mass storage mode
       
   347             toChange = AddAttributeL( aItem, KCaAttrMmcId, KCaMassStorage );
       
   348             }
       
   349         else
       
   350             {
       
   351             toChange = RemoveAttributeL( aItem, KCaAttrMmcId );
       
   352             }
   304         }
   353         }
   305     else
   354     else
   306         {
   355         {
   307         RBuf attrVal;
   356         toChange = RemoveAttributeL( aItem, KCaAttrMmcId );
   308         attrVal.CleanupClosePushL();
       
   309         attrVal.CreateL( KCaMaxAttrValueLen );
       
   310         if( aItem->FindAttribute( KCaAttrMmcId, attrVal ) )
       
   311             {
       
   312             aItem->RemoveAttributeL( KCaAttrMmcId );
       
   313             }
       
   314         else
       
   315             {
       
   316             toUpdate = EFalse;
       
   317             }
       
   318         CleanupStack::PopAndDestroy( &attrVal );
       
   319         //its installed on c: drive - remove attribute
   357         //its installed on c: drive - remove attribute
   320         }
   358         }
   321     return toUpdate;
   359     return toChange;
   322     }
   360     }
   323 
   361 
   324 // ---------------------------------------------------------
   362 // ---------------------------------------------------------
   325 //
   363 //
   326 // ---------------------------------------------------------
   364 // ---------------------------------------------------------
   357 
   395 
   358 // ---------------------------------------------------------
   396 // ---------------------------------------------------------
   359 //
   397 //
   360 // ---------------------------------------------------------
   398 // ---------------------------------------------------------
   361 //
   399 //
   362 TBool CCaSrvAppScanner::HandleRemovableVisibleFlagsUpdateL(
   400 TBool CCaSrvAppScanner::HandleRemovableFlagAndMmcAttrUpdateL(
   363         CCaInnerEntry* aItem )
   401         CCaInnerEntry* aItem, TUint aMmcId )
   364     {
   402     {
   365     TBool toChange( EFalse );
   403     TBool toChange( EFalse );
   366     if( ( aItem->GetFlags() & EVisible ) && IsInRomL( aItem->GetUid() ) )
   404     TComponentId compId = GetComponentIdFromEntryL( aItem );
       
   405 
       
   406     TBool isRemovable( EFalse );
       
   407     if( compId )
       
   408         {
       
   409         CComponentEntry* entry = CComponentEntry::NewLC();
       
   410         iSoftwareRegistry.GetComponentL( compId , *entry );
       
   411         isRemovable = entry->IsRemovable();
       
   412         toChange = HandleMmcAttrUpdateL( entry, aItem, aMmcId );
       
   413         CleanupStack::PopAndDestroy( entry );
       
   414         }
       
   415 
       
   416     if( ( aItem->GetFlags() & EVisible ) && !isRemovable )
   367         {
   417         {
   368         if( ( aItem->GetFlags() & ERemovable ) != 0 )
   418         if( ( aItem->GetFlags() & ERemovable ) != 0 )
   369             {
   419             {
   370             aItem->SetFlags( aItem->GetFlags() & ~ERemovable );
   420             aItem->SetFlags( aItem->GetFlags() & ~ERemovable );
   371             toChange = ETrue;
   421             toChange = ETrue;
   372             }
   422             }
   373         }
   423         }
   374     else
   424     else
   375         {
   425         {
   376         if( ( aItem->GetFlags() & ERemovable ) == 0 )
   426         if( ( aItem->GetFlags() & ERemovable ) == 0 && isRemovable )
   377             {
   427             {
   378             aItem->SetFlags( aItem->GetFlags() | ERemovable );
   428             aItem->SetFlags( aItem->GetFlags() | ERemovable );
   379             toChange = ETrue;
   429             toChange = ETrue;
   380             }
   430             }
   381         }
   431         }
   399 
   449 
   400 // ---------------------------------------------------------
   450 // ---------------------------------------------------------
   401 //
   451 //
   402 // ---------------------------------------------------------
   452 // ---------------------------------------------------------
   403 //
   453 //
   404 TBool CCaSrvAppScanner::HandleMissingVisibleFlagsUpdate(
   454 TBool CCaSrvAppScanner::HandleMissingFlagsUpdate(
   405         CCaInnerEntry* aItem )
   455         CCaInnerEntry* aItem )
   406     {
   456     {
   407     TBool ret( EFalse );
   457     TBool ret( EFalse );
   408     if( aItem->GetFlags() & EMissing ||
   458     if( aItem->GetFlags() & EMissing )
   409         !( aItem->GetFlags() & EVisible ) )
   459         {
   410         {
   460         //application found so we unset "missing" flag
   411         //application found so we unset "missing" and set "visible" flags
   461         aItem->SetFlags( aItem->GetFlags() & ~EMissing );
   412         aItem->SetFlags( aItem->GetFlags() & ~EMissing | EVisible );
       
   413         ret = ETrue;
   462         ret = ETrue;
   414         }
   463         }
   415     return ret;
   464     return ret;
   416     }
   465     }
   417 
   466 
   787     appEntry->SetUid( aUid );
   836     appEntry->SetUid( aUid );
   788     appEntry->SetFlags( EVisible );
   837     appEntry->SetFlags( EVisible );
   789     appEntry->SetRole( EItemEntryRole );
   838     appEntry->SetRole( EItemEntryRole );
   790 
   839 
   791     SetApaAppInfoL( appEntry );
   840     SetApaAppInfoL( appEntry );
   792     HandleRemovableVisibleFlagsUpdateL( appEntry );
   841     HandleRemovableFlagAndMmcAttrUpdateL( appEntry, aCurrentMmcId );
   793     HandleMmcAttrUpdateL( appEntry, aCurrentMmcId );
       
   794 
   842 
   795     iCaStorageProxy.AddL( appEntry );
   843     iCaStorageProxy.AddL( appEntry );
   796     id = appEntry->GetId();
   844     id = appEntry->GetId();
   797 
   845 
   798     AddEntryToPredefinedCollectionL( appEntry );
   846     AddEntryToPredefinedCollectionL( appEntry );
   810     TBool changed( EFalse );
   858     TBool changed( EFalse );
   811     TApaAppInfo* info = new ( ELeave ) TApaAppInfo();
   859     TApaAppInfo* info = new ( ELeave ) TApaAppInfo();
   812     CleanupStack::PushL(info);
   860     CleanupStack::PushL(info);
   813     if( KErrNone == iSrvEngUtils.GetAppInfo( *aEntry, *info ) )
   861     if( KErrNone == iSrvEngUtils.GetAppInfo( *aEntry, *info ) )
   814         {
   862         {
   815         RBuf attrVal;
   863         changed = SetAppCaptionL( aEntry, info ) || changed;
   816         attrVal.CleanupClosePushL();
   864         changed = UpdateComponentIdL( *aEntry ) || changed;
   817         attrVal.CreateL( KCaMaxAttrValueLen );
       
   818         aEntry->FindAttribute( KCaAttrShortName, attrVal );
       
   819         if( attrVal.Compare( info->iShortCaption ) != KErrNone
       
   820                 || aEntry->GetText().Compare( info->iCaption )
       
   821                         != KErrNone )
       
   822             {
       
   823             aEntry->SetTextL( info->iCaption );
       
   824             aEntry->AddAttributeL( KCaAttrShortName, info->iShortCaption );
       
   825             changed = ETrue;
       
   826             }
       
   827 
       
   828 
       
   829         if ( UpdateComponentIdL( *aEntry ) )
       
   830             {
       
   831             changed = ETrue;
       
   832             }
       
   833 
       
   834         CleanupStack::PopAndDestroy( &attrVal );
       
   835 
   865 
   836         // check if its java app and add attr for entries
   866         // check if its java app and add attr for entries
   837         TUid appTypeUid;
   867         TUid appTypeUid;
   838         if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info->iUid ) )
   868         if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info->iUid ) )
   839             {
   869             {
   840             if( appTypeUid == KMidletApplicationTypeUid )
   870             if( appTypeUid == KMidletApplicationTypeUid )
   841                 {
   871                 {
   842                 aEntry->AddAttributeL(
   872                 changed = SetJavaAppL( aEntry ) || changed;
   843                         KCaAttrAppType,
       
   844                         KCaAttrAppTypeValueJava );
       
   845 
       
   846                 TComponentId compId =
       
   847                         iSoftwareRegistry.GetComponentIdForAppL( info->iUid );
       
   848                 CPropertyEntry* propertyEntry =
       
   849                     iSoftwareRegistry.GetComponentPropertyL( compId, KCaScrPropertyAppSettings );
       
   850                 CleanupStack::PushL( propertyEntry );
       
   851                 if ( propertyEntry &&
       
   852                         propertyEntry->PropertyType() == CPropertyEntry::ELocalizedProperty )
       
   853                     {
       
   854                     aEntry->AddAttributeL(
       
   855                             KCaAttrAppSettingsPlugin,
       
   856                             static_cast<CLocalizablePropertyEntry*>(propertyEntry)->StrValue() );
       
   857                     }
       
   858                 CleanupStack::PopAndDestroy( propertyEntry );
       
   859                 }
   873                 }
   860             else if ( appTypeUid == KCWRTApplicationTypeUid )
   874             else if( appTypeUid == KCWRTApplicationTypeUid )
   861                 {
   875                 {
   862                 aEntry->AddAttributeL(
   876                 changed = SetCWRTAppL( aEntry ) || changed;
   863                         KCaAttrAppType,
       
   864                         KCaAttrAppTypeValueCWRT );
       
   865                 TComponentId compId =
       
   866                         iSoftwareRegistry.GetComponentIdForAppL( info->iUid );
       
   867                 CPropertyEntry* isMiniview =
       
   868                                         iSoftwareRegistry.GetComponentPropertyL( compId,
       
   869                                                 KCaScrPropertyIsMiniviewSupported );
       
   870                 CleanupStack::PushL( isMiniview );
       
   871                 // check first if we support mini view
       
   872                 if (isMiniview && isMiniview->PropertyType() == CPropertyEntry::EIntProperty &&
       
   873                         static_cast<CIntPropertyEntry*>(isMiniview)->IntValue())
       
   874                     {
       
   875                     CPropertyEntry* appId =
       
   876                         iSoftwareRegistry.GetComponentPropertyL( compId, KCaScrPropertyAppId );
       
   877                     CleanupStack::PushL( appId );
       
   878                     if ( appId &&
       
   879                          appId->PropertyType() == CPropertyEntry::ELocalizedProperty )
       
   880                         {
       
   881                         aEntry->AddAttributeL(
       
   882                                             KCaAttrAppWidgetUri,
       
   883                                             KCaAttrAppWidgetUriCWRTValue );
       
   884                         aEntry->AddAttributeL(
       
   885                                             KCaAttrAppWidgetParamWebAppId,
       
   886                                             static_cast<CLocalizablePropertyEntry*>(appId)->StrValue() );
       
   887                         }
       
   888                     CleanupStack::PopAndDestroy( appId );
       
   889                     }
       
   890                 CleanupStack::PopAndDestroy( isMiniview );
       
   891                 }
   877                 }
   892             }
   878             }
   893         }
   879         }
   894     CleanupStack::PopAndDestroy( info );
   880     CleanupStack::PopAndDestroy( info );
   895     return changed;
   881     return changed;
       
   882     }
       
   883 
       
   884 // ---------------------------------------------------------------------------
       
   885 //
       
   886 // ---------------------------------------------------------------------------
       
   887 //
       
   888 TBool CCaSrvAppScanner::SetAppCaptionL(
       
   889         CCaInnerEntry* aEntry, TApaAppInfo* info )
       
   890     {
       
   891     TBool changed(EFalse);
       
   892     if( aEntry->GetText().Compare( info->iCaption ) != KErrNone )
       
   893         {
       
   894         aEntry->SetTextL( info->iCaption );
       
   895         changed = ETrue;
       
   896         }
       
   897     changed = AddAttributeL( aEntry, KCaAttrShortName, info->iShortCaption )
       
   898             || changed;
       
   899 
       
   900     return changed;
       
   901     }
       
   902 
       
   903 // ---------------------------------------------------------------------------
       
   904 //
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 TBool CCaSrvAppScanner::SetJavaAppL( CCaInnerEntry* aEntry )
       
   908     {
       
   909     TBool changed = AddAttributeL(
       
   910             aEntry, KCaAttrAppType, KCaAttrAppTypeValueJava );
       
   911     TComponentId compId = GetComponentIdFromEntryL( aEntry );
       
   912     CPropertyEntry* propertyEntry = iSoftwareRegistry.GetComponentPropertyL(
       
   913             compId, KCaScrPropertyAppSettings );
       
   914     CleanupStack::PushL( propertyEntry );
       
   915 
       
   916     if( propertyEntry
       
   917             && propertyEntry->PropertyType()
       
   918                     == CPropertyEntry::ELocalizedProperty )
       
   919         {
       
   920         changed = AddAttributeL( aEntry, KCaAttrAppSettingsPlugin,
       
   921                 static_cast<CLocalizablePropertyEntry*>(
       
   922                         propertyEntry)->StrValue() ) || changed;
       
   923         }
       
   924     CleanupStack::PopAndDestroy( propertyEntry );
       
   925     return changed;
       
   926     }
       
   927 
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 // ---------------------------------------------------------------------------
       
   931 //
       
   932 TBool CCaSrvAppScanner::SetCWRTAppL( CCaInnerEntry* aEntry )
       
   933     {
       
   934     TBool changed = AddAttributeL( aEntry, KCaAttrAppType, KCaAttrAppTypeValueCWRT );
       
   935     TComponentId compId = GetComponentIdFromEntryL( aEntry );
       
   936 
       
   937     CPropertyEntry* isMiniview = iSoftwareRegistry.GetComponentPropertyL(
       
   938             compId, KCaScrPropertyIsMiniviewSupported );
       
   939     CleanupStack::PushL( isMiniview );
       
   940 
       
   941     // check first if we support mini view
       
   942     if( isMiniview && isMiniview->PropertyType() == CPropertyEntry::EIntProperty
       
   943             && static_cast<CIntPropertyEntry*>( isMiniview)->IntValue() )
       
   944         {
       
   945         CPropertyEntry* appId = iSoftwareRegistry.GetComponentPropertyL(
       
   946                 compId, KCaScrPropertyAppId );
       
   947         CleanupStack::PushL( appId );
       
   948 
       
   949         if ( appId
       
   950                 && appId->PropertyType() == CPropertyEntry::ELocalizedProperty )
       
   951             {
       
   952             changed = AddAttributeL(
       
   953                     aEntry, KCaAttrAppWidgetUri, KCaAttrAppWidgetUriCWRTValue )
       
   954                         || changed;
       
   955             changed = AddAttributeL( aEntry, KCaAttrAppWidgetParamWebAppId,
       
   956                     static_cast<CLocalizablePropertyEntry*>(
       
   957                             appId)->StrValue() ) || changed;
       
   958             }
       
   959         CleanupStack::PopAndDestroy( appId );
       
   960         }
       
   961     CleanupStack::PopAndDestroy( isMiniview );
       
   962     return changed;
       
   963     }
       
   964 
       
   965 // ---------------------------------------------------------
       
   966 //
       
   967 // ---------------------------------------------------------
       
   968 //
       
   969 TBool CCaSrvAppScanner::AddAttributeL( CCaInnerEntry* aEntry, const TDesC& aKey,
       
   970         const TDesC& aValue )
       
   971     {
       
   972     TBool changed(EFalse);
       
   973     RBuf attrValue;
       
   974     attrValue.CleanupClosePushL();
       
   975     attrValue.CreateL( KCaMaxAttrValueLen );
       
   976 
       
   977     TBool found = aEntry->FindAttribute( aKey, attrValue );
       
   978     if( !( found && attrValue.Compare( aValue ) == KErrNone ) )
       
   979         {
       
   980         aEntry->AddAttributeL( aKey, aValue );
       
   981         changed = ETrue;
       
   982         }
       
   983     CleanupStack::PopAndDestroy( &attrValue );
       
   984     return changed;
       
   985     }
       
   986 
       
   987 // ---------------------------------------------------------
       
   988 //
       
   989 // ---------------------------------------------------------
       
   990 //
       
   991 TBool CCaSrvAppScanner::RemoveAttributeL( CCaInnerEntry* aEntry,
       
   992         const TDesC& aKey )
       
   993     {
       
   994     TBool toChange( EFalse );
       
   995     RBuf attrVal;
       
   996     attrVal.CleanupClosePushL();
       
   997     attrVal.CreateL( KCaMaxAttrValueLen );
       
   998     if( aEntry->FindAttribute( KCaAttrMmcId, attrVal ) )
       
   999         {
       
  1000         aEntry->RemoveAttributeL( aKey );
       
  1001         toChange = ETrue;
       
  1002         }
       
  1003     CleanupStack::PopAndDestroy( &attrVal );
       
  1004     return toChange;
   896     }
  1005     }
   897 
  1006 
   898 // ---------------------------------------------------------
  1007 // ---------------------------------------------------------
   899 //
  1008 //
   900 // ---------------------------------------------------------
  1009 // ---------------------------------------------------------
   922                 SetMissingFlagL( aCaEntries[i] );
  1031                 SetMissingFlagL( aCaEntries[i] );
   923                 }
  1032                 }
   924             else
  1033             else
   925                 {
  1034                 {
   926                 aCaEntries[i]->RemoveAttributeL( KCaAttrMmcId() );
  1035                 aCaEntries[i]->RemoveAttributeL( KCaAttrMmcId() );
   927                 ClearVisibleFlagL( aCaEntries[i] );
  1036                 ClearAllFlagsL( aCaEntries[i] );
   928                 }
  1037                 }
   929             }
  1038             }
   930         else
  1039         else
   931             {
  1040             {
   932             ClearVisibleFlagL( aCaEntries[i] );
  1041             ClearAllFlagsL( aCaEntries[i] );
   933             }
  1042             }
   934         CleanupStack::PopAndDestroy( &attrVal );
  1043         CleanupStack::PopAndDestroy( &attrVal );
   935         }
  1044         }
   936     }
  1045     }
   937 
  1046 
   950 
  1059 
   951 // ---------------------------------------------------------
  1060 // ---------------------------------------------------------
   952 //
  1061 //
   953 // ---------------------------------------------------------
  1062 // ---------------------------------------------------------
   954 //
  1063 //
   955 void CCaSrvAppScanner::ClearVisibleFlagL( CCaInnerEntry* aEntry )
  1064 void CCaSrvAppScanner::ClearAllFlagsL( CCaInnerEntry* aEntry )
   956     {
  1065     {
   957     if( aEntry->GetFlags() & EVisible )
  1066     if( aEntry->GetFlags() & EVisible )
   958         {
  1067         {
   959         aEntry->SetFlags(
  1068         aEntry->SetFlags( 0 );
   960                 aEntry->GetFlags() &
       
   961                 ~EUninstall &
       
   962                 ~EVisible &
       
   963                 ~EMissing &
       
   964                 ~EUsed );
       
   965         iCaStorageProxy.AddL( aEntry, EFalse, EItemDisappeared );
  1069         iCaStorageProxy.AddL( aEntry, EFalse, EItemDisappeared );
   966         }
  1070         }
   967     }
  1071     }
   968 
  1072 
   969 // ---------------------------------------------------------
  1073 // ---------------------------------------------------------
  1006 
  1110 
  1007 // ---------------------------------------------------------
  1111 // ---------------------------------------------------------
  1008 //
  1112 //
  1009 // ---------------------------------------------------------
  1113 // ---------------------------------------------------------
  1010 //
  1114 //
  1011 TBool CCaSrvAppScanner::IsFileInDrive(
  1115 TBool CCaSrvAppScanner::IsCharInDrive( const TChar& aDriveLetter,
  1012     const TDesC& aFileName,
  1116         const DriveInfo::TDefaultDrives& aDefaultDrive ) const
  1013     const DriveInfo::TDefaultDrives& aDefaultDrive ) const
       
  1014     {
  1117     {
  1015     TBool retVal( EFalse );
  1118     TBool retVal( EFalse );
  1016     if ( aFileName.Length()>0 )
  1119     TInt mmcDrive;
  1017         {
  1120     TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, mmcDrive );
  1018         TInt mmcDrive;
  1121     if( !err )
  1019         TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, mmcDrive );
  1122         {
  1020         if( !err )
  1123         TInt fileDrive;
  1021             {
  1124         err = RFs::CharToDrive( aDriveLetter, fileDrive );
  1022             TInt fileDrive;
  1125         if( !err && fileDrive == mmcDrive )
  1023             err = RFs::CharToDrive( aFileName[0], fileDrive );
  1126             {
  1024             if( !err && fileDrive == mmcDrive )
  1127             retVal = ETrue;
  1025                 {
       
  1026                 retVal = ETrue;
       
  1027                 }
       
  1028             }
  1128             }
  1029         }
  1129         }
  1030     return retVal;
  1130     return retVal;
  1031     }
       
  1032 
       
  1033 // ---------------------------------------------------------
       
  1034 //
       
  1035 // ---------------------------------------------------------
       
  1036 //
       
  1037 TBool CCaSrvAppScanner::IsAppInDriveL(
       
  1038         const TUid aUid,
       
  1039         const DriveInfo::TDefaultDrives& aDefaultDrive ) const
       
  1040     {
       
  1041     TBool ret( EFalse );
       
  1042     TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo();
       
  1043     TInt err = iApaLsSession.GetAppInfo( *appInfo, aUid );
       
  1044     if( !err && IsFileInDrive( appInfo->iFullName, aDefaultDrive ) )
       
  1045         {
       
  1046         ret = ETrue;
       
  1047         }
       
  1048     delete appInfo;
       
  1049     return ret;
       
  1050     }
       
  1051 
       
  1052 // ---------------------------------------------------------
       
  1053 //
       
  1054 // ---------------------------------------------------------
       
  1055 //
       
  1056 TBool CCaSrvAppScanner::IsInMmcL( const TUid aUid ) const
       
  1057     {
       
  1058     return IsAppInDriveL( aUid, DriveInfo::EDefaultRemovableMassStorage );
       
  1059     }
       
  1060 
       
  1061 // ---------------------------------------------------------
       
  1062 //
       
  1063 // ---------------------------------------------------------
       
  1064 //
       
  1065 TBool CCaSrvAppScanner::IsInMassStorageL( const TUid aUid ) const
       
  1066     {
       
  1067     return IsAppInDriveL( aUid, DriveInfo::EDefaultMassStorage );
       
  1068     }
       
  1069 
       
  1070 // ---------------------------------------------------------
       
  1071 //
       
  1072 // ---------------------------------------------------------
       
  1073 //
       
  1074 TBool CCaSrvAppScanner::IsInRomL( TInt aUid )
       
  1075     {
       
  1076     return IsAppInDriveL( TUid::Uid( aUid ), DriveInfo::EDefaultRom );
       
  1077     }
  1131     }
  1078 
  1132 
  1079 // ---------------------------------------------------------
  1133 // ---------------------------------------------------------
  1080 //
  1134 //
  1081 // ---------------------------------------------------------
  1135 // ---------------------------------------------------------
  1156     CleanupStack::PopAndDestroy( &resultEntriesArray );
  1210     CleanupStack::PopAndDestroy( &resultEntriesArray );
  1157     }
  1211     }
  1158 
  1212 
  1159 // ---------------------------------------------------------
  1213 // ---------------------------------------------------------
  1160 //
  1214 //
  1161 // ---------------------------------------------------------//
  1215 // ---------------------------------------------------------
  1162 TBool CCaSrvAppScanner::UpdateComponentIdL( CCaInnerEntry& aEntry ) const
  1216 //
       
  1217 TInt CCaSrvAppScanner::GetComponentIdFromEntryL( CCaInnerEntry* aEntry )
       
  1218     {
       
  1219     TInt id(0);
       
  1220     RBuf componentId;
       
  1221     componentId.CleanupClosePushL();
       
  1222     componentId.CreateL( KCaMaxAttrValueLen );
       
  1223 
       
  1224     TBool found = aEntry->FindAttribute( KCaComponentId, componentId );
       
  1225     if( found )
       
  1226         {
       
  1227         TLex parser;
       
  1228         parser.Assign( componentId );
       
  1229         parser.Val( id );
       
  1230         }
       
  1231     CleanupStack::PopAndDestroy( &componentId );
       
  1232 
       
  1233     return id;
       
  1234     }
       
  1235 
       
  1236 // ---------------------------------------------------------
       
  1237 //
       
  1238 // ---------------------------------------------------------
       
  1239 //
       
  1240 TBool CCaSrvAppScanner::UpdateComponentIdL( CCaInnerEntry& aEntry )
  1163     {
  1241     {
  1164     TBool updated( EFalse );
  1242     TBool updated( EFalse );
  1165 
       
  1166     TUid uid;
       
  1167     TInt err(KErrNone);
       
  1168     TComponentId componentId( 0 );
  1243     TComponentId componentId( 0 );
  1169     TRAP(err, componentId =
  1244 
  1170             iSoftwareRegistry.GetComponentIdForAppL(
  1245     TRAPD(err, componentId = iSoftwareRegistry.GetComponentIdForAppL(
  1171             uid.Uid( aEntry.GetUid() ) ) )
  1246             TUid::Uid( aEntry.GetUid() ) ) )
  1172 
  1247 
  1173     if ( componentId > 0 && err == KErrNone )
  1248     if ( componentId > 0 && err == KErrNone )
  1174         {
  1249         {
  1175         RBuf newComponentId;
  1250         RBuf newComponentId;
  1176         newComponentId.CleanupClosePushL();
  1251         newComponentId.CleanupClosePushL();
  1177         newComponentId.CreateL( sizeof(TComponentId) + 1 );
  1252         newComponentId.CreateL( sizeof(TComponentId) + 1 );
  1178         newComponentId.AppendNum( componentId );
  1253         newComponentId.AppendNum( componentId );
  1179 
  1254 
  1180         RBuf oldComponentId;
  1255         // 'add' or 'update' the component id attribute value
  1181         oldComponentId.CleanupClosePushL();
  1256         updated = AddAttributeL( &aEntry, KCaComponentId, newComponentId );
  1182         oldComponentId.CreateL( KCaMaxAttrValueLen );
  1257 
  1183 
       
  1184         const TBool componentIdAttributeFound =
       
  1185             aEntry.FindAttribute( KCaComponentId, oldComponentId );
       
  1186 
       
  1187         if ( !componentIdAttributeFound
       
  1188             || oldComponentId.Compare( newComponentId ) != 0 )
       
  1189             {
       
  1190             // 'add' or 'update' the component id attribute value
       
  1191             aEntry.AddAttributeL( KCaComponentId,
       
  1192                 newComponentId );
       
  1193 
       
  1194             updated = ETrue;
       
  1195             }
       
  1196 
       
  1197         CleanupStack::PopAndDestroy( &oldComponentId );
       
  1198         CleanupStack::PopAndDestroy( &newComponentId );
  1258         CleanupStack::PopAndDestroy( &newComponentId );
  1199         }
  1259         }
  1200     return updated;
  1260     return updated;
  1201     }
  1261     }