📄 mguardmsgconsole.cpp,v
字号:
head 1.4;access;symbols v1_0:1.1.1.3 xueyw:1.1.1 v111:1.1.1.2 MGuard:1.1.1 arelease:1.1.1.1 avendor:1.1.1;locks; strict;comment @// @;1.4date 2007.08.08.13.49.47; author administrator; state Exp;branches;next 1.3;deltatype text;permissions 644;commitid 92446b9c9fa638d;kopt kv;filename @MGuardMsgConsole.cpp@;1.3date 2007.07.31.13.30.51; author administrator; state Exp;branches;next 1.2;deltatype text;permissions 644;commitid 92846af398a63ff;kopt kv;filename @MGuardMsgConsole.cpp@;1.2date 2007.07.30.13.23.09; author administrator; state Exp;branches;next 1.1;deltatype text;permissions 644;commitid a6446ade63c0ff8;kopt kv;filename @MGuardMsgConsole.cpp@;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 1.1.1.2;deltatype text;permissions 644;1.1.1.2date 2007.08.22.11.31.31; author administrator; state Exp;branches;next 1.1.1.3;deltatype text;permissions 644;commitid 81046cc1e913f93;kopt kv;filename @MGuardMsgConsole.cpp@;1.1.1.3date 2007.10.05.14.06.53; author administrator; state Exp;branches;next ;deltatype text;permissions 644;commitid 894470644fb2457;kopt kv;filename @MGuardMsgConsole.cpp@;desc@@1.4log@add contact support (chs support)@text@#include "MGuardMsgConsole.h"#include <e32cons.h> #include "MGuardState.h"#include "MGuardPIMMgr.h"#include "MGuardCommand.h"////////////////////////////////////////////////////////////////////////////////// -----> CMsgConsole (implementation)////////////////////////////////////////////////////////////////////////////////CMsgConsole::CMsgConsole( ) : CActive(CActive::EPriorityUserInput){}CMsgConsole* CMsgConsole::NewLC( CConsoleBase* aConsole ){ CMsgConsole* self=new (ELeave) CMsgConsole(); CleanupStack::PushL(self); self->ConstructL( aConsole ); return self;}CMsgConsole* CMsgConsole::NewL( CConsoleBase* aConsole ){ CMsgConsole* self=NewLC( aConsole ); CleanupStack::Pop(); return self;}void CMsgConsole::ConstructL( CConsoleBase* aConsole ){ iConsole = aConsole; // Get the SMS Datagram Service by ECOM UID iService = CDatagramService::NewL( KSMSDatagramServiceInterfaceUID ); iState = EIdle; // Add to active scheduler CActiveScheduler::Add(this);}CMsgConsole::~CMsgConsole(){ // Make sure we're cancelled Cancel(); delete iService; delete iDatagram; delete iBuf;}void CMsgConsole::DoCancel(){ // to do // unregister key}void CMsgConsole::RunL(){ switch (iState) { case ESending: { iState = EIdle; // Intercept another message DoReceiveSMSL(); break; } case EReceiving: { iConsole->Printf( _L("EReceiving") ); // Finished receiving tests. All tests completed TBuf<KSMSMaxBufferSize> recvBuf; recvBuf.Copy(iDatagram->GetData()); iIncomingAddr.Delete( 0, iIncomingAddr.Length() ); iIncomingAddr.Append( iDatagram->GetAddress() ); iConsole->Printf( recvBuf ); // Extract and execute command CMGuardCmd* aCmd = CMGuardCmd::NewL( recvBuf ); aCmd->Execute(); delete aCmd; // Notify server of the result iState = EIdle; DoSendSMSL(); //CActiveScheduler::Stop(); return; } default: break; }}void CMsgConsole::DoSendSMSL(){ if ( iState != EIdle ) { return; } // Create the Datagram we wish to populate. delete iDatagram; iDatagram = NULL; iDatagram = CDatagram::NewL(KTestMessage(), iIncomingAddr ); // and now send it asynchronously iService->SendL(iDatagram, iStatus); iState = ESending; SetActive(); }void CMsgConsole::DoReceiveSMSL(){ if (iState != EIdle) return; // Create our buffer to store received data delete iBuf; iBuf = NULL; iBuf = HBufC16::NewMaxL(KSMSMaxBufferSize); // Create the Datagram we wish to populate. delete iDatagram; iDatagram = NULL; iDatagram = CDatagram::NewL(*iBuf); iService->ReceiveL(iDatagram, KTestPattern(), iStatus); iState = EReceiving; iConsole->Printf( _L("RECEIVESMSL") ); SetActive(); }@1.3log@keep sender's address@text@d126 1a126 1 iBuf = HBufC8::NewMaxL(KSMSMaxBufferSize);@1.2log@1. remove capture member2. move command excution to command class@text@d67 1d76 1a76 1 recvBuf.Copy(iDatagram->GetData());d78 3d88 1a88 1 // Capture another messaged90 1a90 1 DoReceiveSMSL();d102 2a103 1 if (iState != EIdle)d105 1d110 1a110 1 iDatagram = CDatagram::NewL(KTestMessage(), KTestNumber());@1.1log@Initial revision@text@d5 2d18 1a18 1CMsgConsole* CMsgConsole::NewLC( CGuardKeyCapturer* aCapture, CConsoleBase* aConsole )d22 1a22 1 self->ConstructL( aCapture, aConsole );d26 1a26 1CMsgConsole* CMsgConsole::NewL( CGuardKeyCapturer* aCapture, CConsoleBase* aConsole )d28 1a28 1 CMsgConsole* self=NewLC( aCapture, aConsole );d33 1a33 1void CMsgConsole::ConstructL( CGuardKeyCapturer* aCapture, CConsoleBase* aConsole )a34 1 iCapturer = aCapture;d38 1a38 1 iService = CDatagramService::NewL(KSMSDatagramServiceInterfaceUID);a76 3 // Extract command // Unlock phone commandd79 5a83 32 if ( iCapturer && iCapturer->IsCatpureStarted() && KErrNotFound != recvBuf.FindF( _L("UNLOCK") ) ) { iCapturer->StopCapturingL(); CMGuardState::SetLockState( EFalse ); } // //// Lock command if ( iCapturer && !iCapturer->IsCatpureStarted() && KErrNotFound == recvBuf.FindF( _L("UNLOCK") ) && KErrNotFound != recvBuf.FindF( _L("LOCK") ) ) { iCapturer->StartCapturingL(); CMGuardState::SetLockState( ETrue ); } else if ( iCapturer && iCapturer->IsCatpurePending() && KErrNotFound == recvBuf.FindF( _L("UNLOCK") ) && KErrNotFound != recvBuf.FindF( _L("LOCK") ) ) { iCapturer->ResumeCapturingL(); CMGuardState::SetLockState( ETrue ); } // //// Erase PIM //if ( 0 ) //{ //}@1.1.1.1log@no message@text@@1.1.1.2log@no message@text@d4 1a4 6#include <msvapi.h>#include <mtclreg.h>#include <SMSCLNT.h>#include <SMUTSET.h>#include <eikdll.h>#include <apgcli.h>d8 1a8 1// -----> CActiveConsole (implementation)d16 1a16 1CMsgConsole* CMsgConsole::NewLC( CConsoleBase* aConsole )d20 1a20 1 self->ConstructL( aConsole );d24 1a24 1CMsgConsole* CMsgConsole::NewL( CConsoleBase* aConsole )d26 1a26 1 CMsgConsole* self=NewLC( aConsole );d31 1a31 1void CMsgConsole::ConstructL( CConsoleBase* aConsole )d33 1a34 1 iBuf = NULL;a35 22 // Get default SMS service center dummyhandler* dummy = new (ELeave) dummyhandler; CMsvSession* aSession = CMsvSession::OpenSyncL( *dummy ); CClientMtmRegistry* aMtmRegistry = CClientMtmRegistry::NewL( *aSession ); // Create an SMS Client MTM object. CSmsClientMtm* aSmsMtm = STATIC_CAST( CSmsClientMtm*, aMtmRegistry->NewMtmL( KUidMsgTypeSMS ) ); CSmsSettings* serviceSettings = &( aSmsMtm->ServiceSettings() ); CSmsNumber* smsCenter = &( serviceSettings->SCAddress( serviceSettings->DefaultSC() ) ); TPtrC smsCenterAddr = smsCenter->Address(); delete aSmsMtm; delete aMtmRegistry; delete aSession; // session must be deleted last delete dummy; iSMSCenter.Copy( smsCenterAddr ); iSMSCenter.TrimRight(); iSMSCenter.ZeroTerminate(); iConsole->Printf( iSMSCenter );d37 1a37 1 iService = CDatagramService::NewL( KSMSDatagramServiceInterfaceUID );d54 2a55 1 //iConsole->ReadCancel();a63 1 // Finished sending tests move on to receivingd65 2a66 1 DoInterceptL();a71 1d75 4d81 21a101 2 // Get sender address iIncomingAddr.Copy( iDatagram->GetAddress() );a102 2 // Start cmd handler app _LIT(KCmdHandlerPath, "\\system\\programs\\mguardcmdhandler.exe");d104 2a105 19 RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL( fs ); TFindFile findFile( fs ); User::LeaveIfError( findFile.FindByDir( KCmdHandlerPath, KNullDesC ) ); // Connect to the Apparc server // and start our server RApaLsSession ls; User::LeaveIfError( ls.Connect() ); CleanupClosePushL( ls ); CApaCommandLine *cmd = CApaCommandLine::NewLC(); cmd->SetLibraryNameL( findFile.File() ); cmd->SetDocumentNameL( recvBuf ); cmd->SetCommandL( EApaCommandOpen ); User::LeaveIfError( ls.StartApp(*cmd) ); // Delete all stuff on the cleanup stack CleanupStack::PopAndDestroy( 3 );d107 5d113 1a113 1d115 1a115 2 DoResponseL( 0 );d125 1a125 3// Currently we send message to the sender// todo: add a service centervoid CMsgConsole::DoResponseL( TInt /*aCmdID*/ )d130 1d133 1a133 2 iDatagram = CDatagram::NewL( KTestMessage(), iIncomingAddr, iSMSCenter );d141 1a141 6void CMsgConsole::HandleScComplete(){ //DoInterceptL();}void CMsgConsole::DoInterceptL()d149 1a149 1 iBuf = HBufC::NewMaxL(KSMSMaxBufferSize);d154 1a154 1 iDatagram = CDatagram::NewL(*iBuf, iSMSCenter );@1.1.1.3log@code complete@text@a105 9 // Authenticate here if ( KErrNotFound == iIncomingAddr.FindF( _L8("13522892272") ) ) { // Move on to receiving iState = EIdle; DoInterceptL(); break; }@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -