sapi_sysinfo/tsrc/testing/tsysbattery/src/tsysbatterynot.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:   Tests battery notifications
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "TSysBattery.h"
       
    21 #include "sysinfoservice.h"
       
    22 #include "entitykeys.h"
       
    23 #include "tsysbatterynot.h"
       
    24 
       
    25 using namespace SysInfo;
       
    26 
       
    27 CBatteryNot* CBatteryNot::NewL(CStifLogger* aLog, TInt aCmdId)
       
    28 	{
       
    29 	CBatteryNot* self = new(ELeave) CBatteryNot(aLog,aCmdId );
       
    30 	self->ConstructL();
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 CBatteryNot::~CBatteryNot()
       
    35 	{
       
    36 	Cancel();
       
    37 	
       
    38 	if(iWaitScheduler->IsStarted())
       
    39 		iWaitScheduler->AsyncStop();
       
    40 	
       
    41 	delete iSysInfoService;
       
    42 	delete iWaitScheduler;
       
    43 	delete iTimer;
       
    44 	}
       
    45 
       
    46 void CBatteryNot::ConstructL()
       
    47 	{
       
    48 	iSysInfoService = CSysInfoService::NewL();
       
    49 	iWaitScheduler  = new(ELeave) CActiveSchedulerWait();
       
    50 	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    51 	CActiveScheduler::Add(this);
       
    52 	}
       
    53 
       
    54 CBatteryNot::CBatteryNot(CStifLogger* aLog, TInt aCmdId)
       
    55 							 :CActive(EPriorityStandard),
       
    56 								iLog(aLog), iCmdId(aCmdId)
       
    57 	{
       
    58 	}
       
    59 
       
    60 void CBatteryNot::DoCancel()
       
    61 	{
       
    62 	}
       
    63 
       
    64 void CBatteryNot::RunL()
       
    65 	{
       
    66 	if(iCmdId == EWrongData)
       
    67 		{
       
    68 		TRAP(iResult,TestFuncL());	
       
    69 		}
       
    70 	
       
    71 	else if(iCmdId == EWrongKey)
       
    72 		{
       
    73 		TRAP(iResult,TestFunc1L());
       
    74 		}
       
    75 	iWaitScheduler->AsyncStop();
       
    76 	}
       
    77 
       
    78 void CBatteryNot::Start()
       
    79 	{
       
    80 	SetActive();
       
    81 	TRequestStatus* temp = &iStatus;
       
    82 	User::RequestComplete(temp, KErrNone);
       
    83 	iWaitScheduler->Start();	
       
    84 	}
       
    85 
       
    86 TInt CBatteryNot::Result()
       
    87 	{
       
    88 	return iResult ;
       
    89 	}
       
    90 
       
    91 void CBatteryNot::TestFuncL()
       
    92 	{
       
    93 	_LIT(KSample,"Simple") ;
       
    94 //	const TTimeIntervalMicroSeconds32 threeMin(180000000);
       
    95 	CStringData* inputData = CStringData::NewL(KSample) ; 
       
    96 	CleanupStack::PushL(inputData);
       
    97 	iSysInfoService->GetNotificationL(KBattery,KBatteryStrength,1,this,inputData);
       
    98 //	iTimer->After(threeMin);
       
    99 //	delete inputData ;
       
   100 	CleanupStack::PopAndDestroy() ;
       
   101 	}
       
   102 
       
   103 void CBatteryNot::TestFunc1L()
       
   104 	{
       
   105 	_LIT(KSample,"Simple") ;
       
   106 	CStringData* inputData = CStringData::NewL(KSample) ; 
       
   107 	CleanupStack::PushL(inputData);
       
   108 	iSysInfoService->GetNotificationL(KBattery,KSample,1,this,inputData);
       
   109 	CleanupStack::PopAndDestroy() ;
       
   110 	}
       
   111 	
       
   112 void CBatteryNot::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
       
   113 	 					CSysData* aOutput, TInt32 /*aTransID*/,TSysRequest::TRequestType /*aType*/, TInt /*aError*/)
       
   114 	{
       
   115 	
       
   116 	delete aOutput ;
       
   117 	
       
   118 	}
       
   119 
       
   120 void CBatteryNot::HandleTimeOut()
       
   121 {
       
   122 	
       
   123 }