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 |
#include"watchtimer.h"
|
|
26 |
#include "serviceerrno.h"
|
|
27 |
|
|
28 |
using namespace LIW ;
|
|
29 |
using namespace SysInfo;
|
|
30 |
using namespace sysinfoaiwparams;
|
|
31 |
|
|
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 |
|
|
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 |
//get notification vibra Active
|
|
193 |
TRAPD(err1, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam,KLiwOptASyncronous,this));
|
|
194 |
iResult = err1;
|
|
195 |
|
|
196 |
TInt pos = 0;
|
|
197 |
const TLiwGenericParam* output2 = outparam->FindFirst( pos,KTransactionId );
|
|
198 |
|
|
199 |
if(pos > 0)
|
|
200 |
TInt32 transactionid = output2->Value().AsTInt32();
|
|
201 |
|
|
202 |
outparam->Reset();
|
|
203 |
inparam->Reset();
|
|
204 |
|
|
205 |
// TLiwGenericParam transid;
|
|
206 |
// transid.SetNameAndValueL(KTransactionId,transactionid);
|
|
207 |
// inparam->AppendL(transid);
|
|
208 |
// transid.Reset();
|
|
209 |
|
|
210 |
TRAPD(errcancel,interface->ExecuteCmdL(KCancel,*inparam,*outparam,KLiwOptCancel,this));
|
|
211 |
|
|
212 |
iTimer->After(OneMinute);
|
|
213 |
|
|
214 |
if(errcancel == KErrNone)
|
|
215 |
{
|
|
216 |
pos = 0;
|
|
217 |
outparam->FindFirst( pos, KErrorCode );
|
|
218 |
if(pos != KErrNotFound)
|
|
219 |
{
|
|
220 |
iResult = (TInt)((*outparam)[pos].Value().AsTInt32());
|
|
221 |
}
|
|
222 |
if(iResult == SErrMissingArgument)
|
|
223 |
{
|
|
224 |
iResult = 0;
|
|
225 |
}
|
|
226 |
else
|
|
227 |
{
|
|
228 |
iResult = -1;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
outparam->Reset();
|
|
232 |
inparam->Reset();
|
|
233 |
|
|
234 |
}//interface
|
|
235 |
else
|
|
236 |
{
|
|
237 |
iLog->Log( _L("API returned error") );
|
|
238 |
iResult = err;
|
|
239 |
iWaitSchedular->AsyncStop();
|
|
240 |
}
|
|
241 |
|
|
242 |
return ;
|
|
243 |
}
|
|
244 |
|
|
245 |
TInt CTestActiveConnCancel::HandleNotifyL(TInt /*aCmdId*/,
|
|
246 |
TInt aEventId,
|
|
247 |
CLiwGenericParamList& /*aEventParamList*/,
|
|
248 |
const CLiwGenericParamList& /*aInParamList*/)
|
|
249 |
{
|
|
250 |
|
|
251 |
if(aEventId == KLiwEventCanceled)
|
|
252 |
{
|
|
253 |
iResult =KErrGeneral;
|
|
254 |
}
|
|
255 |
else
|
|
256 |
{
|
|
257 |
iResult =KErrNone;
|
|
258 |
}
|
|
259 |
|
|
260 |
iWaitSchedular->AsyncStop();
|
|
261 |
return KErrNone;
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
int ActiveConnectionReqCancel(CStifLogger* aLog)
|
|
266 |
{
|
|
267 |
__UHEAP_MARK;
|
|
268 |
|
|
269 |
CTestActiveConnCancel* test = CTestActiveConnCancel::NewL(aLog);
|
|
270 |
|
|
271 |
test->Start();
|
|
272 |
TInt retval = test->Result();
|
|
273 |
delete test;
|
|
274 |
__UHEAP_MARKEND;
|
|
275 |
|
|
276 |
return retval;
|
|
277 |
}
|
|
278 |
|
|
279 |
void CTestActiveConnCancel::HandleTimeOut()
|
|
280 |
{
|
|
281 |
iWaitSchedular->AsyncStop();
|
|
282 |
}
|
|
283 |
|