sapi_sysinfo/tsrc/testing/tsysbattery/src/tsysbatterystrengthasync.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "TSysBattery.h"
       
    21 #include "sysinfoservice.h"
       
    22 #include "entitykeys.h"
       
    23 #include "tsysbatterystrengthasync.h"
       
    24 
       
    25 using namespace SysInfo;
       
    26 _LIT(KBatteryLevel,"BatteryLevel");
       
    27 
       
    28 CBatteryStrengthAsync* CBatteryStrengthAsync::NewL(CStifLogger* aLog)
       
    29 	{
       
    30 	CBatteryStrengthAsync* self = new(ELeave) CBatteryStrengthAsync(aLog);
       
    31 	self->ConstructL();
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CBatteryStrengthAsync::~CBatteryStrengthAsync()
       
    36 	{
       
    37 	Cancel();
       
    38 	
       
    39 	if(iWaitScheduler->IsStarted())
       
    40 		iWaitScheduler->AsyncStop();
       
    41 	
       
    42 	delete iSysInfoService;
       
    43 	delete iWaitScheduler;
       
    44 //	delete iTimer;
       
    45 	}
       
    46 
       
    47 void CBatteryStrengthAsync::ConstructL()
       
    48 	{
       
    49 	iSysInfoService = CSysInfoService::NewL();
       
    50 	iWaitScheduler  = new(ELeave) CActiveSchedulerWait();
       
    51 //	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    52 	CActiveScheduler::Add(this);
       
    53 	}
       
    54 
       
    55 CBatteryStrengthAsync::CBatteryStrengthAsync(CStifLogger* aLog)
       
    56 							 :CActive(EPriorityStandard),
       
    57 								iLog(aLog)
       
    58 	{
       
    59 	}
       
    60 
       
    61 void CBatteryStrengthAsync::DoCancel()
       
    62 	{
       
    63 	}
       
    64 
       
    65 void CBatteryStrengthAsync::RunL()
       
    66 	{
       
    67 	TRAP(iResult,TestFuncL());
       
    68 	iWaitScheduler->AsyncStop();
       
    69 	}
       
    70 
       
    71 void CBatteryStrengthAsync::Start()
       
    72 	{
       
    73 	SetActive();
       
    74 	TRequestStatus* temp = &iStatus;
       
    75 	User::RequestComplete(temp, KErrNone);
       
    76 	iWaitScheduler->Start();	
       
    77 	}
       
    78 
       
    79 TInt CBatteryStrengthAsync::Result()
       
    80 	{
       
    81 	return iResult;
       
    82 	}
       
    83 
       
    84 void CBatteryStrengthAsync::TestFuncL()
       
    85 	{
       
    86 //	const TTimeIntervalMicroSeconds32 OneMinute(60000000);
       
    87 	iSysInfoService->GetInfoL(KBattery,KBatteryLevel,1,this);
       
    88 //	iTimer->After(OneMinute);
       
    89 	}
       
    90 
       
    91 void CBatteryStrengthAsync::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
       
    92 	 					CSysData* /*aOutput*/, TInt32 /*aTransID*/,TSysRequest::TRequestType /*aType*/, TInt /*aError*/)
       
    93 	{
       
    94 
       
    95 	}
       
    96