appfw/apparchitecture/apserv/APSSERV.CPP
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
equal deleted inserted replaced
62:924385140d98 63:c2c61fdca848
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-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".
    24 #include <u32hal.h>
    24 #include <u32hal.h>
    25 #include "apsserv.h"
    25 #include "apsserv.h"
    26 #include "APFREC.H"
    26 #include "APFREC.H"
    27 #include "APSSES.H"
    27 #include "APSSES.H"
    28 #include "APSSTD.H"
    28 #include "APSSTD.H"
       
    29 #include "../aplist/aplappregfinder.h"
    29 #include "../aplist/aplapplistitem.h"
    30 #include "../aplist/aplapplistitem.h"
    30 #include "APSSCAN.H"
    31 #include "APSSCAN.H"
    31 #include "APSSTD.H"
    32 #include "APSSTD.H"
    32 #include "APASVST.H"
    33 #include "APASVST.H"
    33 #include <datastor.h>
    34 #include <datastor.h>
    34 #include "APSRECCACHE.h"
    35 #include "APSRECCACHE.h"
       
    36 #include "apsnnapps.h"
       
    37 #include "../apfile/apinstallationmonitor.h"
    35 #include "../apgrfx/apprivate.h"
    38 #include "../apgrfx/apprivate.h"
    36 #include "apgnotif.h"
    39 #include "apgnotif.h"
    37 
    40 
    38 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    39 #include<usif/scr/scr.h>
       
    40 #include<usif/scr/appregentries.h>
       
    41 #include<swi/sisregistrysession.h>
       
    42 #else
       
    43 #include "../aplist/aplappregfinder.h"
       
    44 #include "apsnnapps.h"
       
    45 #include "../apfile/apinstallationmonitor.h"
       
    46 #endif
       
    47 
       
    48 
       
    49 _LIT(KAppArcServerSemaphore,"AppArcServerSemaphore");
    41 _LIT(KAppArcServerSemaphore,"AppArcServerSemaphore");
    50 _LIT(KAppArcServerThread,"AppArcServerThread");
    42 _LIT(KAppArcServerThread,"AppArcServerThread");
    51 
       
    52 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    53 _LIT(KAppRegistrationFileImportLocation, "?:\\private\\10003a3f\\import\\apps\\");
    43 _LIT(KAppRegistrationFileImportLocation, "?:\\private\\10003a3f\\import\\apps\\");
    54 _LIT(KAppResourceAppsLocation, "?:\\resource\\apps\\");
    44 _LIT(KAppResourceAppsLocation, "?:\\resource\\apps\\");
    55 _LIT(KNonNativeApplicationTypeRegistry, ":\\private\\10003a3f\\NonNativeTypes.dat");
    45 _LIT(KNonNativeApplicationTypeRegistry, ":\\private\\10003a3f\\NonNativeTypes.dat");
    56 
       
    57 //To monitor all drives.
       
    58 const TInt KApaMonitorAllDrives = 0x3FFFFFF;
       
    59 #endif
       
    60 
    46 
    61 /*
    47 /*
    62  * patchable const data values defined in ApsConstData.cpp
    48  * patchable const data values defined in ApsConstData.cpp
    63  */
    49  */
    64 
    50 
    66 IMPORT_C extern const TInt KApaUnloadRecognizersTimeout;
    52 IMPORT_C extern const TInt KApaUnloadRecognizersTimeout;
    67 IMPORT_C extern const TInt KApaDrivesToMonitor;
    53 IMPORT_C extern const TInt KApaDrivesToMonitor;
    68 IMPORT_C extern const TInt KApaLoadMbmIconsOnDemand;
    54 IMPORT_C extern const TInt KApaLoadMbmIconsOnDemand;
    69 
    55 
    70 const TUint8 KPolicyElementWriteDeviceData = 0;
    56 const TUint8 KPolicyElementWriteDeviceData = 0;
       
    57 
       
    58 //To monitor all drives.
       
    59 const TInt KApaMonitorAllDrives = 0x3FFFFFF;
    71 
    60 
    72 const TUint KRangeCount = 3; 
    61 const TUint KRangeCount = 3; 
    73 
    62 
    74 const TInt KAppListServRanges[KRangeCount] = 
    63 const TInt KAppListServRanges[KRangeCount] = 
    75 	{	
    64 	{	
   148 CApaAppArcServer::CApaAppArcServer(TInt aPriority)
   137 CApaAppArcServer::CApaAppArcServer(TInt aPriority)
   149 	: CPolicyServer(aPriority,KApaServPolicy),
   138 	: CPolicyServer(aPriority,KApaServPolicy),
   150 	iAppList(0),
   139 	iAppList(0),
   151 	iTypeStoreModified(0),
   140 	iTypeStoreModified(0),
   152 	iLoadRecognizersOnDemand(KApaLoadDataRecognizersOnDemand),
   141 	iLoadRecognizersOnDemand(KApaLoadDataRecognizersOnDemand),
   153 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
   142 	iLoadMbmIconsOnDemand(KApaLoadMbmIconsOnDemand),
   154 	iForceRegistrationStatus(EForceRegistrationNone),
   143 	iForceRegistrationStatus(EForceRegistrationNone)
   155 #endif
       
   156 	iLoadMbmIconsOnDemand(KApaLoadMbmIconsOnDemand)
       
   157 	{
   144 	{
   158 	
   145 	
   159 #ifdef __WINS__
   146 #ifdef __WINS__
   160 	// KApaLoadDataRecognizersOnDemand and KApaloadIconsOnDemand are Rom patchable constants,
   147 	// KApaLoadDataRecognizersOnDemand and KApaloadIconsOnDemand are Rom patchable constants,
   161 	// so need an emulator equivalent
   148 	// so need an emulator equivalent
   174 void CApaAppArcServer::ConstructL()
   161 void CApaAppArcServer::ConstructL()
   175 	{
   162 	{
   176 	StartL(KAppListServerName);
   163 	StartL(KAppListServerName);
   177 	User::LeaveIfError(Dll::SetTls(this));
   164 	User::LeaveIfError(Dll::SetTls(this));
   178 	User::LeaveIfError(iFs.Connect());
   165 	User::LeaveIfError(iFs.Connect());
   179 
   166 		
   180 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   181     //Connect to sisregistrysession to initially populate the applications information and 
       
   182     //store it to SCR. 
       
   183     Swi::RSisRegistrySession sisReg;
       
   184     sisReg.Connect();
       
   185     sisReg.Close();
       
   186 #endif
       
   187 
       
   188     
       
   189 	// Get the idle timeout delay from the commandline if specified. The default is 50000ms
   167 	// Get the idle timeout delay from the commandline if specified. The default is 50000ms
   190 	const TInt cmdLineLen = User::CommandLineLength();
   168 	const TInt cmdLineLen = User::CommandLineLength();
   191 	TInt idlePeriodicDelay=50000; //default value
   169 	TInt idlePeriodicDelay=50000; //default value
   192 	if(cmdLineLen)
   170 	if(cmdLineLen)
   193 		{
   171 		{
   246 		iRuleBasedPlugIns = CApaScanningRuleBasedPlugIns::NewL();
   224 		iRuleBasedPlugIns = CApaScanningRuleBasedPlugIns::NewL();
   247 		}
   225 		}
   248 	
   226 	
   249 	iAppList=CApaAppList::NewL(iFs, iLoadMbmIconsOnDemand, idlePeriodicDelay); // takes ownership of scanner
   227 	iAppList=CApaAppList::NewL(iFs, iLoadMbmIconsOnDemand, idlePeriodicDelay); // takes ownership of scanner
   250 
   228 
   251 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   252 	// If the phone rebooted halfway through processing updates, there will be a log file left
   229 	// If the phone rebooted halfway through processing updates, there will be a log file left
   253 	// look for one and recover if neccessary
   230 	// look for one and recover if neccessary
   254 	CApsNonNativeApplicationsManager::RecoverFromUpdateLogL(iFs);
   231 	CApsNonNativeApplicationsManager::RecoverFromUpdateLogL(iFs);
   255 #endif	
       
   256 
   232 
   257 	iMimeTypeRecognizer=CApaScanningDataRecognizer::NewL(iFs, !iLoadRecognizersOnDemand);
   233 	iMimeTypeRecognizer=CApaScanningDataRecognizer::NewL(iFs, !iLoadRecognizersOnDemand);
   258 
   234 
   259 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   260 	ConstructPathsToMonitorL();	
   235 	ConstructPathsToMonitorL();	
   261 
   236 
   262 	if ( iAppFsMonitor )
   237 	if ( iAppFsMonitor )
   263 		{
   238 		{
   264 		iAppFsMonitor->Start(ENotifyFile);
   239 		iAppFsMonitor->Start(ENotifyFile);
   265 		iAppFsMonitor->SetBlocked(ETrue);			
   240 		iAppFsMonitor->SetBlocked(ETrue);			
   266 		}
   241 		}
   267 #endif
       
   268 	
       
   269 	TRAP_IGNORE(iAppList->InitListL(this));
   242 	TRAP_IGNORE(iAppList->InitListL(this));
   270 	
   243 	
   271 	//
   244 	//
   272 	iRecEcomMonitor=CApaEComMonitor::NewL(TCallBack(&PlugInNotifyCallBack,this));
   245 	iRecEcomMonitor=CApaEComMonitor::NewL(TCallBack(&PlugInNotifyCallBack,this));
   273 	iRecEcomMonitor->Start();
   246 	iRecEcomMonitor->Start();
   285 
   258 
   286 	//
   259 	//
   287 	iBaBackupSessionWrapper=CBaBackupSessionWrapper::NewL();
   260 	iBaBackupSessionWrapper=CBaBackupSessionWrapper::NewL();
   288 	iBaBackupSessionWrapper->RegisterBackupOperationObserverL(*((MBackupOperationObserver*)this));
   261 	iBaBackupSessionWrapper->RegisterBackupOperationObserverL(*((MBackupOperationObserver*)this));
   289 
   262 
   290 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   263 	//
   291 	TRAP_IGNORE(InitNonNativeApplicationTypeArrayL());
   264 	TChar sysDrive = RFs::GetSystemDriveChar();
   292 #else
   265 	TInt maxSizeofFileName = KNonNativeApplicationTypeRegistry().Length() + 1;
   293     //
   266 	iNonNativeApplicationTypeRegistry.CreateL(maxSizeofFileName);
   294     TChar sysDrive = RFs::GetSystemDriveChar();
   267 	iNonNativeApplicationTypeRegistry.Append(sysDrive);
   295     TInt maxSizeofFileName = KNonNativeApplicationTypeRegistry().Length() + 1;
   268 	iNonNativeApplicationTypeRegistry.Append(KNonNativeApplicationTypeRegistry());
   296     iNonNativeApplicationTypeRegistry.CreateL(maxSizeofFileName);
   269 
   297     iNonNativeApplicationTypeRegistry.Append(sysDrive);
   270 	TRAP_IGNORE(InternalizeNonNativeApplicationTypeArrayL());	// We don't want a corrupt file to prevent from starting
   298     iNonNativeApplicationTypeRegistry.Append(KNonNativeApplicationTypeRegistry());
       
   299 	
       
   300     TRAP_IGNORE(InternalizeNonNativeApplicationTypeArrayL());   // We don't want a corrupt file to prevent from starting	
       
   301 #endif
       
   302     
       
   303 	if(iLoadRecognizersOnDemand)
   271 	if(iLoadRecognizersOnDemand)
   304 		iRecognizerUnloadTimer=CPeriodic::NewL(EPriorityNormal);
   272 		iRecognizerUnloadTimer=CPeriodic::NewL(EPriorityNormal);
   305 
   273 
   306 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   274 	//
   307 	iAppInstallationMonitor = CApaAppInstallationMonitor::NewL(this);
   275 	iAppInstallationMonitor = CApaAppInstallationMonitor::NewL(this);
   308 	iAppInstallationMonitor->Start();
   276 	iAppInstallationMonitor->Start();
   309 #endif	
   277 	}
   310 	}
   278 	
   311 	
       
   312 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   313 void CApaAppArcServer::ConstructPathsToMonitorL()
   279 void CApaAppArcServer::ConstructPathsToMonitorL()
   314 	{
   280 	{
   315 	TInt drivesToMonitor = KApaDrivesToMonitor;
   281 	TInt drivesToMonitor = KApaDrivesToMonitor;
   316 	#ifdef __WINS__
   282 	#ifdef __WINS__
   317 	// KApaDrivesToMonitor is a Rom patchable constant, so need an emulator equivalent
   283 	// KApaDrivesToMonitor is a Rom patchable constant, so need an emulator equivalent
   369 		{
   335 		{
   370 		iAppFsMonitor=CApaFsMonitor::NewL(iFs, KAppRegistrationFileImportLocation, TCallBack(&AppFsNotifyCallBack, this));
   336 		iAppFsMonitor=CApaFsMonitor::NewL(iFs, KAppRegistrationFileImportLocation, TCallBack(&AppFsNotifyCallBack, this));
   371 		iAppFsMonitor->AddLocationL(KAppResourceAppsLocation);
   337 		iAppFsMonitor->AddLocationL(KAppResourceAppsLocation);
   372 		}	
   338 		}	
   373 	}
   339 	}
   374 #endif
   340 	
   375 
       
   376 EXPORT_C CApaAppArcServer::~CApaAppArcServer()
   341 EXPORT_C CApaAppArcServer::~CApaAppArcServer()
   377 	{
   342 	{
   378 	if(iBaBackupSessionWrapper)
   343 	if(iBaBackupSessionWrapper)
   379 		iBaBackupSessionWrapper->DeRegisterBackupOperationObserver(*this);
   344 		iBaBackupSessionWrapper->DeRegisterBackupOperationObserver(*this);
   380 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   381 	delete iAppInstallationMonitor;
   345 	delete iAppInstallationMonitor;
   382     delete iAppFsMonitor;
       
   383     iNonNativeApplicationTypeRegistry.Close();    
       
   384 #endif
       
   385 	delete iAppList; // deletes scanners
   346 	delete iAppList; // deletes scanners
   386 	delete iMimeTypeRecognizer;
   347 	delete iMimeTypeRecognizer;
   387 	delete iMimeTypeToAppMappingsManager;
   348 	delete iMimeTypeToAppMappingsManager;
       
   349 	delete iAppFsMonitor;	
   388 	delete iTypeStoreMonitor;
   350 	delete iTypeStoreMonitor;
   389 	delete iBaBackupSessionWrapper;
   351 	delete iBaBackupSessionWrapper;
   390 	delete iRecognitionCache;
   352 	delete iRecognitionCache;
   391 	delete iRecEcomMonitor;
   353 	delete iRecEcomMonitor;
   392 
   354 
   397 		delete iNonNativeApplicationTypeArray[i].iNativeExecutable;
   359 		delete iNonNativeApplicationTypeArray[i].iNativeExecutable;
   398 
   360 
   399 	iNonNativeApplicationTypeArray.Close();
   361 	iNonNativeApplicationTypeArray.Close();
   400 
   362 
   401 	delete iRecognizerUnloadTimer;
   363 	delete iRecognizerUnloadTimer;
   402 	}
   364 	iNonNativeApplicationTypeRegistry.Close();
   403 
   365 	}
   404 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  
   366 
   405 EXPORT_C void CApaAppArcServer::HandleInstallationStartEvent()
   367 EXPORT_C void CApaAppArcServer::HandleInstallationStartEvent()
   406 	{
   368 	{
   407 	if ( iAppFsMonitor )
   369 	if ( iAppFsMonitor )
   408 		{
   370 		{
   409 		iAppFsMonitor->SetBlocked(ETrue);	
   371 		iAppFsMonitor->SetBlocked(ETrue);	
   417 		{
   379 		{
   418 		iAppFsMonitor->SetBlocked(EFalse);	
   380 		iAppFsMonitor->SetBlocked(EFalse);	
   419 		}
   381 		}
   420 	AppList().RestartScanL();
   382 	AppList().RestartScanL();
   421 	}
   383 	}
   422 #endif
       
   423 
   384 
   424 CSession2* CApaAppArcServer::NewSessionL(const TVersion& aVersion,const RMessage2&/* aMessage*/) const
   385 CSession2* CApaAppArcServer::NewSessionL(const TVersion& aVersion,const RMessage2&/* aMessage*/) const
   425 // Create a new server session.
   386 // Create a new server session.
   426 	{
   387 	{
   427 	// check we're the right version
   388 	// check we're the right version
   433 	}
   394 	}
   434 
   395 
   435 //
   396 //
   436 // scanning code here
   397 // scanning code here
   437 //
   398 //
   438 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   399 
   439 EXPORT_C TCallBack CApaAppArcServer::RescanCallBack()
   400 EXPORT_C TCallBack CApaAppArcServer::RescanCallBack()
   440 	{
   401 	{
   441 	return TCallBack(&AppFsNotifyWithForcedRegistrationsResetCallBack,this);
   402 	return TCallBack(&AppFsNotifyWithForcedRegistrationsResetCallBack,this);
   442 	}
   403 	}
   443 
   404 
   452 	{
   413 	{
   453 	ASSERT(aObject);
   414 	ASSERT(aObject);
   454 	reinterpret_cast<CApaAppArcServer*>(aObject)->UpdateApps();
   415 	reinterpret_cast<CApaAppArcServer*>(aObject)->UpdateApps();
   455 	return KErrNone;
   416 	return KErrNone;
   456 	}
   417 	}
   457 #endif
       
   458 
   418 
   459 TInt CApaAppArcServer::PlugInNotifyCallBack(TAny* aObject)
   419 TInt CApaAppArcServer::PlugInNotifyCallBack(TAny* aObject)
   460 	{
   420 	{
   461 	//update the pre-Platform-security style  recognizers and rule-based plug-ins
   421 	//update the pre-Platform-security style  recognizers and rule-based plug-ins
   462 	ASSERT(aObject);
   422 	ASSERT(aObject);
   469 	ASSERT(aObject);
   429 	ASSERT(aObject);
   470 	reinterpret_cast<CApaAppArcServer*>(aObject)->UpdateTypeStore();
   430 	reinterpret_cast<CApaAppArcServer*>(aObject)->UpdateTypeStore();
   471 	return KErrNone;
   431 	return KErrNone;
   472 	}
   432 	}
   473 
   433 
   474 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   475 void CApaAppArcServer::UpdateApps()
   434 void CApaAppArcServer::UpdateApps()
   476 // update the list
   435 // update the list
   477 	{
   436 	{
   478 	// File system change, rescan
   437 	// File system change, rescan
   479 	TRAP_IGNORE(iAppList->StartIdleUpdateL (this));
   438 	TRAP_IGNORE(iAppList->StartIdleUpdateL (this));
   485  
   444  
   486 void CApaAppArcServer::UpdateAppsByForceRegistration()
   445 void CApaAppArcServer::UpdateAppsByForceRegistration()
   487     {
   446     {
   488     iForceRegistrationStatus|=EForceRegistrationRequested;
   447     iForceRegistrationStatus|=EForceRegistrationRequested;
   489     UpdateApps();
   448     UpdateApps();
   490     }	
   449     }
   491 #endif
       
   492 
   450 
   493 void CApaAppArcServer::NotifyUpdate(TInt aReason)
   451 void CApaAppArcServer::NotifyUpdate(TInt aReason)
   494 // tell all sessions to update their clients
   452 // tell all sessions to update their clients
   495 	{
   453 	{
   496 	// Updates the applist with the icon caption details from the Central Repository.
   454 	// Updates the applist with the icon caption details from the Central Repository.
   520         
   478         
   521         //If service registry is modified, store it to a file
   479         //If service registry is modified, store it to a file
   522         if(modificationStatus)
   480         if(modificationStatus)
   523             TRAP_IGNORE(iMimeTypeToAppMappingsManager->StoreL());
   481             TRAP_IGNORE(iMimeTypeToAppMappingsManager->StoreL());
   524         }
   482         }
   525    
   483     
   526 	// iterate through sessions
   484 	// iterate through sessions
   527 	iSessionIter.SetToFirst();
   485 	iSessionIter.SetToFirst();
   528 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   486 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   529 	
       
   530 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   531     //Get the updated application information from iAppList
       
   532     CArrayFixFlat<TApaAppUpdateInfo>* updatedAppsInfo=iAppList->UpdatedAppsInfo();
       
   533 
       
   534     while (ses!=NULL)
       
   535         {
       
   536         //Call session object NotifyClients and pass the updated application information.
       
   537         ses->NotifyClients(aReason, updatedAppsInfo);    
       
   538         ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
       
   539         }
       
   540 #else
       
   541 	
       
   542 	while (ses!=NULL)
   487 	while (ses!=NULL)
   543 		{
   488 		{
   544 		if(iForceRegistrationStatus & EForceRegistrationRequested)
   489 		if(iForceRegistrationStatus & EForceRegistrationRequested)
   545             {
   490             {
   546              //Notify clients about completion of force registration. 
   491              //Notify clients about completion of force registration. 
   563      else
   508      else
   564          {
   509          {
   565          //If this function is called not because of force registration, clear force registration applist change status. 
   510          //If this function is called not because of force registration, clear force registration applist change status. 
   566         iForceRegistrationStatus &= (~EForceRegistrationAppListChanged);        
   511         iForceRegistrationStatus &= (~EForceRegistrationAppListChanged);        
   567          }
   512          }
   568 #endif     
       
   569 	}
   513 	}
   570 
   514 
   571 void CApaAppArcServer::UpdatePlugIns()
   515 void CApaAppArcServer::UpdatePlugIns()
   572 // update the pre-Platform-security style, ecom style recognizers and rule-based plug-ins
   516 // update the pre-Platform-security style, ecom style recognizers and rule-based plug-ins
   573 	{
   517 	{
   630 		{
   574 		{
   631 	case MBackupOperationObserver::ENone:
   575 	case MBackupOperationObserver::ENone:
   632 	case MBackupOperationObserver::EAbort:
   576 	case MBackupOperationObserver::EAbort:
   633 		break;
   577 		break;
   634 	case MBackupOperationObserver::EStart:
   578 	case MBackupOperationObserver::EStart:
   635 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK   
       
   636 		if ( iAppFsMonitor )
   579 		if ( iAppFsMonitor )
   637 			{
   580 			{
   638 			iAppFsMonitor->SetBlocked(ETrue);	
   581 			iAppFsMonitor->SetBlocked(ETrue);	
   639 			}
   582 			}
   640 #endif		
       
   641 		break;
   583 		break;
   642 	case MBackupOperationObserver::EEnd:
   584 	case MBackupOperationObserver::EEnd:
   643 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	    
       
   644 		if ( iAppFsMonitor )
   585 		if ( iAppFsMonitor )
   645 			{
   586 			{
   646 			iAppFsMonitor->SetBlocked(EFalse);	
   587 			iAppFsMonitor->SetBlocked(EFalse);	
   647 			}
   588 			}
   648 #endif		
       
   649 		break;
   589 		break;
   650 	default:
   590 	default:
   651 		Panic(EEventFromBackupObserverError);
   591 		Panic(EEventFromBackupObserverError);
   652 		break;
   592 		break;
   653 		}
   593 		}
   654 	}
   594 	}
   655 
   595 
   656 void CApaAppArcServer::InitialListPopulationComplete()
   596 void CApaAppArcServer::InitialListPopulationComplete()
   657 	{
   597 	{
   658 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
       
   659 	if ( iAppFsMonitor )
   598 	if ( iAppFsMonitor )
   660 		{
   599 		{
   661 		iAppFsMonitor->SetBlocked(EFalse);	
   600 		iAppFsMonitor->SetBlocked(EFalse);	
   662 		}
   601 		}
   663 #endif	
       
   664 	
   602 	
   665 	// notify clients (whoever is interested) that initial population of list is completed
   603 	// notify clients (whoever is interested) that initial population of list is completed
   666 	iSessionIter.SetToFirst();
   604 	iSessionIter.SetToFirst();
   667 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   605 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   668 	// iterate through sessions
   606 	// iterate through sessions
   671 		ses->NotifyClientForCompletionOfListPopulation();	
   609 		ses->NotifyClientForCompletionOfListPopulation();	
   672 		ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   610 		ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   673 		}
   611 		}
   674 	}
   612 	}
   675 
   613 
   676 
       
   677 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   678 
       
   679 /* 
       
   680  * Cleanup RPointerArray
       
   681  */
       
   682 void CleanupAndDestroyLauncherArray(TAny* aRPrray)
       
   683     {
       
   684     RPointerArray<Usif::CLauncherExecutable>* rpArray = (static_cast<RPointerArray<Usif::CLauncherExecutable>*>(aRPrray));
       
   685     rpArray->ResetAndDestroy();
       
   686     rpArray->Close();
       
   687     }
       
   688 
       
   689 
       
   690 /* 
       
   691  * Gets non-native type to its run time mapping information from SCR and initialzes 
       
   692  * a mapping array
       
   693  */
       
   694 void CApaAppArcServer::InitNonNativeApplicationTypeArrayL()
       
   695     {
       
   696      Usif::RSoftwareComponentRegistry scrSession;
       
   697      User::LeaveIfError(scrSession.Connect());
       
   698      CleanupClosePushL(scrSession);
       
   699      
       
   700      RPointerArray<Usif::CLauncherExecutable> launchers;
       
   701      //Get non-native type to its run-time mappings 
       
   702      scrSession.GetApplicationLaunchersL(launchers);
       
   703      TCleanupItem cleanup(CleanupAndDestroyLauncherArray, &launchers); 
       
   704      CleanupStack::PushL(cleanup);     
       
   705 
       
   706      //Get each mapping and add it to mapping array
       
   707      for(TInt index=0;index<launchers.Count();index++)
       
   708          {
       
   709          Usif::CLauncherExecutable* launcherInfo=launchers[index];
       
   710          SNonNativeApplicationType nonNativeApplicationType;
       
   711          nonNativeApplicationType.iTypeUid.iUid=launcherInfo->TypeId();
       
   712          nonNativeApplicationType.iNativeExecutable=launcherInfo->Launcher().AllocLC();
       
   713          iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType);
       
   714          CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable);     
       
   715          }
       
   716      CleanupStack::PopAndDestroy(2, &scrSession);
       
   717     }
       
   718 
       
   719 void CApaAppArcServer::UpdateAppListL(RArray<TApaAppUpdateInfo>* aAppUpdateInfo, TUid aSecureID)
       
   720 {
       
   721    iAppList->UpdateApplistL(this, aAppUpdateInfo, aSecureID);
       
   722 }
       
   723 #else
       
   724 
       
   725 void CApaAppArcServer::RegisterNonNativeApplicationTypeL(TUid aApplicationType, const TDesC& aNativeExecutable)
   614 void CApaAppArcServer::RegisterNonNativeApplicationTypeL(TUid aApplicationType, const TDesC& aNativeExecutable)
   726     {
   615 	{
   727     for (TInt i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   616 	for (TInt i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   728         {
   617 		{
   729         if (iNonNativeApplicationTypeArray[i].iTypeUid.iUid==aApplicationType.iUid)
   618 		if (iNonNativeApplicationTypeArray[i].iTypeUid.iUid==aApplicationType.iUid)
   730             User::Leave(KErrAlreadyExists);
   619 			User::Leave(KErrAlreadyExists);
   731         }
   620 		}
   732         
   621 		
   733     SNonNativeApplicationType nonNativeApplicationType;
   622 	SNonNativeApplicationType nonNativeApplicationType;
   734     nonNativeApplicationType.iTypeUid.iUid=aApplicationType.iUid;
   623 	nonNativeApplicationType.iTypeUid.iUid=aApplicationType.iUid;
   735     nonNativeApplicationType.iNativeExecutable=aNativeExecutable.AllocLC();
   624 	nonNativeApplicationType.iNativeExecutable=aNativeExecutable.AllocLC();
   736     iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType);
   625 	iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType);
   737     CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable);
   626 	CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable);
   738     CleanupStack::PushL(TCleanupItem(DeleteLastNonNativeApplicationType, this));
   627 	CleanupStack::PushL(TCleanupItem(DeleteLastNonNativeApplicationType, this));
   739     ExternalizeNonNativeApplicationTypeArrayL();
   628 	ExternalizeNonNativeApplicationTypeArrayL();
   740     CleanupStack::Pop(this); // the TCleanupItem
   629 	CleanupStack::Pop(this); // the TCleanupItem
   741     }
   630 	}
   742 
   631 
   743 void CApaAppArcServer::DeregisterNonNativeApplicationTypeL(TUid aApplicationType)
   632 void CApaAppArcServer::DeregisterNonNativeApplicationTypeL(TUid aApplicationType)
   744     {
   633 	{
   745     TInt i;
   634 	TInt i;
   746     for (i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   635 	for (i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   747         {
   636 		{
   748         if (iNonNativeApplicationTypeArray[i].iTypeUid.iUid==aApplicationType.iUid)
   637 		if (iNonNativeApplicationTypeArray[i].iTypeUid.iUid==aApplicationType.iUid)
   749             break;
   638 			break;
   750         }
   639 		}
   751         
   640 		
   752     if (i>=0)
   641 	if (i>=0)
   753         {
   642 		{
   754         ExternalizeNonNativeApplicationTypeArrayL(i);
   643 		ExternalizeNonNativeApplicationTypeArrayL(i);
   755         delete iNonNativeApplicationTypeArray[i].iNativeExecutable;
   644 		delete iNonNativeApplicationTypeArray[i].iNativeExecutable;
   756         iNonNativeApplicationTypeArray[i].iNativeExecutable = NULL;
   645 		iNonNativeApplicationTypeArray[i].iNativeExecutable = NULL;
   757         iNonNativeApplicationTypeArray.Remove(i);
   646 		iNonNativeApplicationTypeArray.Remove(i);
   758         }
   647 		}
   759     }
   648 	}
   760 
   649 
   761 void CApaAppArcServer::InternalizeNonNativeApplicationTypeArrayL()
   650 void CApaAppArcServer::InternalizeNonNativeApplicationTypeArrayL()
   762 	{
   651 	{
   763 	RFile file;
   652 	RFile file;
   764 	CleanupClosePushL(file);
   653 	CleanupClosePushL(file);
   782 		}
   671 		}
   783 		
   672 		
   784 	CleanupStack::PopAndDestroy(&file);
   673 	CleanupStack::PopAndDestroy(&file);
   785 	}
   674 	}
   786 
   675 
   787 
       
   788 void CApaAppArcServer::ExternalizeNonNativeApplicationTypeArrayL(TInt aIndexToIgnore/*=-1*/) const
   676 void CApaAppArcServer::ExternalizeNonNativeApplicationTypeArrayL(TInt aIndexToIgnore/*=-1*/) const
   789     {
   677 	{
   790     RFs& fs=const_cast<RFs&>(iFs);
   678 	RFs& fs=const_cast<RFs&>(iFs);
   791     fs.MkDirAll(iNonNativeApplicationTypeRegistry); // ignore any error
   679 	fs.MkDirAll(iNonNativeApplicationTypeRegistry); // ignore any error
   792     RFile file;
   680 	RFile file;
   793     CleanupClosePushL(file);
   681 	CleanupClosePushL(file);
   794     User::LeaveIfError(file.Replace(fs, iNonNativeApplicationTypeRegistry, EFileShareExclusive|EFileStream|EFileWrite));
   682 	User::LeaveIfError(file.Replace(fs, iNonNativeApplicationTypeRegistry, EFileShareExclusive|EFileStream|EFileWrite));
   795     RFileWriteStream targetStream;
   683 	RFileWriteStream targetStream;
   796     targetStream.Attach(file); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns)
   684 	targetStream.Attach(file); // file gets closed by this call, but that's okay, we don't need it any more (targetStream has its own copy of this RFile object that it owns)
   797     CleanupClosePushL(targetStream);
   685 	CleanupClosePushL(targetStream);
   798     const TInt arrayCount(iNonNativeApplicationTypeArray.Count());
   686 	const TInt arrayCount(iNonNativeApplicationTypeArray.Count());
   799     TInt arrayCountToExternalize=arrayCount;
   687 	TInt arrayCountToExternalize=arrayCount;
   800     if (aIndexToIgnore>=0)
   688 	if (aIndexToIgnore>=0)
   801         --arrayCountToExternalize;
   689 		--arrayCountToExternalize;
   802 
   690 
   803     TCardinality(arrayCountToExternalize).ExternalizeL(targetStream);
   691 	TCardinality(arrayCountToExternalize).ExternalizeL(targetStream);
   804     for (TInt i=0; i<arrayCount; ++i)
   692 	for (TInt i=0; i<arrayCount; ++i)
   805         {
   693 		{
   806         if (i!=aIndexToIgnore)
   694 		if (i!=aIndexToIgnore)
   807             {
   695 			{
   808             const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i];
   696 			const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i];
   809             targetStream.WriteUint32L(nonNativeApplicationType.iTypeUid.iUid);
   697 			targetStream.WriteUint32L(nonNativeApplicationType.iTypeUid.iUid);
   810             targetStream << *nonNativeApplicationType.iNativeExecutable;
   698 			targetStream << *nonNativeApplicationType.iNativeExecutable;
   811             }
   699 			}
   812         }
   700 		}
   813         
   701 		
   814     targetStream.CommitL();
   702 	targetStream.CommitL();
   815     CleanupStack::PopAndDestroy(2, &file);
   703 	CleanupStack::PopAndDestroy(2, &file);
   816     }
   704 	}
   817 #endif
   705 
   818 
   706 TPtrC CApaAppArcServer::NativeExecutableL(TUid aNonNativeApplicationType) const
   819 TPtrC CApaAppArcServer::NativeExecutableL(TUid aNonNativeApplicationType)
       
   820 	{
   707 	{
   821 	for (TInt i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   708 	for (TInt i=iNonNativeApplicationTypeArray.Count()-1; i>=0; --i)
   822 		{
   709 		{
   823 		const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i];
   710 		const SNonNativeApplicationType& nonNativeApplicationType=iNonNativeApplicationTypeArray[i];
   824 		if (nonNativeApplicationType.iTypeUid.iUid==aNonNativeApplicationType.iUid)
   711 		if (nonNativeApplicationType.iTypeUid.iUid==aNonNativeApplicationType.iUid)
   825 			return *nonNativeApplicationType.iNativeExecutable;
   712 			return *nonNativeApplicationType.iNativeExecutable;
   826 		}
   713 		}
   827 
   714 		
   828 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   829 	//If the mapping is not available in the list, search in SCR and add it to the list.
       
   830 	TPtrC nativeExecutableName=FindAndAddNonNativeRuntimeMappingL(aNonNativeApplicationType);
       
   831 	if(nativeExecutableName==KNullDesC())
       
   832 	    User::Leave(KErrNotSupported); // not KErrNotFound
       
   833 
       
   834 	return nativeExecutableName;
       
   835 #else
       
   836 	User::Leave(KErrNotSupported); // not KErrNotFound
   715 	User::Leave(KErrNotSupported); // not KErrNotFound
   837 	return KNullDesC();
   716 	return KNullDesC();
   838 #endif	
   717 	}
   839 	}
       
   840 
       
   841 
       
   842 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   843 TPtrC CApaAppArcServer::FindAndAddNonNativeRuntimeMappingL(TUid aNonNativeApplicationType)
       
   844 {
       
   845     //If non-native type to its runtime is not available search in SCR and update in list 
       
   846     Usif::RSoftwareComponentRegistry scrSession;
       
   847     User::LeaveIfError(scrSession.Connect());
       
   848     CleanupClosePushL(scrSession);
       
   849     
       
   850     RPointerArray<Usif::CLauncherExecutable> launchers;
       
   851     //Get non-native type to its run-time mappings 
       
   852     scrSession.GetApplicationLaunchersL(launchers);
       
   853     TCleanupItem cleanup(CleanupAndDestroyLauncherArray, &launchers); 
       
   854     CleanupStack::PushL(cleanup);     
       
   855 
       
   856     //Search for mapping and add it mapping list.
       
   857     for(TInt index=0;index<launchers.Count();index++)
       
   858         {
       
   859         Usif::CLauncherExecutable* launcherInfo=launchers[index];
       
   860         if(aNonNativeApplicationType.iUid==launcherInfo->TypeId())
       
   861             {
       
   862             SNonNativeApplicationType nonNativeApplicationType;
       
   863             nonNativeApplicationType.iTypeUid.iUid=launcherInfo->TypeId();
       
   864             nonNativeApplicationType.iNativeExecutable=launcherInfo->Launcher().AllocLC();
       
   865             iNonNativeApplicationTypeArray.AppendL(nonNativeApplicationType);
       
   866             CleanupStack::Pop(nonNativeApplicationType.iNativeExecutable);
       
   867             CleanupStack::PopAndDestroy(2, &scrSession);
       
   868             return *nonNativeApplicationType.iNativeExecutable;
       
   869             }
       
   870         }
       
   871     
       
   872     CleanupStack::PopAndDestroy(2, &scrSession);    
       
   873     return KNullDesC();
       
   874 }
       
   875 #endif
       
   876 
   718 
   877 void CApaAppArcServer::DeleteLastNonNativeApplicationType(TAny* aThis)
   719 void CApaAppArcServer::DeleteLastNonNativeApplicationType(TAny* aThis)
   878 	{ // static
   720 	{ // static
   879 	CApaAppArcServer& self=*static_cast<CApaAppArcServer*>(aThis);
   721 	CApaAppArcServer& self=*static_cast<CApaAppArcServer*>(aThis);
   880 	const TInt arrayIndex=self.iNonNativeApplicationTypeArray.Count()-1;
   722 	const TInt arrayIndex=self.iNonNativeApplicationTypeArray.Count()-1;
   892 	TRAP_IGNORE(iAppList->UpdateAppListByShortCaptionL());
   734 	TRAP_IGNORE(iAppList->UpdateAppListByShortCaptionL());
   893 
   735 
   894 	// iterate through sessions
   736 	// iterate through sessions
   895 	iSessionIter.SetToFirst();
   737 	iSessionIter.SetToFirst();
   896 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   738 	CApaAppArcServSession* ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
   897 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   898     while (ses)
       
   899         {
       
   900         ses->NotifyScanComplete();  
       
   901         ses=static_cast<CApaAppArcServSession*>(&(*iSessionIter++));
       
   902         }	
       
   903 #else
       
   904 	while (ses)
   739 	while (ses)
   905 		{
   740 		{
   906 		if((iForceRegistrationStatus & EForceRegistrationRequested) ||
   741 		if((iForceRegistrationStatus & EForceRegistrationRequested) ||
   907 	            !(iForceRegistrationStatus & EForceRegistrationAppListChanged))
   742 	            !(iForceRegistrationStatus & EForceRegistrationAppListChanged))
   908 		    {
   743 		    {
   923 	    //clear force registration applist change status. 
   758 	    //clear force registration applist change status. 
   924             iForceRegistrationStatus &= (~EForceRegistrationAppListChanged);	        
   759             iForceRegistrationStatus &= (~EForceRegistrationAppListChanged);	        
   925 	    }
   760 	    }
   926 	//Clear force registration request status
   761 	//Clear force registration request status
   927         iForceRegistrationStatus &= (~EForceRegistrationRequested);
   762         iForceRegistrationStatus &= (~EForceRegistrationRequested);
   928 #endif        
       
   929 	}
   763 	}
   930 
   764 
   931 /*
   765 /*
   932  * Data Recognizer calls
   766  * Data Recognizer calls
   933  */
   767  */