📄 mguardmain.cpp
字号:
/*
* ============================================================================
* Name : MGuardMain.cpp
* Part of : MGuardMain
* Created : 13.08.2007 by xueyw
* Description:
* Exe source file
* Version :
* Copyright:
* ============================================================================
*/
// Include Files
#include "MGuardMain.h"
#include "MGuardMsgConsole.h"
#include "MGuardScReqHandler.h"
#include "MGuardState.h"
#include <e32base.h>
#include <e32std.h>
#include <e32cons.h>
//#include <etelagsm.h>
#include <plpvariant.h>
// Constants
_LIT(KTextConsoleTitle, "MGuardConsole");
// Global Variables
LOCAL_D CConsoleBase* console;
// Local Functions
LOCAL_C void MainL(const TDesC& /*aArgs*/)
{
// Get subscriber
// try first to read the IMSI
////RTelServer iServer;
////RAdvGsmPhone iPhone;
////RTelServer::TPhoneInfo info;
////// Connect to the telephony server and load the TSY.
////User::LeaveIfError(iServer.Connect());
////CleanupClosePushL(iServer);
////_LIT(KTsyName, "phonetsy.tsy");
////User::LeaveIfError(iServer.LoadPhoneModule(KTsyName));
////// Get the details for the first (and only) phone.
////User::LeaveIfError(iServer.GetPhoneInfo(0, info));
////// Open the phone.
////User::LeaveIfError(iPhone.Open(iServer, info.iName));
////CleanupClosePushL(iPhone);
////TRequestStatus status;
////MAdvGsmPhoneInformation::TSubscriberId myId;
////// get the imsi
////iPhone.GetSubscriberIdNS(status, myId);
//////_LIT8(KFormatDecimal, "size of subscriberId:%u");
//////TBuf8<200> imeiString;
//////imeiString.Format(KFormatDecimal,myId.Length());
////// trace it ReportMessage(imeiString);
////TBuf<200> aValue;
////TInt i=0;
////aValue.Zero();
//////_LIT8(KFlwFormat,"%u");
////for(i=0; i<myId.Length();i++)
////{
//// aValue.Append(myId[i]);
////}
//////
////CleanupStack::PopAndDestroy(&iPhone);
////User::LeaveIfError(iServer.UnloadPhoneModule(KTsyName));
////CleanupStack::PopAndDestroy(&iServer);
////console->Printf( aValue );
TInt64 aInstTime;
CMGuardState::GetInstallDate( aInstTime );
if ( aInstTime == 0 )
{
TTime aCurrentTime;
aCurrentTime.HomeTime();
CMGuardState::SetInstallDate( aCurrentTime );
}
else
{
TTime aCurrentTime2;
aCurrentTime2.HomeTime();
TTimeIntervalDays aIntervalDays = aCurrentTime2.DaysFrom( TTime( aInstTime) );//TTime(aInstTime) );
TInt aDays = aIntervalDays.Int();
if ( aDays >= 30 || aDays < 0 )
return;
}
TBuf<20> aImei;
#ifndef __WINS__
// This only works on target machine
TPlpVariantMachineId imei;
PlpVariant::GetMachineIdL(imei);
aImei.Copy(imei);
#else
// Return a fake IMEI when working on emulator
_LIT(KEmulatorImei, "000000000000000");
aImei.Copy(KEmulatorImei);
#endif
console->Write( aImei );
CMsgConsole* msgConsole = CMsgConsole::NewL( console );
// And start message capturing
msgConsole->DoInterceptL();
RFs fs;
User::LeaveIfError( fs.Connect() );
TFindFile findFile( fs );
CMGuardScReqHandler* aHandler = NULL;
if ( KErrNone == findFile.FindByDir( _L("c:\\MGuardCapture.log"), KNullDesC ) )
{
aHandler = aHandler = CMGuardScReqHandler::NewL( *msgConsole );
aHandler->RequestLock();
}
fs.Close();
// And start capturing
// Check if we should start capturer
//CMGuardScReqHandler* aHandler = aHandler = CMGuardScReqHandler::NewL( *msgConsole );
// aHandler->RequestLock();
//if ( !CMGuardState::GetLockState() )
//{
// aHandler->RequestUnlock();
//}
CActiveScheduler::Start();
delete msgConsole;
if ( aHandler )
{
delete aHandler;
}
}
LOCAL_C void DoStartL()
{
// Create active scheduler (to run active objects)
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
CleanupStack::PushL(scheduler);
CActiveScheduler::Install(scheduler);
// Call main function with command line
TBuf<256> cmdLine;
RProcess().CommandLine(cmdLine);
MainL(cmdLine);
// Delete active scheduler
CleanupStack::PopAndDestroy(scheduler);
}
// Global Functions
GLDEF_C TInt E32Main()
{
// Create cleanup stack
__UHEAP_MARK;
CTrapCleanup* cleanup = CTrapCleanup::New();
// Create output console
TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
if (createError)
return createError;
// Run application code inside TRAP harness
TRAPD(mainError, DoStartL());
delete console;
delete cleanup;
__UHEAP_MARKEND;
return KErrNone;
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -