sysstatemgmt/systemstatemgr/ss/src/startandretry.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "startandretry.h"
       
    17 #include <ssm/ssmstartupproperties.h>
       
    18 #include "rvobserver.h"
       
    19 
       
    20 void CStartAndRetry::Actuate()
       
    21 	{
       
    22 	TInt err = KErrNone;
       
    23 	const TSsmExecutionBehaviour executionBehaviour = iStartupProperties->ExecutionBehaviour();
       
    24 	if ( (ESsmWaitForSignal == executionBehaviour) || (ESsmDeferredWaitForSignal == executionBehaviour) )
       
    25 		{
       
    26 		//issue the request to start the application with check whether we already running or timeout
       
    27 		TRAP( err, DoWaitForStartL() );
       
    28 		}
       
    29 	else
       
    30 		{
       
    31 		err = KErrArgument; 
       
    32 		}
       
    33 	if( KErrNone != err )
       
    34 		{
       
    35 		// Report the completion code and precipitate the destruction of this object.
       
    36 		iStartSafeNotify.RendezvousComplete( err, iCallerIndex );
       
    37 		}
       
    38 	}
       
    39 
       
    40 /** 
       
    41  From MRvObserverNotification
       
    42 */
       
    43 void CStartAndRetry::NotifyCompletion( TInt aCompletion )
       
    44 	{
       
    45 	// Report the completion code and precipitate the destruction of this object.
       
    46 	iStartSafeNotify.RendezvousComplete( aCompletion, iCallerIndex );
       
    47 	}
       
    48 
       
    49 /** 
       
    50  From MRvObserverNotification
       
    51 */
       
    52 void CStartAndRetry::NotifyCancellation( TInt aCompletion )
       
    53 	{
       
    54 	// Report the cacellation code.
       
    55 	iStartSafeNotify.CancellationComplete( aCompletion, iCallerIndex );
       
    56 	}
       
    57 
       
    58 /**
       
    59  The observer was constructed in ConstructL.
       
    60  Total number of attempts is 1 + NoOfRetries().
       
    61  
       
    62  The check for NULL is future-proofing precaution..
       
    63 */
       
    64 void CStartAndRetry::DoWaitForStartL()
       
    65 	{
       
    66 	User::LeaveIfNull( iRvObserver );
       
    67 	iRvObserver->RvAndObserveL( iStartupProperties );
       
    68 	}
       
    69 
       
    70 CStartAndRetry::~CStartAndRetry()
       
    71 	{
       
    72 	delete iRvObserver;
       
    73 	delete iStartupProperties;
       
    74 	}
       
    75 
       
    76 CStartAndRetry* CStartAndRetry::NewL( MStartAndRetryNotifications& aStartSafeNotify, const CSsmStartupProperties& aStartupProperties, RProcess& aProcess, TInt aCallerIndex, CApaStarter* aApaStarter )
       
    77 	{
       
    78 	CStartAndRetry* self = NewLC( aStartSafeNotify, aStartupProperties, aProcess, aCallerIndex, aApaStarter );
       
    79 	CleanupStack::Pop();	
       
    80 	
       
    81 	return self;
       
    82 	}
       
    83 
       
    84 CStartAndRetry* CStartAndRetry::NewLC( MStartAndRetryNotifications& aStartSafeNotify, const CSsmStartupProperties& aStartupProperties, RProcess& aProcess, TInt aCallerIndex, CApaStarter* aApaStarter )
       
    85 	{
       
    86 	CStartAndRetry* self = new(ELeave) CStartAndRetry( aStartSafeNotify, aProcess, aCallerIndex, aApaStarter );
       
    87 	CleanupStack::PushL( self );
       
    88 	self->ConstructL( aStartupProperties );
       
    89 	
       
    90 	return self;
       
    91 	}
       
    92 
       
    93 CStartAndRetry::CStartAndRetry( MStartAndRetryNotifications& aStartSafeNotify, RProcess& aProcess, TInt aCallerIndex, CApaStarter* aApaStarter )
       
    94 : iCallerIndex( aCallerIndex ),
       
    95   iProcess( aProcess ),
       
    96   iStartSafeNotify( aStartSafeNotify ),
       
    97   iApaStarter( aApaStarter )
       
    98 	{
       
    99 	}
       
   100 
       
   101 void CStartAndRetry::ConstructL( const CSsmStartupProperties& aStartupProperties )
       
   102 	{	
       
   103 	iStartupProperties = CSsmStartupProperties::NewL( aStartupProperties );
       
   104 	
       
   105 	iRvObserver = CRvObserver::NewL( iProcess, *this, iApaStarter );
       
   106 	}
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 
       
   112