serviceproviders/sapi_sysinfo/tsrc/dev/servicetests/manual/tsysinfonetworktests/src/tsysinfosigstrengthnotify.cpp
changeset 19 989d2f495d90
child 58 ea43c23d28d2
equal deleted inserted replaced
14:a36b1e19a461 19:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:   tsysinfosigstrengthasyn
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "tsysinfonetworktests.h"
       
    21 #include "sysinfoservice.h"
       
    22 #include "entitykeys.h"
       
    23 #include "tsysinfosigstrengthnotify.h"
       
    24 
       
    25 using namespace SysInfo;
       
    26 
       
    27 CSignalStrNotify* CSignalStrNotify::NewL(CStifLogger* aLog,TInt aStrength)
       
    28 	{
       
    29 	CSignalStrNotify* self = new(ELeave) CSignalStrNotify(aLog,aStrength);
       
    30 	self->ConstructL();
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 CSignalStrNotify::~CSignalStrNotify()
       
    35 	{
       
    36 	Cancel();
       
    37 	
       
    38 	if(iWaitSchedular->IsStarted())
       
    39 		iWaitSchedular->AsyncStop();
       
    40 	
       
    41 	delete iSysInfoService;
       
    42 	delete iWaitSchedular;
       
    43 	delete iTimer;
       
    44 	}
       
    45 
       
    46 void CSignalStrNotify::ConstructL()
       
    47 	{
       
    48 	iSysInfoService = CSysInfoService::NewL();
       
    49 	iWaitSchedular  = new(ELeave) CActiveSchedulerWait();
       
    50 	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    51 	CActiveScheduler::Add(this);
       
    52 	}
       
    53 
       
    54 CSignalStrNotify::CSignalStrNotify(CStifLogger* aLog,TInt aStrength)
       
    55 							 :CActive(EPriorityStandard),
       
    56 								iLog(aLog),iSignalStrength(aStrength)
       
    57 	{
       
    58 	}
       
    59 
       
    60 void CSignalStrNotify::DoCancel()
       
    61 	{
       
    62 	}
       
    63 
       
    64 void CSignalStrNotify::RunL()
       
    65 	{
       
    66 	TestFuncL();
       
    67 	}
       
    68 
       
    69 void CSignalStrNotify::Start()
       
    70 	{
       
    71 	SetActive();
       
    72 	TRequestStatus* temp = &iStatus;
       
    73 	User::RequestComplete(temp, KErrNone);
       
    74 	iWaitSchedular->Start();	
       
    75 	}
       
    76 
       
    77 TInt CSignalStrNotify::Result()
       
    78 	{
       
    79 	return iResult;
       
    80 	}
       
    81 
       
    82 void CSignalStrNotify::TestFuncL()
       
    83 	{
       
    84 	const TTimeIntervalMicroSeconds32 OneMinute(6000000000);
       
    85 	TRAPD(err,iSysInfoService->GetNotificationL(KNetwork,KSignalStrength,2222,this));
       
    86 	iResult  = err;
       
    87 
       
    88 	iTimer->After(OneMinute);
       
    89 	}
       
    90 
       
    91 void CSignalStrNotify::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
       
    92 	 					CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError)
       
    93 	{
       
    94 
       
    95 	iLog->Log(_L("Signal Strength read.."));
       
    96 	
       
    97 	if(!aError)
       
    98 		{
       
    99 		TInt32 tid = aTransID;
       
   100 		TInt SignalStrength = ((CStatus*)aOutput)->Status();
       
   101 		
       
   102 		{
       
   103 			iResult = PASS;
       
   104 			iLog->Log(_L("Signal strength is with in specified range"));
       
   105 			
       
   106 			TInt32 tid = aTransID;
       
   107 			TInt cellId = ((CStatus*)aOutput)->Status();
       
   108 			
       
   109 			TBuf<50> buf;
       
   110 			buf.AppendNum(cellId);
       
   111 			iLog->Log(buf);
       
   112 		
       
   113 			}
       
   114 	
       
   115 		}
       
   116 	else
       
   117 		{
       
   118 		iLog->Log(_L("ERROR SET"));
       
   119 		iResult = FAIL;
       
   120 		}
       
   121 		delete aOutput;
       
   122 	iWaitSchedular->AsyncStop();
       
   123 	}
       
   124 
       
   125 void CSignalStrNotify::HandleTimeOut()
       
   126 {
       
   127 	iLog->Log(_L("TimeOut reached..."));
       
   128 	iSysInfoService->Cancel(1);
       
   129 	iResult = FAIL;
       
   130 	iWaitSchedular->AsyncStop();
       
   131 }