serviceproviders/sapi_sysinfo/tsrc/dev/servicetests/manual/tsysinfonetworktests/src/tsysinforegstatusnotify.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:   tsysinforegstatusnotify
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "tsysinfonetworktests.h"
       
    21 #include "sysinfoservice.h"
       
    22 #include "entitykeys.h"
       
    23 #include "tsysinforegstatusnotify.h"
       
    24 
       
    25 using namespace SysInfo;
       
    26 
       
    27 CRegStatusNotify* CRegStatusNotify::NewL(CStifLogger* aLog)
       
    28 	{
       
    29 	CRegStatusNotify* self = new(ELeave) CRegStatusNotify(aLog);
       
    30 	self->ConstructL();
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 CRegStatusNotify::~CRegStatusNotify()
       
    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 CRegStatusNotify::ConstructL()
       
    47 	{
       
    48 	iSysInfoService = CSysInfoService::NewL();
       
    49 	iWaitSchedular  = new(ELeave) CActiveSchedulerWait();
       
    50 	iTimer			= CWatchTimer::NewL(EPriorityNormal,this);
       
    51 	CActiveScheduler::Add(this);
       
    52 	}
       
    53 
       
    54 CRegStatusNotify::CRegStatusNotify(CStifLogger* aLog)
       
    55 							 :CActive(EPriorityStandard),
       
    56 								iLog(aLog)
       
    57 	{
       
    58 	}
       
    59 
       
    60 void CRegStatusNotify::DoCancel()
       
    61 	{
       
    62 	}
       
    63 
       
    64 void CRegStatusNotify::RunL()
       
    65 	{
       
    66 	TestFuncL();
       
    67 	}
       
    68 
       
    69 void CRegStatusNotify::Start()
       
    70 	{
       
    71 	SetActive();
       
    72 	TRequestStatus* temp = &iStatus;
       
    73 	User::RequestComplete(temp, KErrNone);
       
    74 	iWaitSchedular->Start();	
       
    75 	}
       
    76 
       
    77 TInt CRegStatusNotify::Result()
       
    78 	{
       
    79 	return iResult;
       
    80 	}
       
    81 
       
    82 void CRegStatusNotify::TestFuncL()
       
    83 	{
       
    84 	const TTimeIntervalMicroSeconds32 OneMinute(6000000000);
       
    85 	TRAPD(err ,iSysInfoService->GetNotificationL(KNetwork,KRegistrationStatus,9999,this));
       
    86 	iResult = err ;
       
    87 	iTimer->After(OneMinute);
       
    88 	}
       
    89 
       
    90 void CRegStatusNotify::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
       
    91 	 					CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError)
       
    92 	{
       
    93 
       
    94 	iLog->Log(_L("RegStatusNotify..."));
       
    95 	
       
    96 	if(!aError)
       
    97 		{
       
    98 		TInt32 tid = aTransID;
       
    99 		TInt networkMode= ((CStatus*)aOutput)->Status();
       
   100 		
       
   101 		TBuf<20> buf;
       
   102 		buf.AppendNum(networkMode);
       
   103 		iLog->Log(buf);
       
   104 
       
   105 		iResult = PASS;
       
   106 		
       
   107 		}
       
   108 	else
       
   109 		{
       
   110 		iLog->Log(_L("ERROR SET"));
       
   111 		iResult = FAIL;
       
   112 		}
       
   113 	delete aOutput;
       
   114 	iWaitSchedular->AsyncStop();
       
   115 	}
       
   116 
       
   117 void CRegStatusNotify::HandleTimeOut()
       
   118 {
       
   119 	iLog->Log(_L("TimeOut reached..."));
       
   120 	iSysInfoService->Cancel(9999);
       
   121 	iResult = FAIL;
       
   122 	iWaitSchedular->AsyncStop();
       
   123 }
       
   124 
       
   125 
       
   126