📄 mguardcommand.cpp
字号:
/*
* ============================================================================
* Name : MGuardCommand from MGuardCommand.cpp
* Part of : MGuardCommand
* Created : 29.07.2007 by xueyw
* Description:
* Version :
* Copyright:
* ============================================================================
*/
// Include Files
#include "MGuardCommand.h"
#include "MGuardPIMMgr.h"
#include "MGuardScReqHandler.h"
CMGuardCmd* CMGuardCmd::NewLC( TDesC& aSMSText )
{
CMGuardCmd* self = new (ELeave) CMGuardCmd;
CleanupStack::PushL(self);
self->ConstructL( aSMSText );
return self;
}
CMGuardCmd* CMGuardCmd::NewL( TDesC& aSMSText )
{
CMGuardCmd* self = CMGuardCmd::NewLC( aSMSText );
CleanupStack::Pop(self);
return self;
}
CMGuardCmd::CMGuardCmd()
// note, CBase initialises all member variables to zero
{
}
void CMGuardCmd::ConstructL( TDesC& aSMSText )
{
iCommandID = MGUARDINVALIDCMD;
iRawCommand = aSMSText.Alloc();
iCommandID = ExtractCommand( aSMSText );
iDummyObserver = new (ELeave)CDummyScObserver();
}
CMGuardCmd::~CMGuardCmd()
{
delete iRawCommand;
delete iDummyObserver;
iRawCommand = NULL;
}
TInt CMGuardCmd::ExtractCommand( TDesC& aSMSText )
{
if ( KErrNotFound != aSMSText.FindF( _L("UNLOCK") ) )
{
return MGUARDUNLOCK;
}
if ( KErrNotFound == aSMSText.FindF( _L("UNLOCK") ) &&
KErrNotFound != aSMSText.FindF( _L("LOCK") ) )
{
return MGUARDLOCK;
}
if ( KErrNotFound != aSMSText.FindF( _L("WIPE") ) )
{
return MGUARDWIPE;
}
if ( KErrNotFound != aSMSText.FindF( _L("ADDCONTACT") ) )
{
return MGUARDADDCONTACT; }
return MGUARDINVALIDCMD; }
TInt CMGuardCmd::Execute()
{
switch ( iCommandID )
{
case MGUARDUNLOCK:
{
// Request ScServer to unlock screen
CMGuardScReqHandler* aHandler = CMGuardScReqHandler::NewL( *iDummyObserver );
aHandler->RequestUnlock();
// Start handling requests
// Stop scheduler in CMGuardScReqHandler::RunL()
CActiveScheduler::Start();
RFs aFs;
User::LeaveIfError( aFs.Connect() );
aFs.Delete( _L("c:\\MGuardCapture.log") );
aFs.Close();
delete aHandler;
aHandler = NULL;
}
break;
case MGUARDLOCK:
{
CMGuardScReqHandler* aHandler = CMGuardScReqHandler::NewL( *iDummyObserver );
aHandler->RequestLock();
// Start handling requests
// Stop scheduler in CMGuardScReqHandler::RunL()
CActiveScheduler::Start();
RFs fs;
User::LeaveIfError( fs.Connect() );
RFile aFile;
aFile.Replace( fs, _L("c:\\MGuardCapture.log"), EFileRead );
aFile.Close();
fs.Close();
delete aHandler;
aHandler = NULL;
}
break;
case MGUARDWIPE:
{
CMGuardScReqHandler* aHandler = CMGuardScReqHandler::NewL( *iDummyObserver );
aHandler->RequestLock();
// Start handling requests
// Stop scheduler in CMGuardScReqHandler::RunL()
CActiveScheduler::Start();
delete aHandler;
aHandler = NULL;
RFs fs;
User::LeaveIfError( fs.Connect() );
RFile aFile;
aFile.Replace( fs, _L("c:\\MGuardCapture.log"), EFileRead );
aFile.Close();
fs.Close();
CMGuardPIMMgr* pMgr = CMGuardPIMMgr::NewL();
pMgr->RemoveAllContacts();
delete pMgr; }
break;
case MGUARDADDCONTACT:
{
CMGuardPIMMgr* pMgr = CMGuardPIMMgr::NewL();
TInt aNameIndex = iRawCommand->FindF( _L("NAME=") );
TBuf<50> aContactN;// = contactN->Des();
if ( KErrNotFound != aNameIndex )
{
aNameIndex += 5;
aContactN.Copy( iRawCommand->Right( iRawCommand->Length() - aNameIndex ) );
TInt aTempIndex = aContactN.FindF( _L("=") );
if ( KErrNotFound != aTempIndex )
{
aContactN.Delete( aTempIndex, aContactN.Length() );
}
}
TInt aTelIndex = iRawCommand->FindF( _L("TEL=") );
TBuf<50> aContactT;// = contatT->Des();
if ( KErrNotFound != aTelIndex )
{
aTelIndex += 4;
aContactT.Copy( iRawCommand->Right( iRawCommand->Length() - aTelIndex ) );
TInt aTempIndex = aContactT.FindF( _L("=") );
if ( KErrNotFound != aTempIndex )
{
aContactT.Delete( aTempIndex, aContactT.Length() );
}
}
TInt aAddrIndex = iRawCommand->FindF( _L("ADDR=") );
TBuf<50> aContactA;// = contactA->Des();
if ( KErrNotFound != aAddrIndex )
{
aAddrIndex += 5;
aContactA.Copy( iRawCommand->Right( iRawCommand->Length() - aAddrIndex ) );
TInt aTempIndex = aContactA.FindF( _L("=") );
if ( KErrNotFound != aTempIndex )
{
aContactA.Delete( aTempIndex, aContactA.Length() );
}
}
pMgr->AddContact( aContactN, aContactT, aContactA );
delete pMgr;
// delete contactN;
// delete contatT;
// delete contactA;
}
break;
default:
break; }
return iCommandID; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -