author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:01:36 +0300 | |
branch | RCL_3 |
changeset 58 | ea43c23d28d2 |
parent 19 | 989d2f495d90 |
child 65 | 0b68a1b0c15e |
permissions | -rw-r--r-- |
19 | 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: tsysinfocurrentnetworkasync |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include "tsysinfonetworktests.h" |
|
21 |
#include "sysinfoservice.h" |
|
22 |
#include "entitykeys.h" |
|
23 |
#include "tsysinfocurrentnetworkasync.h" |
|
24 |
||
25 |
using namespace SysInfo; |
|
26 |
||
27 |
CCurrentNetAsync* CCurrentNetAsync::NewL(CStifLogger* aLog) |
|
28 |
{ |
|
29 |
CCurrentNetAsync* self = new(ELeave) CCurrentNetAsync(aLog); |
|
30 |
self->ConstructL(); |
|
31 |
return self; |
|
32 |
} |
|
33 |
||
34 |
CCurrentNetAsync::~CCurrentNetAsync() |
|
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 CCurrentNetAsync::ConstructL() |
|
47 |
{ |
|
48 |
iSysInfoService = CSysInfoService::NewL(); |
|
49 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
50 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
51 |
CActiveScheduler::Add(this); |
|
52 |
} |
|
53 |
||
54 |
CCurrentNetAsync::CCurrentNetAsync(CStifLogger* aLog) |
|
55 |
:CActive(EPriorityStandard), |
|
56 |
iLog(aLog) |
|
57 |
{ |
|
58 |
} |
|
59 |
||
60 |
void CCurrentNetAsync::DoCancel() |
|
61 |
{ |
|
62 |
} |
|
63 |
||
64 |
void CCurrentNetAsync::RunL() |
|
65 |
{ |
|
66 |
TestFuncL(); |
|
67 |
} |
|
68 |
||
69 |
void CCurrentNetAsync::Start() |
|
70 |
{ |
|
71 |
SetActive(); |
|
72 |
TRequestStatus* temp = &iStatus; |
|
73 |
User::RequestComplete(temp, KErrNone); |
|
74 |
iWaitSchedular->Start(); |
|
75 |
} |
|
76 |
||
77 |
TInt CCurrentNetAsync::Result() |
|
78 |
{ |
|
79 |
return iResult; |
|
80 |
} |
|
81 |
||
82 |
void CCurrentNetAsync::TestFuncL() |
|
83 |
{ |
|
58
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
84 |
TInt64 x = 6000000000; |
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
85 |
const TTimeIntervalMicroSeconds32 OneMinute = TTimeIntervalMicroSeconds32(x); |
19 | 86 |
iTransId = 5555; |
87 |
TRAPD(err,iSysInfoService->GetInfoL(KNetwork,KCurrentNetwork,iTransId,this)); |
|
88 |
iResult = err; |
|
89 |
iTimer->After(OneMinute); |
|
90 |
} |
|
91 |
||
92 |
void CCurrentNetAsync::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/, |
|
93 |
CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError) |
|
94 |
{ |
|
95 |
||
96 |
iLog->Log(_L("CurrentNetwork read...")); |
|
97 |
||
98 |
if(!aError) |
|
99 |
{ |
|
100 |
if(aTransID ==iTransId ) |
|
101 |
{ |
|
102 |
TInt32 tid = aTransID; |
|
103 |
CNetworkInfo* networkInfo= ((CNetworkInfo*)aOutput); |
|
104 |
||
105 |
TPtrC networkName = networkInfo->NetworkName(); |
|
106 |
iLog->Log(_L("Network name...")); |
|
107 |
iLog->Log(networkName); |
|
108 |
||
109 |
||
110 |
TInt networkMode =networkInfo->NetworkMode(); |
|
111 |
iLog->Log(_L("Network mode...")); |
|
112 |
TBuf<50> buf; |
|
113 |
buf.AppendNum(networkMode); |
|
114 |
iLog->Log(buf); |
|
115 |
||
116 |
TInt networkStatus = networkInfo->NetworkStatus(); |
|
117 |
iLog->Log(_L("Network Status...")); |
|
118 |
buf.Zero(); |
|
119 |
buf.AppendNum(networkStatus); |
|
120 |
iLog->Log(buf); |
|
121 |
||
122 |
TPtrC countryCode = networkInfo->CountryCode(); |
|
123 |
iLog->Log(_L("Country Code...")); |
|
124 |
buf.Zero(); |
|
125 |
buf.Copy(countryCode); |
|
126 |
iLog->Log(buf); |
|
127 |
||
128 |
TPtrC networkCode = networkInfo->NetworkCode(); |
|
129 |
iLog->Log(_L("Network Code...")); |
|
130 |
buf.Zero(); |
|
131 |
buf.Copy(networkCode); |
|
132 |
iLog->Log(buf); |
|
133 |
||
134 |
TUint locationAreaCode =networkInfo->LocationAreaCode(); |
|
135 |
iLog->Log(_L("Location Area Code...")); |
|
136 |
buf.Zero(); |
|
137 |
buf.AppendNum(locationAreaCode); |
|
138 |
iLog->Log(buf); |
|
139 |
||
140 |
TUint cellId = networkInfo->CellId(); |
|
141 |
iLog->Log(_L("CellId...")); |
|
142 |
buf.Zero(); |
|
143 |
buf.AppendNum(cellId); |
|
144 |
iLog->Log(buf); |
|
145 |
||
146 |
TBool validLocationAreaCode = networkInfo->ValidLocationAreaCode(); |
|
147 |
iLog->Log(_L("ValidLocationAreaCode...")); |
|
148 |
buf.Zero(); |
|
149 |
buf.AppendNum(validLocationAreaCode); |
|
150 |
iLog->Log(buf); |
|
151 |
||
152 |
||
153 |
iResult = PASS; |
|
154 |
} |
|
155 |
||
156 |
||
157 |
else |
|
158 |
{ |
|
159 |
iResult = PASS; |
|
160 |
||
161 |
} |
|
162 |
} |
|
163 |
else |
|
164 |
{ |
|
165 |
iLog->Log(_L("ERROR SET")); |
|
166 |
iResult = FAIL; |
|
167 |
} |
|
168 |
delete aOutput; |
|
169 |
iWaitSchedular->AsyncStop(); |
|
170 |
} |
|
171 |
||
172 |
void CCurrentNetAsync::HandleTimeOut() |
|
173 |
{ |
|
174 |
iLog->Log(_L("TimeOut reached...")); |
|
175 |
iSysInfoService->Cancel(1); |
|
176 |
iResult = FAIL; |
|
177 |
iWaitSchedular->AsyncStop(); |
|
178 |
} |
|
179 |
||
180 |
||
181 |