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"tsysinfoprovidertests.h" |
|
22 |
#include "sysinfointerface.h" |
|
23 |
#include"entitykeys.h" |
|
24 |
#include "sysinfoaiwparams.hrh" |
|
25 |
#include"watchtimer.h" |
|
26 |
||
27 |
using namespace LIW ; |
|
28 |
using namespace SysInfo; |
|
29 |
using namespace sysinfoaiwparams; |
|
30 |
||
31 |
TInt CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32 &aError ); |
|
32 |
||
33 |
class CTestActiveConnCancel : public CActive ,public MLiwNotifyCallback, public MTimeOutCallBack |
|
34 |
{ |
|
35 |
public: |
|
36 |
static CTestActiveConnCancel* NewL(CStifLogger* aLog); |
|
37 |
~CTestActiveConnCancel(); |
|
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 |
||
48 |
void HandleTimeOut (); |
|
49 |
||
50 |
private: |
|
51 |
void ConstructL(); |
|
52 |
CTestActiveConnCancel(CStifLogger* aLog); |
|
53 |
||
54 |
virtual void DoCancel(); |
|
55 |
virtual void RunL(); |
|
56 |
||
57 |
void TestFunc(); |
|
58 |
||
59 |
private: |
|
60 |
CActiveSchedulerWait* iWaitSchedular; |
|
61 |
CLiwServiceHandler* iServiceHandler; |
|
62 |
MLiwInterface* interface ; |
|
63 |
TInt32 btstatus ; |
|
64 |
TInt iResult; |
|
65 |
CStifLogger* iLog; |
|
66 |
CWatchTimer* iTimer; |
|
67 |
||
68 |
}; |
|
69 |
||
70 |
CTestActiveConnCancel* CTestActiveConnCancel::NewL(CStifLogger* aLog) |
|
71 |
{ |
|
72 |
CTestActiveConnCancel* self = new(ELeave) CTestActiveConnCancel(aLog); |
|
73 |
self->ConstructL(); |
|
74 |
return self; |
|
75 |
} |
|
76 |
||
77 |
CTestActiveConnCancel::~CTestActiveConnCancel() |
|
78 |
{ |
|
79 |
Cancel(); |
|
80 |
||
81 |
interface->Close(); |
|
82 |
||
83 |
delete iServiceHandler; |
|
84 |
||
85 |
if(iWaitSchedular->IsStarted()) |
|
86 |
iWaitSchedular->AsyncStop(); |
|
87 |
||
88 |
if(iWaitSchedular) |
|
89 |
delete iWaitSchedular; |
|
90 |
||
91 |
delete iTimer; |
|
92 |
||
93 |
} |
|
94 |
||
95 |
void CTestActiveConnCancel::ConstructL() |
|
96 |
{ |
|
97 |
CActiveScheduler::Add(this); |
|
98 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
99 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
100 |
||
101 |
} |
|
102 |
||
103 |
CTestActiveConnCancel::CTestActiveConnCancel(CStifLogger* aLog) : |
|
104 |
CActive(EPriorityStandard),iResult(-1),iLog(aLog) |
|
105 |
{ |
|
106 |
} |
|
107 |
||
108 |
void CTestActiveConnCancel::DoCancel() |
|
109 |
{ |
|
110 |
||
111 |
//TRAPD(err1,iSysInfoService->GetInfoL(req1)); |
|
112 |
||
113 |
} |
|
114 |
||
115 |
void CTestActiveConnCancel::RunL() |
|
116 |
{ |
|
117 |
TestFunc(); |
|
118 |
} |
|
119 |
||
120 |
void CTestActiveConnCancel::Start() |
|
121 |
{ |
|
122 |
||
123 |
SetActive(); |
|
124 |
TRequestStatus* temp = &iStatus; |
|
125 |
User::RequestComplete(temp, KErrNone); |
|
126 |
iWaitSchedular->Start(); |
|
127 |
} |
|
128 |
||
129 |
TInt CTestActiveConnCancel::Result() |
|
130 |
{ |
|
131 |
return iResult; |
|
132 |
} |
|
133 |
||
134 |
void CTestActiveConnCancel::TestFunc() |
|
135 |
{ |
|
136 |
iLog->Log(_L("In test func")); |
|
137 |
const TTimeIntervalMicroSeconds32 OneMinute(60000); |
|
138 |
||
139 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
140 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
141 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
142 |
||
143 |
TInt err = KErrNone; |
|
144 |
||
145 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
146 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
147 |
||
148 |
RCriteriaArray a; |
|
149 |
a.AppendL(crit); |
|
150 |
||
151 |
iServiceHandler->AttachL(a); |
|
152 |
||
153 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
154 |
||
155 |
delete crit; |
|
156 |
a.Reset(); |
|
157 |
||
158 |
TInt pos = 0; |
|
159 |
||
160 |
outparam->FindFirst( pos, KIDataSource ); |
|
161 |
if(pos != KErrNotFound) |
|
162 |
{ |
|
163 |
//getting the interface handle |
|
164 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
165 |
} |
|
166 |
||
167 |
outparam->Reset(); |
|
168 |
inparam->Reset(); |
|
169 |
||
170 |
if(interface) |
|
171 |
{ |
|
172 |
TLiwGenericParam entity; |
|
173 |
TLiwVariant entityname; |
|
174 |
TLiwGenericParam key; |
|
175 |
TLiwVariant keyname; |
|
176 |
||
177 |
entityname.Set(KConnectivity); |
|
178 |
entity.SetNameAndValueL(KEntity,entityname); |
|
179 |
||
180 |
keyname.Set(KActiveConnections); |
|
181 |
key.SetNameAndValueL(KKey,keyname); |
|
182 |
||
183 |
inparam->AppendL(entity); |
|
184 |
||
185 |
inparam->AppendL(key); |
|
186 |
||
187 |
entity.Reset(); |
|
188 |
entityname.Reset(); |
|
189 |
key.Reset(); |
|
190 |
keyname.Reset(); |
|
191 |
||
192 |
iLog->Log(_L("Issueing Notification Request")); |
|
193 |
//get notification vibra Active |
|
194 |
TRAPD(err1, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam,KLiwOptASyncronous,this)); |
|
195 |
iResult = err1; |
|
196 |
||
197 |
TInt pos = 0; |
|
198 |
const TLiwGenericParam* output2 = outparam->FindFirst( pos,KTransactionId ); |
|
199 |
TInt32 transactionid = output2->Value().AsTInt32(); |
|
200 |
||
201 |
outparam->Reset(); |
|
202 |
inparam->Reset(); |
|
203 |
||
204 |
TLiwGenericParam transid; |
|
205 |
transid.SetNameAndValueL(KTransactionId,transactionid); |
|
206 |
inparam->AppendL(transid); |
|
207 |
transid.Reset(); |
|
208 |
||
209 |
iLog->Log(_L("Issueing Cancel Request")); |
|
210 |
TRAPD(errcancel,interface->ExecuteCmdL(KCancel,*inparam,*outparam,KLiwOptCancel,this)); |
|
211 |
TInt32 Err(KErrNone); |
|
212 |
err |= CheckErrorCode(*outparam,Err); |
|
213 |
if(Err) |
|
214 |
{ |
|
215 |
iLog->Log(_L("Cancle Operation returned err: %d"),Err); |
|
216 |
} |
|
217 |
||
218 |
iTimer->After(OneMinute); |
|
219 |
||
220 |
outparam->Reset(); |
|
221 |
inparam->Reset(); |
|
222 |
||
223 |
}//interface |
|
224 |
else |
|
225 |
{ |
|
226 |
iLog->Log( _L("API returned error") ); |
|
227 |
iResult = err; |
|
228 |
iWaitSchedular->AsyncStop(); |
|
229 |
} |
|
230 |
||
231 |
return ; |
|
232 |
} |
|
233 |
||
234 |
TInt CTestActiveConnCancel::HandleNotifyL(TInt /*aCmdId*/, |
|
235 |
TInt aEventId, |
|
236 |
CLiwGenericParamList& /*aEventParamList*/, |
|
237 |
const CLiwGenericParamList& /*aInParamList*/) |
|
238 |
{ |
|
239 |
iLog->Log(_L("In Handle NotifyL")); |
|
240 |
iLog->Log(_L("EventId: %d"),aEventId); |
|
241 |
if(aEventId == KLiwEventCanceled) |
|
242 |
{ |
|
243 |
iLog->Log(_L("EventId is KLiwEventCanceled")); |
|
244 |
iResult =KErrNone; |
|
245 |
} |
|
246 |
else |
|
247 |
{ |
|
248 |
iLog->Log(_L("Wrong eventID generated")); |
|
249 |
iResult =KErrGeneral; |
|
250 |
} |
|
251 |
||
252 |
iWaitSchedular->AsyncStop(); |
|
253 |
return KErrNone; |
|
254 |
} |
|
255 |
||
256 |
||
257 |
int ActiveConnectionReqCancel(CStifLogger* aLog) |
|
258 |
{ |
|
259 |
__UHEAP_MARK; |
|
260 |
||
261 |
CTestActiveConnCancel* test = CTestActiveConnCancel::NewL(aLog); |
|
262 |
||
263 |
test->Start(); |
|
264 |
TInt retval = test->Result(); |
|
265 |
delete test; |
|
266 |
__UHEAP_MARKEND; |
|
267 |
||
268 |
return retval; |
|
269 |
} |
|
270 |
||
271 |
void CTestActiveConnCancel::HandleTimeOut() |
|
272 |
{ |
|
273 |
iLog->Log(_L("Timeout reached..")); |
|
274 |
iWaitSchedular->AsyncStop(); |
|
275 |
} |
|
276 |
||
277 |
TInt CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32 &aError ) |
|
278 |
{ |
|
279 |
TInt Index = 0; |
|
280 |
const TLiwGenericParam* errcode = aOutList.FindFirst(Index,KErrorCode); |
|
281 |
if ( KErrNotFound == Index ) |
|
282 |
{ |
|
283 |
return FAIL; |
|
284 |
} |
|
285 |
else |
|
286 |
errcode->Value().Get(aError); |
|
287 |
return PASS; |
|
288 |
} |