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