Ejemplo n.º 1
0
/**
 Perform command execution and inter-command delays where required.
*/
void CSsmCmdListExecutor::DoExecute()
	{
	const TInt KMilliToMicro = 1000;
	
	// Are inter-command delays required?
	if( iInterCmdDelay > 0 )
		{
		// Do a delay or execute a command?
		if( iDoDelayToggle )
			{
			DEBUGPRINT2( _L("***** Performing inter-cmd delay of  %d ms"), iInterCmdDelay );
			iDoDelayToggle = EFalse;
			iTimer.After( iStatus, iInterCmdDelay * KMilliToMicro );
			
			SetActive();			
			}
		else
			{
			DEBUGPRINT2( _L("***** Exececute cmd no. %d"), iCommandIndex );
			iDoDelayToggle = ETrue;
			iCommandList->Execute( iCommandIndex++, iStatus );
			
			SetActive();
			}
		}
	else
		{
		// Execute the commands without delays.
		DEBUGPRINT2( _L("***** Execute cmd no. %d without a delay"), iCommandIndex );
		iCommandList->Execute( iCommandIndex++, iStatus );
		
		SetActive();		
		}
	
	}
void NosuchGraphics::triangle(double x0, double y0, double x1, double y1, double x2, double y2, int xdir=1, int ydir=1) {
	DEBUGPRINT2(("Drawing triangle xy0=%.3f,%.3f xy1=%.3f,%.3f xy2=%.3f,%.3f",x0,y0,x1,y1,x2,y2));
	if ( m_filled ) {
		NosuchColor c = m_fill_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_fill_alpha);
		DEBUGPRINT2(("   fill_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_fill_alpha));
		glBegin(GL_TRIANGLE_STRIP); 
		glVertex3d( xdir*x0, ydir*y0, 0.0f );
		glVertex3d( xdir*x1, ydir*y1, 0.0f );
		glVertex3d( xdir*x2, ydir*y2, 0.0f );
		glEnd();
	}
	if ( m_stroked ) {
		NosuchColor c = m_stroke_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_stroke_alpha);
		DEBUGPRINT2(("   stroke_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_stroke_alpha));
		glBegin(GL_LINE_LOOP); 
		glVertex2d( xdir*x0, ydir*y0); 
		glVertex2d( xdir*x1, ydir*y1);
		glVertex2d( xdir*x2, ydir*y2);
		glEnd();
	}
	if ( ! m_filled && ! m_stroked ) {
		DEBUGPRINT(("Hey, triangle() called when both m_filled and m_stroked are off!?"));
	}
}
void CSsmCommandListResourceReaderImpl::CResourcePool::GetCommandListIdsL(RArray<TInt>& aArray) const
	{
	TInt count = iMappings.Count();
	__ASSERT_ALWAYS(count > 0, PanicNow(KPanicCmdResourceReader, ENotInitialized3));
	if (aArray.Count() != 0)
		{
		SSMLOGLEAVE(KErrArgument);
		}
	aArray.ReserveL(count);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	TInt i = 0;
	for(i = 0; i < iMappings.Count() - 1 ; ++i)
		{
		if(iMappings[i].iCommandListId != iMappings[i+1].iCommandListId)
			{
			aArray.AppendL(iMappings[i].iCommandListId);
			}
		}
	//append the last element anyway as it is already compared
	aArray.AppendL(iMappings[i].iCommandListId);
	aArray.Compress();
		
	DEBUGPRINT2(_L("The number of substates in resource files : %d"),iMappings.Count() );
	DEBUGPRINT2(_L("The number of substates after filtering duplicates : %d"),aArray.Count());
#else
	for(TInt i = 0; i < count; ++i)
		{
		aArray.AppendL(iMappings[i].iCommandListId);
		}
#endif
	}
void NosuchGraphics::ellipse(double x0, double y0, double w, double h) {
	DEBUGPRINT2(("Drawing ellipse xy0=%.3f,%.3f wh=%.3f,%.3f",x0,y0,w,h));
	if ( m_filled ) {
		NosuchColor c = m_fill_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_fill_alpha);
		DEBUGPRINT2(("   fill_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_fill_alpha));
		glBegin(GL_TRIANGLE_FAN);
		double radius = w;
		glVertex2d(x0, y0);
		for ( double degree=0.0f; degree <= 360.0f; degree+=5.0f ) {
			glVertex2d(x0 + sin(degree2radian(degree)) * radius, y0 + cos(degree2radian(degree)) * radius);
		}
		glEnd();
	}
	if ( m_stroked ) {
		NosuchColor c = m_stroke_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_stroke_alpha);
		DEBUGPRINT2(("   stroke_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_stroke_alpha));
		glBegin(GL_LINE_LOOP);
		double radius = w;
		for ( double degree=0.0f; degree <= 360.0f; degree+=5.0f ) {
			glVertex2d(x0 + sin(degree2radian(degree)) * radius, y0 + cos(degree2radian(degree)) * radius);
		}
		glEnd();
	}

	if ( ! m_filled && ! m_stroked ) {
		DEBUGPRINT(("Hey, ellipse() called when both m_filled and m_stroked are off!?"));
	}
}
/*
Helper function to get the startup boot count and maximum boot attempts limit 
from the central repository
*/
void CGsaStatePolicyStartup::GetStartupCountAndMaxbootLimitL(TInt &aBootcount, TInt &aResetLimit)
	{
	CRepository* repository = CRepository::NewLC( KCRUidSsmStartupPolicy );
	User::LeaveIfError( repository->Get( KSsmStartupErrorResetLimit, aResetLimit ) );
	DEBUGPRINT2( _L("Reset limit is %d"), aResetLimit );
	User::LeaveIfError( repository->Get( KSsmStartupErrorResetCounter, aBootcount ) );
	DEBUGPRINT2( _L("Reset count is %d"), aBootcount );
	CleanupStack::Pop(repository);
	}
TInt CSsmCommandListResourceReaderImpl::CPreparer::RunError(TInt aError)
	{
	DEBUGPRINT2(_L("Resource reader preparer reason (%d)"), aError);
	CompleteClientRequest(aError);
	ResetReadyForNextPrepare();
	return KErrNone;
	}
TInt CSsmCommandListResourceReaderImpl::CInitialiser::RunError(TInt aError)
	{
	DEBUGPRINT2(_L("Resource reader initialiser reason (%d)"), aError);
	CompleteClientRequest(aError);
	ResetToUninitialisedState();
	return KErrNone;
	}
Ejemplo n.º 8
0
/**
Static function used to create and start CSsmSwpPolicyServer
@return KErrAlreadyExists if the server is already running
*/
EXPORT_C TInt CSsmSwpPolicyServer::StartSsmSwpPolicySrv(const TDesC& aServerName)
	{
	TAny* threadParam = reinterpret_cast<TAny*>(const_cast<TDesC*>(&aServerName));

	// Create a Unique name for the thread name
	TName name(aServerName);
	_LIT(KUnderScore, "_");
	name.Append(KUnderScore);
	name.AppendNum(Math::Random(), EHex);

	const TInt KSsmPolicySrvMinHeapSize = 0x2000;	// 8kB
	const TInt KSsmPolicySrvMaxHeapSize = 10 * KSsmPolicySrvMinHeapSize;
	RThread srvThread;
	TInt err = srvThread.Create(name, &CSsmSwpPolicyServer::SsmSwpPolicySrvThreadFn, 
								 KDefaultStackSize, KSsmPolicySrvMinHeapSize, KSsmPolicySrvMaxHeapSize, 
								 threadParam, EOwnerProcess);

	DEBUGPRINT2(_L("CSsmSwpPolicyServer: SsmSwpPolicyServer created with %d") ,err);
	if(KErrNone == err)
		{
		TRequestStatus trs;
	
		srvThread.Rendezvous(trs);
		srvThread.Resume();
		
		User::WaitForRequest(trs);	
		err = trs.Int();
		srvThread.Close();
		}

	return err;
	}
Ejemplo n.º 9
0
/**
 @return - A CTestStep derived instance
 */
CTestStep* CCmdTestServer::CreateTestStep(const TDesC& aStepName)
	{
	CTestStep* testStep = NULL;

	if (aStepName == KTCCustomCmdTestSecurityPinCheck)
		{
		testStep = new CCustomCmdTestSecurityPinCheck();
		}
	else if (aStepName == KTCCustomCmdTestDeviceSecurityPinCheck)
		{
		testStep = new CCustomCmdTestDeviceSecurityPinCheck();
		}	
	else if (aStepName == KTCCustomCmdTestActivateEmergencyCall)
		{
		testStep = new CCustomCmdTestActivateEmergencyCall();
		}
	else if (aStepName == KTCCustomCmdTestDeActivateEmergencyCall)
		{
		testStep = new CCustomCmdTestDeActivateEmergencyCall();
		}
	else if (aStepName == KTestExecuteCustCmd)
		{
		testStep = new CTestExecuteCustCmd();
		}		
		
	else 
		{
		DEBUGPRINT2(_L("Unknown CmdTest step %S"), &aStepName);
	   	User::Panic(KCustomCmdTestServerName, KErrArgument);
		}

	return testStep;
	}
Ejemplo n.º 10
0
/**
 Connect to the CLE server with the specified name. If the server is not found, this function will attempt to start it
 and retry connecting to it.
 
@param aServerName The name of the CLE server to connect to
@leave KErrNoMemory if no memory.
@leave One of the system-wide error codes.
*/
void RCleSession::ConnectL(const TDesC& aServerName)
	{
	// Guard against multiple calls.
	if( KNullHandle != iHandle )
		{
		User::Leave( KErrAlreadyExists );
		}

	TInt err = CreateSession(aServerName, iVersion, KCleSrvMsgSlots);
	if( (KErrNotFound == err) || (KErrServerTerminated == err) )
		{
		err = CCleServer::StartCleSrv(aServerName);

		DEBUGPRINT2(_L("Starting CleSrv completed with %d"),err);
		if (KErrNone !=  err && KErrAlreadyExists != err)
			{
			User::Leave(err);
			}

		User::LeaveIfError( CreateSession(aServerName, iVersion, KCleSrvMsgSlots) );
		}
	else
		{
		User::LeaveIfError( err );
		}	
	}	
void NosuchGraphics::quad(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) {
	DEBUGPRINT2(("   Drawing quad = %.3f %.3f, %.3f %.3f, %.3f %.3f, %.3f %.3f",x0,y0,x1,y1,x2,y2,x3,y3));
	if ( m_filled ) {
		glBegin(GL_QUADS);
		NosuchColor c = m_fill_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_fill_alpha);
		glVertex2d( x0, y0); 
		glVertex2d( x1, y1); 
		glVertex2d( x2, y2); 
		glVertex2d( x3, y3); 
		glEnd();
	}
	if ( m_stroked ) {
		NosuchColor c = m_stroke_color;
		glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_stroke_alpha);
		glBegin(GL_LINE_LOOP); 
		glVertex2d( x0, y0); 
		glVertex2d( x1, y1); 
		glVertex2d( x2, y2); 
		glVertex2d( x3, y3); 
		glEnd();
	}
	if ( ! m_filled && ! m_stroked ) {
		DEBUGPRINT(("Hey, quad() called when both m_filled and m_stroked are off!?"));
	}
}
Ejemplo n.º 12
0
/**
Called from CSession destructor.
*/
void CSsmSwpPolicyServer::DeregisterSession(const TInt& aSessionIndex)
	{
	__ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid));
	
	DeleteSSwpPolicySessionInfo(aSessionIndex);
	iSessionInfoArray[aSessionIndex].iInUse = EFalse;

	// Remove unused elements at the end of the array, so iSessionInfoArray can be (granular) shrunk 
    const TInt count = iSessionInfoArray.Count(); 
    TBool slotRemoved = EFalse; 
    for (TInt i = count-1; i >= 0 ; i--) 
         {
        if (!iSessionInfoArray[i].iInUse) 
        	{
            iSessionInfoArray.Remove(i); 
            slotRemoved = ETrue; 
        	}
        else 
        	{
        	break;
        	}
         } 
	   if (slotRemoved) 
		   { 
		   iSessionInfoArray.GranularCompress(); 
		   } 
	DEBUGPRINT2(_L("De-registered SsmSwpPolicyCli slot %d"), aSessionIndex);
 	}
Ejemplo n.º 13
0
/**
Iterate through iSessionInfoArray to find an unused array element
If found, use it. Otherwise, Append() a new SSwpPolicySessionInfo.
This function is called during CSession construction.
*/
void CSsmSwpPolicyServer::RegisterSessionL(TInt& aSessionIndex)
	{
	const TInt count = iSessionInfoArray.Count();
	TBool slotFound = EFalse;
	
	for(TInt i = 0; i < count; ++i)
		{
		if(!iSessionInfoArray[i].iInUse)
			{
			DEBUGPRINT1(_L("CSsmSwpPolicyServer: Using the free slot of the sessionarray"));
			iSessionInfoArray[i].iInUse = ETrue;
			__ASSERT_ALWAYS(NULL, iSessionInfoArray[i].iSwpPolicy);
			aSessionIndex = i;
			slotFound = ETrue;
			break;
			}
		}
	
	if(!slotFound)
		{
		DEBUGPRINT1(_L("CSsmSwpPolicyServer: No free slot found, so appending a new member to the sessionarray"));
		SSwpPolicySessionInfo sessionInfo;
		sessionInfo.iInUse = ETrue;
		sessionInfo.iSwpPolicy = NULL;
		sessionInfo.iSsmSwpPolicyStepCompletion = NULL;
		iSessionInfoArray.AppendL(sessionInfo);
		// using count instead of iSessionInfoArray.Count()-1 as it is set before appending the element to the array,
		// and its value is equal to iSessionInfoArray.Count()-1
		aSessionIndex = count;
		}
	DEBUGPRINT2(_L("Registered SsmSwpPolicyCli in slot %d"), aSessionIndex);
	}
Ejemplo n.º 14
0
void CStartupProperties::DoSanityCheck(TStartupCommandType aCommandType) const
	{
	if ((iStartMethod < EFireAndForget) || (iStartMethod > EDeferredWaitForStart))
		{	
		DEBUGPRINT2(_L("Invalid start_method value of %d"), iStartMethod);
		PanicNow(KPanicStartupProperties, EInvalidStartMethod);
		} 
	
	// The timeout and no_of_retries_on_failure fields can only be used
 	// with EWaitForStart. Check that no values other than the defaults have been 
 	// provisioned
 	if (iStartMethod != EWaitForStart)
 		{
 		if (iTimeout)   
			{	
			DEBUGPRINT2(_L("Timeout should be 0, invalid timeout value of %d"), iTimeout);
			PanicNow(KPanicStartupProperties, EInvalidTimeout);
			} 
		if (iNoOfRetries)
			{
			DEBUGPRINT2(_L("no_of_retries_on_failure should be 0, invalid value of %d"), iNoOfRetries);
			PanicNow(KPanicStartupProperties, EInvalidNoOfRetries);
			}
 		}
 	
	if ((aCommandType == EStartupApp) || (aCommandType == EStartupProcess))
		{
		// Check that the fail_on_error value is valid for version 1 struct.
		if ((iRecoveryMethod.iActionOnCommandFailure != EIgnoreCommandFailure) && (iRecoveryMethod.iActionOnCommandFailure != EPanicOnCommandFailure))
			{	
			DEBUGPRINT2(_L("Invalid fail_on_error: %d"), iRecoveryMethod.iActionOnCommandFailure);
			PanicNow(KPanicStartupProperties, EInvalidRecoveryMethod);
			} 
		}
	else if ((aCommandType == EStartupApp2) || (aCommandType == EStartupProcess2))
		{
		// Check that the fail_on_error value is valid for version 2 struct.	
		if ((iRecoveryMethod.iRecoveryMethod > ECriticalNoRetries) || (iRecoveryMethod.iRecoveryMethod < EIgnoreOnFailure))
			{	
			DEBUGPRINT2(_L("Invalid retry_failure_recovery_method: %d"), iRecoveryMethod.iRecoveryMethod);
			PanicNow(KPanicStartupProperties, EInvalidRecoveryMethod);
			} 
		}
	}
Ejemplo n.º 15
0
TInt CTimerList::RunError(TInt aError)
	{
	DEBUGPRINT2(_L("CTimerList: RunError called with error=%d"), aError);

	// Current CTimerList::RunL()'s implementation doesn't leave so we are just returning KErrNone.
	// In case further derived implementations of this RunL() leaves, then this method can be changed 
	// to handle the error properly.
	aError = KErrNone;
	return aError;
	}
NosuchOscManager::NosuchOscManager(NosuchOscListener* server, std::string host, int port) {

	DEBUGPRINT2(("NosuchOscManager constructor port=%d",port));
	// _seq = -1;
	// _tcp = new NosuchOscTcpInput(host,port);
	_tcp = NULL;
	_udp = new NosuchOscUdpInput(host,port,server);
	_shouldbeshutdown = false;
	_shutdowncomplete = false;
}
Ejemplo n.º 17
0
NosuchDaemon::NosuchDaemon(
    int osc_port,
    std::string osc_host,
    NosuchOscListener* oscproc,
    int http_port,
    std::string html_dir,
    NosuchJsonListener* jsonproc)
{
    DEBUGPRINT2(("NosuchDaemon CONSTRUCTOR!"));

    daemon_shutting_down = false;
    _httpserver = NULL;
    _oscinput = NULL;
    _listening = false;
    _network_thread_created = false;

    if ( NosuchNetworkInit() ) {
        DEBUGPRINT(("Unable to initialize networking in NosuchDaemon constructor, there will be no listeners"));
        return;
    }

    _listening = true;

    _httpserver = new NosuchHttpServer(jsonproc, http_port, html_dir, 60, 60000);

    if ( osc_port < 0 || oscproc == NULL ) {
        DEBUGPRINT(("NOT listening for OSC because oscport<0 or missing"));
        _oscinput = NULL;
    } else {
        _oscinput = new NosuchOscManager(oscproc,osc_host,osc_port);
        _oscinput->Listen();
    }

    DEBUGPRINT2(("About to use pthread_create in NosuchDaemon"));
    int err = pthread_create(&_network_thread, NULL, network_threadfunc, this);
    if (err) {
        NosuchErrorOutput("pthread_create failed!? err=%d",err);
    } else {
        _network_thread_created = true;
    }
}
Ejemplo n.º 18
0
/**
Destroys a surface previously created with CreateSurfaceL() and unregisters it with the windows
server for all displays. The client must stop using the surface before calling this method. All
buffers retrieved with NextBuffer() will become invalid and can no longer be used.

@param aSurface The surface to delete
*/
EXPORT_C void CVideoRenderer::DestroySurface(const TSurfaceId& aSurface)
	{
	if (aSurface != iSurfaceId || iBufferManager == NULL)
		{
		// surface id is not expected or surface has not been created
		return;
		}
	
	// cancel the active objects that use the surface
	if (iTimed)
		{
		TRequestStatus request = KRequestPending;
		TRequestStatus logonRequest = KRequestPending;

		// While a function call is in progress this thread is suspended
		// and the undertaker will not catch panics, listen for these here
		iRendererThread.Logon(logonRequest);

		// Send request to renderer thread
		iRendererRelay->DestroySurface(&request);
		User::WaitForRequest(logonRequest, request);

		if(logonRequest != KRequestPending)
			{
			// renderer thread got panic from surface update session, so panic client
			TInt reason = iRendererThread.ExitReason();
			TExitCategoryName category = iRendererThread.ExitCategory();
			User::Panic(category,reason);
			}

		// Thread is still alive and well
		iRendererThread.LogonCancel(logonRequest);
		User::WaitForRequest(logonRequest); // Consume the signal

		__ASSERT_DEBUG(request != KRequestPending, User::Panic(_L("CVR::DestroySurface"), KErrCorrupt));
		}
	else
		{
		iRendererRelay->DestroySurface(NULL);
		}

	UnregisterSurface();
	
	delete iBufferManager;
	iBufferManager = NULL;
	iRendererRelay->SetBufferManager(NULL);
	
	TInt err = iSurfaceManager.CloseSurface(iSurfaceId);
	DEBUGPRINT2(_L("RSurfaceManager::CloseSurface returned with %d"), err);
	}
Ejemplo n.º 19
0
void CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::RunL()
	{
	DEBUGPRINT2(_L("CSsmSwpPolicyStepCompletion: CSsmSwpPolicyStepCompletion State %d"), iStep);
	// Completes the message
	iMessagePtr.Complete(iStatus.Int());

	// swp transition will be marked as complete only after the execution of HandleCleReturnValue method
	if (iStep == EHandleCleReturnValue)
		{
		// In order to avoid the memory leak we have to delete the session info as this swp transition is cancelled, 
		// and the same session can be used for the next similar swp transition.
		iServer.DeleteSSwpPolicySessionInfo(iSessionIndex);
		}
	}
Ejemplo n.º 20
0
/**
Calls HandleCleReturnValue of the SwpPolicy.
*/
void CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::StartHandleCleReturnValue(const TSsmSwp& aSwp, TInt aError, TInt aSeverity, const RMessagePtr2& aMessagePtr2)
	{
	__ASSERT_DEBUG(!IsActive(), PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError4));
	__ASSERT_DEBUG(iStep == ECallCommandList, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError4));

	// This message will be completed in RunL().
	iMessagePtr = aMessagePtr2;

	// HandleCleReturnValue should be called only after executing the command list which is returned by swp policy.
	// CSsmSwpPolicyFrame does all the step checking before giving the request to ssmswppolicyserver so no further checking is required here.
	iStep = EHandleCleReturnValue;
	DEBUGPRINT2(_L("CSsmSwpPolicyStepCompletion: CSsmSwpPolicyStepCompletion State %d"), iStep);
	iSwpPolicy->HandleCleReturnValue(aSwp, aError, aSeverity, iStatus);
	SetActive();
	}
Ejemplo n.º 21
0
/**
Calls Initialize of the SwpPolicy. Sets the active object state as EInitialize.
*/
void CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::StartInitialize(const RMessagePtr2& aMessagePtr2)
	{
	__ASSERT_DEBUG(!IsActive(), PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError1));
	__ASSERT_DEBUG(iStep == EIdle, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError1));

	// This message will be completed in RunL().
	iMessagePtr = aMessagePtr2;

	// Initialize is the first step in the process of swp transition.
	// CSsmSwpPolicyFrame does	all the step checking before giving the request to ssmswppolicyserver 
	// so no further checking is required here.
	iStep = EInitialize;
	iSwpPolicy->Initialize(iStatus);
	SetActive();
	DEBUGPRINT2(_L("CSsmSwpPolicyStepCompletion: CSsmSwpPolicyStepCompletion State %d"), iStep);
	}
Ejemplo n.º 22
0
/**
Calls PrepareCommandList of the SwpPolicy. Sets the active object state as EPrepareCommandList.
*/
void CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::StartPrepareCommandList(const TSsmSwp& aSwp, const RMessagePtr2& aMessagePtr2)
	{
	__ASSERT_DEBUG(!IsActive(), PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError2));
	__ASSERT_DEBUG(iStep == EInitialize, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError2));

	// This message will be completed in RunL().
	iMessagePtr = aMessagePtr2;

	// PrepareCommandList should be called only after initializing the swp policy.  
	// CSsmSwpPolicyFrame does all the step checking before giving the request to ssmswppolicyserver 
	// so no further checking is required here.
	iStep = EPrepareCommandList;
	DEBUGPRINT2(_L("CSsmSwpPolicyStepCompletion: CSsmSwpPolicyStepCompletion State %d"), iStep);
	iSwpPolicy->PrepareCommandList(aSwp, iStatus);
	SetActive();
	}
Ejemplo n.º 23
0
/**
 * stops stopwatch
 * @pre: sw is a valid non-NULL reference to a stopwatch
 *      sw might be either stopped or started.
 * @post: the stopwatch is stopped. the different statistics are updated
 * @return: 0 on success, -1 on error
 */
int sw_stop(stopwatch* sw){
    struct timespec stoptime;
    CHECKNULL(sw, -1);
    if (clock_gettime(sw->clock_type, &stoptime) != 0){
        DEBUGPRINT2("Error on clock_gettime(): probably invalid clock_id\n");
        return -1;
    }
    if (timespeccmp0(&(sw->laststart)) == 0){
        /* already stopped */
        return 0;
    }
    if (update_time_stats(sw, &stoptime) != 0){
        return -1;
    }
    /* reset the starting time */
    memset(&(sw->laststart), 0, sizeof(struct timespec));
    return 0;
}
/**
Gets the hardware reason for KSystemStartupModeKey and makes a RFs connection.
Creates Command list path and the resource reader for startup.

@leave One of the error value returned by 
	    RProperty::Get() 
	    RFs::Connect() 
	    RArray::AppendL() 
	    NewL()
@see RProperty::Get
*/
void CGsaStatePolicyStartup::ConstructL()
	{
	// Read the hardware reason
	User::LeaveIfError(RProperty::Get(KUidSystemCategory, KSystemStartupModeKey, iHardwareReason));
	User::LeaveIfError(iFs.Connect());
	
	// Add supported transitions from Startup 'ESsmStartup'
	iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmFail, KSsmAnySubState));
	iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, KSsmAnySubState));
	iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, ESsmShutdownSubStateCritical));

	TFileName cmdListPath;
	GetCommandListPath(iHardwareReason, cmdListPath);
	DEBUGPRINT2(_L("Startup Policy : Startup command list path : %S"), &cmdListPath);

	// create resource reader
	iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, cmdListPath, *this);	
	}
void CSsmCommandListResourceReaderImpl::CResourcePool::AppendL(const TMapping& aMapping)
	{
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE 
	//check if the mapping already exists
	TInt index = iMappings.Find(aMapping);
	if (index != KErrNotFound)
		{
		DEBUGPRINT2(_L("Duplicate Substate found at index: %d"), index);
		}
	TInt err = iMappings.InsertInSignedKeyOrderAllowRepeats(aMapping);
#else
	TInt err = iMappings.InsertInSignedKeyOrder(aMapping); 
    if(KErrAlreadyExists == err) 
		{ 
		PanicNow(KPanicCmdResourceReader, EDuplicateSubstateInCommandList); 
		} 
#endif
    User::LeaveIfError(err);     
	}
Ejemplo n.º 26
0
/**
 Loads and sets up the custom command dll
*/
void CCmdCustomCommand::PrepareCustomCmdL()
	{
	TInt err = KErrNone;
	if (!iLoaded)
		{
		// load the dll
		DEBUGPRINT2(_L("Loading library %S..."), &iInfo->FileName());
		err = iLibrary.Load(iInfo->FileName());
		if (err == KErrNone)
			{
			iLoaded = ETrue;
			if(iInfo->Unloading() == ENeverUnload)
				{
				//Record the handle into the file.
				//If it fails to write the handle, ignore it.
				//We don't want to stop the processing of the command due to this failure. 
				TRAP_IGNORE(WriteHandleToFileL(iLibrary.Handle()));
				}
			}
		}

	if (iLoaded)
		{
		err = KErrNotFound;

		// get a pointer to the function
		DEBUGPRINT2A("Looking up ordinal %d...", iInfo->Ordinal());
		TLibraryFunction function = iLibrary.Lookup(iInfo->Ordinal());
		if (function)
			{	
			// cast the pointer to our custom cmd type
			CustomCmdFunctionType customCmdFunction = reinterpret_cast<CustomCmdFunctionType>(function);
			iCustomCommand = (*customCmdFunction)();
			if (iCustomCommand)
				{
				err = KErrNone;
				}
			}
		}

	MoveToNextStateL(err, EInitialiseDll);
	}
Ejemplo n.º 27
0
/**
 Process entry point. Called by client using RProcess API
 @return - Standard Epoc error code on process exit
 */
TInt E32Main(void)
	{
	__UHEAP_MARK;
	CTrapCleanup* cleanup = CTrapCleanup::New();
	if(cleanup == NULL)
		{
		return KErrNoMemory;
		}

	TRAPD(err,MainL());
	if (err)
		{
		DEBUGPRINT2(_L("CustCmdTestServer::MainL - Error: %d"), err);
	   	SSMLOGLEAVE(err);
		}
	delete cleanup;

	__UHEAP_MARKEND;
	return KErrNone;
	}
Ejemplo n.º 28
0
/**
 * (re-)start stopwatch
 * @pre: sw is a valid non-NULL reference to a stopwatch
 *      sw might be either stopped or started.
 * @post: the stopwatch is started.
 *      in case of an already started stopwatch, the different statistics are
 *      updated, and the last start (the time reference) is set to the current
 *      time value.
 * @return: 0 on success, -1 on error
 */
int sw_start(stopwatch* sw){
    struct timespec starttime;
    CHECKNULL(sw, -1);
    if (clock_gettime(sw->clock_type, &starttime) != 0){
        DEBUGPRINT2("Error on clock_gettime(): probably invalid clock_id\n");
        return -1;
    }
    /* first start or start after stop */
    if (timespeccmp0((&sw->laststart)) == 0 ){
        memcpy(&(sw->laststart), &starttime, sizeof(struct timespec));
        sw->nstarts += 1;
        return 0;
    }
    if (update_time_stats(sw, &starttime) != 0){
        return -1;
    }
    /* reset starting time */
    memcpy(&(sw->laststart), &starttime, sizeof(struct timespec));
    sw->nstarts += 1;
    return 0;
}
Ejemplo n.º 29
0
/** Implementation of MStartupCommand interface.

@see MStartupCommand.
*/
void CAppStarter::Execute(TRequestStatus& aCallerStatus)
	{
	aCallerStatus = KRequestPending;

	TPtrC appFileName = iAppInfo->FileName();
	TPtrC args = iAppInfo->Args();
	TParsePtrC parser(iAppInfo->FileName());

	DEBUGPRINT3(_L("SysStart: starting %S %S"), &appFileName, &args);

	TInt err = KErrNone;		

	TInt tried=0;
		
	if (iAppInfo->StartMethod() == EDeferredWaitForStart)
		{
		// Start process asynchronously, iCommandStatus will be checked at MultipleWait
		// and monitoring will commence afterwards if required
		TRAP(err, iProvider.StartSafe().StartL(*iAppInfo, iProcess, iCommandStatus));
		DEBUGPRINT2(_L("SysStart: Attempted %S with StartMethod()==EDeferredWaitForStart"), &appFileName);
		}		
	else
		{
		// Start process synchronously for EWaitForStart and EFireAndForget case
		TRAP(err, iProvider.StartSafe().StartL(*iAppInfo, iProcess, tried));
		DEBUGPRINT4(_L("SysStart: Attempted %S %d times, result: %d"), &appFileName, (tried + 1), err);
		
		// Start monitor if required
		if (KErrNone == err && iAppInfo->Monitored())
			{
			const TBool KEvenIfAlreadyDead = ETrue;
			TRAP(err, iProvider.SysMonSessionL().MonitorL(*iAppInfo, iProcess, KEvenIfAlreadyDead));			
			DEBUGPRINT3(_L("SysStart: Attempted to monitor %S, result: %d "), &appFileName, err);
			}
		}		
 	
	TRequestStatus* callerStatus = &aCallerStatus;
	User::RequestComplete(callerStatus, err);
	}
/**
Construct a policy frame object based on the SWP value supplied

@param aSwp The swp to resolve
@return A policy frame containing a valid policy for the swp value
@leave KErrNotFound If the swp is not registered
@leave Any error returned from LoadLibraryLC
*/
CSsmSwpPolicyFrame* CSsmSwpPolicyResolver::GetSwpPolicyL(const TSsmSwp& aSwp)
	{
	TBuf<KMaxFileName + 2> libraryFilename; //KMaxFileName + KRomDriveLetter().Length()
	GetFileNameForSwpL(aSwp, libraryFilename);

	RLibrary library;
	LoadLibraryLC(library, libraryFilename);

	// make a process-owned copy of the handle as it has to be used by SsmSwpPolicyServer, 
	// which runs in a separate thread
	User::LeaveIfError(library.Duplicate(RThread(), EOwnerProcess));
	
	CSsmSwpPolicyFrame* policy = CreatePolicyLC(library);
	CleanupStack::Pop(policy);
	policy->SetLibrary(library); // takes ownership of open library handle
	CleanupStack::Pop(&library);
	policy->SetSwpKey(aSwp.Key());

	DEBUGPRINT2(_L("Created Swp Policy DLL %S"), &libraryFilename);

	return policy;
	}