author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include <liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include<liwservicehandler.h> |
19 | 22 |
|
23 |
#include"tsysinfoprovidernetworktests.h" |
|
24 |
#include "sysinfointerface.h" |
|
25 |
#include "sysinfoaiwparams.hrh" |
|
26 |
#include "tcurrentnetworknotify.h" |
|
27 |
#include"entitykeys.h" |
|
28 |
||
29 |
using namespace LIW ; |
|
30 |
using namespace SysInfo; |
|
31 |
||
32 |
using namespace sysinfoaiwparams; |
|
33 |
||
34 |
||
35 |
CCurrentNetNotify* CCurrentNetNotify::NewL(CStifLogger* aLog) |
|
36 |
{ |
|
37 |
CCurrentNetNotify* self = new(ELeave) CCurrentNetNotify(aLog); |
|
38 |
self->ConstructL(); |
|
39 |
return self; |
|
40 |
} |
|
41 |
||
42 |
CCurrentNetNotify::~CCurrentNetNotify() |
|
43 |
{ |
|
44 |
Cancel(); |
|
45 |
||
46 |
interface->Close(); |
|
47 |
||
48 |
delete iServiceHandler; |
|
49 |
||
50 |
if(iWaitSchedular->IsStarted()) |
|
51 |
iWaitSchedular->AsyncStop(); |
|
52 |
||
53 |
if(iWaitSchedular) |
|
54 |
delete iWaitSchedular; |
|
55 |
||
56 |
delete iTimer; |
|
57 |
||
58 |
} |
|
59 |
||
60 |
void CCurrentNetNotify::ConstructL() |
|
61 |
{ |
|
62 |
CActiveScheduler::Add(this); |
|
63 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
64 |
||
65 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
66 |
} |
|
67 |
||
68 |
CCurrentNetNotify::CCurrentNetNotify(CStifLogger* aLog) : |
|
69 |
CActive(EPriorityStandard),iResult(-1),iLog(aLog) |
|
70 |
{ |
|
71 |
} |
|
72 |
||
73 |
void CCurrentNetNotify::DoCancel() |
|
74 |
{ |
|
75 |
||
76 |
//TRAPD(err1,iSysInfoService->GetInfoL(req1)); |
|
77 |
||
78 |
} |
|
79 |
||
80 |
void CCurrentNetNotify::RunL() |
|
81 |
{ |
|
82 |
TestFuncL(); |
|
83 |
} |
|
84 |
||
85 |
void CCurrentNetNotify::Start() |
|
86 |
{ |
|
87 |
||
88 |
SetActive(); |
|
89 |
TRequestStatus* temp = &iStatus; |
|
90 |
User::RequestComplete(temp, KErrNone); |
|
91 |
iWaitSchedular->Start(); |
|
92 |
} |
|
93 |
||
94 |
TInt CCurrentNetNotify::Result() |
|
95 |
{ |
|
96 |
return iResult; |
|
97 |
} |
|
98 |
||
99 |
void CCurrentNetNotify::TestFuncL() |
|
100 |
{ |
|
101 |
const TTimeIntervalMicroSeconds32 OneMinute(6000000000); |
|
102 |
TInt result =KErrNone; |
|
103 |
||
104 |
TInt32 oldDisplayLang = 0 ,newDisplayLang = 0; |
|
105 |
||
106 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
107 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
108 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
109 |
||
110 |
TInt err = KErrNone; |
|
111 |
||
112 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
113 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
114 |
||
115 |
RCriteriaArray a; |
|
116 |
a.AppendL(crit); |
|
117 |
||
118 |
iServiceHandler->AttachL(a); |
|
119 |
||
120 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
121 |
||
122 |
delete crit; |
|
123 |
a.Reset(); |
|
124 |
||
125 |
TInt pos = 0; |
|
126 |
||
127 |
outparam->FindFirst( pos, KIDataSource ); |
|
128 |
if(pos != KErrNotFound) |
|
129 |
{ |
|
130 |
//getting the interface handle |
|
131 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
132 |
} |
|
133 |
||
134 |
outparam->Reset(); |
|
135 |
inparam->Reset(); |
|
136 |
||
137 |
if(interface) |
|
138 |
{ |
|
139 |
TLiwGenericParam entity; |
|
140 |
TLiwVariant entityname; |
|
141 |
TLiwGenericParam key; |
|
142 |
TLiwVariant keyname; |
|
143 |
||
144 |
entityname.Set(KNetwork); |
|
145 |
entity.SetNameAndValueL(KEntity,entityname); |
|
146 |
||
147 |
keyname.Set(KCurrentNetwork); |
|
148 |
key.SetNameAndValueL(KKey,keyname); |
|
149 |
||
150 |
inparam->AppendL(entity); |
|
151 |
||
152 |
inparam->AppendL(key); |
|
153 |
||
154 |
entity.Reset(); |
|
155 |
entityname.Reset(); |
|
156 |
key.Reset(); |
|
157 |
keyname.Reset(); |
|
158 |
||
159 |
//get notification vibra Active |
|
160 |
TRAPD(err1, interface->ExecuteCmdL(KGetNotification,*inparam,*outparam,KLiwOptASyncronous,this)); |
|
161 |
iResult = err1; |
|
162 |
if(err1 == KErrNone) |
|
163 |
{ |
|
164 |
iResult = err1; |
|
165 |
}//err1 |
|
166 |
||
167 |
}//interface |
|
168 |
else |
|
169 |
{ |
|
170 |
iLog->Log( _L("API returned error") ); |
|
171 |
iResult = err; |
|
172 |
iWaitSchedular->AsyncStop(); |
|
173 |
} |
|
174 |
||
175 |
iTimer->After(OneMinute); |
|
176 |
||
177 |
return ; |
|
178 |
} |
|
179 |
||
180 |
TInt CCurrentNetNotify::HandleNotifyL(TInt aCmdId, |
|
181 |
TInt aEventId, |
|
182 |
CLiwGenericParamList& aEventParamList, |
|
183 |
const CLiwGenericParamList& aInParamList) |
|
184 |
{ |
|
185 |
||
186 |
TInt pos = 0 ,err =0; |
|
187 |
aEventParamList.FindFirst( pos, KErrorCode ); |
|
188 |
if(pos != KErrNotFound) |
|
189 |
{ |
|
190 |
if( (aEventParamList)[pos].Value().AsTInt32() != KErrNone ) |
|
191 |
err = (TInt)((aEventParamList)[pos].Value().AsTInt32()); |
|
192 |
} |
|
193 |
||
194 |
pos = 0 ; |
|
195 |
const TLiwGenericParam* output2 = aEventParamList.FindFirst( pos,KReturnValue ); |
|
196 |
if(output2) |
|
197 |
{ |
|
198 |
const CLiwMap* Map = output2->Value().AsMap(); |
|
199 |
if ( Map ) |
|
200 |
{ |
|
201 |
||
202 |
TLiwVariant networkNameVar; |
|
203 |
Map->FindL(KNetworkName,networkNameVar); |
|
204 |
TPtrC networkName = networkNameVar.AsDes(); |
|
205 |
TBuf<50> buf; |
|
206 |
buf.Copy(networkName); |
|
207 |
iLog->Log(buf); |
|
208 |
networkNameVar.Reset(); |
|
209 |
||
210 |
TLiwVariant networkStatusVar; |
|
211 |
Map->FindL(KNetworkStatus,networkStatusVar); |
|
212 |
TInt networkStatus = networkStatusVar.AsTInt32(); |
|
213 |
buf.Zero(); |
|
214 |
buf.AppendNum(networkStatus); |
|
215 |
iLog->Log(buf); |
|
216 |
networkStatusVar.Reset(); |
|
217 |
||
218 |
TLiwVariant networkModeVar; |
|
219 |
Map->FindL(sysinfoaiwparams::KNetworkMode,networkModeVar); |
|
220 |
TInt networkMode = networkModeVar.AsTInt32(); |
|
221 |
buf.Zero(); |
|
222 |
buf.AppendNum(networkMode); |
|
223 |
iLog->Log(buf); |
|
224 |
networkModeVar.Reset(); |
|
225 |
||
226 |
TLiwVariant countryCodeVar; |
|
227 |
Map->FindL(KCountryCode,countryCodeVar); |
|
228 |
TPtrC countryCode = countryCodeVar.AsDes(); |
|
229 |
buf.Zero(); |
|
230 |
buf.Copy(countryCode); |
|
231 |
iLog->Log(buf); |
|
232 |
countryCodeVar.Reset(); |
|
233 |
||
234 |
TLiwVariant networkCodeVar; |
|
235 |
Map->FindL(KNetworkCode,networkCodeVar); |
|
236 |
TPtrC networkCode = networkCodeVar.AsDes(); |
|
237 |
buf.Zero(); |
|
238 |
buf.Copy(networkCode); |
|
239 |
iLog->Log(buf); |
|
240 |
networkCodeVar.Reset(); |
|
241 |
||
242 |
TLiwVariant locationStatusVar; |
|
243 |
Map->FindL(KLocationStatus,locationStatusVar); |
|
244 |
TBool locationStatus = locationStatusVar.AsTBool(); |
|
245 |
buf.Zero(); |
|
246 |
buf.AppendNum(locationStatus); |
|
247 |
iLog->Log(buf); |
|
248 |
locationStatusVar.Reset(); |
|
249 |
||
250 |
TLiwVariant locationAreaCodeVar; |
|
251 |
Map->FindL(KAreaCode,locationAreaCodeVar); |
|
252 |
TUint locationAreaCode = locationAreaCodeVar.AsTUint(); |
|
253 |
buf.Zero(); |
|
254 |
buf.AppendNum(locationAreaCode); |
|
255 |
iLog->Log(buf); |
|
256 |
locationAreaCodeVar.Reset(); |
|
257 |
||
258 |
||
259 |
TLiwVariant cellIdVar; |
|
260 |
Map->FindL(KCellId,cellIdVar); |
|
261 |
TUint cellId = cellIdVar.AsTUint(); |
|
262 |
buf.Zero(); |
|
263 |
buf.AppendNum(cellId); |
|
264 |
iLog->Log(buf); |
|
265 |
cellIdVar.Reset(); |
|
266 |
||
267 |
||
268 |
}//map |
|
269 |
||
270 |
}//output |
|
271 |
else |
|
272 |
{ |
|
273 |
||
274 |
iLog->Log( _L("Output data Set to NULL") ); |
|
275 |
} |
|
276 |
||
277 |
||
278 |
iWaitSchedular->AsyncStop(); |
|
279 |
} |
|
280 |
||
281 |
||
282 |
void CCurrentNetNotify::HandleTimeOut() |
|
283 |
{/* |
|
284 |
iLog->Log(_L("TimeOut reached...")); |
|
285 |
interface->Close(); |
|
286 |
iResult = FAIL; |
|
287 |
iWaitSchedular->AsyncStop(); |
|
288 |
*/ |
|
289 |
} |