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