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

📄 mguardkeycapture.cpp.bak,v

📁 symbian s60手机上的短信拦截源代码。
💻 BAK,V
字号:
head     1.1;branch   1.1.1;access   ;symbols 	arelease:1.1.1.1	avendor:1.1.1;locks    ; strict;comment  @# @;1.1date     2007.07.24.10.59.30;  author administrator;  state Exp;branches 1.1.1.1;next     ;deltatype   text;permissions	644;1.1.1.1date     2007.07.24.10.59.30;  author administrator;  state Exp;branches ;next     ;permissions	644;desc@@1.1log@Initial revision@text@/** ============================================================================*  Name     :  MGuardKeyCapture.cpp*  Part of  :  MGuard*  Created  :  July 21 by xueyw*  Description:*  Copyright: * ============================================================================*///  Include Files  #include "MGuardKeyCapture.h"#include <e32base.h>#include <e32std.h>#include <apgwgnam.h>           // CApaWindowGroupName#include <aknkeylock.h> #include <apacmdln.h>#include <eikdll.h>// Capture KNumberOfPressesToCapture key pressesconst TInt KNumberOfPressesToCapture = 3;////////////////////////////////////// CGuardKeyCapturer////////////////////////////////////// ConstructorCGuardKeyCapturer::CGuardKeyCapturer() :CActive( EPriorityNormal ){	iCaptureStarted = EFalse;	iCapturePending = EFalse;	iCaptureHandleCount = 0;			// Connect to the window server	User::LeaveIfError( iWsSession.Connect() );	// Create an invisible window group. Well, we'll make it invisible later	/** @@todo Can ELeave be used with R-classes? */	iWindowGroup = new (ELeave) RWindowGroup ( iWsSession );	// @@see RBlankWindow::Construct	iWindowGroup->Construct( (TUint32)iWindowGroup, EFalse );}// DestructorCGuardKeyCapturer::~CGuardKeyCapturer(){	delete iWindowGroupName;	delete iWindowGroup;	iWsSession.Close();}// Cancel listening to key pressesvoid CGuardKeyCapturer::DoCancel(){	for ( TInt aIndex = 0; aIndex < iCaptureHandleCount; aIndex ++ )	{		iWindowGroup->CancelCaptureKey( iCaptureHandle[ aIndex ] );	}		RAknKeyLock keyLock; // first step	//	Lock keyboard	User::LeaveIfError(keyLock.Connect());  // second step	CleanupClosePushL(keyLock);	keyLock.DisableKeyLock(); // third step	keyLock.Close(); // fourth step	CleanupStack::PopAndDestroy(); // keyLock}void CGuardKeyCapturer::StopCapturingL(){	for ( TInt aIndex = 0; aIndex < iCaptureHandleCount; aIndex ++ )	{		iWindowGroup->CancelCaptureKey( iCaptureHandle[ aIndex ] );	}		RAknKeyLock keyLock; // first step	//	Lock keyboard	User::LeaveIfError(keyLock.Connect());  // second step	CleanupClosePushL(keyLock);	keyLock.DisableKeyLock(); // third step	keyLock.Close(); // fourth step	CleanupStack::PopAndDestroy(); // keyLock			iCaptureHandleCount = 0;	iCapturePending = ETrue;}void CGuardKeyCapturer::ResumeCapturingL(){	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyNull , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBell , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyTab , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyLineFeed , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyVerticalTab , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyFormFeed , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEnter , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEscape , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeySpace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyDelete , 0, 0 ) );		iCaptureHandleCount ++;		for ( TInt aCode = EKeyPrintScreen; aCode < EKeyKeyboardExtend; aCode ++ )	{		User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( aCode , 0, 0 ) );		iCaptureHandleCount ++;	}	iCapturePending = EFalse;			RAknKeyLock keyLock; // first step	//	Start phone app	_LIT(KPhoneAppPath, "\\system\\apps\\phone\\phone.app");	{		//	Open with the default/last known app		CApaCommandLine * cmd = CApaCommandLine::NewL();        		cmd->SetLibraryNameL( KPhoneAppPath );        		cmd->SetCommandL( EApaCommandOpen );		EikDll::StartAppL( *cmd );		delete cmd;	}	//	Lock keyboard	User::LeaveIfError(keyLock.Connect());  // second step	CleanupClosePushL(keyLock);	keyLock.EnableKeyLock(); // third step	keyLock.Close(); // fourth step	CleanupStack::PopAndDestroy(); // keyLock	}void CGuardKeyCapturer::StartCapturingL() {	// You cannot just call CaptureLongKey for the same key code	// You MUST call CaptureKey first	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyNull , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBell , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyTab , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyLineFeed , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyVerticalTab , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyFormFeed , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEnter , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEscape , 0, 0 ) );	iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeySpace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) );		iCaptureHandleCount ++;	User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyDelete , 0, 0 ) );		iCaptureHandleCount ++;		for ( TInt aCode = EKeyPrintScreen; aCode < EKeyKeyboardExtend; aCode ++ )	{		User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( aCode , 0, 0 ) );		iCaptureHandleCount ++;	}		// 	And finally capture long key presses	//	User::LeaveIfError( iLongCaptureHandle = iWindowGroup->CaptureLongKey( KKeyCode , KKeyCode, 0, 0, 0, 0 ) );	// 	Send created window to the background and hide it from the	// 	application switcher	iWindowGroup->SetOrdinalPosition(-1);	iWindowGroup->EnableReceiptOfFocus( EFalse );	iWindowGroupName = CApaWindowGroupName::NewL( iWsSession );	iWindowGroupName->SetHidden(ETrue);	iWindowGroupName->SetWindowGroupName( *iWindowGroup );	// 	Tell window server, that we are ready to receive events	//	It's first time	iWsSession.EventReady( &this->iStatus );	CActiveScheduler::Add( this );		iCaptureStarted = ETrue;	SetActive();		RAknKeyLock keyLock; // first step	//	Start phone app	_LIT(KPhoneAppPath, "\\system\\apps\\phone\\phone.app");	{		//	Open with the default/last known app		CApaCommandLine * cmd = CApaCommandLine::NewL();        		cmd->SetLibraryNameL( KPhoneAppPath );        		cmd->SetCommandL( EApaCommandOpen );		EikDll::StartAppL( *cmd );		delete cmd;	}	//	Lock keyboard	User::LeaveIfError(keyLock.Connect());  // second step	CleanupClosePushL(keyLock);	keyLock.EnableKeyLock(); // third step	keyLock.Close(); // fourth step	CleanupStack::PopAndDestroy(); // keyLock	}// Key press happenedvoid CGuardKeyCapturer::RunL(){	if( iStatus == KErrNone ) 	{		// EEventKey received		TWsEvent we;		iWsSession.GetEvent( we );		//if( we.Key()->iCode == KKeyCode ) 		{			if( we.Key()->iRepeats == 0 )			{			}			else			{			}			RAknKeyLock keyLock; // first step			//	Start phone app			_LIT(KPhoneAppPath, "\\system\\apps\\phone\\phone.app");			{				//	Open with the default/last known app				CApaCommandLine * cmd = CApaCommandLine::NewL();        				cmd->SetLibraryNameL( KPhoneAppPath );        				cmd->SetCommandL( EApaCommandOpen );				EikDll::StartAppL( *cmd );				delete cmd;			}			//	Lock keyboard			User::LeaveIfError(keyLock.Connect());  // second step			CleanupClosePushL(keyLock);			keyLock.EnableKeyLock(); // third step			keyLock.Close(); // fourth step			CleanupStack::PopAndDestroy(); // keyLock		}		//else 		//	{		//	//// This should never happen, but just to demonstrate how 		//	//// it is possible to forward events to the default destination		//	//TInt foregroundAppId = iWsSession.GetFocusWindowGroup();		//	//iWsSession.SendEventToWindowGroup( foregroundAppId, we );		//	}  // if iCode		//if( iCaptureCounter == KNumberOfPressesToCapture ) 		//	{		//	// exit MainL() inner loop		//	CActiveScheduler::Stop();		//	}		//else 		{			iWsSession.EventReady( &iStatus );			SetActive();		}  // if captured enough times	}  // if iStatus	else 	{		// Framework notified of some error		/** @@todo Handle error if required */	}}// End of file@1.1.1.1log@no message@text@@

⌨️ 快捷键说明

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