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) 2002 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include <liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include<liwservicehandler.h> |
19 | 22 |
|
23 |
#include"tsysinfoprovidernetworktests.h" |
|
24 |
#include "sysinfointerface.h" |
|
25 |
#include "sysinfoaiwparams.hrh" |
|
26 |
#include "tsignalstrengthasyn.h" |
|
27 |
#include"entitykeys.h" |
|
28 |
||
29 |
using namespace LIW ; |
|
30 |
using namespace SysInfo; |
|
31 |
||
32 |
using namespace sysinfoaiwparams; |
|
33 |
||
34 |
||
35 |
||
36 |
CSignalStrAsync* CSignalStrAsync::NewL(CStifLogger* aLog,TInt Strength) |
|
37 |
{ |
|
38 |
CSignalStrAsync* self = new(ELeave) CSignalStrAsync(aLog,Strength); |
|
39 |
self->ConstructL(); |
|
40 |
return self; |
|
41 |
} |
|
42 |
||
43 |
CSignalStrAsync::~CSignalStrAsync() |
|
44 |
{ |
|
45 |
Cancel(); |
|
46 |
||
47 |
interface->Close(); |
|
48 |
||
49 |
delete iServiceHandler; |
|
50 |
||
51 |
if(iWaitSchedular->IsStarted()) |
|
52 |
iWaitSchedular->AsyncStop(); |
|
53 |
||
54 |
if(iWaitSchedular) |
|
55 |
delete iWaitSchedular; |
|
56 |
||
57 |
delete iTimer; |
|
58 |
||
59 |
} |
|
60 |
||
61 |
void CSignalStrAsync::ConstructL() |
|
62 |
{ |
|
63 |
CActiveScheduler::Add(this); |
|
64 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
65 |
||
66 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
67 |
} |
|
68 |
||
69 |
CSignalStrAsync::CSignalStrAsync(CStifLogger* aLog,TInt aStrength) : |
|
70 |
CActive(EPriorityStandard),iResult(-1),iLog(aLog),iSignalStrength(aStrength) |
|
71 |
{ |
|
72 |
} |
|
73 |
||
74 |
void CSignalStrAsync::DoCancel() |
|
75 |
{ |
|
76 |
||
77 |
//TRAPD(err1,iSysInfoService->GetInfoL(req1)); |
|
78 |
||
79 |
} |
|
80 |
||
81 |
void CSignalStrAsync::RunL() |
|
82 |
{ |
|
83 |
TestFuncL(); |
|
84 |
} |
|
85 |
||
86 |
void CSignalStrAsync::Start() |
|
87 |
{ |
|
88 |
||
89 |
SetActive(); |
|
90 |
TRequestStatus* temp = &iStatus; |
|
91 |
User::RequestComplete(temp, KErrNone); |
|
92 |
iWaitSchedular->Start(); |
|
93 |
} |
|
94 |
||
95 |
TInt CSignalStrAsync::Result() |
|
96 |
{ |
|
97 |
return iResult; |
|
98 |
} |
|
99 |
||
100 |
void CSignalStrAsync::TestFuncL() |
|
101 |
{ |
|
102 |
const TTimeIntervalMicroSeconds32 OneMinute(6000000000); |
|
103 |
TInt result =KErrNone; |
|
104 |
||
105 |
TInt32 oldDisplayLang = 0 ,newDisplayLang = 0; |
|
106 |
||
107 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
108 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
109 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
110 |
||
111 |
TInt err = KErrNone; |
|
112 |
||
113 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
114 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
115 |
||
116 |
RCriteriaArray a; |
|
117 |
a.AppendL(crit); |
|
118 |
||
119 |
iServiceHandler->AttachL(a); |
|
120 |
||
121 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
122 |
||
123 |
delete crit; |
|
124 |
a.Reset(); |
|
125 |
||
126 |
TInt pos = 0; |
|
127 |
||
128 |
outparam->FindFirst( pos, KIDataSource ); |
|
129 |
if(pos != KErrNotFound) |
|
130 |
{ |
|
131 |
//getting the interface handle |
|
132 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
133 |
} |
|
134 |
||
135 |
outparam->Reset(); |
|
136 |
inparam->Reset(); |
|
137 |
||
138 |
if(interface) |
|
139 |
{ |
|
140 |
TLiwGenericParam entity; |
|
141 |
TLiwVariant entityname; |
|
142 |
TLiwGenericParam key; |
|
143 |
TLiwVariant keyname; |
|
144 |
||
145 |
entityname.Set(KNetwork); |
|
146 |
entity.SetNameAndValueL(KEntity,entityname); |
|
147 |
||
148 |
keyname.Set(KSignalStrength); |
|
149 |
key.SetNameAndValueL(KKey,keyname); |
|
150 |
||
151 |
inparam->AppendL(entity); |
|
152 |
||
153 |
inparam->AppendL(key); |
|
154 |
||
155 |
entity.Reset(); |
|
156 |
entityname.Reset(); |
|
157 |
key.Reset(); |
|
158 |
keyname.Reset(); |
|
159 |
||
160 |
//get notification vibra Active |
|
161 |
TRAPD(err1, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam,KLiwOptASyncronous,this)); |
|
162 |
iResult = err1; |
|
163 |
if(err1 == KErrNone) |
|
164 |
{ |
|
165 |
iResult = err1; |
|
166 |
}//err1 |
|
167 |
||
168 |
}//interface |
|
169 |
else |
|
170 |
{ |
|
171 |
iLog->Log( _L("API returned error") ); |
|
172 |
iResult = err; |
|
173 |
iWaitSchedular->AsyncStop(); |
|
174 |
} |
|
175 |
||
176 |
iTimer->After(OneMinute); |
|
177 |
||
178 |
return ; |
|
179 |
} |
|
180 |
||
181 |
TInt CSignalStrAsync::HandleNotifyL(TInt aCmdId, |
|
182 |
TInt aEventId, |
|
183 |
CLiwGenericParamList& aEventParamList, |
|
184 |
const CLiwGenericParamList& aInParamList) |
|
185 |
{ |
|
186 |
||
187 |
TInt pos = 0 ,err =0; |
|
188 |
aEventParamList.FindFirst( pos, KErrorCode ); |
|
189 |
if(pos != KErrNotFound) |
|
190 |
{ |
|
191 |
if( (aEventParamList)[pos].Value().AsTInt32() != KErrNone ) |
|
192 |
err = (TInt)((aEventParamList)[pos].Value().AsTInt32()); |
|
193 |
} |
|
194 |
||
195 |
pos = 0 ; |
|
196 |
const TLiwGenericParam* output2 = aEventParamList.FindFirst( pos,KReturnValue ); |
|
197 |
if(output2) |
|
198 |
{ |
|
199 |
const CLiwMap* Map = output2->Value().AsMap(); |
|
200 |
if ( Map ) |
|
201 |
{ |
|
202 |
||
203 |
TLiwVariant regTypeVar; |
|
204 |
Map->FindL(KStatus,regTypeVar); |
|
205 |
TInt regType = regTypeVar.AsTInt32(); |
|
206 |
regTypeVar.Reset(); |
|
207 |
||
208 |
TBuf<50> buf; |
|
209 |
buf.AppendNum(regType); |
|
210 |
iLog->Log(buf); |
|
211 |
||
212 |
}//map |
|
213 |
||
214 |
}//output |
|
215 |
else |
|
216 |
{ |
|
217 |
||
218 |
iLog->Log( _L("Output data Set to NULL") ); |
|
219 |
} |
|
220 |
||
221 |
||
222 |
iWaitSchedular->AsyncStop(); |
|
223 |
} |
|
224 |
||
225 |
||
226 |
void CSignalStrAsync::HandleTimeOut() |
|
227 |
{/* |
|
228 |
iLog->Log(_L("TimeOut reached...")); |
|
229 |
interface->Close(); |
|
230 |
iResult = FAIL; |
|
231 |
iWaitSchedular->AsyncStop(); |
|
232 |
*/ |
|
233 |
} |