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) 2009 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
18 |
#include <liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
19 |
#include<liwservicehandler.h> |
19 | 20 |
|
21 |
#include "tsysinfoprovidergeneraltests.h" |
|
22 |
#include "sysinfointerface.h" |
|
23 |
#include"entitykeys.h" |
|
24 |
#include "sysinfoaiwparams.hrh" |
|
25 |
#include"watchtimer.h" |
|
26 |
#include "serviceerrno.h" |
|
27 |
||
28 |
using namespace LIW ; |
|
29 |
using namespace SysInfo; |
|
30 |
using namespace sysinfoaiwparams; |
|
31 |
||
32 |
||
33 |
class CTestConnList : public CActive ,public MLiwNotifyCallback, public MTimeOutCallBack |
|
34 |
{ |
|
35 |
public: |
|
36 |
static CTestConnList* NewL(CStifLogger* aLog); |
|
37 |
~CTestConnList(); |
|
38 |
void Start(); |
|
39 |
TInt Result(); |
|
40 |
||
41 |
TInt HandleNotifyL(TInt aCmdId, |
|
42 |
TInt aEventId, |
|
43 |
CLiwGenericParamList& aEventParamList, |
|
44 |
const CLiwGenericParamList& aInParamList); |
|
45 |
||
46 |
IMPORT_C static TInt32 GetTransactionID(); |
|
47 |
void HandleTimeOut (); |
|
48 |
private: |
|
49 |
void ConstructL(); |
|
50 |
CTestConnList(CStifLogger* aLog); |
|
51 |
||
52 |
virtual void DoCancel(); |
|
53 |
virtual void RunL(); |
|
54 |
||
55 |
void TestFunc(); |
|
56 |
||
57 |
private: |
|
58 |
CActiveSchedulerWait* iWaitSchedular; |
|
59 |
CLiwServiceHandler* iServiceHandler; |
|
60 |
MLiwInterface* interface ; |
|
61 |
TInt32 btstatus ; |
|
62 |
TInt iResult; |
|
63 |
CStifLogger* iLog; |
|
64 |
CWatchTimer* iTimer; |
|
65 |
}; |
|
66 |
||
67 |
CTestConnList* CTestConnList::NewL(CStifLogger* aLog) |
|
68 |
{ |
|
69 |
CTestConnList* self = new(ELeave) CTestConnList(aLog); |
|
70 |
self->ConstructL(); |
|
71 |
return self; |
|
72 |
} |
|
73 |
||
74 |
CTestConnList::~CTestConnList() |
|
75 |
{ |
|
76 |
Cancel(); |
|
77 |
||
78 |
interface->Close(); |
|
79 |
||
80 |
delete iServiceHandler; |
|
81 |
||
82 |
if(iWaitSchedular->IsStarted()) |
|
83 |
iWaitSchedular->AsyncStop(); |
|
84 |
||
85 |
if(iWaitSchedular) |
|
86 |
delete iWaitSchedular; |
|
87 |
delete iTimer; |
|
88 |
} |
|
89 |
||
90 |
void CTestConnList::ConstructL() |
|
91 |
{ |
|
92 |
CActiveScheduler::Add(this); |
|
93 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
94 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
95 |
} |
|
96 |
||
97 |
CTestConnList::CTestConnList(CStifLogger* aLog) : |
|
98 |
CActive(EPriorityStandard),iResult(-1),iLog(aLog) |
|
99 |
{ |
|
100 |
} |
|
101 |
||
102 |
void CTestConnList::DoCancel() |
|
103 |
{ |
|
104 |
||
105 |
//TRAPD(err1,iSysInfoService->GetInfoL(req1)); |
|
106 |
||
107 |
} |
|
108 |
||
109 |
void CTestConnList::RunL() |
|
110 |
{ |
|
111 |
TestFunc(); |
|
112 |
} |
|
113 |
||
114 |
void CTestConnList::Start() |
|
115 |
{ |
|
116 |
||
117 |
SetActive(); |
|
118 |
TRequestStatus* temp = &iStatus; |
|
119 |
User::RequestComplete(temp, KErrNone); |
|
120 |
iWaitSchedular->Start(); |
|
121 |
} |
|
122 |
||
123 |
TInt CTestConnList::Result() |
|
124 |
{ |
|
125 |
return iResult; |
|
126 |
} |
|
127 |
||
128 |
void CTestConnList::TestFunc() |
|
129 |
{ |
|
130 |
const TTimeIntervalMicroSeconds32 OneMinute(60000000); |
|
131 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
132 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
133 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
134 |
||
135 |
TInt err = KErrNone; |
|
136 |
||
137 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
138 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
139 |
||
140 |
RCriteriaArray a; |
|
141 |
a.AppendL(crit); |
|
142 |
||
143 |
iServiceHandler->AttachL(a); |
|
144 |
||
145 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
146 |
||
147 |
delete crit; |
|
148 |
a.Reset(); |
|
149 |
||
150 |
TInt pos = 0; |
|
151 |
||
152 |
outparam->FindFirst( pos, KIDataSource ); |
|
153 |
if(pos != KErrNotFound) |
|
154 |
{ |
|
155 |
//getting the interface handle |
|
156 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
157 |
} |
|
158 |
||
159 |
outparam->Reset(); |
|
160 |
inparam->Reset(); |
|
161 |
||
162 |
if(interface) |
|
163 |
{ |
|
164 |
TLiwGenericParam entity; |
|
165 |
TLiwVariant entityname; |
|
166 |
TLiwGenericParam key; |
|
167 |
TLiwVariant keyname; |
|
168 |
||
169 |
entityname.Set(KConnectivity); |
|
170 |
entity.SetNameAndValueL(KEntity,entityname); |
|
171 |
||
172 |
keyname.Set(KActiveConnections); |
|
173 |
key.SetNameAndValueL(KKey,keyname); |
|
174 |
||
175 |
inparam->AppendL(entity); |
|
176 |
||
177 |
inparam->AppendL(key); |
|
178 |
||
179 |
entity.Reset(); |
|
180 |
entityname.Reset(); |
|
181 |
key.Reset(); |
|
182 |
keyname.Reset(); |
|
183 |
||
184 |
//get notification vibra Active |
|
185 |
TRAPD(err1, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam,KLiwOptASyncronous,this)); |
|
186 |
iTimer->After(OneMinute); |
|
187 |
||
188 |
iResult = err1; |
|
189 |
if(err1 == KErrNone) |
|
190 |
{ |
|
191 |
pos = 0 ; |
|
192 |
outparam->FindFirst( pos, KErrorCode ); |
|
193 |
if(pos != KErrNotFound) |
|
194 |
{ |
|
195 |
iResult = (TInt)((*outparam)[pos].Value().AsTInt32()); |
|
196 |
} |
|
197 |
if(iResult == SErrBadArgumentType) |
|
198 |
{ |
|
199 |
iLog->Log(_L("after KCancel SErrBadArgumentType:")); |
|
200 |
iResult = -1; |
|
201 |
} |
|
202 |
else |
|
203 |
{ |
|
204 |
iResult = 0; |
|
205 |
} |
|
206 |
}//err1 |
|
207 |
outparam->Reset(); |
|
208 |
inparam->Reset(); |
|
209 |
||
210 |
}//interface |
|
211 |
else |
|
212 |
{ |
|
213 |
iLog->Log( _L("Interface not loaded..") ); |
|
214 |
iResult = err; |
|
215 |
iWaitSchedular->AsyncStop(); |
|
216 |
} |
|
217 |
||
218 |
return ; |
|
219 |
} |
|
220 |
||
221 |
TInt CTestConnList::HandleNotifyL(TInt /*aCmdId*/, |
|
222 |
TInt /*aEventId*/, |
|
223 |
CLiwGenericParamList& aEventParamList, |
|
224 |
const CLiwGenericParamList& /*aInParamList*/) |
|
225 |
{ |
|
226 |
iLog->Log(_L("In HandleNotifyL")); |
|
227 |
TInt pos = 0; |
|
228 |
aEventParamList.FindFirst( pos, KErrorCode ); |
|
229 |
if(pos != KErrNotFound) |
|
230 |
{ |
|
231 |
if( (aEventParamList)[pos].Value().AsTInt32() != KErrNone ) |
|
232 |
iResult = (TInt)((aEventParamList)[pos].Value().AsTInt32()); |
|
233 |
TBuf<50> buf; |
|
234 |
buf.AppendNum(iResult); |
|
235 |
iLog->Log(_L("Error Code: ")); |
|
236 |
iLog->Log(buf); |
|
237 |
} |
|
238 |
||
239 |
pos = 0 ; |
|
240 |
const TLiwGenericParam* output2 = aEventParamList.FindFirst( pos,KReturnValue ); |
|
241 |
if(output2) |
|
242 |
{ |
|
243 |
iLog->Log(_L("KReturnValue Found")); |
|
244 |
const CLiwMap* Map = output2->Value().AsMap(); |
|
245 |
if ( Map ) |
|
246 |
{ |
|
247 |
TLiwVariant data; |
|
248 |
Map->FindL(KConnectionList,data); |
|
249 |
CLiwIterable* iterlist=data.AsIterable(); |
|
250 |
||
251 |
if(iterlist) |
|
252 |
{ |
|
253 |
TLiwVariant iterdata;int countlist = 0; |
|
254 |
while(iterlist->NextL(iterdata)) |
|
255 |
{ |
|
256 |
const CLiwMap* Map = iterdata.AsMap(); |
|
257 |
if ( Map ) |
|
258 |
{ |
|
259 |
TLiwVariant iapidVar; |
|
260 |
Map->FindL(KIAPID,iapidVar); |
|
261 |
TInt32 iapid = iapidVar.AsTInt32(); |
|
262 |
TBuf<50> buf; |
|
263 |
buf.AppendNum(iapid); |
|
264 |
iLog->Log(_L("IAPID")); |
|
265 |
iLog->Log(buf); |
|
266 |
iapidVar.Reset(); |
|
267 |
||
268 |
||
269 |
TLiwVariant bearerTypeVar; |
|
270 |
Map->FindL(KConnectionType,bearerTypeVar); |
|
271 |
TInt32 bearerType = bearerTypeVar.AsTInt32(); |
|
272 |
buf.Zero(); |
|
273 |
buf.AppendNum(bearerType); |
|
274 |
iLog->Log(_L("Bearer Type:")); |
|
275 |
iLog->Log(buf); |
|
276 |
bearerTypeVar.Reset(); |
|
277 |
||
278 |
TLiwVariant iapNameVar; |
|
279 |
Map->FindL(KIAPName,iapNameVar); |
|
280 |
TPtrC iapName = iapNameVar.AsDes(); |
|
281 |
buf.Zero(); |
|
282 |
buf.Copy(iapName); |
|
283 |
iLog->Log(_L("IAP Name:")); |
|
284 |
iLog->Log(buf); |
|
285 |
iapNameVar.Reset(); |
|
286 |
||
287 |
TLiwVariant netNameVar; |
|
288 |
Map->FindL(KNetworkName,netNameVar); |
|
289 |
TPtrC netName = netNameVar.AsDes(); |
|
290 |
buf.Zero(); |
|
291 |
buf.Copy(netName); |
|
292 |
iLog->Log(_L("network Name:")); |
|
293 |
iLog->Log(buf); |
|
294 |
netNameVar.Reset(); |
|
295 |
||
296 |
TLiwVariant connNameVar; |
|
297 |
Map->FindL(KIAPConnectionName,connNameVar); |
|
298 |
TPtrC connName = connNameVar.AsDes(); |
|
299 |
buf.Zero(); |
|
300 |
buf.Copy(connName); |
|
301 |
iLog->Log(_L("Connection Name:")); |
|
302 |
iLog->Log(buf); |
|
303 |
connNameVar.Reset(); |
|
304 |
} |
|
305 |
else |
|
306 |
{ |
|
307 |
iLog->Log(_L("Iterator data is not a map")); |
|
308 |
} |
|
309 |
||
310 |
countlist++; |
|
311 |
if(countlist < 2) |
|
312 |
iterlist->Reset(); |
|
313 |
||
314 |
iterdata.Reset(); |
|
315 |
}// while |
|
316 |
iterlist->DecRef(); |
|
317 |
}// |
|
318 |
else |
|
319 |
{ |
|
320 |
iLog->Log(_L("KConnectionList is not a Iterable object")); |
|
321 |
} |
|
322 |
}//map |
|
323 |
else |
|
324 |
{ |
|
325 |
iLog->Log(_L("Return value is not a map")); |
|
326 |
} |
|
327 |
aEventParamList.Reset(); |
|
328 |
}//output |
|
329 |
iWaitSchedular->AsyncStop(); |
|
330 |
return KErrNone; |
|
331 |
} |
|
332 |
void CTestConnList::HandleTimeOut() |
|
333 |
{ |
|
334 |
iWaitSchedular->AsyncStop(); |
|
335 |
} |
|
336 |
||
337 |
||
338 |
int ConnList(CStifLogger* aLog) |
|
339 |
{ |
|
340 |
__UHEAP_MARK; |
|
341 |
||
342 |
CTestConnList* test = CTestConnList::NewL(aLog); |
|
343 |
||
344 |
test->Start(); |
|
345 |
TInt retval = test->Result(); |
|
346 |
delete test; |
|
347 |
__UHEAP_MARKEND; |
|
348 |
||
349 |
return retval; |
|
350 |
} |
|
351 |