appfw/apparchitecture/aplist/aplapplist.cpp
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
child 82 4610cd70c542
equal deleted inserted replaced
62:924385140d98 63:c2c61fdca848
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 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
    24 #include <bautils.h>			// BaflUtils::NearestLanguageFile()
    25 #include <bautils.h>			// BaflUtils::NearestLanguageFile()
    25 #include <s32mem.h>				// RBufWriteStream
    26 #include <s32mem.h>				// RBufWriteStream
    26 #include "aplappinforeader.h"
    27 #include "aplappinforeader.h"
    27 #include "apsiconcaptionoverride.h"
    28 #include "apsiconcaptionoverride.h"
    28 #ifdef SYMBIAN_BAFL_SYSUTIL
    29 #ifdef SYMBIAN_BAFL_SYSUTIL
    29 #include <bafl/sysutil.h>
    30 #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
       
    37 #endif
    31 #endif
    38 
    32 
    39 
    33 
    40 // Delays in the pseudo idle object that builds the application list
    34 // Delays in the pseudo idle object that builds the application list
    41 //
    35 //
    51 //On adding further info to this file, KROMVersionCacheFileMajorVersion or KROMVersionCacheFileMinorVersion or KROMVersionCacheFileBuildVersion needs to be incremented appropriately.
    45 //On adding further info to this file, KROMVersionCacheFileMajorVersion or KROMVersionCacheFileMinorVersion or KROMVersionCacheFileBuildVersion needs to be incremented appropriately.
    52 _LIT(KROMVersionStringCacheFileName, "ROMVersionCache.bin");
    46 _LIT(KROMVersionStringCacheFileName, "ROMVersionCache.bin");
    53 const TInt8 KROMVersionCacheFileMajorVersion=1;
    47 const TInt8 KROMVersionCacheFileMajorVersion=1;
    54 const TInt8 KROMVersionCacheFileMinorVersion=0;
    48 const TInt8 KROMVersionCacheFileMinorVersion=0;
    55 const TInt16 KROMVersionCacheFileBuildVersion=0;
    49 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};
       
    63 #endif
    50 #endif
    64 
    51 
    65 
    52 
    66 GLDEF_C void Panic(TApgPanic aPanic)
    53 GLDEF_C void Panic(TApgPanic aPanic)
    67 	{
    54 	{
    95 	RChangeNotifier iLangNotifier;
    82 	RChangeNotifier iLangNotifier;
    96 	CApaAppList& iAppList;
    83 	CApaAppList& iAppList;
    97 	TLanguage iPrevLanguage;
    84 	TLanguage iPrevLanguage;
    98 	};
    85 	};
    99 
    86 
   100 
    87 		
   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 
       
   467 //
    88 //
   468 // Local functions
    89 // Local functions
   469 //
    90 //
   470 
    91 
   471 void CleanupServiceArray(TAny* aServiceArray)
    92 void CleanupServiceArray(TAny* aServiceArray)
   485 //
   106 //
   486 // Class CApaAppList
   107 // Class CApaAppList
   487 //
   108 //
   488 
   109 
   489 EXPORT_C CApaAppList* CApaAppList::NewL(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   110 EXPORT_C CApaAppList* CApaAppList::NewL(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   490     {
   111 	{
   491     CApaAppList* self=new (ELeave) CApaAppList(aFs, aLoadMbmIconsOnDemand, aIdlePeriodicDelay);
   112 	CApaAppList* self=new (ELeave) CApaAppList(aFs, aLoadMbmIconsOnDemand, aIdlePeriodicDelay);
   492     CleanupStack::PushL(self);
   113 	CleanupStack::PushL(self);
   493     self->ConstructL();
   114 	self->ConstructL();
   494     CleanupStack::Pop(self);
   115 	CleanupStack::Pop(self);
   495     return self;
   116 	return self;
   496     }
   117 	}
   497 
   118 
   498 CApaAppList::CApaAppList(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   119 CApaAppList::CApaAppList(RFs& aFs, TBool aLoadMbmIconsOnDemand, TInt aIdlePeriodicDelay)
   499     :iFs(aFs),
   120 	:iFs(aFs),
   500     iFlags(0),
   121 	iFlags(0),
   501     iIdlePeriodicDelay(aIdlePeriodicDelay),
   122 	iIdlePeriodicDelay(aIdlePeriodicDelay),
   502     iLoadMbmIconsOnDemand(aLoadMbmIconsOnDemand),
   123 	iLoadMbmIconsOnDemand(aLoadMbmIconsOnDemand),
   503     iUninstalledApps(NULL)  
   124     iUninstalledApps(NULL)	
   504     {
   125 	{
   505     }
   126 	}
   506 
       
   507 
   127 
   508 void CApaAppList::ConstructL()
   128 void CApaAppList::ConstructL()
   509 	{
   129 	{
   510 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
       
   511 	iAppRegFinder = CApaAppRegFinder::NewL(iFs);
   130 	iAppRegFinder = CApaAppRegFinder::NewL(iFs);
   512 #endif
       
   513 	
   131 	
   514 	User::LeaveIfError(iFsShareProtected.Connect());
   132 	User::LeaveIfError(iFsShareProtected.Connect());
   515 	User::LeaveIfError(iFsShareProtected.ShareProtected());
   133 	User::LeaveIfError(iFsShareProtected.ShareProtected());
   516 	User::LeaveIfError(Dll::SetTls(this));
   134 	User::LeaveIfError(Dll::SetTls(this));
   517 	
   135 	
   518 	//Start language change monitor.
   136 	//Start language change monitor.
   519 	iAppLangMonitor = CApaLangChangeMonitor::NewL(*this);
   137 	iAppLangMonitor = CApaLangChangeMonitor::NewL(*this);
   520 
       
   521 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  	
       
   522 	const TInt KArrayGranularity = 128;
   138 	const TInt KArrayGranularity = 128;
   523 	iForcedRegistrations = new (ELeave) CDesCArraySeg(KArrayGranularity);
   139 	iForcedRegistrations = new (ELeave) CDesCArraySeg(KArrayGranularity);
   524 #endif	
       
   525 	
   140 	
   526 	// Init the AppsList cache paths
   141 	// Init the AppsList cache paths
   527 	_LIT(KAppsListCacheFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList.bin");
   142 	_LIT(KAppsListCacheFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList.bin");
   528 	_LIT(KAppsListCacheBackUpFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList_Backup.bin");
   143 	_LIT(KAppsListCacheBackUpFileName, ":\\private\\10003a3f\\AppsListCache\\AppsList_Backup.bin");
   529 	_LIT(KAppsListCachePath, ":\\private\\10003a3f\\AppsListCache\\");
   144 	_LIT(KAppsListCachePath, ":\\private\\10003a3f\\AppsListCache\\");
   559 	iObserver = NULL;
   174 	iObserver = NULL;
   560 	iFsShareProtected.Close();
   175 	iFsShareProtected.Close();
   561 
   176 
   562 	delete iDefaultIconArray;
   177 	delete iDefaultIconArray;
   563 	delete iDefaultAppIconMbmFileName;
   178 	delete iDefaultAppIconMbmFileName;
   564 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   565 	delete iAppRegFinder;
   179 	delete iAppRegFinder;
   566     delete iForcedRegistrations;
       
   567 #endif
       
   568 	delete iAppIdler;
   180 	delete iAppIdler;
   569 	delete iAppListStorer;
   181 	delete iAppListStorer;
   570 	delete iAppIconLoader;
   182 	delete iAppIconLoader;
   571 	delete iAppLangMonitor;
   183 	delete iAppLangMonitor;
       
   184 	delete iForcedRegistrations;
   572 	delete iIconCaptionObserver;
   185 	delete iIconCaptionObserver;
   573 	delete iIconCaptionOverrides;
   186 	delete iIconCaptionOverrides;
   574 	iAppsListCacheFileName.Close();
   187 	iAppsListCacheFileName.Close();
   575 	iAppsListCacheBackUpFileName.Close();
   188 	iAppsListCacheBackUpFileName.Close();
   576 	iAppsListCachePath.Close();
   189 	iAppsListCachePath.Close();
   577 	
   190 	
   578 	iCustomAppList.ResetAndDestroy();
   191 	iCustomAppList.ResetAndDestroy();
   579 	iCustomAppList.Close();
   192 	iCustomAppList.Close();
   580 
   193 	}
   581 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   194 
   582 	iForceRegAppUids.Close();	
       
   583 	delete iScrAppInfo;
       
   584 	iScr.Close();
       
   585 #endif	
       
   586 	}
       
   587 
       
   588 
       
   589 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK   
       
   590 // Stop scanning applications if installation or uninstallation has started	
   195 // Stop scanning applications if installation or uninstallation has started	
   591 EXPORT_C void CApaAppList::StopScan(TBool aNNAInstall)
   196 EXPORT_C void CApaAppList::StopScan(TBool aNNAInstall)
   592 	{
   197 	{
   593 	if (aNNAInstall)
   198 	if (aNNAInstall)
   594 		{
   199 		{
   599 		delete iAppIdler;
   204 		delete iAppIdler;
   600 		iAppIdler=NULL;
   205 		iAppIdler=NULL;
   601 		}
   206 		}
   602 	UndoSetPending(iAppData);
   207 	UndoSetPending(iAppData);
   603 	}
   208 	}
   604 
   209 	
   605 // Allow scanning when installation or uninstallation is complete
   210 // Allow scanning when installation or uninstallation is complete
   606 EXPORT_C void CApaAppList::RestartScanL()
   211 EXPORT_C void CApaAppList::RestartScanL()
   607 	{
   212 	{
   608 	TRAP_IGNORE(PurgeL());
   213 	TRAP_IGNORE(PurgeL());
   609 	StartIdleUpdateL();
   214 	StartIdleUpdateL();
   611 
   216 
   612 EXPORT_C TBool CApaAppList::AppListUpdatePending()
   217 EXPORT_C TBool CApaAppList::AppListUpdatePending()
   613 	{
   218 	{
   614 	return iNNAInstallation;
   219 	return iNNAInstallation;
   615 	}
   220 	}
   616 #endif
   221 
       
   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 	}
   617 
   233 
   618 EXPORT_C void CApaAppList::StartIdleUpdateL()
   234 EXPORT_C void CApaAppList::StartIdleUpdateL()
   619 /** Updates the list asynchronously, using an idle time active object, 
   235 /** Updates the list asynchronously, using an idle time active object, 
   620 and no observer. When the update is finished, the resulting app 
   236 and no observer. When the update is finished, the resulting app 
   621 list is stored. */
   237 list is stored. */
   649 	if (iAppIdler)
   265 	if (iAppIdler)
   650 		{
   266 		{
   651 		delete iAppIdler;
   267 		delete iAppIdler;
   652 		iAppIdler=NULL;
   268 		iAppIdler=NULL;
   653 		}
   269 		}
   654 
   270 		
   655 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   656 	// DEF072701
   271 	// DEF072701
   657 	// When performing the update scan let the idle object have lower priority.
   272 	// When performing the update scan let the idle object have lower priority.
   658 	if (IsFirstScanComplete())
   273 	if (IsFirstScanComplete())
   659 		{
   274 		{
   660 		iAppIdler=CPeriodic::NewL(CActive::EPriorityLow);
   275 		iAppIdler=CPeriodic::NewL(CActive::EPriorityLow);
   663 		{
   278 		{
   664 		iAppIdler=CPeriodic::NewL(CActive::EPriorityStandard);
   279 		iAppIdler=CPeriodic::NewL(CActive::EPriorityStandard);
   665 		}
   280 		}
   666 	SetPending(iAppData);
   281 	SetPending(iAppData);
   667 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
   282 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
   668     // DEF072701
   283  
   669     // If this is the first scan i.e the boot scan then it may take some time. Thus
   284  	// DEF072701
   670     // the periodic delay value should be used so that this process will stop periodically 
   285  	// If this is the first scan i.e the boot scan then it may take some time. Thus
   671     // to allow time for other processes.
   286  	// the periodic delay value should be used so that this process will stop periodically 
   672     // If this is just a re-scan it should take much less time. Therefore it should just
   287  	// to allow time for other processes.
   673     // be completed in one go rather than periodically delayed. Thus the delay value
   288  	// If this is just a re-scan it should take much less time. Therefore it should just
   674     // should be set to 0.
   289  	// be completed in one go rather than periodically delayed. Thus the delay value
   675     iAppIdler->Start(KIdleStartDelay, IsFirstScanComplete()? 0 : iIdlePeriodicDelay, TCallBack(IdleUpdateCallbackL, this));
   290  	// should be set to 0.
   676 #else	
   291 	iAppIdler->Start(KIdleStartDelay, IsFirstScanComplete()? 0 : iIdlePeriodicDelay, TCallBack(IdleUpdateCallbackL, this));
   677 	
   292 	}
   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
       
   795 
   293 
   796 EXPORT_C void CApaAppList::StartIdleUpdateL(MApaAppListObserver* aObserver)
   294 EXPORT_C void CApaAppList::StartIdleUpdateL(MApaAppListObserver* aObserver)
   797 /** Updates the list asynchronously, using an idle time active object 
   295 /** Updates the list asynchronously, using an idle time active object 
   798 and an observer. When the update is finished, the resulting app list 
   296 and an observer. When the update is finished, the resulting app list 
   799 is stored and the observer is notified with an MApaAppListServObserver::EAppListChanged 
   297 is stored and the observer is notified with an MApaAppListServObserver::EAppListChanged 
   827  * If Restore operation fails then it 
   325  * If Restore operation fails then it 
   828  * starts updating the list asynchronously, by calling StartIdleUpdateL().
   326  * starts updating the list asynchronously, by calling StartIdleUpdateL().
   829 
   327 
   830 @param aObserver Observer to be notified when the update has finished. */
   328 @param aObserver Observer to be notified when the update has finished. */
   831 	{
   329 	{
   832     
       
   833 #ifdef APPARC_SHOW_TRACE    
       
   834     RDebug::Printf("[Apparc] *****************START CREATING APPLIST ****************************");
       
   835 #endif    
       
   836     
       
   837 	DeleteAppsListBackUpAndTempFiles();
   330 	DeleteAppsListBackUpAndTempFiles();
   838 	
       
   839 	TInt ret = KErrGeneral;
   331 	TInt ret = KErrGeneral;
   840 #ifndef __WINS__ // on the emulator, don't read app list from file, as doing so means apps
   332 #ifndef __WINS__ // on the emulator, don't read app list from file, as doing so means apps
   841                  // built while the emulator isn't running won't appear in the list
   333                  // built while the emulator isn't running won't appear in the list
   842 	TRAP(ret, RestoreL());
   334 	TRAP(ret, RestoreL());
   843 #endif
   335 #endif
   844 	if (ret != KErrNone)
   336 	if (ret != KErrNone)
   845 		{
   337 		{
   846 		// There was an error during restore, so update the list asynchronously.
   338 		// There was an error during restore, so update the list asynchronously.
   847 		DeleteAppData();
   339 		DeleteAppData();
   848 		iFs.Delete(iAppsListCacheFileName);
   340 		iFs.Delete(iAppsListCacheFileName);
   849 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   341 		StartIdleUpdateL(aObserver);
   850 		InitializeApplistL(aObserver);		
       
   851 #else
       
   852         StartIdleUpdateL(aObserver);		
       
   853 #endif
       
   854 		
       
   855 		}
   342 		}
   856 	else
   343 	else
   857 		{
   344 		{
   858 		iObserver = aObserver;
   345 		iObserver = aObserver;
   859 		if (iLoadMbmIconsOnDemand)
   346 		if (iLoadMbmIconsOnDemand)
   871 	{
   358 	{
   872 	iAppIconLoader = new(ELeave) CApaIdleIconLoader(iAppData, iFs, *this);
   359 	iAppIconLoader = new(ELeave) CApaIdleIconLoader(iAppData, iFs, *this);
   873 	iAppIconLoader->Start();
   360 	iAppIconLoader->Start();
   874 	}
   361 	}
   875 
   362 
       
   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 	}
   876 
   393 
   877 void CApaAppList::DeleteAppsListBackUpAndTempFiles()
   394 void CApaAppList::DeleteAppsListBackUpAndTempFiles()
   878 /** Deletes all files inside AppsListCache folder except AppsList.bin */
   395 /** Deletes all files inside AppsListCache folder except AppsList.bin */
   879 	{
   396 	{
   880 	_LIT(KTemp, "AppsList.bin");
   397 	_LIT(KTemp, "AppsList.bin");
   965 		{
   482 		{
   966 		if (softwareVersion.Compare(actualSoftwareVersion) != 0)
   483 		if (softwareVersion.Compare(actualSoftwareVersion) != 0)
   967 			{
   484 			{
   968 			//Leave if the current version is different from the previous stored version and recreate applist.
   485 			//Leave if the current version is different from the previous stored version and recreate applist.
   969 #ifdef _DEBUG
   486 #ifdef _DEBUG
   970 			RDebug::Print(_L("[Apparc] !!Firmware update detected!! Rebuilding AppList"));
   487 			RDebug::Print(_L("!!Firmware update detected!! Rebuilding AppList"));
   971 #endif
   488 #endif
   972 			User::Leave(KErrGeneral);
   489 			User::Leave(KErrGeneral);
   973 			}
   490 			}
   974 		}
   491 		}
   975 	else
   492 	else
   976 		{
   493 		{
   977 		//Leave if any error reading the version information, except if file is not present
   494 		//Leave if any error reading the version information, except if file is not present
   978 		if (err != KErrPathNotFound && err != KErrNotFound)
   495 		if (err != KErrPathNotFound && err != KErrNotFound)
   979 			{
   496 			{
   980 #ifdef _DEBUG
   497 #ifdef _DEBUG
   981 			RDebug::Print(_L("[Apparc] !!Error %d reading Firmware version.  Rebuilding AppList"),err);
   498 			RDebug::Print(_L("!!Error %d reading Firmware version.  Rebuilding AppList"),err);
   982 #endif
   499 #endif
   983 			User::Leave(err);
   500 			User::Leave(err);
   984 			}
   501 			}
   985 		}
   502 		}
   986 	CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName
   503 	CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName
  1014 			}
   531 			}
  1015 		}	
   532 		}	
  1016 	// Close the stream;
   533 	// Close the stream;
  1017 	CleanupStack::PopAndDestroy(&theReadStream);
   534 	CleanupStack::PopAndDestroy(&theReadStream);
  1018 
   535 
  1019 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1020 	iFlags |= ENotifyUpdateOnFirstScanComplete;
       
  1021 #else
       
  1022 	iFs.Rename(iAppsListCacheFileName, iAppsListCacheBackUpFileName);
   536 	iFs.Rename(iAppsListCacheFileName, iAppsListCacheBackUpFileName);
  1023 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanRemovableDrives);	// Builds the Removable Media Drive List
   537 	iAppRegFinder->FindAllAppsL(CApaAppRegFinder::EScanRemovableDrives);	// Builds the Removable Media Drive List
  1024 
   538 
  1025 	iFlags |= ENotifyUpdateOnFirstScanComplete;
   539 	iFlags |= ENotifyUpdateOnFirstScanComplete;
  1026 
   540 
  1027 	// It runs an update scan on removable media apps.
   541 	// It runs an update scan on removable media apps.
  1028 	ScanRemovableDrivesAndUpdateL();
   542 	ScanRemovableDrivesAndUpdateL();
  1029 #endif
       
  1030 	}
   543 	}
  1031 
   544 
  1032 EXPORT_C TBool CApaAppList::IsLanguageChangePending() const
   545 EXPORT_C TBool CApaAppList::IsLanguageChangePending() const
  1033 /** Returns ETrue if a language change event is received and a re-scan is in progress otherwise EFalse. */
   546 /** Returns ETrue if a language change event is received and a re-scan is in progress otherwise EFalse. */
  1034 	{
   547 	{
  1072 		if (iFlags & EAppListHasChanged || iFlags & ENotifyUpdateOnFirstScanComplete)
   585 		if (iFlags & EAppListHasChanged || iFlags & ENotifyUpdateOnFirstScanComplete)
  1073 			iObserver->NotifyUpdate(MApaAppListServObserver::EAppListChanged);	// NotifyUpdate will notify clients for both list update and scan complete.
   586 			iObserver->NotifyUpdate(MApaAppListServObserver::EAppListChanged);	// NotifyUpdate will notify clients for both list update and scan complete.
  1074 		else
   587 		else
  1075 			iObserver->NotifyScanComplete();	// NotifyScanComplete will notify clients for scan complete.
   588 			iObserver->NotifyScanComplete();	// NotifyScanComplete will notify clients for scan complete.
  1076 
   589 
  1077 		//iObserver=NULL;
   590 		iObserver=NULL;
  1078 		}
   591 		}
  1079 	}
   592 	}
  1080 
   593 
  1081 void CApaAppList::StopIdler()
   594 void CApaAppList::StopIdler()
  1082 	{
   595 	{
  1083  	delete iAppIdler;
   596  	delete iAppIdler;
  1084 	iAppIdler=NULL;
   597 	iAppIdler=NULL;
  1085 	}
   598 	}
  1086 
   599 
  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
       
  1296 TInt CApaAppList::IdleUpdateL()
   600 TInt CApaAppList::IdleUpdateL()
  1297 // returns ETrue if there is more scanning to be done.
   601 // returns ETrue if there is more scanning to be done.
  1298 	{
   602 	{
  1299     
       
  1300 	TBool more=EFalse;
   603 	TBool more=EFalse;
  1301 	TApaAppEntry currentApp = TApaAppEntry();
   604 	TApaAppEntry currentApp = TApaAppEntry();
  1302 	TRAPD(err, more = iAppRegFinder->NextL(currentApp, *iForcedRegistrations));
   605 	TRAPD(err, more = iAppRegFinder->NextL(currentApp, *iForcedRegistrations));
  1303 	if (err!=KErrNone)
   606 	if (err!=KErrNone)
  1304 		{
   607 		{
  1330 		iFlags |= EAppListHasChanged;
   633 		iFlags |= EAppListHasChanged;
  1331 
   634 
  1332 	return more;
   635 	return more;
  1333 	}
   636 	}
  1334 
   637 
       
   638 EXPORT_C TBool CApaAppList::IsIdleUpdateComplete() const
       
   639 /** Tests whether an asynchronous update of the list is currently in progress.
       
   640 
       
   641 @return True if no asynchronous update of the list is currently in progress, 
       
   642 otherwise false. */
       
   643 	{
       
   644 	return iAppIdler == NULL;
       
   645 	}
       
   646 
       
   647 void CApaAppList::SetPending(CApaAppData* aAppData)
       
   648 	// set all apps to pending update - we'll find them again as we scan
       
   649 	{
       
   650   	for (; aAppData; aAppData = aAppData->iNext)
       
   651 		aAppData->SetAppPending();
       
   652 	}
       
   653 
       
   654 void CApaAppList::SetNotFound(CApaAppData* aAppData, TBool& aHasChanged)
       
   655 	// mark any unfound apps not present
       
   656 	{
       
   657 	while (aAppData)
       
   658 		{
       
   659 		if (aAppData->IsPending())
       
   660 			{
       
   661 			aAppData->iIsPresent = CApaAppData::ENotPresent;
       
   662 			aHasChanged = ETrue;
       
   663 			}
       
   664 		aAppData = aAppData->iNext;
       
   665 		}
       
   666 	}
       
   667 
       
   668 void CApaAppList::AddToList( CApaAppData* aAppData )
       
   669 	{
       
   670 	__ASSERT_DEBUG(aAppData, Panic(EPanicNullPointer));
       
   671 	aAppData->iNext=iAppData;
       
   672 	iAppData=aAppData;
       
   673 	}
       
   674 
  1335 void CApaAppList::UpdateNextAppL(const TApaAppEntry& aAppEntry,TBool& aHasChanged)
   675 void CApaAppList::UpdateNextAppL(const TApaAppEntry& aAppEntry,TBool& aHasChanged)
  1336     {
   676 	{
  1337     CApaAppData* appData=AppDataByUid(aAppEntry.iUidType[2]);
   677 	CApaAppData* appData=AppDataByUid(aAppEntry.iUidType[2]);
  1338     if (appData==NULL)
   678 	if (appData==NULL)
  1339         {// not in list, so add it at the start
   679 		{// not in list, so add it at the start
  1340         TRAPD(err,appData=CApaAppData::NewL(aAppEntry, iFs));
   680 		TRAPD(err,appData=CApaAppData::NewL(aAppEntry, iFs));
  1341         if (err==KErrNone)
   681 		if (err==KErrNone)
  1342             {
   682 			{
  1343             AddToList( appData );
   683 			AddToList( appData );
  1344             aHasChanged=ETrue;
   684 			aHasChanged=ETrue;
  1345             }
   685 			}
  1346         }
   686 		}
  1347     else if (appData->IsPending())
   687 	else if (appData->IsPending())
  1348         { // not found yet during current scan - we may need to override this one
   688 		{ // not found yet during current scan - we may need to override this one
  1349         
   689 		
  1350         // On a system which scans for registration .RSC files (V2 apps) first, followed by
   690 		// 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
   691 		// .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,
   692 		// 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).
   693 		// with the V2 .RSC filename as their filenames will never match (which is what we want in this case).
  1354         TPtrC currentFileName;
   694 		TPtrC currentFileName;
  1355         if (appData->RegistrationFileUsed())
   695 		if (appData->RegistrationFileUsed())
  1356             currentFileName.Set(*appData->iRegistrationFile);
   696 			currentFileName.Set(*appData->iRegistrationFile);
  1357         else
   697 		else
  1358             currentFileName.Set(*appData->iFullName);
   698 			currentFileName.Set(*appData->iFullName);
  1359     
   699 	
  1360         if (aAppEntry.iFullName.CompareF(currentFileName)!=0)
   700 		if (aAppEntry.iFullName.CompareF(currentFileName)!=0)
  1361             {
   701 			{
  1362             delete appData->iSuccessor;
   702 			delete appData->iSuccessor;
  1363             appData->iSuccessor = NULL;
   703 			appData->iSuccessor = NULL;
  1364             appData->iSuccessor = CApaAppEntry::NewL(aAppEntry);
   704 			appData->iSuccessor = CApaAppEntry::NewL(aAppEntry);
  1365 
   705 
  1366             appData->iIsPresent = CApaAppData::ESuperseded;
   706 			appData->iIsPresent = CApaAppData::ESuperseded;
  1367             aHasChanged=ETrue;
   707 			aHasChanged=ETrue;
  1368             }
   708 			}
  1369         else
   709 		else
  1370             {
   710 			{
  1371             if (appData->Update() || appData->iIsPresent==CApaAppData::ENotPresentPendingUpdate) 
   711 			if (appData->Update() || appData->iIsPresent==CApaAppData::ENotPresentPendingUpdate) 
  1372                 aHasChanged=ETrue; 
   712 				aHasChanged=ETrue; 
  1373 
   713 
  1374             appData->iIsPresent = CApaAppData::EIsPresent;
   714 			appData->iIsPresent = CApaAppData::EIsPresent;
  1375             }
   715 			}
  1376         }
   716 		}
  1377     }
   717 	}
  1378 
   718 
  1379 void CApaAppList::SetPending(CApaAppData* aAppData)
   719 /**
  1380     // set all apps to pending update - we'll find them again as we scan
   720 @internalComponent
  1381     {
   721 */
  1382     for (; aAppData; aAppData = aAppData->iNext)
   722 EXPORT_C CApaAppData* CApaAppList::FindAndAddSpecificAppL(CApaAppRegFinder* aFinder, TUid aAppUid)
  1383         aAppData->SetAppPending();
   723 	{
  1384     }
   724 //Scans and adds the specified application to the app list if found
  1385 
   725 	__ASSERT_DEBUG(aFinder, Panic(EPanicNullPointer));
  1386 void CApaAppList::SetNotFound(CApaAppData* aAppData, TBool& aHasChanged)
   726 	TBool found = EFalse;
  1387     // mark any unfound apps not present
   727 	TApaAppEntry appEntry;
  1388     {
   728 	aFinder->FindAllAppsL(CApaAppRegFinder::EScanAllDrives);
  1389     while (aAppData)
   729 	while (aFinder->NextL(appEntry, *iForcedRegistrations))
  1390         {
   730 		{
  1391         if (aAppData->IsPending())
   731 		if (appEntry.iUidType[2] == aAppUid)
  1392             {
   732 			{
  1393             aAppData->iIsPresent = CApaAppData::ENotPresent;
   733 			found = ETrue;
  1394             aHasChanged = ETrue;
   734 			break;
  1395             }
   735 			}
  1396         aAppData = aAppData->iNext;
   736 		}
  1397         }
   737 	
  1398     }
   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 	}
  1399 
   754 
  1400 EXPORT_C void CApaAppList::PurgeL()
   755 EXPORT_C void CApaAppList::PurgeL()
  1401 /** Removes any applications from the list if they are no longer present 
   756 /** Removes any applications from the list if they are no longer present 
  1402 on the phone. It updates applications that have been 
   757 on the phone. It updates applications that have been 
  1403 superceded. */
   758 superceded. */
  1404     {
   759 	{
  1405     CApaAppData* appData=iAppData;
   760 	CApaAppData* appData=iAppData;
  1406     CApaAppData* prev=NULL;
   761 	CApaAppData* prev=NULL;
  1407     while (appData)
   762 	while (appData)
  1408         {
   763 		{
  1409         CApaAppData* next=appData->iNext;
   764 		CApaAppData* next=appData->iNext;
  1410         if (appData->iIsPresent==CApaAppData::ENotPresent)
   765 		if (appData->iIsPresent==CApaAppData::ENotPresent)
  1411             {
   766 			{
  1412             if (prev)
   767 			if (prev)
  1413                 prev->iNext=next;
   768 				prev->iNext=next;
  1414             else
   769 			else
  1415                 iAppData=next;
   770 				iAppData=next;
  1416             
   771 			
  1417             //Add uninstalled application UID to a list
   772             //Add uninstalled application UID to a list
  1418             if(iUninstalledApps==NULL)
   773             if(iUninstalledApps==NULL)
  1419                 iUninstalledApps=new(ELeave) CArrayFixFlat<TUid>(1);
   774                 iUninstalledApps=new(ELeave) CArrayFixFlat<TUid>(1);
  1420             
   775             
  1421             iUninstalledApps->AppendL(appData->AppEntry().iUidType[2]);
   776             iUninstalledApps->AppendL(appData->AppEntry().iUidType[2]);
  1422             
   777 			
  1423             delete appData;
   778 			delete appData;
  1424             }
   779 			}
  1425         else if (appData->iIsPresent==CApaAppData::ESuperseded)
   780 		else if (appData->iIsPresent==CApaAppData::ESuperseded)
  1426             {
   781 			{
  1427             CApaAppData* newApp=NULL;
   782 			CApaAppData* newApp=NULL;
  1428             TApaAppEntry appEntry;
   783 			TApaAppEntry appEntry;
  1429             appData->iSuccessor->Get(appEntry);
   784 			appData->iSuccessor->Get(appEntry);
  1430             TRAPD(err,newApp=CApaAppData::NewL(appEntry, iFs));
   785 			TRAPD(err,newApp=CApaAppData::NewL(appEntry, iFs));
  1431             if (err==KErrNone)
   786 			if (err==KErrNone)
  1432                 {
   787 				{
  1433                 // remove the old one and add the new one in its place
   788 				// remove the old one and add the new one in its place
  1434                 if (prev)
   789 				if (prev)
  1435                     prev->iNext=newApp;
   790 					prev->iNext=newApp;
  1436                 else
   791 				else
  1437                     iAppData=newApp;
   792 					iAppData=newApp;
  1438         
   793 		
  1439                 newApp->iNext = appData->iNext;
   794 				newApp->iNext = appData->iNext;
  1440                 delete appData;
   795 				delete appData;
  1441                 // increment the iterator
   796 				// increment the iterator
  1442                 prev = newApp;
   797 				prev = newApp;
  1443                 }
   798 				}
  1444             }
   799 			}
  1445         else
   800 		else
  1446             prev=appData;
   801 			prev=appData;
  1447         
   802 		
  1448         appData=next;
   803 		appData=next;
  1449         }
   804 		}
  1450     }
   805 	}
  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 
       
  1556 
   806 
  1557 EXPORT_C TInt CApaAppList::Count() const
   807 EXPORT_C TInt CApaAppList::Count() const
  1558 /** Gets the count of applications present in the app list.
   808 /** Gets the count of applications present in the app list.
  1559 
   809 
  1560 @return The number of applications in the list. */
   810 @return The number of applications in the list. */
  1589 regardless of screen mode.
   839 regardless of screen mode.
  1590 @return A pointer to the first application that can use the 
   840 @return A pointer to the first application that can use the 
  1591 specified screen mode. */
   841 specified screen mode. */
  1592 	{
   842 	{
  1593 
   843 
  1594 	CApaAppData* appData=iAppData;
   844 	CApaAppData* appData=iValidFirstAppData;
  1595 
   845 
  1596 	if(aScreenMode!=KIgnoreScreenMode)
   846 	if(aScreenMode!=KIgnoreScreenMode)
  1597 		{
   847 		{
  1598 		while (appData && !appData->CanUseScreenMode(aScreenMode))
   848 		while (appData && !appData->CanUseScreenMode(aScreenMode))
  1599 			appData = appData->iNext;
   849 			appData = appData->iNext;
  1683 		}
   933 		}
  1684 
   934 
  1685 	return NULL;
   935 	return NULL;
  1686 	}
   936 	}
  1687 	
   937 	
  1688 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  1689 /**
   938 /**
  1690 Adds a registration file to the iForcedRegistrations array.
   939 Adds a registration file to the iForcedRegistrations array.
  1691 
   940 
  1692 @param aRegistrationFile The function takes ownership of the HBufC.
   941 @param aRegistrationFile The function takes ownership of the HBufC.
  1693 @internalComponent
   942 @internalComponent
  1703 EXPORT_C void CApaAppList::ResetForcedRegistrations()
   952 EXPORT_C void CApaAppList::ResetForcedRegistrations()
  1704 	{
   953 	{
  1705 	if(iForcedRegistrations)
   954 	if(iForcedRegistrations)
  1706 		iForcedRegistrations->Reset();
   955 		iForcedRegistrations->Reset();
  1707 	}
   956 	}
  1708 #endif
       
  1709 
   957 
  1710 /** Finds the preferred application to handle the specified data type.
   958 /** Finds the preferred application to handle the specified data type.
  1711 
   959 
  1712 @param aDataType The data type of interest.
   960 @param aDataType The data type of interest.
  1713 @return The third UID of the application in the list which has the 
   961 @return The third UID of the application in the list which has the 
  1797 	{
  1045 	{
  1798 	if (!(iFlags & EFirstScanComplete) && iObserver)
  1046 	if (!(iFlags & EFirstScanComplete) && iObserver)
  1799 		iObserver->InitialListPopulationComplete();
  1047 		iObserver->InitialListPopulationComplete();
  1800 	iValidFirstAppData = iAppData;
  1048 	iValidFirstAppData = iAppData;
  1801 	iFlags|=EFirstScanComplete;
  1049 	iFlags|=EFirstScanComplete;
  1802 
       
  1803 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  	
       
  1804 	iNNAInstallation = EFalse;
  1050 	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    
       
  1815 	}
  1051 	}
  1816 
  1052 
  1817 /**
  1053 /**
  1818  *
  1054  *
  1819  * Tests whether the first scan for list of Apps has completed.
  1055  * Tests whether the first scan for list of Apps has completed.
  1842 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1078 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1843 		app = NextApp(app, KIgnoreScreenMode);
  1079 		app = NextApp(app, KIgnoreScreenMode);
  1844 
  1080 
  1845 	if (app)
  1081 	if (app)
  1846 		{
  1082 		{
  1847 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1848 		if (!app->RegistrationFileUsed())
  1083 		if (!app->RegistrationFileUsed())
  1849 			User::Leave(KErrNotSupported);
  1084 			User::Leave(KErrNotSupported);
  1850 #endif		
       
  1851 
  1085 
  1852 		if (app->iServiceArray)
  1086 		if (app->iServiceArray)
  1853 			{
  1087 			{
  1854 			CBufFlat* const buf = CBufFlat::NewL(KBufferExpansionGranularity);
  1088 			CBufFlat* const buf = CBufFlat::NewL(KBufferExpansionGranularity);
  1855 			CleanupStack::PushL(buf);
  1089 			CleanupStack::PushL(buf);
  1875 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1109 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1876 		app = NextApp(app, KIgnoreScreenMode);
  1110 		app = NextApp(app, KIgnoreScreenMode);
  1877 
  1111 
  1878 	if (app)
  1112 	if (app)
  1879 		{
  1113 		{
  1880 	
       
  1881 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1882 		if (!app->RegistrationFileUsed())
  1114 		if (!app->RegistrationFileUsed())
  1883 			User::Leave(KErrNotSupported);
  1115 			User::Leave(KErrNotSupported);
  1884 #endif
  1116 
  1885 		
       
  1886 		if (app->iServiceArray)
  1117 		if (app->iServiceArray)
  1887 			{
  1118 			{
  1888 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1119 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1889 			CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
  1120 			CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
  1890 			CleanupStack::PushL(uidArray);
  1121 			CleanupStack::PushL(uidArray);
  1916 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1147 	while (app && app->AppEntry().iUidType[2] != aAppUid)
  1917 		app = NextApp(app, KIgnoreScreenMode);
  1148 		app = NextApp(app, KIgnoreScreenMode);
  1918 
  1149 
  1919 	if (app)
  1150 	if (app)
  1920 		{
  1151 		{
  1921 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  1922 		if (!app->RegistrationFileUsed())
  1152 		if (!app->RegistrationFileUsed())
  1923 			User::Leave(KErrNotSupported);
  1153 			User::Leave(KErrNotSupported);
  1924 #endif		
       
  1925 
  1154 
  1926 		if (app->iServiceArray)
  1155 		if (app->iServiceArray)
  1927 			{
  1156 			{
  1928 			CArrayFixFlat<TApaAppServiceInfo>* implArray = NULL;
  1157 			CArrayFixFlat<TApaAppServiceInfo>* implArray = NULL;
  1929 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  1158 			CArrayFixFlat<TApaAppServiceInfo>& serviceArray = *(app->iServiceArray);
  2473 	// if it is a language change event, start a rescan on app-list.
  1702 	// if it is a language change event, start a rescan on app-list.
  2474 	if (status.Int() == EChangesLocale && iPrevLanguage != User::Language())
  1703 	if (status.Int() == EChangesLocale && iPrevLanguage != User::Language())
  2475 		{		
  1704 		{		
  2476 		iPrevLanguage = User::Language();
  1705 		iPrevLanguage = User::Language();
  2477 		iAppList.iFlags |= CApaAppList::ELangChangePending;
  1706 		iAppList.iFlags |= CApaAppList::ELangChangePending;
  2478 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK		
       
  2479 		iAppList.InitializeLangAppListL();
       
  2480 #endif
       
  2481 		iAppList.StartIdleUpdateL(iAppList.iObserver);
  1707 		iAppList.StartIdleUpdateL(iAppList.iObserver);
  2482 		}
  1708 		}
  2483 	}
  1709 	}
  2484 
  1710 
  2485 TInt CApaAppList::CApaLangChangeMonitor::RunError(TInt /*aError*/)
  1711 TInt CApaAppList::CApaLangChangeMonitor::RunError(TInt /*aError*/)