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