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 |
||
26 |
using namespace LIW ; |
|
27 |
using namespace SysInfo; |
|
28 |
using namespace sysinfoaiwparams; |
|
29 |
||
30 |
||
31 |
class CTestAsync3 : public CActive ,public MLiwNotifyCallback |
|
32 |
{ |
|
33 |
public: |
|
34 |
static CTestAsync3* NewL(CStifLogger* aLog); |
|
35 |
~CTestAsync3(); |
|
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 |
CTestAsync3(CStifLogger* aLog); |
|
49 |
||
50 |
virtual void DoCancel(); |
|
51 |
virtual void RunL(); |
|
52 |
||
53 |
void TestFunc(); |
|
54 |
||
55 |
private: |
|
56 |
||
57 |
CActiveSchedulerWait* iWaitSchedular; |
|
58 |
CLiwServiceHandler* iServiceHandler; |
|
59 |
MLiwInterface* interface ; |
|
60 |
TInt32 btstatus ; |
|
61 |
TInt iResult; |
|
62 |
CStifLogger* iLog; |
|
63 |
}; |
|
64 |
||
65 |
CTestAsync3* CTestAsync3::NewL(CStifLogger* aLog) |
|
66 |
{ |
|
67 |
CTestAsync3* self = new(ELeave) CTestAsync3(aLog); |
|
68 |
self->ConstructL(); |
|
69 |
return self; |
|
70 |
} |
|
71 |
||
72 |
CTestAsync3::~CTestAsync3() |
|
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 CTestAsync3::ConstructL() |
|
88 |
{ |
|
89 |
CActiveScheduler::Add(this); |
|
90 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
91 |
} |
|
92 |
||
93 |
CTestAsync3::CTestAsync3(CStifLogger* aLog) : |
|
94 |
CActive(EPriorityStandard),iResult(-1),iLog(aLog) |
|
95 |
{ |
|
96 |
} |
|
97 |
||
98 |
void CTestAsync3::DoCancel() |
|
99 |
{ |
|
100 |
||
101 |
//TRAPD(err1,iSysInfoService->GetInfoL(req1)); |
|
102 |
||
103 |
} |
|
104 |
||
105 |
void CTestAsync3::RunL() |
|
106 |
{ |
|
107 |
TestFunc(); |
|
108 |
} |
|
109 |
||
110 |
void CTestAsync3::Start() |
|
111 |
{ |
|
112 |
||
113 |
SetActive(); |
|
114 |
TRequestStatus* temp = &iStatus; |
|
115 |
User::RequestComplete(temp, KErrNone); |
|
116 |
iWaitSchedular->Start(); |
|
117 |
} |
|
118 |
||
119 |
TInt CTestAsync3::Result() |
|
120 |
{ |
|
121 |
return iResult; |
|
122 |
} |
|
123 |
||
124 |
void CTestAsync3::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 |
||
149 |
||
150 |
outparam->FindFirst( pos, KIDataSource ); |
|
151 |
if(pos != KErrNotFound) |
|
152 |
{ |
|
153 |
//getting the interface handle |
|
154 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
155 |
} |
|
156 |
||
157 |
outparam->Reset(); |
|
158 |
inparam->Reset(); |
|
159 |
||
160 |
if(interface) |
|
161 |
{ |
|
162 |
TLiwGenericParam entity; |
|
163 |
TLiwVariant entityname; |
|
164 |
TLiwGenericParam key; |
|
165 |
TLiwVariant keyname; |
|
166 |
||
167 |
entityname.Set(KConnectivity); |
|
168 |
entity.SetNameAndValueL(KEntity,entityname); |
|
169 |
||
170 |
keyname.Set(SysInfo::KConnectionStatus); |
|
171 |
key.SetNameAndValueL(KKey,keyname); |
|
172 |
||
173 |
inparam->AppendL(entity); |
|
174 |
||
175 |
inparam->AppendL(key); |
|
176 |
||
177 |
entity.Reset(); |
|
178 |
entityname.Reset(); |
|
179 |
key.Reset(); |
|
180 |
keyname.Reset(); |
|
181 |
||
182 |
iLog->Log(_L("Calling notification")); |
|
183 |
||
184 |
//get notification vibra Active |
|
185 |
TRAPD(err1, interface->ExecuteCmdL(KGetNotification,*inparam,*outparam,KLiwOptASyncronous,this)); |
|
186 |
iResult = err1; |
|
187 |
if(err1 == KErrNone) |
|
188 |
{ |
|
189 |
; |
|
190 |
||
191 |
}//err1 |
|
192 |
outparam->Reset(); |
|
193 |
inparam->Reset(); |
|
194 |
}//interface |
|
195 |
else |
|
196 |
{ |
|
197 |
iLog->Log( _L("API returned error") ); |
|
198 |
iResult = err; |
|
199 |
iWaitSchedular->AsyncStop(); |
|
200 |
} |
|
201 |
return ; |
|
202 |
} |
|
203 |
||
204 |
TInt CTestAsync3::HandleNotifyL(TInt aCmdId, |
|
205 |
TInt aEventId, |
|
206 |
CLiwGenericParamList& aEventParamList, |
|
207 |
const CLiwGenericParamList& aInParamList) |
|
208 |
{ |
|
209 |
TInt pos = 0; |
|
210 |
aEventParamList.FindFirst( pos, KErrorCode ); |
|
211 |
if(pos != KErrNotFound) |
|
212 |
{ |
|
213 |
if( (aEventParamList)[pos].Value().AsTInt32() != KErrNone ) |
|
214 |
iResult = (TInt)((aEventParamList)[pos].Value().AsTInt32()); |
|
215 |
} |
|
216 |
||
217 |
pos = 0 ; |
|
218 |
const TLiwGenericParam* output2 = aEventParamList.FindFirst( pos,KReturnValue ); |
|
219 |
||
220 |
if(output2) |
|
221 |
{ |
|
222 |
const CLiwMap* Map = output2->Value().AsMap(); |
|
223 |
if ( Map ) |
|
224 |
{ |
|
225 |
||
226 |
TLiwVariant connstate; |
|
227 |
Map->FindL(sysinfoaiwparams::KConnectionStatus,connstate); |
|
228 |
TUint state = connstate.AsTUint(); |
|
229 |
TBuf<50> buf; |
|
230 |
buf.AppendNum(state); |
|
231 |
iLog->Log(_L("ConnectionStatus: ")); |
|
232 |
iLog->Log(buf); |
|
233 |
connstate.Reset(); |
|
234 |
||
235 |
TLiwVariant iapidVar; |
|
236 |
Map->FindL(KIAPID,iapidVar); |
|
237 |
TInt32 iapid = iapidVar.AsTInt32(); |
|
238 |
buf.Zero(); |
|
239 |
buf.AppendNum(iapid); |
|
240 |
iLog->Log(_L("IAPID")); |
|
241 |
iLog->Log(buf); |
|
242 |
iapidVar.Reset(); |
|
243 |
||
244 |
||
245 |
TLiwVariant bearerTypeVar; |
|
246 |
Map->FindL(KConnectionType,bearerTypeVar); |
|
247 |
TInt32 bearerType = bearerTypeVar.AsTInt32(); |
|
248 |
buf.Zero(); |
|
249 |
buf.AppendNum(bearerType); |
|
250 |
iLog->Log(_L("Bearer Type:")); |
|
251 |
iLog->Log(buf); |
|
252 |
bearerTypeVar.Reset(); |
|
253 |
||
254 |
TLiwVariant iapNameVar; |
|
255 |
Map->FindL(KIAPName,iapNameVar); |
|
256 |
TPtrC iapName = iapNameVar.AsDes(); |
|
257 |
buf.Zero(); |
|
258 |
buf.Copy(iapName); |
|
259 |
iLog->Log(_L("IAP Name:")); |
|
260 |
iLog->Log(buf); |
|
261 |
iapNameVar.Reset(); |
|
262 |
||
263 |
TLiwVariant netNameVar; |
|
264 |
Map->FindL(KNetworkName,netNameVar); |
|
265 |
TPtrC netName = netNameVar.AsDes(); |
|
266 |
buf.Zero(); |
|
267 |
buf.Copy(netName); |
|
268 |
iLog->Log(_L("network Name:")); |
|
269 |
iLog->Log(buf); |
|
270 |
netNameVar.Reset(); |
|
271 |
||
272 |
TLiwVariant connNameVar; |
|
273 |
Map->FindL(KIAPConnectionName,connNameVar); |
|
274 |
TPtrC connName = connNameVar.AsDes(); |
|
275 |
buf.Zero(); |
|
276 |
buf.Copy(connName); |
|
277 |
iLog->Log(_L("Connection Name:")); |
|
278 |
iLog->Log(buf); |
|
279 |
connNameVar.Reset(); |
|
280 |
}//map |
|
281 |
((CLiwMap*)Map)->DecRef(); |
|
282 |
}//output |
|
283 |
aEventParamList.Reset(); |
|
284 |
iWaitSchedular->AsyncStop(); |
|
285 |
} |
|
286 |
||
287 |
||
288 |
int ConnectionNotification(CStifLogger* aLog) |
|
289 |
{ |
|
290 |
__UHEAP_MARK; |
|
291 |
||
292 |
CTestAsync3* test = CTestAsync3::NewL(aLog); |
|
293 |
||
294 |
test->Start(); |
|
295 |
TInt retval = test->Result(); |
|
296 |
delete test; |
|
297 |
__UHEAP_MARKEND; |
|
298 |
||
299 |
return retval; |
|
300 |
} |
|
301 |