appfw/apparchitecture/apserv/APSSES.CPP
branchRCL_3
changeset 20 c2c61fdca848
parent 19 924385140d98
equal deleted inserted replaced
19:924385140d98 20:c2c61fdca848
    36 #include <s32mem.h>
    36 #include <s32mem.h>
    37 #include <s32strm.h>
    37 #include <s32strm.h>
    38 #include <s32file.h>
    38 #include <s32file.h>
    39 #include "../apgrfx/apprivate.h"
    39 #include "../apgrfx/apprivate.h"
    40 #include "apgnotif.h"
    40 #include "apgnotif.h"
       
    41 #include "../aplist/aplappregfinder.h"
    41 #include "ApLaunchChecker.h"
    42 #include "ApLaunchChecker.h"
       
    43 #include "apsnnapps.h"
    42 #include "../aplist/aplapplistitem.h"
    44 #include "../aplist/aplapplistitem.h"
    43 
    45 
    44 #include "apsecutils.h"
    46 #include "apsecutils.h"
    45 
       
    46 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    47 #include "../aplist/aplappregfinder.h"
       
    48 #include "apsnnapps.h"
       
    49 #else
       
    50 #include "usif/scr/scr.h"
       
    51 #endif
       
    52 
    47 
    53 const TInt KApaAppListServMaxBuffer=256;
    48 const TInt KApaAppListServMaxBuffer=256;
    54 #include "APSRECCACHE.h"
    49 #include "APSRECCACHE.h"
    55 const TInt KApaAppInfoArrayGranularity = 4;
    50 const TInt KApaAppInfoArrayGranularity = 4;
    56 const TInt KApaAppInfoDesMaxLength = sizeof(TApaAppInfo);
    51 const TInt KApaAppInfoDesMaxLength = sizeof(TApaAppInfo);
   150 	self->ConstructL();
   145 	self->ConstructL();
   151 	CleanupStack::Pop(self);
   146 	CleanupStack::Pop(self);
   152 	return self;
   147 	return self;
   153 	}
   148 	}
   154 
   149 
   155 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  
       
   156 CApaAppListServSession::CApaAppListServSession(RFs& aFs, CApaAppArcServer& aAppArcSrv, CApaAppList& aAppList)
   150 CApaAppListServSession::CApaAppListServSession(RFs& aFs, CApaAppArcServer& aAppArcSrv, CApaAppList& aAppList)
   157  : iFs(aFs), iAppArcSrv(aAppArcSrv), iAppList(aAppList), iApaAppInfoArray(KApaAppInfoArrayGranularity)
   151  : iFs(aFs), iAppArcSrv(aAppArcSrv), iAppList(aAppList), iApaAppInfoArray(KApaAppInfoArrayGranularity)
   158 	{
   152 	{
   159 
   153 
   160 	}
   154 	}
   161 #else
       
   162 CApaAppListServSession::CApaAppListServSession(RFs& aFs, CApaAppArcServer& aAppArcSrv, CApaAppList& aAppList)
       
   163  : iFs(aFs), iAppArcSrv(aAppArcSrv), iAppList(aAppList), iApaAppInfoArray(KApaAppInfoArrayGranularity), 
       
   164    iNotificationRequested(EFalse)
       
   165 	{
       
   166 
       
   167 	}
       
   168 #endif
       
   169 
   155 
   170 void CApaAppListServSession::ConstructL()
   156 void CApaAppListServSession::ConstructL()
   171 	{
   157 	{
   172 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
       
   173 	iNonNativeApplicationsManager = CApsNonNativeApplicationsManager::NewL(iAppArcSrv,iFs);
   158 	iNonNativeApplicationsManager = CApsNonNativeApplicationsManager::NewL(iAppArcSrv,iFs);
   174 #endif
       
   175 	}
   159 	}
   176 	
   160 	
   177 
   161 
   178 CApaAppListServSession::~CApaAppListServSession()
   162 CApaAppListServSession::~CApaAppListServSession()
   179 	{
   163 	{
   180 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
       
   181 	delete iNonNativeApplicationsManager;
   164 	delete iNonNativeApplicationsManager;
   182 #endif
       
   183 	iApaAppInfoArray.ResetAndDestroy();
   165 	iApaAppInfoArray.ResetAndDestroy();
   184 	iApaAppInfoArray.Close();
   166 	iApaAppInfoArray.Close();
   185 	}
   167 	}
   186 
   168 
   187 CApaAppList& CApaAppListServSession::AppList()
   169 CApaAppList& CApaAppListServSession::AppList()
   267 		break;
   249 		break;
   268 	case EAppListServApplicationLanguage:
   250 	case EAppListServApplicationLanguage:
   269 		ApplicationLanguageL(aMessage);
   251 		ApplicationLanguageL(aMessage);
   270 		break;
   252 		break;
   271 	case EAppListServAppInfoProvidedByRegistrationFile: // private OpCode for CEikApplication's use only
   253 	case EAppListServAppInfoProvidedByRegistrationFile: // private OpCode for CEikApplication's use only
   272 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   273 		AppInfoProvidedByRegistrationFileL(aMessage);
   254 		AppInfoProvidedByRegistrationFileL(aMessage);
   274 #else
       
   275 		ASSERT(0);  // panic debug only
       
   276         User::Leave(KErrNotSupported);
       
   277 #endif		
       
   278 		break;
   255 		break;
   279 	case EAppListServAppIconFileName:
   256 	case EAppListServAppIconFileName:
   280 		IconFileNameL(aMessage);
   257 		IconFileNameL(aMessage);
   281 		break;
   258 		break;
   282 	case EAppListServAppViewIconFileName:
   259 	case EAppListServAppViewIconFileName:
   283 		ViewIconFileNameL(aMessage);
   260 		ViewIconFileNameL(aMessage);
   284 		break;
   261 		break;	
   285 	case EAppListServPrepareNonNativeApplicationsUpdates:
   262 	case EAppListServPrepareNonNativeApplicationsUpdates:
   286 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   287 		iNonNativeApplicationsManager->PrepareNonNativeApplicationsUpdatesL();
   263 		iNonNativeApplicationsManager->PrepareNonNativeApplicationsUpdatesL();
   288 #else
       
   289         ASSERT(0);  // panic debug only
       
   290         User::Leave(KErrNotSupported);
       
   291 #endif		
       
   292 		break;
   264 		break;
   293 	case EAppListServRegisterNonNativeApplication:
   265 	case EAppListServRegisterNonNativeApplication:
   294 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   295 		iNonNativeApplicationsManager->RegisterNonNativeApplicationL(aMessage);
   266 		iNonNativeApplicationsManager->RegisterNonNativeApplicationL(aMessage);
   296 #else
       
   297         ASSERT(0);  // panic debug only
       
   298         User::Leave(KErrNotSupported);
       
   299 #endif		
       
   300 		break;
   267 		break;
   301 	case EAppListServDeregisterNonNativeApplication:
   268 	case EAppListServDeregisterNonNativeApplication:
   302 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   303 		iNonNativeApplicationsManager->DeregisterNonNativeApplicationL(aMessage);
   269 		iNonNativeApplicationsManager->DeregisterNonNativeApplicationL(aMessage);
   304 #else
       
   305         ASSERT(0);  // panic debug only
       
   306         User::Leave(KErrNotSupported);
       
   307 #endif
       
   308 		break;
   270 		break;
   309 	case EAppListServCommitNonNativeApplications:
   271 	case EAppListServCommitNonNativeApplications:
   310 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   311 		iNonNativeApplicationsManager->CommitNonNativeApplicationsUpdatesL(aMessage);
   272 		iNonNativeApplicationsManager->CommitNonNativeApplicationsUpdatesL(aMessage);
   312 		completeMessage=EFalse;
   273 		completeMessage=EFalse;
   313 #else
       
   314         ASSERT(0);  // panic debug only
       
   315         User::Leave(KErrNotSupported);
       
   316 #endif		
       
   317 		break;
   274 		break;
   318 	case EAppListServRollbackNonNativeApplications:
   275 	case EAppListServRollbackNonNativeApplications:
   319 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   320 		iNonNativeApplicationsManager->RollbackNonNativeApplicationsUpdates();
   276 		iNonNativeApplicationsManager->RollbackNonNativeApplicationsUpdates();
   321 #else
       
   322         ASSERT(0);  // panic debug only
       
   323         User::Leave(KErrNotSupported);
       
   324 #endif		
       
   325 		break;
   277 		break;
   326 	case EAppListServGetAppType:
   278 	case EAppListServGetAppType:
   327 		GetAppTypeL(aMessage);
   279 		GetAppTypeL(aMessage);
   328 		break;
   280 		break;
   329 	case EAppListServForceRegistration:
   281 	case EAppListServForceRegistration:
   330 		ForceRegistrationL(aMessage);
   282 		ForceRegistrationL(aMessage);
   331 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 		
       
   332 		completeMessage=EFalse;
   283 		completeMessage=EFalse;
   333 #endif		
       
   334 		break;
   284 		break;
   335 	case EMatchesSecurityPolicy:
   285 	case EMatchesSecurityPolicy:
   336 		MatchesSecurityPolicyL(aMessage);
   286 		MatchesSecurityPolicyL(aMessage);
   337 		break;
   287 		break;
   338 	case EAppListServSetAppShortCaption:
   288 	case EAppListServSetAppShortCaption:
   343 		iApaAppInfoArray.ResetAndDestroy();
   293 		iApaAppInfoArray.ResetAndDestroy();
   344 		iApaAppInfoArray.Compress();
   294 		iApaAppInfoArray.Compress();
   345 	#endif
   295 	#endif
   346 		break;
   296 		break;
   347 	case EDebugAddFailingNonNativeApplicationsUpdate:
   297 	case EDebugAddFailingNonNativeApplicationsUpdate:
   348 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   349 	#ifdef _DEBUG
   298 	#ifdef _DEBUG
   350 		iNonNativeApplicationsManager->ForceFailInNonNativeApplicationsUpdatesL();
   299 		iNonNativeApplicationsManager->ForceFailInNonNativeApplicationsUpdatesL();
   351 	#endif
   300 	#endif
   352 #endif
       
   353 		break;
   301 		break;
   354 	case EDebugAddPanicingNonNativeApplicationsUpdate:
   302 	case EDebugAddPanicingNonNativeApplicationsUpdate:
   355 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   356 	#ifdef _DEBUG
   303 	#ifdef _DEBUG
   357 		iNonNativeApplicationsManager->ForcePanicInNonNativeApplicationsUpdatesL();
   304 		iNonNativeApplicationsManager->ForcePanicInNonNativeApplicationsUpdatesL();
   358 	#endif
   305 	#endif
   359 #endif	
       
   360 		break;
   306 		break;
   361 	case EDebugAddRollbackPanicingNonNativeApplicationsUpdate:
   307 	case EDebugAddRollbackPanicingNonNativeApplicationsUpdate:
   362 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
       
   363 	#ifdef _DEBUG
   308 	#ifdef _DEBUG
   364 		iNonNativeApplicationsManager->ForcePanicInNonNativeApplicationsRollbackL();
   309 		iNonNativeApplicationsManager->ForcePanicInNonNativeApplicationsRollbackL();
   365 	#endif
   310 	#endif
   366 #endif	
   311 		break;
   367 		break;
       
   368 		
       
   369 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 		
       
   370 	case EAppListServUpdateAppList:
       
   371 	    UpdateAppListL(aMessage);
       
   372 	    break;
       
   373     case EAppListUpdatedAppsInfo:
       
   374         UpdatedAppsInfoL(aMessage);
       
   375         break;
       
   376 #endif	    
       
   377 	default:
   312 	default:
   378 		aMessage.Panic(KApaPanicCli,EClientBadRequest);
   313 		aMessage.Panic(KApaPanicCli,EClientBadRequest);
   379 		break;
   314 		break;
   380 	
   315 		}
   381 		}
   316 		
   382 	
       
   383 	if (completeMessage && !aMessage.IsNull())
   317 	if (completeMessage && !aMessage.IsNull())
   384 		aMessage.Complete(KErrNone);
   318 		aMessage.Complete(KErrNone);
   385 	}
   319 	}
   386 
   320 
   387 
   321 
   419 	delete iOpaqueData_pendingDispatchToClient;
   353 	delete iOpaqueData_pendingDispatchToClient;
   420 	}
   354 	}
   421 
   355 
   422 void CApaAppArcServSession::ServiceL(const RMessage2& aMessage)
   356 void CApaAppArcServSession::ServiceL(const RMessage2& aMessage)
   423 	{
   357 	{
   424 #ifdef APPARC_SHOW_TRACE    
       
   425     TFullName* name = new(ELeave) TFullName();
       
   426     RThread client;
       
   427     if ( aMessage.Client( client ) == KErrNone )
       
   428         {
       
   429         client.FullName( *name );
       
   430         client.Close();
       
   431         }
       
   432     RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - START - op code: %04d, client: %S"), this, aMessage.Function(), name );
       
   433     delete name; 
       
   434 #endif
       
   435     
       
   436 	TBool completeMessage = ETrue;
   358 	TBool completeMessage = ETrue;
   437 	switch (aMessage.Function())
   359 	switch (aMessage.Function())
   438 		{
   360 		{
   439 	case EAppListServStartAppWithoutReturningThreadId:
   361 	case EAppListServStartAppWithoutReturningThreadId:
   440 		ASSERT(0);	// panic debug only
   362 		ASSERT(0);	// panic debug only
   548 		const TUid serviceUid(TUid::Uid(aMessage.Int1()));
   470 		const TUid serviceUid(TUid::Uid(aMessage.Int1()));
   549 		AppForDocumentPassedByFileHandleL(aMessage, &serviceUid);
   471 		AppForDocumentPassedByFileHandleL(aMessage, &serviceUid);
   550 		}
   472 		}
   551 		break;
   473 		break;
   552 	case EAppListServRegisterNonNativeApplicationType:
   474 	case EAppListServRegisterNonNativeApplicationType:
   553 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   554 		RegisterNonNativeApplicationTypeL(aMessage);
   475 		RegisterNonNativeApplicationTypeL(aMessage);
   555 #else
       
   556         ASSERT(0);  // panic debug only
       
   557         User::Leave(KErrNotSupported);
       
   558 #endif
       
   559 		break;
   476 		break;
   560 	case EAppListServDeregisterNonNativeApplicationType:
   477 	case EAppListServDeregisterNonNativeApplicationType:
   561 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
   562 		DeregisterNonNativeApplicationTypeL(aMessage);
   478 		DeregisterNonNativeApplicationTypeL(aMessage);
   563 #else
       
   564         ASSERT(0);  // panic debug only
       
   565         User::Leave(KErrNotSupported);
       
   566 #endif		
       
   567 		break;
   479 		break;
   568 	case EAppListServPreferredBufSize:
   480 	case EAppListServPreferredBufSize:
   569 		aMessage.Complete(PreferredBufSize());
   481 		aMessage.Complete(PreferredBufSize());
   570 		break;
   482 		break;
   571 	case EAppListServRecognizeFiles:
   483 	case EAppListServRecognizeFiles:
   622 		REComSession::FinalClose();
   534 		REComSession::FinalClose();
   623 	#endif
   535 	#endif
   624 		break;
   536 		break;
   625 	default:
   537 	default:
   626 		iAppListSession->DoServiceL(aMessage);
   538 		iAppListSession->DoServiceL(aMessage);
   627 #ifdef APPARC_SHOW_TRACE   
       
   628 		RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
       
   629 #endif		
       
   630 		return;
   539 		return;
   631 		}
   540 		}
   632 	
   541 		
   633 #ifdef APPARC_SHOW_TRACE 	
       
   634     RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
       
   635 #endif	
       
   636 	if (completeMessage && !aMessage.IsNull())
   542 	if (completeMessage && !aMessage.IsNull())
   637 		aMessage.Complete(KErrNone);
   543 		aMessage.Complete(KErrNone);
   638 	}
   544 	}
   639 
   545 
   640 
   546 
   658 	TInt preferredBufferSize = 0;
   564 	TInt preferredBufferSize = 0;
   659 	TRAPD(err, preferredBufferSize = iServ.DataRecognizerPreferredBufSizeL());
   565 	TRAPD(err, preferredBufferSize = iServ.DataRecognizerPreferredBufSizeL());
   660 	return (err==KErrNone) ? Min(iMaxBufSize, preferredBufferSize) : iMaxBufSize;
   566 	return (err==KErrNone) ? Min(iMaxBufSize, preferredBufferSize) : iMaxBufSize;
   661 	}
   567 	}
   662 
   568 
   663 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   664 void CApaAppArcServSession::RegisterNonNativeApplicationTypeL(const RMessage2& aMessage)
   569 void CApaAppArcServSession::RegisterNonNativeApplicationTypeL(const RMessage2& aMessage)
   665 	{
   570 	{
   666 	const TUid applicationType(TUid::Uid(aMessage.Int0()));
   571 	const TUid applicationType(TUid::Uid(aMessage.Int0()));
   667 	HBufC* const nativeExecutable=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
   572 	HBufC* const nativeExecutable=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
   668 	{TPtr nativeExecutable_asWritable(nativeExecutable->Des());
   573 	{TPtr nativeExecutable_asWritable(nativeExecutable->Des());
   674 void CApaAppArcServSession::DeregisterNonNativeApplicationTypeL(const RMessage2& aMessage)
   579 void CApaAppArcServSession::DeregisterNonNativeApplicationTypeL(const RMessage2& aMessage)
   675 	{
   580 	{
   676 	const TUid applicationType(TUid::Uid(aMessage.Int0()));
   581 	const TUid applicationType(TUid::Uid(aMessage.Int0()));
   677 	iServ.DeregisterNonNativeApplicationTypeL(applicationType);
   582 	iServ.DeregisterNonNativeApplicationTypeL(applicationType);
   678 	}
   583 	}
   679 #endif
       
   680 
   584 
   681 void CApaAppListServSession::GetAppTypeL(const RMessage2& aMessage)
   585 void CApaAppListServSession::GetAppTypeL(const RMessage2& aMessage)
   682 	{
   586 	{
   683     const TUid KTypeIDToNonNativeUidMapping[2][2]={ {TUid::Uid(0xB031C52A), TUid::Uid(0x10210E26)},  //Java
       
   684                                                     {TUid::Uid(0x7BDB6DA1), TUid::Uid(0x10282821)}}; //Widget 
       
   685    
       
   686 	TInt uid = aMessage.Int0();
   587 	TInt uid = aMessage.Int0();
   687 	CApaAppData* appData = iAppList.AppDataByUid(TUid::Uid(uid));
   588 	CApaAppData* appData = iAppList.AppDataByUid(TUid::Uid(uid));
   688 	if (!appData)
   589 	if (!appData)
   689 	    {
       
   690 		aMessage.Complete(KErrNotFound);
   590 		aMessage.Complete(KErrNotFound);
   691 	    }
       
   692 	else
   591 	else
   693 		{
   592 		{
   694 		TUid typeId(appData->NonNativeApplicationType());
   593 		TPckgBuf<TUid> typeUid(appData->NonNativeApplicationType());
   695 		
   594 		aMessage.WriteL(1,typeUid);
   696 		//Check if non-native type to non-native UID mapping available. Otherwise
       
   697 		//return whatever returned by NonNativeApplicationType.
       
   698 		TUid nonNativeUid=typeId;
       
   699 		TInt numMappings= (sizeof(KTypeIDToNonNativeUidMapping)/ (2*sizeof(TUid)));
       
   700 		
       
   701 		for(TInt index=0; index<numMappings; index++)
       
   702 		    {
       
   703             if(typeId == KTypeIDToNonNativeUidMapping[index][0])
       
   704                 {
       
   705                 nonNativeUid = KTypeIDToNonNativeUidMapping[index][1];
       
   706                 break;
       
   707                 }
       
   708 		    }
       
   709 		
       
   710 		TPckgBuf<TUid> nonNativeUidBuf(nonNativeUid);
       
   711 		aMessage.WriteL(1,nonNativeUidBuf);
       
   712 		aMessage.Complete(KErrNone);
   595 		aMessage.Complete(KErrNone);
   713 		}
   596 		}
   714 	}
   597 	}
   715 
   598 	
   716 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK  
       
   717 void CleanupAndDestroyAppInfoArray(TAny* aRPArray)
       
   718     {
       
   719     RPointerArray<Usif::CApplicationRegistrationData>* rpArray = (static_cast<RPointerArray<Usif::CApplicationRegistrationData>*>(aRPArray));
       
   720     rpArray->ResetAndDestroy();
       
   721     rpArray->Close();
       
   722     }
       
   723 #endif
       
   724 
       
   725 void CApaAppListServSession::ForceRegistrationL(const RMessage2& aMessage)
   599 void CApaAppListServSession::ForceRegistrationL(const RMessage2& aMessage)
   726 	{
   600 	{
   727 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK    
       
   728 	TInt bufferSize = aMessage.GetDesLength(0);
   601 	TInt bufferSize = aMessage.GetDesLength(0);
   729 	User::LeaveIfError(bufferSize);
   602 	User::LeaveIfError(bufferSize);
   730 	HBufC8* const buffer=HBufC8::NewLC(bufferSize);
   603 	HBufC8* const buffer=HBufC8::NewLC(bufferSize);
   731 	TPtr8 buffer_asWritable(buffer->Des());
   604 	TPtr8 buffer_asWritable(buffer->Des());
   732 	aMessage.ReadL(0,buffer_asWritable);
   605 	aMessage.ReadL(0,buffer_asWritable);
   748 	CleanupStack::PopAndDestroy(buffer);
   621 	CleanupStack::PopAndDestroy(buffer);
   749 	
   622 	
   750 	// Trigger a rescan, when rescan completes it will complete iNotifyOnScanCompleteMsg
   623 	// Trigger a rescan, when rescan completes it will complete iNotifyOnScanCompleteMsg
   751 	iNotifyOnScanCompleteMsg=aMessage;
   624 	iNotifyOnScanCompleteMsg=aMessage;
   752 	iAppArcSrv.UpdateAppsByForceRegistration();
   625 	iAppArcSrv.UpdateAppsByForceRegistration();
   753 #else
   626 	}
   754 	const TUid KUidSisLaunchServer={0x1020473f};
   627 	
   755 	
       
   756 	if(aMessage.SecureId().iId != KUidSisLaunchServer.iUid)
       
   757 	    User::Leave(KErrNotSupported);
       
   758 	
       
   759 	//Get the size of the updated apps info buffer
       
   760     TInt bufferSize = aMessage.GetDesLength(0);
       
   761 
       
   762     //Allocate the buffer of bufferSize and read.
       
   763     HBufC8* const buffer=HBufC8::NewLC(bufferSize);
       
   764     TPtr8 buffer_asWritable(buffer->Des());
       
   765     aMessage.ReadL(0,buffer_asWritable);
       
   766         
       
   767     RDesReadStream readStream(*buffer);
       
   768     CleanupClosePushL(readStream);
       
   769     
       
   770     //Read the number of application information available in the buffer.
       
   771     const TUint count=readStream.ReadUint32L();
       
   772 
       
   773     RPointerArray<Usif::CApplicationRegistrationData> appsInfo;
       
   774     TCleanupItem cleanup(CleanupAndDestroyAppInfoArray, &appsInfo); 
       
   775     CleanupStack::PushL(cleanup); 
       
   776     
       
   777     //Read one applciation information at a time and create list of application information.
       
   778     for(TUint index=0; index<count; index++)
       
   779         {
       
   780         Usif::CApplicationRegistrationData* appData= Usif::CApplicationRegistrationData::NewL();
       
   781         CleanupStack::PushL(appData);
       
   782         readStream>>*appData;
       
   783         appsInfo.AppendL(appData);
       
   784         CleanupStack::Pop(appData);
       
   785         }
       
   786     CleanupStack::Pop(); //Remove cleanup
       
   787     CleanupStack::PopAndDestroy(2, buffer); //delete readStream, buffer	
       
   788 
       
   789     iAppList.UpdateApplistByForceRegAppsL(appsInfo);
       
   790 #endif	
       
   791 	}
       
   792 
       
   793 void CApaAppArcServSession::AppForDocumentPassedByFileHandleL(const RMessage2& aMessage, const TUid* aServiceUid)
   628 void CApaAppArcServSession::AppForDocumentPassedByFileHandleL(const RMessage2& aMessage, const TUid* aServiceUid)
   794 	{
   629 	{
   795 #if defined(__PROFILE)
   630 #if defined(__PROFILE)
   796 	TProfile profile;
   631 	TProfile profile;
   797 	RDebug::ProfileReset(5,1);
   632 	RDebug::ProfileReset(5,1);
   920 	TApaAppEntry dummy;
   755 	TApaAppEntry dummy;
   921 	CApaAppData* app = NULL;
   756 	CApaAppData* app = NULL;
   922 	if (!FindAppInList(app, dummy, aUid))
   757 	if (!FindAppInList(app, dummy, aUid))
   923 		User::Leave(KErrNotFound);
   758 		User::Leave(KErrNotFound);
   924 
   759 
   925     return *app;
   760 	return *app;
   926     }
   761 	}
   927 
       
   928 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   929 /**
       
   930 locate app in list, return EFalse if it isn't present
       
   931 search is regardless of screen mode.
       
   932 @internalComponent
       
   933 */
       
   934 TBool CApaAppListServSession::FindAppInList(CApaAppData*& aApp, TApaAppEntry& aEntry, TUid aAppUid)
       
   935     {
       
   936     // Look for the app with aAppUid in the applist we keep
       
   937     const CApaAppList& list = iAppList;
       
   938     aApp = list.AppDataByUid(aAppUid);
       
   939     if (aApp)
       
   940         aEntry = aApp->AppEntry();
       
   941     
       
   942     // If the app list is currently in flux, try to nail down the app by looking for it specifically
       
   943     const TBool appPendingOnLangChange = (aApp && list.IsLanguageChangePending() && aApp->IsPending());
       
   944 
       
   945     if ((!aApp || appPendingOnLangChange) && !list.IsIdleUpdateComplete())
       
   946         {
       
   947         // 1. App wasn't found, but an app scan is currently in progress,
       
   948         // so try to find and add the specific app we're looking for to the list
       
   949         
       
   950         // 2. On language change event, current app scan could not yet update the found app, 
       
   951         // so try to update the specific app we're looking for, in the list.
       
   952         if(aAppUid != KNullUid)
       
   953             {
       
   954             CApaAppData* app = NULL;
       
   955             TRAPD(err, app = FindSpecificAppL(aAppUid));
       
   956             if (!err && app)
       
   957                 {
       
   958                 // app has been found and added to the app list
       
   959                 aApp = app;
       
   960                 aEntry = aApp->AppEntry();
       
   961                 }
       
   962             }
       
   963         }
       
   964 
       
   965     return (aApp != NULL);
       
   966     }
       
   967 
       
   968 #else
       
   969 /**
       
   970 locate app in list, return EFalse if it isn't present
       
   971 search is regardless of screen mode.
       
   972 @internalComponent
       
   973 */
       
   974 TBool CApaAppListServSession::FindAppInList(CApaAppData*& aApp, TApaAppEntry& aEntry, TUid aAppUid)
       
   975     {
       
   976     // Look for the application with aAppUid in the applist
       
   977     const CApaAppList& list = iAppList;
       
   978     aApp = list.AppDataByUid(aAppUid);
       
   979    
       
   980     TBool appListChanging= (list.IsLanguageChangePending()||!list.IsIdleUpdateComplete());
       
   981    //If the application is not in the applist and applist is still getting updated then find the 
       
   982    //requested application specifically and add to applist.
       
   983     TInt err=KErrNone;
       
   984     if( (!aApp && appListChanging) || (aApp && aApp->IsLangChangePending()))
       
   985         TRAP(err, aApp=FindSpecificAppL(aAppUid));
       
   986 
       
   987     if (!err && aApp)
       
   988         aEntry = aApp->AppEntry(); 
       
   989     
       
   990     return (aApp != NULL);
       
   991     }
       
   992 
       
   993 #endif
       
   994 
   762 
   995 void CApaAppListServSession::SendArrayL(const MArrayItemWriter& aArrayItemWriter,const RMessage2& aMessage) const
   763 void CApaAppListServSession::SendArrayL(const MArrayItemWriter& aArrayItemWriter,const RMessage2& aMessage) const
   996 	{
   764 	{
   997 	const TInt sizeOfBuffer=aMessage.Int1();
   765 	const TInt sizeOfBuffer=aMessage.Int1();
   998 	const TInt arrayItemCount=aArrayItemWriter.ArrayItemCount();
   766 	const TInt arrayItemCount=aArrayItemWriter.ArrayItemCount();
  1257                   priority = KDataTypePriorityNormal;
  1025                   priority = KDataTypePriorityNormal;
  1258                   }
  1026                   }
  1259               }
  1027               }
  1260           else
  1028           else
  1261               {
  1029               {
  1262 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK          
       
  1263               Usif::RSoftwareComponentRegistry scrCon;
       
  1264               User::LeaveIfError(scrCon.Connect());
       
  1265               CleanupClosePushL(scrCon);
       
  1266               TApaAppEntry appEntry=appData->AppEntry();
       
  1267               
       
  1268 			  //If component id of an application is non-zero then it is installed by installer
       
  1269 			  //after phone marketed.
       
  1270               TBool isInstalledApp=(scrCon.GetComponentIdForAppL(appEntry.iUidType[2])!=0);
       
  1271 
       
  1272               //data priority for UnTrusted apps would be capped if it is greater than the threshold priority i.e, KMaxTInt16.
       
  1273               if (!isSidTrusted && isInstalledApp) 
       
  1274                   {
       
  1275                   priority = KDataTypeUnTrustedPriorityThreshold; 
       
  1276                   }
       
  1277               CleanupStack::PopAndDestroy(); //scrCon
       
  1278 #else
       
  1279               TPtrC registrationFilePath = appData->RegistrationFileName();
  1030               TPtrC registrationFilePath = appData->RegistrationFileName();
  1280               TInt match = registrationFilePath.MatchF (
  1031               TInt match = registrationFilePath.MatchF (
  1281                                           KLitPathForUntrustedRegistrationResourceFiles );
  1032                                           KLitPathForUntrustedRegistrationResourceFiles );
  1282               //Check if registration file is in path for untrusted apps 
  1033               //Check if registration file is in path for untrusted apps 
  1283               //and its SID is untrusted
  1034               //and its SID is untrusted
  1285                   {
  1036                   {
  1286                   // "cap" the priority if UnTrusted apps claim for priority higher 
  1037                   // "cap" the priority if UnTrusted apps claim for priority higher 
  1287                   // than UnTrusted apps Threshold priority
  1038                   // than UnTrusted apps Threshold priority
  1288                   priority = KDataTypeUnTrustedPriorityThreshold;
  1039                   priority = KDataTypeUnTrustedPriorityThreshold;
  1289                   }
  1040                   }
  1290 #endif
       
  1291               }
  1041               }
  1292           }
  1042           }
  1293 	   else
  1043 	   else
  1294 		  {
  1044 		  {
  1295               //if the application is not present in the applist 
  1045               //if the application is not present in the applist 
  1455 	aInfo.iCaption = app->Caption();
  1205 	aInfo.iCaption = app->Caption();
  1456 	aInfo.iShortCaption = app->ShortCaption();
  1206 	aInfo.iShortCaption = app->ShortCaption();
  1457 	}
  1207 	}
  1458 	
  1208 	
  1459 TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage)
  1209 TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage)
  1460     {
  1210 	{
  1461     ASSERT(aName==NULL);
  1211     ASSERT(aName==NULL);
  1462     
  1212     
  1463     aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
  1213     aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
  1464     TPtr name(aName->Des());
  1214     TPtr name(aName->Des());
  1465     aMessage.ReadL(1, name);
  1215     aMessage.ReadL(1, name);
  1492         User::Leave(error);
  1242         User::Leave(error);
  1493         }
  1243         }
  1494     
  1244     
  1495     TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy
  1245     TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy
  1496     return bufPtr;
  1246     return bufPtr;
  1497     }
  1247 	}
  1498 
  1248 
  1499 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
  1249 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
  1500 // Recognize the data type of an object
  1250 // Recognize the data type of an object
  1501     {
  1251 	{
  1502     HBufC* name=NULL;
  1252 	HBufC* name=NULL;
  1503     RChunk localChunk;
  1253     RChunk localChunk;
  1504     
  1254     
  1505     TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1255 	TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1506 
  1256 
  1507     const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr);
  1257 	const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr);
  1508 
  1258 
  1509     CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
  1259 	CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
  1510     aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
  1260 	aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
  1511     }
  1261 	}
  1512 
  1262 
  1513 
  1263 
  1514 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage)
  1264 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage)
  1515 	{
  1265 	{
  1516 	// if there is an outstanding async. request, we even don't allow 
  1266 	// if there is an outstanding async. request, we even don't allow 
  1781 	aMessage.WriteL(0, TPckgC<TDataRecognitionResult>(result));
  1531 	aMessage.WriteL(0, TPckgC<TDataRecognitionResult>(result));
  1782 	}
  1532 	}
  1783 	
  1533 	
  1784 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage)
  1534 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage)
  1785 // Determine whether an object is of a specific data type
  1535 // Determine whether an object is of a specific data type
  1786     {
  1536 	{
  1787     HBufC* name=NULL;
  1537 	HBufC* name=NULL;
  1788     RChunk localChunk;
  1538 	RChunk localChunk;
  1789     
  1539 	
  1790     TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1540 	TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1791     TDataType dataType;
  1541 	TDataType dataType;
  1792     {TPckg<TDataType> dataType_asDescriptor(dataType);
  1542 	{TPckg<TDataType> dataType_asDescriptor(dataType);
  1793     aMessage.ReadL(0, dataType_asDescriptor);}
  1543 	aMessage.ReadL(0, dataType_asDescriptor);}
  1794     aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType));
  1544 	aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType));
  1795     CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
  1545 	CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
  1796     }
  1546 	}
  1797 
  1547 
  1798 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)
  1548 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)
  1799 	{
  1549 	{
  1800 	RFile file;
  1550 	RFile file;
  1801 	CleanupClosePushL(file);
  1551 	CleanupClosePushL(file);
  1950 	TApaAppCapabilityBuf capabilityBuf;
  1700 	TApaAppCapabilityBuf capabilityBuf;
  1951 	aAppData.Capability(capabilityBuf);
  1701 	aAppData.Capability(capabilityBuf);
  1952 	return (capabilityBuf().iAttributes & TApaAppCapability::EControlPanelItem);
  1702 	return (capabilityBuf().iAttributes & TApaAppCapability::EControlPanelItem);
  1953 	}
  1703 	}
  1954 
  1704 
       
  1705 /**
       
  1706 locate app in list, return EFalse if it isn't present
       
  1707 search is regardless of screen mode.
       
  1708 @internalComponent
       
  1709 */
       
  1710 TBool CApaAppListServSession::FindAppInList(CApaAppData*& aApp, TApaAppEntry& aEntry, TUid aAppUid)
       
  1711 	{
       
  1712 	// Look for the app with aAppUid in the app list we keep
       
  1713 	const CApaAppList& list = iAppList;
       
  1714 	aApp = list.AppDataByUid(aAppUid);
       
  1715 	if (aApp)
       
  1716 		aEntry = aApp->AppEntry();
       
  1717 	
       
  1718 	// If the app list is currently in flux, try to nail down the app by looking for it specifically
       
  1719 	const TBool appPendingOnLangChange = (aApp && list.IsLanguageChangePending() && aApp->IsPending());	
       
  1720 	if ((!aApp || appPendingOnLangChange) && !list.IsIdleUpdateComplete())
       
  1721 		{
       
  1722 		// 1. App wasn't found, but an app scan is currently in progress,
       
  1723 		// so try to find and add the specific app we're looking for to the list
       
  1724 		
       
  1725 		// 2. On language change event, current app scan could not yet update the found app, 
       
  1726 		// so try to update the specific app we're looking for, in the list.
       
  1727 		if(aAppUid != KNullUid)
       
  1728 			{
       
  1729 			CApaAppData* app = NULL;
       
  1730 			TRAPD(err, app = FindSpecificAppL(aAppUid));
       
  1731 			if (!err && app)
       
  1732 				{
       
  1733 				// app has been found and added to the app list
       
  1734 				aApp = app;
       
  1735 				aEntry = aApp->AppEntry();
       
  1736 				}
       
  1737  			}
       
  1738  		}
       
  1739 
       
  1740 	return (aApp != NULL);
       
  1741 	}
  1955 
  1742 
  1956 CApaAppData* CApaAppListServSession::FindSpecificAppL(TUid aAppUid)
  1743 CApaAppData* CApaAppListServSession::FindSpecificAppL(TUid aAppUid)
  1957 	{
  1744 	{
  1958 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
  1745 	//Scans the drives and folder lists for the specific app
  1959     CApaAppData* app = iAppList.FindAndAddSpecificAppL(aAppUid);	
  1746 	CApaAppRegFinder* regFinder = CApaAppRegFinder::NewLC(iFs);
  1960 #else
  1747 	CApaAppData* app = iAppList.FindAndAddSpecificAppL(regFinder, aAppUid);
  1961     //Scans the drives and folder lists for the specific app
  1748 	CleanupStack::PopAndDestroy(regFinder);
  1962     CApaAppRegFinder* regFinder = CApaAppRegFinder::NewLC(iFs);    
       
  1963     CApaAppData* app = iAppList.FindAndAddSpecificAppL(regFinder, aAppUid);
       
  1964     CleanupStack::PopAndDestroy(regFinder);
       
  1965 #endif
       
  1966 	return app;
  1749 	return app;
  1967 	}
  1750 	}
  1968 
  1751 
  1969 void CApaAppListServSession::GetAppInfoL(const RMessage2& aMessage)
  1752 void CApaAppListServSession::GetAppInfoL(const RMessage2& aMessage)
  1970 	{
  1753 	{
  2006 	if (!iNotifyMessage.IsNull())
  1789 	if (!iNotifyMessage.IsNull())
  2007 		aMessage.Panic(KApaPanicCli,ENotifierAlreadyPresent);
  1790 		aMessage.Panic(KApaPanicCli,ENotifierAlreadyPresent);
  2008 	else
  1791 	else
  2009 		{
  1792 		{
  2010 		const TBool completeImmediatelyIfNoScanImpendingOrInProgress=aMessage.Int0();
  1793 		const TBool completeImmediatelyIfNoScanImpendingOrInProgress=aMessage.Int0();
  2011 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
  1794 		if ((!completeImmediatelyIfNoScanImpendingOrInProgress) ||
  2012         if ((!completeImmediatelyIfNoScanImpendingOrInProgress) ||
  1795 			iAppArcSrv.AppFsMonitor().AnyNotificationImpending() ||
  2013             iAppList.AppScanInProgress())   
  1796 			iAppList.AppScanInProgress())
  2014 #else
       
  2015         if ((!completeImmediatelyIfNoScanImpendingOrInProgress) ||
       
  2016             iAppArcSrv.AppFsMonitor().AnyNotificationImpending() ||
       
  2017             iAppList.AppScanInProgress())		
       
  2018 #endif
       
  2019 			iNotifyMessage=aMessage;
  1797 			iNotifyMessage=aMessage;
  2020 		else
  1798 		else
  2021 			aMessage.Complete(KErrNone);
  1799 			aMessage.Complete(KErrNone);
  2022 		}
  1800 		}
  2023 	
  1801 	}
  2024 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 	
  1802 
  2025 	iNotificationRequested=ETrue;
       
  2026 #endif	
       
  2027 	}
       
  2028 
       
  2029 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
       
  2030 void CApaAppArcServSession::NotifyClients(TInt aReason, CArrayFixFlat<TApaAppUpdateInfo>* aUpdatedAppsInfo)
       
  2031 #else
       
  2032 void CApaAppArcServSession::NotifyClients(TInt aReason)
  1803 void CApaAppArcServSession::NotifyClients(TInt aReason)
  2033 #endif
  1804 	{
  2034 
  1805 	iAppListSession->NotifyClients(aReason);
  2035 	{
  1806 	}
  2036 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  2037 	iAppListSession->NotifyClients(aReason, aUpdatedAppsInfo);
       
  2038 #else
       
  2039 	iAppListSession->NotifyClients(aReason);	
       
  2040 #endif
       
  2041 	}
       
  2042 
       
  2043 
  1807 
  2044 void CApaAppListServSession::CancelNotify()
  1808 void CApaAppListServSession::CancelNotify()
  2045 	{
  1809 	{
  2046 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK     
       
  2047 	NotifyClients(KErrCancel, NULL);
       
  2048 #else
       
  2049 	NotifyClients(KErrCancel);
  1810 	NotifyClients(KErrCancel);
  2050 #endif
  1811 	}
  2051 	}
  1812 
  2052 
       
  2053 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
       
  2054 void CApaAppListServSession::NotifyClients(TInt aReason, CArrayFixFlat<TApaAppUpdateInfo>* aUpdatedAppsInfo)
       
  2055 #else
       
  2056 void CApaAppListServSession::NotifyClients(TInt aReason)
  1813 void CApaAppListServSession::NotifyClients(TInt aReason)
  2057 #endif
       
  2058 	{
  1814 	{
  2059 	if (!iNotifyMessage.IsNull())
  1815 	if (!iNotifyMessage.IsNull())
  2060 		iNotifyMessage.Complete(aReason);
  1816 		iNotifyMessage.Complete(aReason);
  2061 	
  1817 	
  2062 	//Notify client for scan complete.
  1818 	//Notify client for scan complete.
  2063 	NotifyScanComplete();
  1819 	NotifyScanComplete();
  2064 	
  1820 	}
  2065 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
  1821 
  2066 	if(aUpdatedAppsInfo && iNotificationRequested)
       
  2067 	    {
       
  2068         //Append the updated applications information to iAppsUpdated
       
  2069         TInt count=aUpdatedAppsInfo->Count();
       
  2070         for(TInt index=0; index<count; index++)
       
  2071             {
       
  2072             TRAPD(err, iAppsUpdated.AppendL((*aUpdatedAppsInfo)[index]));
       
  2073             if(err != KErrNone)
       
  2074                 {
       
  2075                 iAppsUpdated.Reset();
       
  2076                 break;
       
  2077                 }
       
  2078             }
       
  2079 	    }
       
  2080 #endif	
       
  2081 	}
       
  2082 
       
  2083 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  2084 void CApaAppListServSession::AppInfoProvidedByRegistrationFileL(const RMessage2& aMessage)
  1822 void CApaAppListServSession::AppInfoProvidedByRegistrationFileL(const RMessage2& aMessage)
  2085 	{
  1823 	{
  2086 	// get UID of required app
  1824 	// get UID of required app
  2087 	const TUid uid = TUid::Uid(aMessage.Int0());
  1825 	const TUid uid = TUid::Uid(aMessage.Int0());
  2088 
  1826 
  2091 	
  1829 	
  2092 	const TBool registrationFileUsed = app.RegistrationFileUsed();
  1830 	const TBool registrationFileUsed = app.RegistrationFileUsed();
  2093 	TPckgC<TBool> pckg(registrationFileUsed);
  1831 	TPckgC<TBool> pckg(registrationFileUsed);
  2094 	aMessage.WriteL(1, pckg);
  1832 	aMessage.WriteL(1, pckg);
  2095 	}
  1833 	}
  2096 #endif
       
  2097 
       
  2098 
  1834 
  2099 void CApaAppListServSession::IconFileNameL(const RMessage2& aMessage)
  1835 void CApaAppListServSession::IconFileNameL(const RMessage2& aMessage)
  2100 	{
  1836 	{
  2101 	// get UID of required app
  1837 	// get UID of required app
  2102 	const TUid uid=TUid::Uid(aMessage.Int0());
  1838 	const TUid uid=TUid::Uid(aMessage.Int0());
  2103 
  1839 
  2104 	// locate app in list
  1840 	// locate app in list
  2105 	const CApaAppData& app = FindAppInListL(uid);
  1841 	const CApaAppData& app = FindAppInListL(uid);
  2106 
  1842 
  2107 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
  1843 	if (!app.RegistrationFileUsed())
  2108 	if (!app.RegistrationFileUsed())     
  1844 		User::Leave(KErrNotSupported);
  2109 	    User::Leave(KErrNotSupported);     
  1845 	else
  2110 	 else     
  1846 		{
  2111 	 { 
  1847 		TPtrC iconFileName(app.IconFileName());
  2112 #endif
  1848 		if (iconFileName.Length() == 0)
  2113 	 
  1849 			User::Leave(KErrNotFound);
  2114         TPtrC iconFileName(app.IconFileName());
  1850 		else
  2115         if (iconFileName.Length() == 0)
  1851 			{
  2116             User::Leave(KErrNotFound);
  1852 			TFileName fileName = iconFileName;
  2117         else
  1853 			TPckgC<TFileName> pckg(fileName);
  2118             {
  1854 			aMessage.WriteL(1, pckg);
  2119             TFileName fileName = iconFileName;
  1855 			}
  2120             TPckgC<TFileName> pckg(fileName);
  1856 		}
  2121             aMessage.WriteL(1, pckg);
       
  2122             }
       
  2123         
       
  2124 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  2125 	 }
       
  2126 #endif
       
  2127 	
       
  2128 	}
  1857 	}
  2129 
  1858 
  2130 void CApaAppListServSession::ViewIconFileNameL(const RMessage2& aMessage)
  1859 void CApaAppListServSession::ViewIconFileNameL(const RMessage2& aMessage)
  2131 	{
  1860 	{
  2132 	// get UID of required app
  1861 	// get UID of required app
  2137 	TPtrC viewIconFileName;
  1866 	TPtrC viewIconFileName;
  2138 
  1867 
  2139 	// locate app in list
  1868 	// locate app in list
  2140 	const CApaAppData& app = FindAppInListL(uid);
  1869 	const CApaAppData& app = FindAppInListL(uid);
  2141 
  1870 
  2142 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
  1871 	if (!app.RegistrationFileUsed())
  2143     if (!app.RegistrationFileUsed())     
  1872 		User::Leave(KErrNotSupported);
  2144         User::Leave(KErrNotSupported);     
  1873 	else
  2145      else     
  1874 		{
  2146      { 
  1875 		const CArrayPtr<CApaAppViewData>& viewDataArray = *app.Views();
  2147 #endif
  1876 		const TInt count = viewDataArray.Count();
  2148 	
  1877 		for (TInt ii=0; ii<count; ii++)
  2149         const CArrayPtr<CApaAppViewData>& viewDataArray = *app.Views();
  1878 			{
  2150         const TInt count = viewDataArray.Count();
  1879 			const CApaAppViewData& appViewData = *viewDataArray[ii];
  2151         for (TInt ii=0; ii<count; ii++)
  1880 			if (appViewData.Uid() == viewUid)
  2152             {
  1881 				{
  2153             const CApaAppViewData& appViewData = *viewDataArray[ii];
  1882 				viewIconFileName.Set(appViewData.IconFileName());
  2154             if (appViewData.Uid() == viewUid)
  1883 				break;
  2155                 {
  1884 				}
  2156                 viewIconFileName.Set(appViewData.IconFileName());
  1885 			}
  2157                 break;
  1886 
  2158                 }
  1887 		if (viewIconFileName.Length() == 0)
  2159             }
  1888 			User::Leave(KErrNotFound);
  2160     
  1889 		else
  2161         if (viewIconFileName.Length() == 0)
  1890 			{
  2162             User::Leave(KErrNotFound);
  1891 			TFileName fileName = viewIconFileName;
  2163         else
  1892 			TPckgC<TFileName> pckg(fileName);
  2164             {
  1893 			aMessage.WriteL(2, pckg);
  2165             TFileName fileName = viewIconFileName;
  1894 			}
  2166             TPckgC<TFileName> pckg(fileName);
  1895 		}
  2167             aMessage.WriteL(2, pckg);
       
  2168             }
       
  2169 
       
  2170 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  2171      }
       
  2172 #endif
       
  2173     
       
  2174 	}
  1896 	}
  2175 
  1897 
  2176 void CApaAppArcServSession::GetAppServicesL(const RMessage2& aMessage)
  1898 void CApaAppArcServSession::GetAppServicesL(const RMessage2& aMessage)
  2177 	{
  1899 	{
  2178 	const TInt initialBufSize = aMessage.Int2();
  1900 	const TInt initialBufSize = aMessage.Int2();
  2367 	//See if the session is intrested in scan complete notification.
  2089 	//See if the session is intrested in scan complete notification.
  2368 	if (!iNotifyOnScanCompleteMsg.IsNull())
  2090 	if (!iNotifyOnScanCompleteMsg.IsNull())
  2369 		{
  2091 		{
  2370 		iNotifyOnScanCompleteMsg.Complete(KErrNone);
  2092 		iNotifyOnScanCompleteMsg.Complete(KErrNone);
  2371 		}
  2093 		}
  2372 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
  2373 	iNonNativeApplicationsManager->NotifyScanComplete();
  2094 	iNonNativeApplicationsManager->NotifyScanComplete();
  2374 #endif	
       
  2375 	} //lint !e1762 Suppress member function could be made const
  2095 	} //lint !e1762 Suppress member function could be made const
  2376 	
  2096 	
  2377 
       
  2378 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
  2379 
       
  2380 //Update applist based on the information provided by the installers.
       
  2381 void CApaAppListServSession::UpdateAppListL(const RMessage2& aMessage)
       
  2382 {
       
  2383     //Create the update info array from the buffer.
       
  2384     TInt bufferSize = aMessage.GetDesLength(0);
       
  2385     User::LeaveIfError(bufferSize);
       
  2386     HBufC8* const buffer=HBufC8::NewLC(bufferSize);
       
  2387     TPtr8 buffer_asWritable(buffer->Des());
       
  2388     aMessage.ReadL(0,buffer_asWritable);
       
  2389         
       
  2390     RDesReadStream readStream(*buffer);
       
  2391     CleanupClosePushL(readStream);
       
  2392     const TUint count=readStream.ReadUint32L();
       
  2393 
       
  2394     RArray<TApaAppUpdateInfo> *appUpdateInfo=new (ELeave) RArray<TApaAppUpdateInfo>(5);
       
  2395     CleanupStack::PushL(appUpdateInfo);
       
  2396     
       
  2397     for(TUint index=0; index<count; index++)
       
  2398         {
       
  2399         TApaAppUpdateInfo appInfo;
       
  2400         readStream>>appInfo;
       
  2401         appUpdateInfo->AppendL(appInfo);
       
  2402         }
       
  2403     CleanupStack::Pop(appUpdateInfo);
       
  2404     CleanupStack::PopAndDestroy(2, buffer); //delete readStream, buffer
       
  2405     
       
  2406     iAppArcSrv.UpdateAppListL(appUpdateInfo, TUid::Uid(aMessage.SecureId()));
       
  2407 }
       
  2408 
       
  2409 
       
  2410 void CApaAppListServSession::UpdatedAppsInfoL(const RMessage2& aMessage)
       
  2411     {
       
  2412     //Read the buffer size
       
  2413     TInt sizeOfBuffer=aMessage.Int1();
       
  2414     TInt count=iAppsUpdated.Count();
       
  2415     TInt sizeRequired= sizeof(TInt)+(sizeof(TApaAppUpdateInfo) * count);
       
  2416 
       
  2417     TPckgBuf<TInt> pckg(sizeRequired);
       
  2418     
       
  2419     //If size of the buffer is not enough write the required size and leave.
       
  2420     if(sizeOfBuffer<sizeRequired)
       
  2421         {
       
  2422         aMessage.WriteL(1, pckg);    
       
  2423         User::Leave(KErrOverflow);
       
  2424         }
       
  2425     
       
  2426     //If the passed buffer size is enough, create a buffer to write updates application information.
       
  2427     CBufFlat* buffer=CBufFlat::NewL(sizeRequired);
       
  2428     CleanupStack::PushL(buffer);
       
  2429     buffer->ExpandL(0, sizeRequired);
       
  2430     
       
  2431     RBufWriteStream writeStream;
       
  2432     writeStream.Open(*buffer);
       
  2433     
       
  2434     //Write count to stream.
       
  2435     writeStream.WriteUint32L(count);
       
  2436     
       
  2437     //Write updated applications information to stream.
       
  2438     for(TInt index=0; index<count; index++)
       
  2439         {
       
  2440         writeStream<<iAppsUpdated[index];
       
  2441         }
       
  2442     //Write the buffer into passed buffer.
       
  2443     aMessage.WriteL(0, buffer->Ptr(0));
       
  2444     //Write size of the buffer
       
  2445     aMessage.WriteL(1, pckg);
       
  2446     
       
  2447     CleanupStack::PopAndDestroy(buffer); 
       
  2448     iAppsUpdated.Reset();
       
  2449     iNotificationRequested=EFalse;
       
  2450     }
       
  2451 #endif
       
  2452 
       
  2453 // TSizeArrayItemWriter
  2097 // TSizeArrayItemWriter
  2454 
  2098 
  2455 TInt TSizeArrayItemWriter::ArrayItemCount() const
  2099 TInt TSizeArrayItemWriter::ArrayItemCount() const
  2456 	{
  2100 	{
  2457 	return iArray.Count();
  2101 	return iArray.Count();