📄 mguardscsvr.cpp,v
字号:
head 1.1;access;symbols v1_0:1.1.1.1 xueyw:1.1.1 v111:1.1.1.1 MGuard:1.1.1;locks; strict;comment @// @;1.1date 2007.08.22.11.22.04; author administrator; state Exp;branches 1.1.1.1;next ;deltatype text;permissions 644;commitid aac46cc1c5b385b;kopt kv;filename @MGuardScSvr.cpp@;1.1.1.1date 2007.08.22.11.31.31; author administrator; state Exp;branches;next ;deltatype text;permissions 644;commitid 81046cc1e913f93;kopt kv;filename @MGuardScSvr.cpp@;desc@@1.1log@sc take care of the lock/unlock of the screen@text@/** ============================================================================* Name : MGuardScSvr.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 "MGuardScCommon.h"CMGuardScSvr* CMGuardScSvr::NewL(){ CMGuardScSvr* mGuardServer = CMGuardScSvr::NewLC(); CleanupStack::Pop( mGuardServer ); return mGuardServer;}// -----------------------------------------------------------------------------// CMGuardScSvr::NewLC()// Two-phased constructor.// -----------------------------------------------------------------------------//CMGuardScSvr* CMGuardScSvr::NewLC(){ CMGuardScSvr* mGuardServer = new ( ELeave ) CMGuardScSvr( EPriorityNormal ); CleanupStack::PushL( mGuardServer ); mGuardServer->ConstructL(); return mGuardServer;}void CMGuardScSvr::DecrementSessions(){ iSessionCount--; //if ( iSessionCount <= 0 ) //{ // CActiveScheduler::Stop(); //}}void CMGuardScSvr::IncrementSessions(){ iSessionCount++;}// -----------------------------------------------------------------------------// CMGuardScSvr::ConstructL()// Symbian 2nd phase constructor can leave.// -----------------------------------------------------------------------------//void CMGuardScSvr::ConstructL(){ // Check if the phone is locked // If locked iCapture = NULL; StartL( KMGuardScSvrName );}// -----------------------------------------------------------------------------// CMGuardScSvr::CMGuardScSvr()// C++ default constructor can NOT contain any code, that might leave.// -----------------------------------------------------------------------------//CMGuardScSvr::CMGuardScSvr( TInt aPriority ): CServer( aPriority ){ // Implementation not required}// -----------------------------------------------------------------------------// CMGuardScSvr::~CMGuardScSvr()// Destructor.// -----------------------------------------------------------------------------//CMGuardScSvr::~CMGuardScSvr(){ delete iCapture; iCapture = NULL;}// -----------------------------------------------------------------------------// CMGuardScSvr::NewSessionL()// -----------------------------------------------------------------------------//CSharableSession* CMGuardScSvr::NewSessionL( const TVersion& aVersion ) const{ // Check we are the right version if ( !User::QueryVersionSupported( TVersion( KMGuardScSvrMajorVersionNumber, KMGuardScSvrMinorVersionNumber, KMGuardScSvrBuildVersionNumber ), aVersion ) ) { User::Leave( KErrNotSupported ); } // Make new session RThread client = Message().Client(); return CMGuardScSession::NewL( client, *const_cast<CMGuardScSvr*> ( this ) );}// -----------------------------------------------------------------------------// CMGuardScSvr::RunError()// Processes any errors.// -----------------------------------------------------------------------------//TInt CMGuardScSvr::RunError( TInt aError ){ if ( aError == KErrBadDescriptor ) { // A bad descriptor error implies a badly programmed client, // so panic it; otherwise report the error to the client PanicClient( Message(), EBadDescriptor ); } else { Message().Complete( aError ); } // The leave will result in an early return from CServer::RunL(), skipping // the call to request another message. So do that now in order to keep the // server running. ReStart(); return KErrNone; // Handled the error fully}// -----------------------------------------------------------------------------// CMGuardScSvr::PanicClient()// Panics the client.// -----------------------------------------------------------------------------//void CMGuardScSvr::PanicClient( const RMessage& aMessage, TMGuardServPanic aPanic ){ aMessage.Panic( KCSMGuardScSvr, aPanic );}// -----------------------------------------------------------------------------// CMGuardScSvr::PanicServer()// Panics the server.// -----------------------------------------------------------------------------//void CMGuardScSvr::PanicServer( TMGuardServPanic aPanic ){ User::Panic( KCSMGuardScSvr, aPanic );}// -----------------------------------------------------------------------------// CMGuardScSvr::LockScreenL()// -----------------------------------------------------------------------------//void CMGuardScSvr::LockScreenL(){ //if ( !iHeartbeat ) //{ // iHeartbeat = CHeartbeat::NewL( EPriorityHigh ); // iHeartbeat->Start( ETwelveOClock, this ); //} if ( !iCapture ) iCapture = new (ELeave)CGuardKeyCapturer(); if ( iCapture->IsCaptureStarted() && iCapture->IsCatpurePending() ) { iCapture->ResumeCapturingL(); } else if ( !iCapture->IsCaptureStarted() ) { iCapture->StartCapturingL(); } // Notify client of the result SendResultToSessions();}void CMGuardScSvr::UnlockScreenL(){ if ( !iCapture ) iCapture = new (ELeave) CGuardKeyCapturer(); if ( !iCapture->IsCatpurePending() ) { iCapture->StopCapturingL(); } // Notify client of the result SendResultToSessions();}// -----------------------------------------------------------------------------// CMGuardScSvr::SendResultToSessions()// Informs all the clients.// -----------------------------------------------------------------------------//void CMGuardScSvr::SendResultToSessions(){ iSessionIter.SetToFirst(); CMGuardScSession* session; session = reinterpret_cast<CMGuardScSession*>( iSessionIter++ ); while ( session ) { session->SendResultToClient(); session = reinterpret_cast<CMGuardScSession*>( iSessionIter++ ); }}// -----------------------------------------------------------------------------// CMGuardScSvr::ThreadFunctionL()// Second stage startup for the server thread.// -----------------------------------------------------------------------------//void CMGuardScSvr::ThreadFunctionL(){ // Construct active scheduler CActiveScheduler* activeScheduler = new ( ELeave ) CActiveScheduler; CleanupStack::PushL( activeScheduler ); // Install active scheduler // We don't need to check whether an active scheduler is already installed // as this is a new thread, so there won't be one CActiveScheduler::Install( activeScheduler ); // Construct our server CMGuardScSvr::NewLC(); // Anonymous RSemaphore semaphore; User::LeaveIfError( semaphore.OpenGlobal( KMGuardScSvrSemaphoreName ) ); // Semaphore opened ok semaphore.Signal(); semaphore.Close(); // Start handling requests CActiveScheduler::Start(); CleanupStack::PopAndDestroy( 2, activeScheduler ); //Anonymous CTimeServer}// -----------------------------------------------------------------------------// CMGuardScSvr::ThreadFunction()// Main function for the server thread.// -----------------------------------------------------------------------------//TInt CMGuardScSvr::ThreadFunction( TAny* /*aNone*/ ){ CTrapCleanup* cleanupStack = CTrapCleanup::New(); if ( !( cleanupStack ) ) { PanicServer( ECreateTrapCleanup ); } TRAPD( err, ThreadFunctionL() ); if ( err != KErrNone ) { PanicServer( ESrvCreateServer ); } delete cleanupStack; cleanupStack = NULL; return KErrNone;}@1.1.1.1log@no message@text@@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -