appfw/apparchitecture/aplist/aplapplist.cpp
branchRCL_3
changeset 62 924385140d98
parent 0 2e3d3ce01487
child 63 c2c61fdca848
equal deleted inserted replaced
58:0818dd463d41 62:924385140d98
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19 #include "aplapplistitem.h"
    19 #include "aplapplistitem.h"
    20 #include "../apgrfx/APGSTD.H"	// EPanicNullPointer
    20 #include "../apgrfx/APGSTD.H"	// EPanicNullPointer
    21 #include "APFDEF.H"
    21 #include "APFDEF.H"
    22 #include "../apparc/TRACE.H"
    22 #include "../apparc/TRACE.H"
    23 #include "apgnotif.h"			// MApaAppListServObserver
    23 #include "apgnotif.h"			// MApaAppListServObserver
    24 #include "aplappregfinder.h"	// CApaAppRegFinder
       
    25 #include <bautils.h>			// BaflUtils::NearestLanguageFile()
    24 #include <bautils.h>			// BaflUtils::NearestLanguageFile()
    26 #include <s32mem.h>				// RBufWriteStream
    25 #include <s32mem.h>				// RBufWriteStream
    27 #include "aplappinforeader.h"
    26 #include "aplappinforeader.h"
    28 #include "apsiconcaptionoverride.h"
    27 #include "apsiconcaptionoverride.h"
    29 #ifdef SYMBIAN_BAFL_SYSUTIL
    28 #ifdef SYMBIAN_BAFL_SYSUTIL
    30 #include <bafl/sysutil.h>
    29 #include <bafl/sysutil.h>
       
    30 #endif
       
    31 
       
    32 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    33 #include<usif/scr/scr.h>
       
    34 #include<usif/scr/appregentries.h>
       
    35 #else
       
    36 #include "aplappregfinder.h"    // CApaAppRegFinder
    31 #endif
    37 #endif
    32 
    38 
    33 
    39 
    34 // Delays in the pseudo idle object that builds the application list
    40 // Delays in the pseudo idle object that builds the application list
    35 //
    41 //
    45 //On adding further info to this file, KROMVersionCacheFileMajorVersion or KROMVersionCacheFileMinorVersion or KROMVersionCacheFileBuildVersion needs to be incremented appropriately.
    51 //On adding further info to this file, KROMVersionCacheFileMajorVersion or KROMVersionCacheFileMinorVersion or KROMVersionCacheFileBuildVersion needs to be incremented appropriately.
    46 _LIT(KROMVersionStringCacheFileName, "ROMVersionCache.bin");
    52 _LIT(KROMVersionStringCacheFileName, "ROMVersionCache.bin");
    47 const TInt8 KROMVersionCacheFileMajorVersion=1;
    53 const TInt8 KROMVersionCacheFileMajorVersion=1;
    48 const TInt8 KROMVersionCacheFileMinorVersion=0;
    54 const TInt8 KROMVersionCacheFileMinorVersion=0;
    49 const TInt16 KROMVersionCacheFileBuildVersion=0;
    55 const TInt16 KROMVersionCacheFileBuildVersion=0;
       
    56 #endif
       
    57 
       
    58 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    59 const TInt KNumAppEntriesFromSCR=10;
       
    60 
       
    61 const TInt KSCRConnectionWaitTime=20000; //Time to wait if SCR is busy
       
    62 const TUid KUidSisLaunchServer={0x1020473f};
    50 #endif
    63 #endif
    51 
    64 
    52 
    65 
    53 GLDEF_C void Panic(TApgPanic aPanic)
    66 GLDEF_C void Panic(TApgPanic aPanic)
    54 	{
    67 	{
    82 	RChangeNotifier iLangNotifier;
    95 	RChangeNotifier iLangNotifier;
    83 	CApaAppList& iAppList;
    96 	CApaAppList& iAppList;
    84 	TLanguage iPrevLanguage;
    97 	TLanguage iPrevLanguage;
    85 	};
    98 	};
    86 
    99 
    87 		
   100 
       
   101 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   102 
       
   103 enum TApaSCRFetchAction
       
   104     {
       
   105     EGetAllAppsInfo, //Fetch all application the information from SCR
       
   106     EGetSpecificAppsInfo //Fetch only provided application uids information
       
   107     };
       
   108 
       
   109 /*
       
   110  * Contain information about appliations to be fetched from SCR.
       
   111  */
       
   112 
       
   113 NONSHARABLE_CLASS(CApaAppSCRFetchInfo : public CBase)
       
   114     { 
       
   115 public:
       
   116     static CApaAppSCRFetchInfo* NewL(TApaSCRFetchAction aSCRFetchAction, RArray<TApaAppUpdateInfo>* aAppUpdateInfo);
       
   117     ~CApaAppSCRFetchInfo();
       
   118     RArray<TApaAppUpdateInfo>* AppUpdateInfo();
       
   119     TApaSCRFetchAction SCRFetchAction();
       
   120     
       
   121 private:
       
   122     CApaAppSCRFetchInfo(TApaSCRFetchAction aSCRFetchAction, RArray<TApaAppUpdateInfo>* aAppUpdateInfo);
       
   123     
       
   124 private:
       
   125     TApaSCRFetchAction iSCRFetchAction;
       
   126     RArray<TApaAppUpdateInfo>* iAppUpdateInfo;
       
   127     };
       
   128 
       
   129 
       
   130 /*
       
   131  * Reads multiple application information from SCR and caches it. When requested provides one application
       
   132  * information at a time.
       
   133  */
       
   134 NONSHARABLE_CLASS(CApaAppList::CApaScrAppInfo)
       
   135     {
       
   136 public:
       
   137     static CApaScrAppInfo* NewL(const Usif::RSoftwareComponentRegistry& aScrCon, TInt aNumEntries);    
       
   138     void GetAllAppsInfoL();
       
   139     void GetSpecificAppsInfoL(RArray<TApaAppUpdateInfo>* aAppUpdateInfo);    
       
   140     TUid GetNextApplicationInfo(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData);
       
   141     TApaSCRFetchAction GetSCRFetchAction();    
       
   142     ~CApaScrAppInfo();
       
   143     
       
   144 private:
       
   145     void ConstructL();
       
   146     CApaScrAppInfo(const Usif::RSoftwareComponentRegistry& aScr, TInt aNumEntries);
       
   147     void GetAppUidListL(RArray<TApaAppUpdateInfo>& aAppUpdateInfoArr, RArray<TUid>& aAppUids);
       
   148     TUid GetAllAppsNextApplicationInfoL(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData); 
       
   149     TUid GetSpecificAppsNextApplicationInfoL(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData);  
       
   150 private:
       
   151     Usif::RApplicationRegistryView iScrAppView;
       
   152     RPointerArray<Usif::CApplicationRegistrationData> iAppInfo;
       
   153     RPointerArray<CApaAppSCRFetchInfo> iSCRFetchInfoQueue;
       
   154     const Usif::RSoftwareComponentRegistry& iSCR;   
       
   155     TBool iIsSCRRegViewOpen;
       
   156     TInt iSpecificAppsIndex;
       
   157     CApaAppSCRFetchInfo* iAppSCRFetchInfo;
       
   158     TBool iMoreAppInfo;
       
   159     TInt iNumEntriesToFetch;
       
   160     };
       
   161 
       
   162 
       
   163 
       
   164 CApaAppSCRFetchInfo* CApaAppSCRFetchInfo::NewL(TApaSCRFetchAction aSCRFetchAction, RArray<TApaAppUpdateInfo>* aAppUpdateInfo)
       
   165             {
       
   166             //Ownership of aAppUpdateInfo is transfered to this object.
       
   167             CApaAppSCRFetchInfo* self=new (ELeave) CApaAppSCRFetchInfo(aSCRFetchAction, aAppUpdateInfo);
       
   168             return(self);
       
   169             }
       
   170 
       
   171 
       
   172 CApaAppSCRFetchInfo::CApaAppSCRFetchInfo(TApaSCRFetchAction aSCRFetchAction, RArray<TApaAppUpdateInfo>* aAppUpdateInfo):
       
   173         iSCRFetchAction(aSCRFetchAction),        
       
   174         iAppUpdateInfo(aAppUpdateInfo)
       
   175         {
       
   176         }
       
   177 
       
   178 CApaAppSCRFetchInfo::~CApaAppSCRFetchInfo()
       
   179     {
       
   180     delete iAppUpdateInfo;
       
   181     }
       
   182 
       
   183 RArray<TApaAppUpdateInfo>* CApaAppSCRFetchInfo::AppUpdateInfo()
       
   184             {
       
   185             return iAppUpdateInfo;
       
   186             }
       
   187 
       
   188 
       
   189 TApaSCRFetchAction CApaAppSCRFetchInfo::SCRFetchAction()
       
   190     {
       
   191     return iSCRFetchAction;
       
   192     }
       
   193 
       
   194 
       
   195 //CApaAppList::CApaScrAppInfo
       
   196 
       
   197 CApaAppList::CApaScrAppInfo* CApaAppList::CApaScrAppInfo::NewL(const Usif::RSoftwareComponentRegistry& aScrCon, TInt aNumEntries)
       
   198     { 
       
   199     CApaScrAppInfo* self=new(ELeave) CApaScrAppInfo(aScrCon, aNumEntries);
       
   200     CleanupStack::PushL(self);    
       
   201     self->ConstructL();
       
   202     CleanupStack::Pop();
       
   203     return self;
       
   204     }
       
   205 
       
   206 
       
   207 CApaAppList::CApaScrAppInfo::CApaScrAppInfo(const Usif::RSoftwareComponentRegistry& aScr, TInt aNumEntries):
       
   208         iSCR(aScr),
       
   209         iIsSCRRegViewOpen(EFalse),
       
   210         iSpecificAppsIndex(-1),
       
   211         iAppSCRFetchInfo(NULL),
       
   212         iMoreAppInfo(EFalse),
       
   213         iNumEntriesToFetch(aNumEntries)
       
   214        
       
   215     {
       
   216     }
       
   217 
       
   218 void CApaAppList::CApaScrAppInfo::ConstructL()
       
   219     {
       
   220     }
       
   221 
       
   222 
       
   223 CApaAppList::CApaScrAppInfo::~CApaScrAppInfo()
       
   224     {
       
   225     if(iAppSCRFetchInfo)
       
   226         {
       
   227         delete iAppSCRFetchInfo; 
       
   228         iAppSCRFetchInfo=NULL;
       
   229         }
       
   230     
       
   231     iAppInfo.ResetAndDestroy();
       
   232     iSCRFetchInfoQueue.ResetAndDestroy();
       
   233     iScrAppView.Close();
       
   234     }
       
   235 
       
   236 /*
       
   237  * Gets all the application information available in the SCR. It adds SCR fetch info with action EGetAllAppsInfo to a queue 
       
   238  * to get all the application information. The information can be obtained one at a time by calling GetNextApplicationInfoL 
       
   239  * function.
       
   240  */
       
   241 void CApaAppList::CApaScrAppInfo::GetAllAppsInfoL()
       
   242     {
       
   243     CApaAppSCRFetchInfo* appSCRFetchInfo = CApaAppSCRFetchInfo::NewL(EGetAllAppsInfo, NULL);
       
   244     CleanupStack::PushL(appSCRFetchInfo);      
       
   245     iSCRFetchInfoQueue.AppendL(appSCRFetchInfo);
       
   246     CleanupStack::Pop();
       
   247     }
       
   248 
       
   249 
       
   250 /*
       
   251  * Gets specific application information from the SCR. It adds SCR fetch info request with action EGetSpecificAppsInfo 
       
   252  * along with the required uid list to the queue. The information can be obtained one at a time by calling GetNextApplicationInfoL 
       
   253  * function.
       
   254  */
       
   255 void CApaAppList::CApaScrAppInfo::GetSpecificAppsInfoL(RArray<TApaAppUpdateInfo>* aAppUpdateInfo)
       
   256     {
       
   257     CApaAppSCRFetchInfo* appSCRFetchInfo=CApaAppSCRFetchInfo::NewL(EGetSpecificAppsInfo, aAppUpdateInfo);
       
   258     CleanupStack::PushL(appSCRFetchInfo);
       
   259     iSCRFetchInfoQueue.AppendL(appSCRFetchInfo);
       
   260     CleanupStack::Pop();   
       
   261     }
       
   262 
       
   263 /*
       
   264  * Create array of uids from TApaAppUpdateInfo array.
       
   265  */
       
   266 void CApaAppList::CApaScrAppInfo::GetAppUidListL(RArray<TApaAppUpdateInfo>& aAppUpdateInfoArr, RArray<TUid>& aAppUids)
       
   267     {
       
   268     TInt count=aAppUpdateInfoArr.Count();
       
   269     
       
   270     for(TInt index=0;index<count;index++)
       
   271         {
       
   272         TApaAppUpdateInfo appUpdateInfo=aAppUpdateInfoArr[index];
       
   273         aAppUids.AppendL(appUpdateInfo.iAppUid);
       
   274         }
       
   275     }
       
   276 
       
   277 
       
   278 TApaSCRFetchAction CApaAppList::CApaScrAppInfo::GetSCRFetchAction()
       
   279 {
       
   280     return iAppSCRFetchInfo->SCRFetchAction();
       
   281 }
       
   282 
       
   283 
       
   284 /*
       
   285  * Provides one application information at a time. Returns Null UID if no more application information available.
       
   286  * Ownership of aAppData is transfered to calling function.
       
   287  */
       
   288 TUid CApaAppList::CApaScrAppInfo::GetNextApplicationInfo(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData)
       
   289     {
       
   290     aAppData=NULL;
       
   291     TUid appUid=KNullUid;
       
   292 
       
   293     while(appUid==KNullUid)
       
   294         {
       
   295         //If there is no valid current SCR fetch information, get it from SCR fetch info queue
       
   296         if(!iAppSCRFetchInfo)
       
   297             {
       
   298             if(iSCRFetchInfoQueue.Count()>0)
       
   299                 {
       
   300                 //Get next SCR fetch info
       
   301                 iAppSCRFetchInfo=iSCRFetchInfoQueue[0]; 
       
   302                 iSCRFetchInfoQueue.Remove(0); 
       
   303                 iMoreAppInfo=ETrue;               
       
   304                 }
       
   305             else
       
   306                 {
       
   307                 //No more SCR fetch information avaialable.
       
   308                 break;
       
   309                 }
       
   310             }
       
   311         
       
   312         //Get next application information        
       
   313         if(iAppSCRFetchInfo->SCRFetchAction()==EGetAllAppsInfo)
       
   314             {
       
   315             //If there is a leave with current SCR fetch info, ignore and proceed with next SCR fetch info
       
   316             TRAP_IGNORE(appUid=GetAllAppsNextApplicationInfoL(aAppAction, aAppData));
       
   317             }
       
   318         else
       
   319             {
       
   320             //If there is a leave with current SCR fetch info, ignore and proceed with next SCR fetch info        
       
   321             TRAP_IGNORE(appUid=GetSpecificAppsNextApplicationInfoL(aAppAction, aAppData));       
       
   322             }
       
   323             
       
   324         if(appUid==KNullUid)
       
   325             {
       
   326             //If no application information avaialble with current fetch action reset the values for next SCR fetch action.
       
   327             delete iAppSCRFetchInfo;
       
   328             iAppSCRFetchInfo=NULL;
       
   329             iScrAppView.Close();
       
   330             iIsSCRRegViewOpen=EFalse;            
       
   331             }
       
   332         }
       
   333     
       
   334     return(appUid);
       
   335     }
       
   336 
       
   337 TUid CApaAppList::CApaScrAppInfo::GetAllAppsNextApplicationInfoL(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData)
       
   338     {
       
   339     TUid appUid=KNullUid;
       
   340 
       
   341     if(iAppInfo.Count()==0 && iMoreAppInfo)
       
   342         {
       
   343         //Open registry view if its not open.
       
   344         if(!iIsSCRRegViewOpen)
       
   345             {
       
   346             TInt err=KErrNone;
       
   347             TInt timeOut=KSCRConnectionWaitTime;
       
   348 
       
   349             //Retry if an error occurs while opening a SCR view. 
       
   350             while(timeOut < KSCRConnectionWaitTime*8)
       
   351             {
       
   352             TRAP(err, iScrAppView.OpenViewL(iSCR));
       
   353             if(err != KErrNone)
       
   354                 {
       
   355                 User::After(timeOut);
       
   356                 timeOut= (2*timeOut); 
       
   357                 }
       
   358             else
       
   359                 {
       
   360                 break;
       
   361                 }
       
   362             }
       
   363             User::LeaveIfError(err);
       
   364             iIsSCRRegViewOpen=ETrue;
       
   365             }
       
   366         
       
   367         //Get next available applications information.
       
   368         iScrAppView.GetNextApplicationRegistrationInfoL(iNumEntriesToFetch, iAppInfo);
       
   369         if(iAppInfo.Count()<KNumAppEntriesFromSCR)
       
   370             iMoreAppInfo=EFalse;
       
   371         }
       
   372 
       
   373     //If no application information avaialble, return Null UID.
       
   374     if(iAppInfo.Count()==0)
       
   375         return KNullUid;
       
   376 
       
   377     aAppData=iAppInfo[0];
       
   378     aAppAction=TApaAppUpdateInfo::EAppPresent;
       
   379     iAppInfo.Remove(0);
       
   380     appUid=aAppData->AppUid();
       
   381     return appUid;
       
   382     }
       
   383 
       
   384 
       
   385 /*
       
   386  * Gets next application information when specific applications information requested.
       
   387  */
       
   388 TUid CApaAppList::CApaScrAppInfo::GetSpecificAppsNextApplicationInfoL(TApaAppUpdateInfo::TApaAppAction& aAppAction, Usif::CApplicationRegistrationData*& aAppData)
       
   389     {
       
   390     TUid appUid=KNullUid;
       
   391     TApaAppUpdateInfo::TApaAppAction action = TApaAppUpdateInfo::EAppNotPresent; //To make compiler happy
       
   392     Usif::CApplicationRegistrationData* appData=NULL;
       
   393     
       
   394     while(appUid==KNullUid)
       
   395         {
       
   396         if(iAppInfo.Count()==0 && iMoreAppInfo)
       
   397             {
       
   398             //Open registry view if its not open and also provides application uid list for which applist needs to be updated.
       
   399             if(!iIsSCRRegViewOpen)
       
   400                 {
       
   401                 RArray<TUid> appUids;
       
   402                 CleanupClosePushL(appUids);
       
   403                 //Get application uids list.
       
   404                 GetAppUidListL(*iAppSCRFetchInfo->AppUpdateInfo(), appUids);
       
   405                 
       
   406                 TInt err=KErrNone;
       
   407                 do
       
   408                     {
       
   409                     TRAP(err, iScrAppView.OpenViewL(iSCR, appUids));
       
   410                     if(err)
       
   411                         User::After(KSCRConnectionWaitTime);
       
   412                     }
       
   413                 while(err!=KErrNone);
       
   414 
       
   415                 CleanupStack::PopAndDestroy();
       
   416                 iIsSCRRegViewOpen=ETrue;
       
   417                 iSpecificAppsIndex=0;
       
   418                 }
       
   419             
       
   420             //Get next available applications information.
       
   421             iScrAppView.GetNextApplicationRegistrationInfoL(iNumEntriesToFetch,iAppInfo);
       
   422             if(iAppInfo.Count()<KNumAppEntriesFromSCR)
       
   423                 iMoreAppInfo=EFalse;
       
   424             }
       
   425     
       
   426         RArray<TApaAppUpdateInfo>& appUpdateInfo=*iAppSCRFetchInfo->AppUpdateInfo();
       
   427         
       
   428         
       
   429         if(iSpecificAppsIndex<appUpdateInfo.Count())
       
   430             {
       
   431             appUid=appUpdateInfo[iSpecificAppsIndex].iAppUid;
       
   432             action=appUpdateInfo[iSpecificAppsIndex].iAction;
       
   433     
       
   434             //If application information avaialable, and if application action is not uninstalled or
       
   435             //If application action is uninstalled and the uninstalled application exists in SCR,
       
   436             //then get the info and assign to aAppData.
       
   437             if(iAppInfo.Count()>0)
       
   438                 {
       
   439                 if(iAppInfo[0]->AppUid()==appUid)
       
   440                     {
       
   441                     appData=iAppInfo[0];
       
   442                     iAppInfo.Remove(0);
       
   443                     }
       
   444                 }
       
   445             
       
   446             iSpecificAppsIndex++;
       
   447             
       
   448             //If action is not uninstalled, there should be application data in SCR. Otherwise skip the application action.
       
   449             if((action!=TApaAppUpdateInfo::EAppNotPresent) && appData==NULL)
       
   450                 {
       
   451                 appUid=KNullUid;
       
   452                 }
       
   453             
       
   454             }
       
   455             //If there are no more applications in the current update applist, break the loop;     
       
   456             if(appUpdateInfo.Count()==iSpecificAppsIndex)
       
   457                 break;        
       
   458         }
       
   459     
       
   460     aAppData=appData;
       
   461     aAppAction=action;
       
   462     return appUid;
       
   463     }
       
   464 
       
   465 #endif
       
   466 
    88 //
   467 //
    89 // Local functions
   468 // Local functions
    90 //
   469 //
    91 
   470 
    92 void CleanupServiceArray(TAny* aServiceArray)
   471 void CleanupServiceArray(TAny* aServiceArray)
   106 //
   485 //
   107 // Class CApaAppList
   486 // Class CApaAppList
   108 //
   487 //
   109 
   488 
   110 EXPORT_C CApaAppList* CApaAppList::NewL(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   489 EXPORT_C CApaAppList* CApaAppList::NewL(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   111 	{
   490     {
   112 	CApaAppList* self=new (ELeave) CApaAppList(aFs, aLoadMbmIconsOnDemand, aIdlePeriodicDelay);
   491     CApaAppList* self=new (ELeave) CApaAppList(aFs, aLoadMbmIconsOnDemand, aIdlePeriodicDelay);
   113 	CleanupStack::PushL(self);
   492     CleanupStack::PushL(self);
   114 	self->ConstructL();
   493     self->ConstructL();
   115 	CleanupStack::Pop(self);
   494     CleanupStack::Pop(self);
   116 	return self;
   495     return self;
   117 	}
   496     }
   118 
   497 
   119 CApaAppList::CApaAppList(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   498 CApaAppList::CApaAppList(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   120 	:iFs(aFs),
   499     :iFs(aFs),
   121 	iFlags(0),
   500     iFlags(0),
   122 	iIdlePeriodicDelay(aIdlePeriodicDelay),
   501     iIdlePeriodicDelay(aIdlePeriodicDelay),
   123 	iLoadMbmIconsOnDemand(aLoadMbmIconsOnDemand),
   502     iLoadMbmIconsOnDemand(aLoadMbmIconsOnDemand),
   124     iUninstalledApps(NULL)	
   503     iUninstalledApps(NULL)  
   125 	{
   504     {
   126 	}
   505     }
       
   506 
   127 
   507 
   128 void CApaAppList::ConstructL()
   508 void CApaAppList::ConstructL()
   129 	{
   509 	{
       
   510 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
   130 	iAppRegFinder = CApaAppRegFinder::NewL(iFs);
   511 	iAppRegFinder = CApaAppRegFinder::NewL(iFs);
       
   512 #endif
   131 	
   513 	
   132 	User::LeaveIfError(iFsShareProtected.Connect());
   514 	User::LeaveIfError(iFsShareProtected.Connect());
   133 	User::LeaveIfError(iFsShareProtected.ShareProtected());
   515 	User::LeaveIfError(iFsShareProtected.ShareProtected());
   134 	User::LeaveIfError(Dll::SetTls(this));
   516 	User::LeaveIfError(Dll::SetTls(this));
   135 	
   517 	
   136 	//Start language change monitor.
   518 	//Start language change monitor.
   137 	iAppLangMonitor = CApaLangChangeMonitor::NewL(*this);
   519 	iAppLangMonitor = CApaLangChangeMonitor::NewL(*this);
       
   520 
       
   521 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  	
   138 	const TInt KArrayGranularity = 128;
   522 	const TInt KArrayGranularity = 128;
   139 	iForcedRegistrations = new (ELeave) CDesCArraySeg(KArrayGranularity);
   523 	iForcedRegistrations = new (ELeave) CDesCArraySeg(KArrayGranularity);
       
   524 #endif	
   140 	
   525 	
   141 	// Init the AppsList cache paths
   526 	// Init the AppsList cache paths
   142 	_LIT(KAppsListCacheFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList.bin");
   527 	_LIT(KAppsListCacheFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList.bin");
   143 	_LIT(KAppsListCacheBackUpFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList_Backup.bin");
   528 	_LIT(KAppsListCacheBackUpFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList_Backup.bin");
   144 	_LIT(KAppsListCachePath, ":\\private\\10003a3f\\AppsListCache\\");
   529 	_LIT(KAppsListCachePath, ":\\private\\10003a3f\\AppsListCache\\");
   174 	iObserver = NULL;
   559 	iObserver = NULL;
   175 	iFsShareProtected.Close();
   560 	iFsShareProtected.Close();
   176 
   561 
   177 	delete iDefaultIconArray;
   562 	delete iDefaultIconArray;
   178 	delete iDefaultAppIconMbmFileName;
   563 	delete iDefaultAppIconMbmFileName;
       
   564 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   179 	delete iAppRegFinder;
   565 	delete iAppRegFinder;
       
   566     delete iForcedRegistrations;
       
   567 #endif
   180 	delete iAppIdler;
   568 	delete iAppIdler;
   181 	delete iAppListStorer;
   569 	delete iAppListStorer;
   182 	delete iAppIconLoader;
   570 	delete iAppIconLoader;
   183 	delete iAppLangMonitor;
   571 	delete iAppLangMonitor;
   184 	delete iForcedRegistrations;
       
   185 	delete iIconCaptionObserver;
   572 	delete iIconCaptionObserver;
   186 	delete iIconCaptionOverrides;
   573 	delete iIconCaptionOverrides;
   187 	iAppsListCacheFileName.Close();
   574 	iAppsListCacheFileName.Close();
   188 	iAppsListCacheBackUpFileName.Close();
   575 	iAppsListCacheBackUpFileName.Close();
   189 	iAppsListCachePath.Close();
   576 	iAppsListCachePath.Close();
   190 	
   577 	
   191 	iCustomAppList.ResetAndDestroy();
   578 	iCustomAppList.ResetAndDestroy();
   192 	iCustomAppList.Close();
   579 	iCustomAppList.Close();
   193 	}
   580 
   194 
   581 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   582 	iForceRegAppUids.Close();	
       
   583 	delete iScrAppInfo;
       
   584 	iScr.Close();
       
   585 #endif	
       
   586 	}
       
   587 
       
   588 
       
   589 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK   
   195 // Stop scanning applications if installation or uninstallation has started	
   590 // Stop scanning applications if installation or uninstallation has started	
   196 EXPORT_C void CApaAppList::StopScan(TBool aNNAInstall)
   591 EXPORT_C void CApaAppList::StopScan(TBool aNNAInstall)
   197 	{
   592 	{
   198 	if (aNNAInstall)
   593 	if (aNNAInstall)
   199 		{
   594 		{
   204 		delete iAppIdler;
   599 		delete iAppIdler;
   205 		iAppIdler=NULL;
   600 		iAppIdler=NULL;
   206 		}
   601 		}
   207 	UndoSetPending(iAppData);
   602 	UndoSetPending(iAppData);
   208 	}
   603 	}
   209 	
   604 
   210 // Allow scanning when installation or uninstallation is complete
   605 // Allow scanning when installation or uninstallation is complete
   211 EXPORT_C void CApaAppList::RestartScanL()
   606 EXPORT_C void CApaAppList::RestartScanL()
   212 	{
   607 	{
   213 	TRAP_IGNORE(PurgeL());
   608 	TRAP_IGNORE(PurgeL());
   214 	StartIdleUpdateL();
   609 	StartIdleUpdateL();
   216 
   611 
   217 EXPORT_C TBool CApaAppList::AppListUpdatePending()
   612 EXPORT_C TBool CApaAppList::AppListUpdatePending()
   218 	{
   613 	{
   219 	return iNNAInstallation;
   614 	return iNNAInstallation;
   220 	}
   615 	}
   221 
   616 #endif
   222 void CApaAppList::UndoSetPending(CApaAppData* aAppData)
       
   223 	// Reset all apps to pevious pending state so they don't get purged
       
   224 	{
       
   225   	for (; aAppData; aAppData = aAppData->iNext)
       
   226 		{
       
   227 		if (aAppData->iIsPresent == CApaAppData::EPresentPendingUpdate)
       
   228 			{
       
   229 			aAppData->iIsPresent = CApaAppData::EIsPresent;
       
   230 			}
       
   231 		}
       
   232 	}
       
   233 
   617 
   234 EXPORT_C void CApaAppList::StartIdleUpdateL()
   618 EXPORT_C void CApaAppList::StartIdleUpdateL()
   235 /** Updates the list asynchronously, using an idle time active object, 
   619 /** Updates the list asynchronously, using an idle time active object, 
   236 and no observer. When the update is finished, the resulting app 
   620 and no observer. When the update is finished, the resulting app 
   237 list is stored. */
   621 list is stored. */
   265 	if (iAppIdler)
   649 	if (iAppIdler)
   266 		{
   650 		{
   267 		delete iAppIdler;
   651 		delete iAppIdler;
   268 		iAppIdler=NULL;
   652 		iAppIdler=NULL;
   269 		}
   653 		}
   270 		
   654 
       
   655 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   271 	// DEF072701
   656 	// DEF072701
   272 	// When performing the update scan let the idle object have lower priority.
   657 	// When performing the update scan let the idle object have lower priority.
   273 	if (IsFirstScanComplete())
   658 	if (IsFirstScanComplete())
   274 		{
   659 		{
   275 		iAppIdler=CPeriodic::NewL(CActive::EPriorityLow);
   660 		iAppIdler=CPeriodic::NewL(CActive::EPriorityLow);
   278 		{
   663 		{
   279 		iAppIdler=CPeriodic::NewL(CActive::EPriorityStandard);
   664 		iAppIdler=CPeriodic::NewL(CActive::EPriorityStandard);
   280 		}
   665 		}
   281 	SetPending(iAppData);
   666 	SetPending(iAppData);
   282 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
   667 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
   283  
   668     // DEF072701
   284  	// DEF072701
   669     // If this is the first scan i.e the boot scan then it may take some time. Thus
   285  	// If this is the first scan i.e the boot scan then it may take some time. Thus
   670     // the periodic delay value should be used so that this process will stop periodically 
   286  	// the periodic delay value should be used so that this process will stop periodically 
   671     // to allow time for other processes.
   287  	// to allow time for other processes.
   672     // If this is just a re-scan it should take much less time. Therefore it should just
   288  	// If this is just a re-scan it should take much less time. Therefore it should just
   673     // be completed in one go rather than periodically delayed. Thus the delay value
   289  	// be completed in one go rather than periodically delayed. Thus the delay value
   674     // should be set to 0.
   290  	// should be set to 0.
   675     iAppIdler->Start(KIdleStartDelay, IsFirstScanComplete()? 0 : iIdlePeriodicDelay, TCallBack(IdleUpdateCallbackL, this));
   291 	iAppIdler->Start(KIdleStartDelay, IsFirstScanComplete()? 0 : iIdlePeriodicDelay, TCallBack(IdleUpdateCallbackL, this));
   676 #else	
   292 	}
   677 	
       
   678     iAppIdler=CPeriodic::NewL(CActive::EPriorityStandard);
       
   679     iAppIdler->Start(KIdleStartDelay, IsFirstScanComplete()? 0 : iIdlePeriodicDelay, TCallBack(IdleUpdateCallbackL, this));
       
   680 
       
   681 #endif    
       
   682  	}
       
   683 
       
   684 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
       
   685 EXPORT_C void CApaAppList::InitializeApplistL(MApaAppListObserver* aObserver)
       
   686     {
       
   687     if(!iScr.Handle())
       
   688         User::LeaveIfError(iScr.Connect());
       
   689     
       
   690     if(iScrAppInfo==NULL)
       
   691         iScrAppInfo=CApaScrAppInfo::NewL(iScr, KNumAppEntriesFromSCR);
       
   692     
       
   693     iScrAppInfo->GetAllAppsInfoL();
       
   694     
       
   695     StartIdleUpdateL(aObserver);   
       
   696     }
       
   697 
       
   698 
       
   699 void CApaAppList::InitializeLangAppListL()
       
   700     {
       
   701     if(!iScr.Handle())
       
   702         User::LeaveIfError(iScr.Connect());
       
   703     
       
   704     if(iScrAppInfo==NULL) 
       
   705         iScrAppInfo=CApaScrAppInfo::NewL(iScr, KNumAppEntriesFromSCR);
       
   706     
       
   707     iScrAppInfo->GetAllAppsInfoL();
       
   708     
       
   709     // set iIsLangChangePending=ETrue, to all the application present in the applist    
       
   710     CApaAppData* appData=iAppData;    
       
   711     while(appData)
       
   712         {
       
   713         appData->iIsLangChangePending=ETrue;
       
   714         appData=appData->iNext;
       
   715         }
       
   716     }
       
   717 	
       
   718 	
       
   719 EXPORT_C void CApaAppList::UpdateApplistL(MApaAppListObserver* aObserver, RArray<TApaAppUpdateInfo>* aAppUpdateInfo, TUid aSecureID)
       
   720     {
       
   721     //If update applist is called by SWI, clear force registrations from applist.
       
   722     if(aSecureID == KUidSisLaunchServer)
       
   723         {
       
   724         TInt count=iForceRegAppUids.Count();
       
   725         for(TInt index=0; index<count; index++)
       
   726             FindAndDeleteApp(iForceRegAppUids[index]);
       
   727         iForceRegAppUids.Reset();
       
   728         }
       
   729     
       
   730     if(aAppUpdateInfo->Count() == 0)
       
   731         return;
       
   732     
       
   733     //If SCR connection is not valid then connect.
       
   734     if(!iScr.Handle())
       
   735         User::LeaveIfError(iScr.Connect());
       
   736     
       
   737     if(iScrAppInfo==NULL)
       
   738         iScrAppInfo=CApaScrAppInfo::NewL(iScr, KNumAppEntriesFromSCR);
       
   739     
       
   740     iScrAppInfo->GetSpecificAppsInfoL(aAppUpdateInfo);
       
   741     
       
   742     if(IsIdleUpdateComplete())
       
   743         StartIdleUpdateL(aObserver);   
       
   744     }
       
   745 
       
   746 void CleanupAndDestroyAppInfoArray(TAny* aRPArray)
       
   747     {
       
   748     RPointerArray<Usif::CApplicationRegistrationData>* rpArray = (static_cast<RPointerArray<Usif::CApplicationRegistrationData>*>(aRPArray));
       
   749     rpArray->ResetAndDestroy();
       
   750     rpArray->Close();
       
   751     }
       
   752 
       
   753 
       
   754 EXPORT_C void CApaAppList::UpdateApplistByForceRegAppsL(RPointerArray<Usif::CApplicationRegistrationData>& aForceRegAppsInfo)
       
   755     {
       
   756     //Get number of force registered application information.
       
   757     TInt count=aForceRegAppsInfo.Count();
       
   758     Usif::RSoftwareComponentRegistry scr;
       
   759     User::LeaveIfError(scr.Connect());
       
   760     CleanupClosePushL(scr);
       
   761     
       
   762     //As this function takes the ownership of aForceRegAppsInfo, this needs to be destroyed if any leave occurs.
       
   763     TCleanupItem cleanup(CleanupAndDestroyAppInfoArray, &aForceRegAppsInfo); 
       
   764     CleanupStack::PushL(cleanup);
       
   765     
       
   766     //Get each force registered application information and add it to applist.
       
   767     for(TInt index=0; index<count; index++)
       
   768         {
       
   769         Usif::CApplicationRegistrationData* appInfo=aForceRegAppsInfo[index];
       
   770         CApaAppData* appData = CApaAppData::NewL(*appInfo, iFs, scr);
       
   771         TUid appUid=appInfo->AppUid();
       
   772         
       
   773         //Delete if the application already exist in the applist.
       
   774         FindAndDeleteApp(appUid);
       
   775         AddToList(appData);
       
   776         //Maintain added force registered application uids so that it can be cleared from applist
       
   777         //once installation complete.
       
   778         iForceRegAppUids.AppendL(appUid);
       
   779         }
       
   780     
       
   781     CleanupStack::PopAndDestroy(2); //cleanup, scr
       
   782     }
       
   783 
       
   784 
       
   785 // The function transfers ownership of the pointer owned by a CApaAppList to the caller
       
   786 // to avoid copying the array.
       
   787 EXPORT_C  CArrayFixFlat<TApaAppUpdateInfo>* CApaAppList::UpdatedAppsInfo()
       
   788 {
       
   789     CArrayFixFlat<TApaAppUpdateInfo>* updatedAppsInfo=iAppsUpdated;
       
   790     iAppsUpdated=NULL;
       
   791     return updatedAppsInfo;
       
   792 }
       
   793 
       
   794 #endif
   293 
   795 
   294 EXPORT_C void CApaAppList::StartIdleUpdateL(MApaAppListObserver* aObserver)
   796 EXPORT_C void CApaAppList::StartIdleUpdateL(MApaAppListObserver* aObserver)
   295 /** Updates the list asynchronously, using an idle time active object 
   797 /** Updates the list asynchronously, using an idle time active object 
   296 and an observer. When the update is finished, the resulting app list 
   798 and an observer. When the update is finished, the resulting app list 
   297 is stored and the observer is notified with an MApaAppListServObserver::EAppListChanged 
   799 is stored and the observer is notified with an MApaAppListServObserver::EAppListChanged 
   325  * If Restore operation fails then it 
   827  * If Restore operation fails then it 
   326  * starts updating the list asynchronously, by calling StartIdleUpdateL().
   828  * starts updating the list asynchronously, by calling StartIdleUpdateL().
   327 
   829 
   328 @param aObserver Observer to be notified when the update has finished. */
   830 @param aObserver Observer to be notified when the update has finished. */
   329 	{
   831 	{
       
   832     
       
   833 #ifdef APPARC_SHOW_TRACE    
       
   834     RDebug::Printf("[Apparc] *****************START CREATING APPLIST ****************************");
       
   835 #endif    
       
   836     
   330 	DeleteAppsListBackUpAndTempFiles();
   837 	DeleteAppsListBackUpAndTempFiles();
       
   838 	
   331 	TInt ret = KErrGeneral;
   839 	TInt ret = KErrGeneral;
   332 #ifndef __WINS__ // on the emulator, don't read app list from file, as doing so means apps
   840 #ifndef __WINS__ // on the emulator, don't read app list from file, as doing so means apps
   333                  // built while the emulator isn't running won't appear in the list
   841                  // built while the emulator isn't running won't appear in the list
   334 	TRAP(ret, RestoreL());
   842 	TRAP(ret, RestoreL());
   335 #endif
   843 #endif
   336 	if (ret != KErrNone)
   844 	if (ret != KErrNone)
   337 		{
   845 		{
   338 		// There was an error during restore, so update the list asynchronously.
   846 		// There was an error during restore, so update the list asynchronously.
   339 		DeleteAppData();
   847 		DeleteAppData();
   340 		iFs.Delete(iAppsListCacheFileName);
   848 		iFs.Delete(iAppsListCacheFileName);
   341 		StartIdleUpdateL(aObserver);
   849 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   850 		InitializeApplistL(aObserver);		
       
   851 #else
       
   852         StartIdleUpdateL(aObserver);		
       
   853 #endif
       
   854 		
   342 		}
   855 		}
   343 	else
   856 	else
   344 		{
   857 		{
   345 		iObserver = aObserver;
   858 		iObserver = aObserver;
   346 		if (iLoadMbmIconsOnDemand)
   859 		if (iLoadMbmIconsOnDemand)
   358 	{
   871 	{
   359 	iAppIconLoader = new(ELeave) CApaIdleIconLoader(iAppData, iFs, *this);
   872 	iAppIconLoader = new(ELeave) CApaIdleIconLoader(iAppData, iFs, *this);
   360 	iAppIconLoader->Start();
   873 	iAppIconLoader->Start();
   361 	}
   874 	}
   362 
   875 
   363 void CApaAppList::ScanRemovableDrivesAndUpdateL()
       
   364 /** Rename Appslist.bin file to AppsList_Backup.bin, so that it can be renamed back, 
       
   365      if the update scan on removable media drives does not change applist. */
       
   366 	{
       
   367 	const TArray<const TDriveUnitInfo> listOfRemovableMediaDrives = iAppRegFinder->DriveList();
       
   368 	const TInt count = listOfRemovableMediaDrives.Count();
       
   369 
       
   370 	// Removable media scan would take place only if removable drives are present.
       
   371 	if (count)
       
   372 		{
       
   373 		CApaAppData* appData = iAppData;
       
   374 		while (appData)
       
   375 			{
       
   376 			for (TInt driveIndex = 0; driveIndex < count; ++driveIndex)
       
   377 				{
       
   378 				if (TParsePtrC(*appData->iRegistrationFile).Drive() == listOfRemovableMediaDrives[driveIndex].iUnit.Name())
       
   379 					{
       
   380 					appData->SetAppPending();
       
   381 					break;
       
   382 					}
       
   383 				}
       
   384 			appData = appData->iNext;
       
   385 			}
       
   386 
       
   387 		while (IdleUpdateL())
       
   388 			{ // It updates the removable media apps present in AppList if it has changed.
       
   389 
       
   390 			};
       
   391 		}
       
   392 	}
       
   393 
   876 
   394 void CApaAppList::DeleteAppsListBackUpAndTempFiles()
   877 void CApaAppList::DeleteAppsListBackUpAndTempFiles()
   395 /** Deletes all files inside AppsListCache folder except AppsList.bin */
   878 /** Deletes all files inside AppsListCache folder except AppsList.bin */
   396 	{
   879 	{
   397 	_LIT(KTemp, "AppsList.bin");
   880 	_LIT(KTemp, "AppsList.bin");
   482 		{
   965 		{
   483 		if (softwareVersion.Compare(actualSoftwareVersion) != 0)
   966 		if (softwareVersion.Compare(actualSoftwareVersion) != 0)
   484 			{
   967 			{
   485 			//Leave if the current version is different from the previous stored version and recreate applist.
   968 			//Leave if the current version is different from the previous stored version and recreate applist.
   486 #ifdef _DEBUG
   969 #ifdef _DEBUG
   487 			RDebug::Print(_L("!!Firmware update detected!! Rebuilding AppList"));
   970 			RDebug::Print(_L("[Apparc] !!Firmware update detected!! Rebuilding AppList"));
   488 #endif
   971 #endif
   489 			User::Leave(KErrGeneral);
   972 			User::Leave(KErrGeneral);
   490 			}
   973 			}
   491 		}
   974 		}
   492 	else
   975 	else
   493 		{
   976 		{
   494 		//Leave if any error reading the version information, except if file is not present
   977 		//Leave if any error reading the version information, except if file is not present
   495 		if (err != KErrPathNotFound && err != KErrNotFound)
   978 		if (err != KErrPathNotFound && err != KErrNotFound)
   496 			{
   979 			{
   497 #ifdef _DEBUG
   980 #ifdef _DEBUG
   498 			RDebug::Print(_L("!!Error %d reading Firmware version.  Rebuilding AppList"),err);
   981 			RDebug::Print(_L("[Apparc] !!Error %d reading Firmware version.  Rebuilding AppList"),err);
   499 #endif
   982 #endif
   500 			User::Leave(err);
   983 			User::Leave(err);
   501 			}
   984 			}
   502 		}
   985 		}
   503 	CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName
   986 	CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName
   531 			}
  1014 			}
   532 		}	
  1015 		}	
   533 	// Close the stream;
  1016 	// Close the stream;
   534 	CleanupStack::PopAndDestroy(&theReadStream);
  1017 	CleanupStack::PopAndDestroy(&theReadStream);
   535 
  1018 
       
  1019 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1020 	iFlags |= ENotifyUpdateOnFirstScanComplete;
       
  1021 #else
   536 	iFs.Rename(iAppsListCacheFileName, iAppsListCacheBackUpFileName);
  1022 	iFs.Rename(iAppsListCacheFileName, iAppsListCacheBackUpFileName);
   537 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanRemovableDrives);	// Builds the Removable Media Drive List
  1023 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanRemovableDrives);	// Builds the Removable Media Drive List
   538 
  1024 
   539 	iFlags |= ENotifyUpdateOnFirstScanComplete;
  1025 	iFlags |= ENotifyUpdateOnFirstScanComplete;
   540 
  1026 
   541 	// It runs an update scan on removable media apps.
  1027 	// It runs an update scan on removable media apps.
   542 	ScanRemovableDrivesAndUpdateL();
  1028 	ScanRemovableDrivesAndUpdateL();
       
  1029 #endif
   543 	}
  1030 	}
   544 
  1031 
   545 EXPORT_C TBool CApaAppList::IsLanguageChangePending() const
  1032 EXPORT_C TBool CApaAppList::IsLanguageChangePending() const
   546 /** Returns ETrue if a language change event is received and a re-scan is in progress otherwise EFalse. */
  1033 /** Returns ETrue if a language change event is received and a re-scan is in progress otherwise EFalse. */
   547 	{
  1034 	{
   585 		if (iFlags & EAppListHasChanged || iFlags & ENotifyUpdateOnFirstScanComplete)
  1072 		if (iFlags & EAppListHasChanged || iFlags & ENotifyUpdateOnFirstScanComplete)
   586 			iObserver->NotifyUpdate(MApaAppListServObserver::EAppListChanged);	// NotifyUpdate will notify clients for both list update and scan complete.
  1073 			iObserver->NotifyUpdate(MApaAppListServObserver::EAppListChanged);	// NotifyUpdate will notify clients for both list update and scan complete.
   587 		else
  1074 		else
   588 			iObserver->NotifyScanComplete();	// NotifyScanComplete will notify clients for scan complete.
  1075 			iObserver->NotifyScanComplete();	// NotifyScanComplete will notify clients for scan complete.
   589 
  1076 
   590 		iObserver=NULL;
  1077 		//iObserver=NULL;
   591 		}
  1078 		}
   592 	}
  1079 	}
   593 
  1080 
   594 void CApaAppList::StopIdler()
  1081 void CApaAppList::StopIdler()
   595 	{
  1082 	{
   596  	delete iAppIdler;
  1083  	delete iAppIdler;
   597 	iAppIdler=NULL;
  1084 	iAppIdler=NULL;
   598 	}
  1085 	}
   599 
  1086 
       
  1087 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1088 
       
  1089 // returns ETrue if there more application information avaialable.
       
  1090 TInt CApaAppList::IdleUpdateL()
       
  1091     {
       
  1092 
       
  1093     Usif::CApplicationRegistrationData* appInfo=NULL;
       
  1094     TApaAppUpdateInfo::TApaAppAction action=TApaAppUpdateInfo::EAppPresent; //to make compiler happy. Actual value is assigned by GetNextApplicationInfo
       
  1095     TUid appUid;
       
  1096     
       
  1097     //Ownership of appInfo is transfered to this function.
       
  1098     appUid=iScrAppInfo->GetNextApplicationInfo(action,appInfo);
       
  1099     
       
  1100     if(appUid==KNullUid) 
       
  1101         return EFalse;
       
  1102     
       
  1103     CleanupStack::PushL(appInfo);
       
  1104     CApaAppData *appData=NULL;    
       
  1105     CApaAppData* app = NULL;
       
  1106     
       
  1107     switch(action)
       
  1108         {
       
  1109         case TApaAppUpdateInfo::EAppNotPresent:
       
  1110             if(appInfo==NULL)
       
  1111                 {
       
  1112                 TInt ret=FindAndDeleteApp(appUid);
       
  1113                 if(ret==KErrNone)
       
  1114                     iFlags |= EAppListHasChanged;
       
  1115 
       
  1116                 //Add uninstalled application UID to a list
       
  1117                 if(iUninstalledApps==NULL)
       
  1118                     iUninstalledApps=new(ELeave) CArrayFixFlat<TUid>(1);
       
  1119                 
       
  1120                 iUninstalledApps->AppendL(appUid);
       
  1121                 }
       
  1122             break;
       
  1123             
       
  1124         case TApaAppUpdateInfo::EAppPresent:
       
  1125             // holds the application information from Applist
       
  1126             app = AppDataByUid(appInfo->AppUid());
       
  1127             
       
  1128             if( app && IsLanguageChangePending() && (iScrAppInfo->GetSCRFetchAction() == EGetAllAppsInfo))
       
  1129                 {
       
  1130                 //Application needs to be updated because of language change
       
  1131                 RPointerArray<Usif::CLocalizableAppInfo> localisationInfo;
       
  1132                 localisationInfo=appInfo->LocalizableAppInfoList();
       
  1133                 ASSERT(!(localisationInfo.Count()>1));
       
  1134                 
       
  1135                 if((localisationInfo.Count()>0) && (app->ApplicationLanguage() != localisationInfo[0]->ApplicationLanguage()))
       
  1136                     {
       
  1137                     // holds the application information read from SCR db
       
  1138                     appData=CApaAppData::NewL(*appInfo, iFs, iScr);    
       
  1139                     FindAndDeleteApp(appUid);
       
  1140                     AddToList(appData);  
       
  1141                     iFlags |= EAppListHasChanged;
       
  1142                     }
       
  1143                 else
       
  1144                     {
       
  1145                     app->iIsLangChangePending=EFalse;                
       
  1146                     }
       
  1147                 }
       
  1148             else
       
  1149                 {
       
  1150                 // holds the application information read from SCR db
       
  1151                 appData=CApaAppData::NewL(*appInfo, iFs, iScr);
       
  1152                 if(app)
       
  1153                     {
       
  1154                     //Application found in applist. Delete existing application information from applist and create new
       
  1155                     //application information object and add to the applist.
       
  1156                     FindAndDeleteApp(appUid);
       
  1157                     AddToList( appData );
       
  1158                     }
       
  1159                 else
       
  1160                     {
       
  1161                     AddToList( appData );                   
       
  1162                     }
       
  1163                 iFlags |= EAppListHasChanged;
       
  1164                 }
       
  1165             
       
  1166             break;
       
  1167             
       
  1168         case TApaAppUpdateInfo::EAppInfoChanged:
       
  1169             appData=CApaAppData::NewL(*appInfo, iFs, iScr);
       
  1170             //Delete existing application information from applist and create new application information object and 
       
  1171             //add to the applist.
       
  1172             FindAndDeleteApp(appUid);
       
  1173             AddToList( appData );
       
  1174             iFlags |= EAppListHasChanged;
       
  1175             break;
       
  1176         }
       
  1177 
       
  1178     //If first scan not complete or if phone language is changed then clear the updated application list
       
  1179     //Otherwise add application updated apps list
       
  1180     if(!(iFlags&EFirstScanComplete) || (iFlags&ELangChangePending))
       
  1181         {
       
  1182         if(!iAppsUpdated)
       
  1183             delete iAppsUpdated;
       
  1184         iAppsUpdated=NULL;
       
  1185         }
       
  1186     else
       
  1187         {
       
  1188         if(!iAppsUpdated)
       
  1189             iAppsUpdated= new(ELeave) CArrayFixFlat<TApaAppUpdateInfo>(1);
       
  1190     
       
  1191         TApaAppUpdateInfo appUpdateInfo(appUid, action);
       
  1192         iAppsUpdated->AppendL(appUpdateInfo);
       
  1193         }
       
  1194     
       
  1195     CleanupStack::PopAndDestroy(appInfo); 
       
  1196     return ETrue;
       
  1197     }
       
  1198 
       
  1199 
       
  1200 
       
  1201 /*
       
  1202  * Finds and delete an application from applist.
       
  1203  */
       
  1204 TInt CApaAppList::FindAndDeleteApp(TUid aAppUid)
       
  1205     {
       
  1206     CApaAppData* appData=iAppData;
       
  1207     CApaAppData* prevAppData=NULL;
       
  1208     
       
  1209     while(appData && appData->iUidType[2] != aAppUid)
       
  1210         {
       
  1211         prevAppData=appData;
       
  1212         appData=appData->iNext;
       
  1213         }
       
  1214 
       
  1215     if(appData)
       
  1216         {
       
  1217         if(prevAppData)
       
  1218             {
       
  1219             //If the application position is not the first application in the list
       
  1220             prevAppData->iNext=appData->iNext;
       
  1221             }
       
  1222         else
       
  1223             {
       
  1224             //If the application position is first in the list
       
  1225             iAppData=appData->iNext;
       
  1226             }
       
  1227 
       
  1228 #ifdef APPARC_SHOW_TRACE  
       
  1229         if(appData)
       
  1230             {
       
  1231             RDebug::Print(_L("[Apparc] Application with UID: %X is deleted from applist"), appData->iUidType[2]);
       
  1232             }
       
  1233 #endif
       
  1234 
       
  1235         delete appData;
       
  1236         return(KErrNone);
       
  1237         }
       
  1238 
       
  1239     //if application not found, return KErrNotFound
       
  1240     return(KErrNotFound);
       
  1241     }
       
  1242 
       
  1243 /**
       
  1244 @internalComponent
       
  1245 */
       
  1246 EXPORT_C CApaAppData* CApaAppList::FindAndAddSpecificAppL(TUid aAppUid)
       
  1247     {
       
  1248     Usif::RSoftwareComponentRegistry scrCon;
       
  1249 	//If SCR connection not avaialable then connect to SCR. Otherwise use the 
       
  1250 	//existing connection.
       
  1251     if(!iScr.Handle())
       
  1252         {
       
  1253         User::LeaveIfError(scrCon.Connect());
       
  1254         CleanupClosePushL(scrCon);
       
  1255         }
       
  1256     else
       
  1257         scrCon=iScr;
       
  1258   
       
  1259     
       
  1260     //Pass 1 as number of entries to fetch from SCR as only specific application information is required.
       
  1261     CApaScrAppInfo *scrAppInfo=CApaScrAppInfo::NewL(scrCon, 1); 
       
  1262     CleanupStack::PushL(scrAppInfo);
       
  1263 
       
  1264     RArray<TApaAppUpdateInfo>* appUpdateInfoList=new (ELeave) RArray<TApaAppUpdateInfo>(1);
       
  1265     CleanupStack::PushL(appUpdateInfoList);
       
  1266     TApaAppUpdateInfo appUpdateInfo(aAppUid, TApaAppUpdateInfo::EAppPresent) ;
       
  1267     appUpdateInfoList->AppendL(appUpdateInfo);
       
  1268 
       
  1269     scrAppInfo->GetSpecificAppsInfoL(appUpdateInfoList);
       
  1270     CleanupStack::Pop(appUpdateInfoList);
       
  1271     
       
  1272     Usif::CApplicationRegistrationData* appInfo=NULL;
       
  1273     TApaAppUpdateInfo::TApaAppAction action;
       
  1274     TUid uid;
       
  1275     uid=scrAppInfo->GetNextApplicationInfo(action, appInfo);
       
  1276     CleanupStack::PushL(appInfo);
       
  1277 
       
  1278     CApaAppData *appData=NULL;
       
  1279     if(appInfo)
       
  1280         {
       
  1281         appData=CApaAppData::NewL(*appInfo, iFs, scrCon);
       
  1282         FindAndDeleteApp(uid);
       
  1283         AddToList(appData);
       
  1284         iFlags |= EAppListHasChanged;
       
  1285         }
       
  1286     CleanupStack::PopAndDestroy(2, scrAppInfo);
       
  1287     
       
  1288 	//If SCR session established in this function, then close it.
       
  1289     if(!iScr.Handle())
       
  1290         CleanupStack::PopAndDestroy();
       
  1291         
       
  1292     return appData;
       
  1293     }
       
  1294 
       
  1295 #else
   600 TInt CApaAppList::IdleUpdateL()
  1296 TInt CApaAppList::IdleUpdateL()
   601 // returns ETrue if there is more scanning to be done.
  1297 // returns ETrue if there is more scanning to be done.
   602 	{
  1298 	{
       
  1299     
   603 	TBool more=EFalse;
  1300 	TBool more=EFalse;
   604 	TApaAppEntry currentApp = TApaAppEntry();
  1301 	TApaAppEntry currentApp = TApaAppEntry();
   605 	TRAPD(err, more = iAppRegFinder->NextL(currentApp, *iForcedRegistrations));
  1302 	TRAPD(err, more = iAppRegFinder->NextL(currentApp, *iForcedRegistrations));
   606 	if (err!=KErrNone)
  1303 	if (err!=KErrNone)
   607 		{
  1304 		{
   633 		iFlags |= EAppListHasChanged;
  1330 		iFlags |= EAppListHasChanged;
   634 
  1331 
   635 	return more;
  1332 	return more;
   636 	}
  1333 	}
   637 
  1334 
   638 EXPORT_C TBool CApaAppList::IsIdleUpdateComplete() const
  1335 void CApaAppList::UpdateNextAppL(const TApaAppEntry& aAppEntry,TBool& aHasChanged)
   639 /** Tests whether an asynchronous update of the list is currently in progress.
  1336     {
   640 
  1337     CApaAppData* appData=AppDataByUid(aAppEntry.iUidType[2]);
   641 @return True if no asynchronous update of the list is currently in progress, 
  1338     if (appData==NULL)
   642 otherwise false. */
  1339         {// not in list, so add it at the start
   643 	{
  1340         TRAPD(err,appData=CApaAppData::NewL(aAppEntry, iFs));
   644 	return iAppIdler == NULL;
  1341         if (err==KErrNone)
   645 	}
  1342             {
       
  1343             AddToList( appData );
       
  1344             aHasChanged=ETrue;
       
  1345             }
       
  1346         }
       
  1347     else if (appData->IsPending())
       
  1348         { // not found yet during current scan - we may need to override this one
       
  1349         
       
  1350         // On a system which scans for registration .RSC files (V2 apps) first, followed by
       
  1351         // .APP files (V1 apps), it's valid for a V1 app to override a V2 app (if the V2 app
       
  1352         // has just been removed). If this is the case, assume it's ok to compare the V1 .APP filename,
       
  1353         // with the V2 .RSC filename as their filenames will never match (which is what we want in this case).
       
  1354         TPtrC currentFileName;
       
  1355         if (appData->RegistrationFileUsed())
       
  1356             currentFileName.Set(*appData->iRegistrationFile);
       
  1357         else
       
  1358             currentFileName.Set(*appData->iFullName);
       
  1359     
       
  1360         if (aAppEntry.iFullName.CompareF(currentFileName)!=0)
       
  1361             {
       
  1362             delete appData->iSuccessor;
       
  1363             appData->iSuccessor = NULL;
       
  1364             appData->iSuccessor = CApaAppEntry::NewL(aAppEntry);
       
  1365 
       
  1366             appData->iIsPresent = CApaAppData::ESuperseded;
       
  1367             aHasChanged=ETrue;
       
  1368             }
       
  1369         else
       
  1370             {
       
  1371             if (appData->Update() || appData->iIsPresent==CApaAppData::ENotPresentPendingUpdate) 
       
  1372                 aHasChanged=ETrue; 
       
  1373 
       
  1374             appData->iIsPresent = CApaAppData::EIsPresent;
       
  1375             }
       
  1376         }
       
  1377     }
   646 
  1378 
   647 void CApaAppList::SetPending(CApaAppData* aAppData)
  1379 void CApaAppList::SetPending(CApaAppData* aAppData)
   648 	// set all apps to pending update - we'll find them again as we scan
  1380     // set all apps to pending update - we'll find them again as we scan
   649 	{
  1381     {
   650   	for (; aAppData; aAppData = aAppData->iNext)
  1382     for (; aAppData; aAppData = aAppData->iNext)
   651 		aAppData->SetAppPending();
  1383         aAppData->SetAppPending();
   652 	}
  1384     }
   653 
  1385 
   654 void CApaAppList::SetNotFound(CApaAppData* aAppData, TBool& aHasChanged)
  1386 void CApaAppList::SetNotFound(CApaAppData* aAppData, TBool& aHasChanged)
   655 	// mark any unfound apps not present
  1387     // mark any unfound apps not present
   656 	{
  1388     {
   657 	while (aAppData)
  1389     while (aAppData)
   658 		{
  1390         {
   659 		if (aAppData->IsPending())
  1391         if (aAppData->IsPending())
   660 			{
  1392             {
   661 			aAppData->iIsPresent = CApaAppData::ENotPresent;
  1393             aAppData->iIsPresent = CApaAppData::ENotPresent;
   662 			aHasChanged = ETrue;
  1394             aHasChanged = ETrue;
   663 			}
  1395             }
   664 		aAppData = aAppData->iNext;
  1396         aAppData = aAppData->iNext;
   665 		}
  1397         }
   666 	}
  1398     }
   667 
       
   668 void CApaAppList::AddToList( CApaAppData* aAppData )
       
   669 	{
       
   670 	__ASSERT_DEBUG(aAppData, Panic(EPanicNullPointer));
       
   671 	aAppData->iNext=iAppData;
       
   672 	iAppData=aAppData;
       
   673 	}
       
   674 
       
   675 void CApaAppList::UpdateNextAppL(const TApaAppEntry& aAppEntry,TBool& aHasChanged)
       
   676 	{
       
   677 	CApaAppData* appData=AppDataByUid(aAppEntry.iUidType[2]);
       
   678 	if (appData==NULL)
       
   679 		{// not in list, so add it at the start
       
   680 		TRAPD(err,appData=CApaAppData::NewL(aAppEntry, iFs));
       
   681 		if (err==KErrNone)
       
   682 			{
       
   683 			AddToList( appData );
       
   684 			aHasChanged=ETrue;
       
   685 			}
       
   686 		}
       
   687 	else if (appData->IsPending())
       
   688 		{ // not found yet during current scan - we may need to override this one
       
   689 		
       
   690 		// On a system which scans for registration .RSC files (V2 apps) first, followed by
       
   691 		// .APP files (V1 apps), it's valid for a V1 app to override a V2 app (if the V2 app
       
   692 		// has just been removed). If this is the case, assume it's ok to compare the V1 .APP filename,
       
   693 		// with the V2 .RSC filename as their filenames will never match (which is what we want in this case).
       
   694 		TPtrC currentFileName;
       
   695 		if (appData->RegistrationFileUsed())
       
   696 			currentFileName.Set(*appData->iRegistrationFile);
       
   697 		else
       
   698 			currentFileName.Set(*appData->iFullName);
       
   699 	
       
   700 		if (aAppEntry.iFullName.CompareF(currentFileName)!=0)
       
   701 			{
       
   702 			delete appData->iSuccessor;
       
   703 			appData->iSuccessor = NULL;
       
   704 			appData->iSuccessor = CApaAppEntry::NewL(aAppEntry);
       
   705 
       
   706 			appData->iIsPresent = CApaAppData::ESuperseded;
       
   707 			aHasChanged=ETrue;
       
   708 			}
       
   709 		else
       
   710 			{
       
   711 			if (appData->Update() || appData->iIsPresent==CApaAppData::ENotPresentPendingUpdate) 
       
   712 				aHasChanged=ETrue; 
       
   713 
       
   714 			appData->iIsPresent = CApaAppData::EIsPresent;
       
   715 			}
       
   716 		}
       
   717 	}
       
   718 
       
   719 /**
       
   720 @internalComponent
       
   721 */
       
   722 EXPORT_C CApaAppData* CApaAppList::FindAndAddSpecificAppL(CApaAppRegFinder* aFinder, TUid aAppUid)
       
   723 	{
       
   724 //Scans and adds the specified application to the app list if found
       
   725 	__ASSERT_DEBUG(aFinder, Panic(EPanicNullPointer));
       
   726 	TBool found = EFalse;
       
   727 	TApaAppEntry appEntry;
       
   728 	aFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
       
   729 	while (aFinder->NextL(appEntry, *iForcedRegistrations))
       
   730 		{
       
   731 		if (appEntry.iUidType[2] == aAppUid)
       
   732 			{
       
   733 			found = ETrue;
       
   734 			break;
       
   735 			}
       
   736 		}
       
   737 	
       
   738 	CApaAppData* app = NULL;
       
   739 	if (found)
       
   740 		{
       
   741 		// add the app to the list
       
   742 		TBool hasChanged = EFalse;
       
   743 		CApaAppData* prevFirstAppInList = iAppData;
       
   744 		UpdateNextAppL(appEntry, hasChanged);
       
   745 		if (iAppData != prevFirstAppInList)
       
   746 			app = iAppData;		// assume the new app was added to the list
       
   747 
       
   748 		if (hasChanged)
       
   749 			iFlags |= EAppListHasChanged;
       
   750 		}
       
   751 
       
   752 	return app;
       
   753 	}
       
   754 
  1399 
   755 EXPORT_C void CApaAppList::PurgeL()
  1400 EXPORT_C void CApaAppList::PurgeL()
   756 /** Removes any applications from the list if they are no longer present 
  1401 /** Removes any applications from the list if they are no longer present 
   757 on the phone. It updates applications that have been 
  1402 on the phone. It updates applications that have been 
   758 superceded. */
  1403 superceded. */
   759 	{
  1404     {
   760 	CApaAppData* appData=iAppData;
  1405     CApaAppData* appData=iAppData;
   761 	CApaAppData* prev=NULL;
  1406     CApaAppData* prev=NULL;
   762 	while (appData)
  1407     while (appData)
   763 		{
  1408         {
   764 		CApaAppData* next=appData->iNext;
  1409         CApaAppData* next=appData->iNext;
   765 		if (appData->iIsPresent==CApaAppData::ENotPresent)
  1410         if (appData->iIsPresent==CApaAppData::ENotPresent)
   766 			{
  1411             {
   767 			if (prev)
  1412             if (prev)
   768 				prev->iNext=next;
  1413                 prev->iNext=next;
   769 			else
  1414             else
   770 				iAppData=next;
  1415                 iAppData=next;
   771 			
  1416             
   772             //Add uninstalled application UID to a list
  1417             //Add uninstalled application UID to a list
   773             if(iUninstalledApps==NULL)
  1418             if(iUninstalledApps==NULL)
   774                 iUninstalledApps=new(ELeave) CArrayFixFlat<TUid>(1);
  1419                 iUninstalledApps=new(ELeave) CArrayFixFlat<TUid>(1);
   775             
  1420             
   776             iUninstalledApps->AppendL(appData->AppEntry().iUidType[2]);
  1421             iUninstalledApps->AppendL(appData->AppEntry().iUidType[2]);
   777 			
  1422             
   778 			delete appData;
  1423             delete appData;
   779 			}
  1424             }
   780 		else if (appData->iIsPresent==CApaAppData::ESuperseded)
  1425         else if (appData->iIsPresent==CApaAppData::ESuperseded)
   781 			{
  1426             {
   782 			CApaAppData* newApp=NULL;
  1427             CApaAppData* newApp=NULL;
   783 			TApaAppEntry appEntry;
  1428             TApaAppEntry appEntry;
   784 			appData->iSuccessor->Get(appEntry);
  1429             appData->iSuccessor->Get(appEntry);
   785 			TRAPD(err,newApp=CApaAppData::NewL(appEntry, iFs));
  1430             TRAPD(err,newApp=CApaAppData::NewL(appEntry, iFs));
   786 			if (err==KErrNone)
  1431             if (err==KErrNone)
   787 				{
  1432                 {
   788 				// remove the old one and add the new one in its place
  1433                 // remove the old one and add the new one in its place
   789 				if (prev)
  1434                 if (prev)
   790 					prev->iNext=newApp;
  1435                     prev->iNext=newApp;
   791 				else
  1436                 else
   792 					iAppData=newApp;
  1437                     iAppData=newApp;
   793 		
  1438         
   794 				newApp->iNext = appData->iNext;
  1439                 newApp->iNext = appData->iNext;
   795 				delete appData;
  1440                 delete appData;
   796 				// increment the iterator
  1441                 // increment the iterator
   797 				prev = newApp;
  1442                 prev = newApp;
   798 				}
  1443                 }
   799 			}
  1444             }
   800 		else
  1445         else
   801 			prev=appData;
  1446             prev=appData;
   802 		
  1447         
   803 		appData=next;
  1448         appData=next;
   804 		}
  1449         }
   805 	}
  1450     }
       
  1451 
       
  1452 void CApaAppList::ScanRemovableDrivesAndUpdateL()
       
  1453 /** Rename Appslist.bin file to AppsList_Backup.bin, so that it can be renamed back, 
       
  1454      if the update scan on removable media drives does not change applist. */
       
  1455     {
       
  1456     const TArray<const TDriveUnitInfo> listOfRemovableMediaDrives = iAppRegFinder->DriveList();
       
  1457     const TInt count = listOfRemovableMediaDrives.Count();
       
  1458 
       
  1459     // Removable media scan would take place only if removable drives are present.
       
  1460     if (count)
       
  1461         {
       
  1462         CApaAppData* appData = iAppData;
       
  1463         while (appData)
       
  1464             {
       
  1465             for (TInt driveIndex = 0; driveIndex < count; ++driveIndex)
       
  1466                 {
       
  1467                 if (TParsePtrC(*appData->iRegistrationFile).Drive() == listOfRemovableMediaDrives[driveIndex].iUnit.Name())
       
  1468                     {
       
  1469                     appData->SetAppPending();
       
  1470                     break;
       
  1471                     }
       
  1472                 }
       
  1473             appData = appData->iNext;
       
  1474             }
       
  1475 
       
  1476         while (IdleUpdateL())
       
  1477             { // It updates the removable media apps present in AppList if it has changed.
       
  1478 
       
  1479             };
       
  1480         }
       
  1481     }
       
  1482 
       
  1483 void CApaAppList::UndoSetPending(CApaAppData* aAppData)
       
  1484     // Reset all apps to pevious pending state so they don't get purged
       
  1485     {
       
  1486     for (; aAppData; aAppData = aAppData->iNext)
       
  1487         {
       
  1488         if (aAppData->iIsPresent == CApaAppData::EPresentPendingUpdate)
       
  1489             {
       
  1490             aAppData->iIsPresent = CApaAppData::EIsPresent;
       
  1491             }
       
  1492         }
       
  1493     }
       
  1494 
       
  1495 /**
       
  1496 @internalComponent
       
  1497 */
       
  1498 EXPORT_C CApaAppData* CApaAppList::FindAndAddSpecificAppL(CApaAppRegFinder* aFinder, TUid aAppUid)
       
  1499     {
       
  1500 //Scans and adds the specified application to the app list if found
       
  1501   __ASSERT_DEBUG(aFinder, Panic(EPanicNullPointer));
       
  1502   TBool found = EFalse;
       
  1503   TApaAppEntry appEntry;
       
  1504   aFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
       
  1505   while (aFinder->NextL(appEntry, *iForcedRegistrations))
       
  1506       {
       
  1507       if (appEntry.iUidType[2] == aAppUid)
       
  1508           {
       
  1509           found = ETrue;
       
  1510           break;
       
  1511           }
       
  1512       }
       
  1513   
       
  1514   CApaAppData* app = NULL;
       
  1515   if (found)
       
  1516       {
       
  1517       // add the app to the list
       
  1518       TBool hasChanged = EFalse;
       
  1519       CApaAppData* prevFirstAppInList = iAppData;
       
  1520       UpdateNextAppL(appEntry, hasChanged);
       
  1521       if (iAppData != prevFirstAppInList)
       
  1522           app = iAppData;     // assume the new app was added to the list
       
  1523 
       
  1524       if (hasChanged)
       
  1525           iFlags |= EAppListHasChanged;
       
  1526       }
       
  1527 
       
  1528   return app;
       
  1529     return NULL;
       
  1530     }
       
  1531 
       
  1532 #endif
       
  1533 
       
  1534 EXPORT_C TBool CApaAppList::IsIdleUpdateComplete() const
       
  1535 /** Tests whether an asynchronous update of the list is currently in progress.
       
  1536 
       
  1537 @return True if no asynchronous update of the list is currently in progress, 
       
  1538 otherwise false. */
       
  1539 	{
       
  1540 	return iAppIdler == NULL;
       
  1541 	}
       
  1542 
       
  1543 
       
  1544 void CApaAppList::AddToList( CApaAppData* aAppData )
       
  1545 	{
       
  1546 	__ASSERT_DEBUG(aAppData, Panic(EPanicNullPointer));
       
  1547 	aAppData->iNext=iAppData;
       
  1548 	iAppData=aAppData;
       
  1549 	
       
  1550 #ifdef APPARC_SHOW_TRACE	
       
  1551     RDebug::Print(_L("[Apparc] Application with UID: %X is added to applist"), aAppData->iUidType[2]);
       
  1552 #endif
       
  1553     
       
  1554 	}
       
  1555 
   806 
  1556 
   807 EXPORT_C TInt CApaAppList::Count() const
  1557 EXPORT_C TInt CApaAppList::Count() const
   808 /** Gets the count of applications present in the app list.
  1558 /** Gets the count of applications present in the app list.
   809 
  1559 
   810 @return The number of applications in the list. */
  1560 @return The number of applications in the list. */
   839 regardless of screen mode.
  1589 regardless of screen mode.
   840 @return A pointer to the first application that can use the 
  1590 @return A pointer to the first application that can use the 
   841 specified screen mode. */
  1591 specified screen mode. */
   842 	{
  1592 	{
   843 
  1593 
   844 	CApaAppData* appData=iValidFirstAppData;
  1594 	CApaAppData* appData=iAppData;
   845 
  1595 
   846 	if(aScreenMode!=KIgnoreScreenMode)
  1596 	if(aScreenMode!=KIgnoreScreenMode)
   847 		{
  1597 		{
   848 		while (appData && !appData->CanUseScreenMode(aScreenMode))
  1598 		while (appData && !appData->CanUseScreenMode(aScreenMode))
   849 			appData = appData->iNext;
  1599 			appData = appData->iNext;
   933 		}
  1683 		}
   934 
  1684 
   935 	return NULL;
  1685 	return NULL;
   936 	}
  1686 	}
   937 	
  1687 	
       
  1688 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   938 /**
  1689 /**
   939 Adds a registration file to the iForcedRegistrations array.
  1690 Adds a registration file to the iForcedRegistrations array.
   940 
  1691 
   941 @param aRegistrationFile The function takes ownership of the HBufC.
  1692 @param aRegistrationFile The function takes ownership of the HBufC.
   942 @internalComponent
  1693 @internalComponent
   952 EXPORT_C void CApaAppList::ResetForcedRegistrations()
  1703 EXPORT_C void CApaAppList::ResetForcedRegistrations()
   953 	{
  1704 	{
   954 	if(iForcedRegistrations)
  1705 	if(iForcedRegistrations)
   955 		iForcedRegistrations->Reset();
  1706 		iForcedRegistrations->Reset();
   956 	}
  1707 	}
       
  1708 #endif
   957 
  1709 
   958 /** Finds the preferred application to handle the specified data type.
  1710 /** Finds the preferred application to handle the specified data type.
   959 
  1711 
   960 @param aDataType The data type of interest.
  1712 @param aDataType The data type of interest.
   961 @return The third UID of the application in the list which has the 
  1713 @return The third UID of the application in the list which has the 
  1045 	{
  1797 	{
  1046 	if (!(iFlags & EFirstScanComplete) && iObserver)
  1798 	if (!(iFlags & EFirstScanComplete) && iObserver)
  1047 		iObserver->InitialListPopulationComplete();
  1799 		iObserver->InitialListPopulationComplete();
  1048 	iValidFirstAppData = iAppData;
  1800 	iValidFirstAppData = iAppData;
  1049 	iFlags|=EFirstScanComplete;
  1801 	iFlags|=EFirstScanComplete;
       
  1802 
       
  1803 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  	
  1050 	iNNAInstallation = EFalse;
  1804 	iNNAInstallation = EFalse;
       
  1805 #endif
       
  1806 	
       
  1807 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1808 	delete iScrAppInfo;
       
  1809 	iScrAppInfo=NULL;
       
  1810     iScr.Close();
       
  1811 #endif
       
  1812 #ifdef APPARC_SHOW_TRACE    
       
  1813     RDebug::Printf("[Apparc] *****************END CREATING APPLIST ****************************");
       
  1814 #endif    
  1051 	}
  1815 	}
  1052 
  1816 
  1053 /**
  1817 /**
  1054  *
  1818  *
  1055  * Tests whether the first scan for list of Apps has completed.
  1819  * Tests whether the first scan for list of Apps has completed.
  1078 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1842 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1079 		app = NextApp(app, KIgnoreScreenMode);
  1843 		app = NextApp(app, KIgnoreScreenMode);
  1080 
  1844 
  1081 	if (app)
  1845 	if (app)
  1082 		{
  1846 		{
       
  1847 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
  1083 		if (!app->RegistrationFileUsed())
  1848 		if (!app->RegistrationFileUsed())
  1084 			User::Leave(KErrNotSupported);
  1849 			User::Leave(KErrNotSupported);
       
  1850 #endif		
  1085 
  1851 
  1086 		if (app->iServiceArray)
  1852 		if (app->iServiceArray)
  1087 			{
  1853 			{
  1088 			CBufFlat* const buf = CBufFlat::NewL(KBufferExpansionGranularity);
  1854 			CBufFlat* const buf = CBufFlat::NewL(KBufferExpansionGranularity);
  1089 			CleanupStack::PushL(buf);
  1855 			CleanupStack::PushL(buf);
  1109 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1875 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1110 		app = NextApp(app, KIgnoreScreenMode);
  1876 		app = NextApp(app, KIgnoreScreenMode);
  1111 
  1877 
  1112 	if (app)
  1878 	if (app)
  1113 		{
  1879 		{
       
  1880 	
       
  1881 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
  1114 		if (!app->RegistrationFileUsed())
  1882 		if (!app->RegistrationFileUsed())
  1115 			User::Leave(KErrNotSupported);
  1883 			User::Leave(KErrNotSupported);
  1116 
  1884 #endif
       
  1885 		
  1117 		if (app->iServiceArray)
  1886 		if (app->iServiceArray)
  1118 			{
  1887 			{
  1119 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1888 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1120 			CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
  1889 			CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
  1121 			CleanupStack::PushL(uidArray);
  1890 			CleanupStack::PushL(uidArray);
  1147 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1916 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1148 		app = NextApp(app, KIgnoreScreenMode);
  1917 		app = NextApp(app, KIgnoreScreenMode);
  1149 
  1918 
  1150 	if (app)
  1919 	if (app)
  1151 		{
  1920 		{
       
  1921 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
  1152 		if (!app->RegistrationFileUsed())
  1922 		if (!app->RegistrationFileUsed())
  1153 			User::Leave(KErrNotSupported);
  1923 			User::Leave(KErrNotSupported);
       
  1924 #endif		
  1154 
  1925 
  1155 		if (app->iServiceArray)
  1926 		if (app->iServiceArray)
  1156 			{
  1927 			{
  1157 			CArrayFixFlat<TApaAppServiceInfo>* implArray = NULL;
  1928 			CArrayFixFlat<TApaAppServiceInfo>* implArray = NULL;
  1158 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1929 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1702 	// if it is a language change event, start a rescan on app-list.
  2473 	// if it is a language change event, start a rescan on app-list.
  1703 	if (status.Int() == EChangesLocale && iPrevLanguage != User::Language())
  2474 	if (status.Int() == EChangesLocale && iPrevLanguage != User::Language())
  1704 		{		
  2475 		{		
  1705 		iPrevLanguage = User::Language();
  2476 		iPrevLanguage = User::Language();
  1706 		iAppList.iFlags |= CApaAppList::ELangChangePending;
  2477 		iAppList.iFlags |= CApaAppList::ELangChangePending;
       
  2478 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK		
       
  2479 		iAppList.InitializeLangAppListL();
       
  2480 #endif
  1707 		iAppList.StartIdleUpdateL(iAppList.iObserver);
  2481 		iAppList.StartIdleUpdateL(iAppList.iObserver);
  1708 		}
  2482 		}
  1709 	}
  2483 	}
  1710 
  2484 
  1711 TInt CApaAppList::CApaLangChangeMonitor::RunError(TInt /*aError*/)
  2485 TInt CApaAppList::CApaLangChangeMonitor::RunError(TInt /*aError*/)