📄 mguardscsession.cpp
字号:
/*
* ============================================================================
* Name : MGuardScSession.cpp
* Part of : MGuardScSvr
* Created : 18.08.2007 by xueyw
* Description:
* Exe header file
* Version :
* Copyright:
* ============================================================================
*/
#include <e32svr.h>
#include "MGuardScSession.h"
#include "MGuardScSvr.h"
#include "MGuardScSvr.pan"
#include "MGuardScCommon.h"
CMGuardScSession* CMGuardScSession::NewL( RThread& aClient,
CMGuardScSvr& aServer )
{
CMGuardScSession* self = CMGuardScSession::NewLC( aClient, aServer );
CleanupStack::Pop( self );
return self;
}
CMGuardScSession* CMGuardScSession::NewLC( RThread& aClient,
CMGuardScSvr& aServer )
{
CMGuardScSession* self = new ( ELeave ) CMGuardScSession( aClient,
aServer );
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
void CMGuardScSession::ConstructL()
{
iServer.IncrementSessions();
}
CMGuardScSession::CMGuardScSession( RThread& aClient, CMGuardScSvr& aServer )
: CSession( aClient ), iServer( aServer )
{
// Implementation not required
}
CMGuardScSession::~CMGuardScSession()
{
iServer.DecrementSessions();
}
void CMGuardScSession::ServiceL( const RMessage& aMessage )
{
switch ( aMessage.Function() )
{
case EMGuardServRequestLock:
RequestLockL( aMessage );
break;
case EMGuardServRequestUnlock:
RequestUnlockL( aMessage );
break;
case EMGuardServCancelRequestLock:
case EMGuardServCancelRequestUnlock:
//if ( iWaitingForTick )
{
iMessage.Complete( KErrCancel );
//iWaitingForTick = EFalse;
}
aMessage.Complete( KErrNone );
break;
default:
PanicClient( EBadRequest );
}
}
void CMGuardScSession::RequestUnlockL( const RMessage& aMessage )
{
//if ( iWaitingForTick )
//{
// // We're already busy
// PanicClient( EReqAlreadyPending );
//}
//else
{
// Keep a copy of message - for later use
iMessage = aMessage ;
// Start the work performed by the server
// (just a wait for new second in this case)
iServer.UnlockScreenL();
// iWaitingForTick = ETrue;
}
}
// Ask the server to lock screen
void CMGuardScSession::RequestLockL( const RMessage& aMessage )
{
//if ( iWaitingForTick )
//{
// // We're already busy
// PanicClient( EReqAlreadyPending );
//}
//else
{
// Keep a copy of message - for later use
iMessage = aMessage ;
// Start the work performed by the server
// (just a wait for new second in this case)
iServer.LockScreenL();
// iWaitingForTick = ETrue;
}
}
// -----------------------------------------------------------------------------
// CMGuardScSession::SendResultToClient()
// -----------------------------------------------------------------------------
//
void CMGuardScSession::SendResultToClient()
{
//if ( iWaitingForTick )
{
// iWaitingForTick = EFalse;
iMessage.Complete( iMessage.Function() );
}
}
// -----------------------------------------------------------------------------
// CMGuardScSession::PanicClient()
// Causes the client thread to panic.
// -----------------------------------------------------------------------------
//
void CMGuardScSession::PanicClient( TInt aPanic ) const
{
Panic( KCSMGuardScSvr, aPanic ); // Note: this panics the client thread,
// not server
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -