⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mguardscsvrsession.cpp,v

📁 symbian s60手机上的短信拦截源代码。
💻 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.19.40;	author administrator;	state Exp;branches	1.1.1.1;next	;deltatype	text;permissions	644;commitid	6b446cc1bcb3685;kopt	kv;filename	@MGuardScSvrSession.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	@MGuardScSvrSession.cpp@;desc@@1.1log@sc take care of  the lock/unlock of the screen@text@/** ============================================================================*  Name     : MGuardScSvrSession.cpp*  Part of  : MGuardSc*  Created  : 19.08.2007 by xueyw*  Description:*  Version  :*  Copyright: * ============================================================================*/#include <e32base.h>#include <e32math.h>#include "MGuardScSvrSession.h"#include "MGuardScCommon.h"#include "MGuardScSvrSession.h"// FUNCTION PROTOTYPESstatic TInt StartServer();static TInt CreateServerProcess();// ========================= MEMBER FUNCTIONS ==================================// -----------------------------------------------------------------------------// RMGuardSvrSession::RMGuardSvrSession()// C++ default constructor can NOT contain any code, that might leave.// -----------------------------------------------------------------------------//RMGuardSvrSession::RMGuardSvrSession()	: RSessionBase(), iTimeBuffer( NULL, 0, 0 ){	// No implementation required}// -----------------------------------------------------------------------------// RMGuardSvrSession::Connect()// Connects to the server and create a session.// -----------------------------------------------------------------------------//TInt RMGuardSvrSession::Connect(){	TInt error = ::StartServer();	if ( KErrNone == error )	{		error = CreateSession( KMGuardScSvrName,			Version(),			KDefaultMessageSlots );	}	return error;}// -----------------------------------------------------------------------------// RTimeServerSession::Version()// Gets the version number.// -----------------------------------------------------------------------------//TVersion RMGuardSvrSession::Version() const{	return( TVersion( KMGuardScSvrMajorVersionNumber,		KMGuardScSvrMinorVersionNumber,		KMGuardScSvrBuildVersionNumber ) );}void RMGuardSvrSession::RequestLock( TTime& aTime, TRequestStatus& aStatus ){	TAny* messageParameters[KMaxMessageArguments];	iTimeBuffer.Set( reinterpret_cast<TUint8*>( &aTime ), sizeof( aTime ),		sizeof( aTime ) );	messageParameters[0] = static_cast<TAny*>( &iTimeBuffer );	SendReceive( EMGuardServRequestLock, &messageParameters[0], aStatus );}void RMGuardSvrSession::RequestUnlock( TTime& aTime, TRequestStatus& aStatus ){	TAny* messageParameters[KMaxMessageArguments];	iTimeBuffer.Set( reinterpret_cast<TUint8*>( &aTime ), sizeof( aTime ),		sizeof( aTime ) );	messageParameters[0] = static_cast<TAny*>( &iTimeBuffer );	SendReceive( EMGuardServRequestUnlock, &messageParameters[0], aStatus );}void RMGuardSvrSession::CancelRequestLock() const{	SendReceive( EMGuardServCancelRequestLock, NULL );}// ============================= OTHER FUNCTIONS ===============================// -----------------------------------------------------------------------------// StartServer()// Starts the server if it is not already running// -----------------------------------------------------------------------------//static TInt StartServer(){	TInt result;	TFindServer findTimeServer( KMGuardScSvrName );	TFullName name;	result = findTimeServer.Next( name );	if ( result == KErrNone )	{		// Server already running		return KErrNone;	}	//	If not already running, start the server	RSemaphore semaphore;	result = semaphore.CreateGlobal( KMGuardScSvrSemaphoreName, 0 );	if ( result != KErrNone )	{		return  result;	}	result = CreateServerProcess();	if ( result != KErrNone )	{		return  result;	}	//	Deadlock possible if server panic before calling semaphore.Signal();	semaphore.Wait();	semaphore.Close();	return KErrNone;}// -----------------------------------------------------------------------------// CreateServerProcess()// Creates a server process// -----------------------------------------------------------------------------//static TInt CreateServerProcess(){	TInt result;	const TUidType serverUid( KNullUid, KNullUid, KServerUid3 );	//const TUidType serverUid( KNullUid, KNullUid, KNullUid );#ifdef __WINS__	RLibrary lib;	result = lib.Load( KMGuardServerFilename, serverUid );	if ( result != KErrNone )	{		return  result;	}	//  Get the WinsMain function	TLibraryFunction functionWinsMain = lib.Lookup( 1 );	//  Call it and cast the result to a thread function	TThreadFunction serverThreadFunction =		reinterpret_cast<TThreadFunction>( functionWinsMain() );	TName threadName( KMGuardScSvrName );	// Append a random number to make it unique	threadName.AppendNum( Math::Random(), EHex );	RThread server;	// Create new server thread	result = server.Create( threadName,		serverThreadFunction, // Thread's main function		KDefaultStackSize,		NULL,		&lib,		NULL,		KServerMinHeapSize,		KServerMaxHeapSize,		EOwnerProcess );	lib.Close();    // If successful, server thread has handle to library now	if ( result != KErrNone )	{		return  result;	}	server.SetPriority( EPriorityMore );#else	RProcess server;	_LIT( KStrEmpty,"" );	result = server.Create( KMGuardServerFilename, KStrEmpty, serverUid );	if ( result != KErrNone )	{		return  result;	}#endif	server.Resume();	server.Close();	return  KErrNone;}@1.1.1.1log@no message@text@@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -