localisation/apparchitecture/apserv/apsnnapps.cpp
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-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 the License "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".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // Non-Native application registration functionality for the AppArc server session
    14 // Non-Native application registration functionality for the AppArc server session
    15 // 
    15 // 
       
    16 // apsnnapps.cpp
    16 //
    17 //
    17 
    18 
    18 
    19 
    19 #include "apsnnapps.h"
    20 #include "apsnnapps.h"
    20 
    21 
    21 #include <bautils.h>
    22 #include <bautils.h>
    22 #include <f32file.h>
    23 #include <f32file.h>
    23 #include <s32file.h>
    24 #include <s32file.h>
    24 
    25 
    25 #include "APSCLSV.H"
    26 #include "APSCLSV.H"
    26 #include "APSSERV.H"
    27 #include "apsserv.h"
    27 #include "APSSTD.H"
    28 #include "APSSTD.H"
    28 #include "../apgrfx/apprivate.h"
    29 #include "../apgrfx/apprivate.h"
    29 #include "apsnnappupdates.h"
    30 #include "apsnnappupdates.h"
    30 
    31 
    31 /**
    32 /**
   130 	while(err == KErrNone)
   131 	while(err == KErrNone)
   131 		{
   132 		{
   132 		TRAP(err,InternalizeActionL(aStream,aPosition));
   133 		TRAP(err,InternalizeActionL(aStream,aPosition));
   133 		if(err == KErrNone || err == KErrCorrupt || err == KErrEof)
   134 		if(err == KErrNone || err == KErrCorrupt || err == KErrEof)
   134 			{
   135 			{
   135 			// We anticipate that the last update we try to read may be incomplete or corrupt.
   136 			// We anticipate that the last update we try to read may be not complete or corrupt.
   136 			// if we get either of these, jsut stop reading in the list of updates.
   137 			// if we get either of these, jsut stop reading in the list of updates.
   137 			}
   138 			}
   138 		else
   139 		else
   139 			{
   140 			{
   140 			// something really unexpected, e.g. KErrNoMemory
   141 			// something really unexpected, e.g. KErrNoMemory
   208 		{
   209 		{
   209 	case CApsNonNativeApplicationsUpdate::ERegisterApplication:
   210 	case CApsNonNativeApplicationsUpdate::ERegisterApplication:
   210 		update = CApsRegisterNonNativeApplication::NewL(iFs, aUid, TDriveName(), CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   211 		update = CApsRegisterNonNativeApplication::NewL(iFs, aUid, TDriveName(), CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   211 		break;
   212 		break;
   212 	case CApsNonNativeApplicationsUpdate::EDeregisterApplication:
   213 	case CApsNonNativeApplicationsUpdate::EDeregisterApplication:
   213 		update = CApsDeregisterNonNativeApplication::NewL(iFs, *CApaAppListServer::Self(), aUid, CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   214 		update = CApsDeregisterNonNativeApplication::NewL(iFs, *CApaAppArcServer::Self(), aUid, CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   214 		break;
   215 		break;
   215 #ifdef _DEBUG
   216 #ifdef _DEBUG
   216 	case CApsNonNativeApplicationsUpdate::EFail:
   217 	case CApsNonNativeApplicationsUpdate::EFail:
   217 		update = new(ELeave) CApsAlwaysFailUpdate(iFs, CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   218 		update = new(ELeave) CApsAlwaysFailUpdate(iFs, CApsNonNativeApplicationsUpdate::ENeedsInternalizing);
   218 		break;
   219 		break;
   335 
   336 
   336 /**
   337 /**
   337 @internalComponent
   338 @internalComponent
   338 */
   339 */
   339 RApsUpdateLog::RApsUpdateLog(RFs& aFs) :
   340 RApsUpdateLog::RApsUpdateLog(RFs& aFs) :
   340 		iFs(aFs)
   341 	iFs(aFs), iFilesRegistered(NULL), iDrivesAffected(NULL)
   341 	{
   342 	{
   342 	TChar drive = RFs::GetSystemDriveChar();
   343 	TChar drive = RFs::GetSystemDriveChar();
   343 	iLogFileName.Append(drive);
   344 	iLogFileName.Append(drive);
   344 	iLogFileName.Append(KNonNativeApplicationsUpdateLog);
   345 	iLogFileName.Append(KNonNativeApplicationsUpdateLog);
   345 	}
   346 	}
   351 
   352 
   352 @internalComponent
   353 @internalComponent
   353 */
   354 */
   354 void RApsUpdateLog::OpenL()
   355 void RApsUpdateLog::OpenL()
   355 	{
   356 	{
       
   357 	ASSERT(!iFilesRegistered && !iDrivesAffected);
       
   358 	const TInt KArrayGranularity = 128;
       
   359 	iFilesRegistered = new (ELeave) CDesCArraySeg(KArrayGranularity);
       
   360 	iDrivesAffected = new (ELeave) CDesCArraySeg(KArrayGranularity);
   356 	User::LeaveIfError(iLogWriteStream.Replace(iFs,iLogFileName,EFileShareExclusive|EFileStream|EFileWrite));
   361 	User::LeaveIfError(iLogWriteStream.Replace(iFs,iLogFileName,EFileShareExclusive|EFileStream|EFileWrite));
   357 	}
   362 	}
   358 
   363 
   359 /**
   364 /**
   360 RApsUpdateLog::Open
   365 RApsUpdateLog::Open
   377 @internalComponent
   382 @internalComponent
   378 */
   383 */
   379 void RApsUpdateLog::Close()
   384 void RApsUpdateLog::Close()
   380 	{
   385 	{
   381 	_LIT(KLitPathForTemporaryFiles, "\\private\\10003a3f\\temp\\");
   386 	_LIT(KLitPathForTemporaryFiles, "\\private\\10003a3f\\temp\\");
   382 	const TInt count = iDrivesAffected.Count();
   387 	const TInt count = (iDrivesAffected ? iDrivesAffected->Count() : 0);
   383 	CFileMan* fileman = NULL;
   388 	CFileMan* fileman = NULL;
   384 	TRAPD(err, fileman = CFileMan::NewL(iFs));
   389 	TRAPD(err, fileman = CFileMan::NewL(iFs));
   385 	if (err == KErrNone) 
   390 	if (err == KErrNone) 
   386 		{
   391 		{
   387 		for(TInt i = 0; i < count; ++i)
   392 		for(TInt i = 0; i < count; ++i)
   388 			{
   393 			{
   389 			TFileName dir(*(iDrivesAffected[i]));
   394 			TFileName dir((*iDrivesAffected)[i]);
   390 			dir.Append(KLitPathForTemporaryNonNativeResourceAndIconFiles);
   395 			dir.Append(KLitPathForTemporaryNonNativeResourceAndIconFiles);
   391 			fileman->RmDir(dir); // recursive
   396 			fileman->RmDir(dir); // recursive
   392 			iFs.RmDir(KLitPathForTemporaryFiles); // non-recursive
   397 			iFs.RmDir(KLitPathForTemporaryFiles); // non-recursive
   393 			}
   398 			}
   394 		delete fileman;
   399 		delete fileman;
   395 		}
   400 		}
   396 	
   401 	
   397 	iFilesRegistered.ResetAndDestroy();
   402 	delete iFilesRegistered;
   398 	iDrivesAffected.ResetAndDestroy();
   403 	iFilesRegistered = NULL;
       
   404 	
       
   405 	delete iDrivesAffected;
       
   406 	iDrivesAffected = NULL;
       
   407 	
   399 	iLogWriteStream.Close();
   408 	iLogWriteStream.Close();
   400 	iFs.Delete(iLogFileName);
   409 	iFs.Delete(iLogFileName);
   401 	}
   410 	}
   402 
   411 
   403 
   412 
   409 This stops them from being incorrectly hidden from the scan performed to find
   418 This stops them from being incorrectly hidden from the scan performed to find
   410 the registration file to delete.
   419 the registration file to delete.
   411 
   420 
   412 @internalComponent
   421 @internalComponent
   413 */
   422 */
   414 RPointerArray<HBufC>& RApsUpdateLog::NewRegistrationFiles()
   423 CDesCArray& RApsUpdateLog::NewRegistrationFiles()
   415 	{
   424 	{
   416 	return iFilesRegistered;
   425 	return *iFilesRegistered;
   417 	}
   426 	}
   418 
   427 
   419 
   428 
   420 /**
   429 /**
   421 CApsNonNativeApplicationsUpdateList::RApsUpdateLog holds a list of drives that have been used
   430 CApsNonNativeApplicationsUpdateList::RApsUpdateLog holds a list of drives that have been used
   422 in the transaction. This is then used to clean up the temporary file directories
   431 in the transaction. This is then used to clean up the temporary file directories
   423 
   432 
   424 @internalComponent
   433 @internalComponent
   425 */
   434 */
   426 RPointerArray<HBufC>& RApsUpdateLog::DrivesAffected()
   435 CDesCArray& RApsUpdateLog::DrivesAffected()
   427 	{
   436 	{
   428 	return iDrivesAffected;
   437 	return *iDrivesAffected;
   429 	}
   438 	}
   430 
   439 
   431 /**
   440 /**
   432 Returns the stream that updates should write their recovery log data to
   441 Returns the stream that updates should write their recovery log data to
   433 @internalComponent
   442 @internalComponent
   449 		iNotifyOnScanCompleteMsg.Complete(KErrNone);
   458 		iNotifyOnScanCompleteMsg.Complete(KErrNone);
   450 		}
   459 		}
   451 	} //lint !e1762 Suppress member function could be made const
   460 	} //lint !e1762 Suppress member function could be made const
   452 
   461 
   453 
   462 
   454 CApsNonNativeApplicationsManager* CApsNonNativeApplicationsManager::NewL(CApaAppListServer& aServ, RFs& aFs)
   463 CApsNonNativeApplicationsManager* CApsNonNativeApplicationsManager::NewL(CApaAppArcServer& aServ, RFs& aFs)
   455 	{
   464 	{
   456 	CApsNonNativeApplicationsManager* self = new(ELeave)CApsNonNativeApplicationsManager(aServ, aFs);
   465 	CApsNonNativeApplicationsManager* self = new(ELeave)CApsNonNativeApplicationsManager(aServ, aFs);
   457 	return self;
   466 	return self;
   458 	}
   467 	}
   459 
   468 
   460 CApsNonNativeApplicationsManager::~CApsNonNativeApplicationsManager()
   469 CApsNonNativeApplicationsManager::~CApsNonNativeApplicationsManager()
   461 	{
   470 	{
   462 	delete iUpdateList;
   471 	delete iUpdateList;
   463 	}
   472 	}
   464 
   473 
   465 CApsNonNativeApplicationsManager::CApsNonNativeApplicationsManager(CApaAppListServer& aServ, RFs& aFs) :
   474 CApsNonNativeApplicationsManager::CApsNonNativeApplicationsManager(CApaAppArcServer& aServ, RFs& aFs) :
   466 		iServ(aServ),
   475 		iServ(aServ),
   467 		iFs(aFs)
   476 		iFs(aFs)
   468 	{
   477 	{
   469 	}
   478 	}
   470 
   479 
   471 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   480 //
   472 
   481 
   473 void CApsNonNativeApplicationsManager::PrepareNonNativeApplicationsUpdatesL()
   482 void CApsNonNativeApplicationsManager::PrepareNonNativeApplicationsUpdatesL()
   474 	{
   483 	{
   475 	if (iServ.AppList().AppScanInProgress())
   484 	if (iServ.AppList().AppScanInProgress())
   476 		{
   485 		{
   496 		User::Leave(KErrNotReady);
   505 		User::Leave(KErrNotReady);
   497 		}	
   506 		}	
   498 	}
   507 	}
   499 
   508 
   500 
   509 
   501 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   510 //
   502  
   511  
   503  void CApsNonNativeApplicationsManager::RegisterNonNativeApplicationL(const RMessage2& aMessage)
   512  void CApsNonNativeApplicationsManager::RegisterNonNativeApplicationL(const RMessage2& aMessage)
   504 	{
   513 	{
   505 	CheckForUpdateAppsLockL();
   514 	CheckForUpdateAppsLockL();
   506 	CleanupStack::PushL(TCleanupItem(&StaticAbortNonNativeApplicationsUpdates,this));
   515 	CleanupStack::PushL(TCleanupItem(&StaticAbortNonNativeApplicationsUpdates,this));
   597 
   606 
   598 	CleanupStack::PopAndDestroy(2, &target); // ipcParameter0, target
   607 	CleanupStack::PopAndDestroy(2, &target); // ipcParameter0, target
   599 	}
   608 	}
   600 
   609 
   601 
   610 
   602 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   611 //
   603  
   612  
   604 void CApsNonNativeApplicationsManager::DeregisterNonNativeApplicationL(const RMessage2& aMessage)
   613 void CApsNonNativeApplicationsManager::DeregisterNonNativeApplicationL(const RMessage2& aMessage)
   605 	{
   614 	{
   606 	CheckForUpdateAppsLockL();
   615 	CheckForUpdateAppsLockL();
   607 	CleanupStack::PushL(TCleanupItem(&StaticAbortNonNativeApplicationsUpdates,this));
   616 	CleanupStack::PushL(TCleanupItem(&StaticAbortNonNativeApplicationsUpdates,this));
   608 	const TUid applicationUid(TUid::Uid(aMessage.Int0()));
   617 	const TUid applicationUid(TUid::Uid(aMessage.Int0()));
   609 	iUpdateList->Append(CApsDeregisterNonNativeApplication::NewL(iFs, iServ, applicationUid));
   618 	iUpdateList->Append(CApsDeregisterNonNativeApplication::NewL(iFs, iServ, applicationUid));
   610 	CleanupStack::Pop(this);
   619 	CleanupStack::Pop(this);
   611 	}
   620 	}
   612 
   621 
   613 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   622 //
   614 
   623 
   615 #ifdef _DEBUG
   624 #ifdef _DEBUG
   616 void CApsNonNativeApplicationsManager::ForceFailInNonNativeApplicationsUpdatesL()
   625 void CApsNonNativeApplicationsManager::ForceFailInNonNativeApplicationsUpdatesL()
   617 	{
   626 	{
   618 	CheckForUpdateAppsLockL();
   627 	CheckForUpdateAppsLockL();
   637 	CleanupStack::Pop(this);
   646 	CleanupStack::Pop(this);
   638 	}
   647 	}
   639 
   648 
   640 #endif // _DEBUG
   649 #endif // _DEBUG
   641 
   650 
   642 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   651 //
   643 
   652 
   644 void CApsNonNativeApplicationsManager::CommitNonNativeApplicationsUpdatesL(const RMessage2& aMessage)
   653 void CApsNonNativeApplicationsManager::CommitNonNativeApplicationsUpdatesL(const RMessage2& aMessage)
   645 	{
   654 	{
   646 	CheckForUpdateAppsLockL();
   655 	CheckForUpdateAppsLockL();
   647 
   656 
   666 		//The request is completed without waiting till completion application list preparation. 
   675 		//The request is completed without waiting till completion application list preparation. 
   667 		aMessage.Complete(KErrNone); 
   676 		aMessage.Complete(KErrNone); 
   668 	else	
   677 	else	
   669 		//The request is not completed till completion application list preparation.		
   678 		//The request is not completed till completion application list preparation.		
   670 		iNotifyOnScanCompleteMsg=aMessage;
   679 		iNotifyOnScanCompleteMsg=aMessage;
   671 	
   680 
   672 	// Trigger a rescan
   681 	// Trigger a rescan
   673 	iServ.UpdateApps();
   682 	iServ.UpdateApps();
   674 	}
   683 	}
   675 
   684 
   676 /**
   685 /**