author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
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 |
||
18 |
#include <e32svr.h> |
|
19 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
20 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
21 |
#include <lbsrequestor.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
22 |
#include <liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
23 |
#include <liwcommon.h> |
19 | 24 |
|
25 |
#include "tcomplugin.h" |
|
26 |
||
27 |
||
28 |
_LIT(LogFileName , "C:\\Notifications.txt") ; |
|
29 |
||
30 |
//--------------------------------------------------------------------------------------------------------- |
|
31 |
/** |
|
32 |
*@ This call back interface is for testing Trace |
|
33 |
*/ |
|
34 |
//--------------------------------------------------------------------------------------------------------- |
|
35 |
||
36 |
class LocUpdateCallBack : public MLiwNotifyCallback |
|
37 |
{ |
|
38 |
TInt iCount ; |
|
39 |
TInt iRetStatus ; |
|
40 |
public : |
|
41 |
TInt HandleNotifyL( |
|
42 |
TInt aCmdId, |
|
43 |
TInt aEventId, |
|
44 |
CLiwGenericParamList& aEventParamList, |
|
45 |
const CLiwGenericParamList& aInParamList); |
|
46 |
||
47 |
LocUpdateCallBack() :iCount(0) , iRetStatus(KErrGeneral) //Default constructor |
|
48 |
{ |
|
49 |
; |
|
50 |
} |
|
51 |
}; |
|
52 |
||
53 |
||
54 |
||
55 |
TInt LocUpdateCallBack :: HandleNotifyL( |
|
56 |
TInt aCmdId, |
|
57 |
TInt aEventId, |
|
58 |
CLiwGenericParamList& aEventParamList, |
|
59 |
const CLiwGenericParamList& aInParamList) |
|
60 |
{ |
|
61 |
||
62 |
TBuf8<50> data ; |
|
63 |
TRealFormat format ; |
|
64 |
||
65 |
iCount++ ; |
|
66 |
||
67 |
RFile LogFile ; |
|
68 |
RFs LogSession ; |
|
69 |
TBuf8<50> Buffer(_L8("Latitude = ")) ; |
|
70 |
||
71 |
||
72 |
||
73 |
LogSession.Connect() ; |
|
74 |
||
75 |
if(LogFile.Open(LogSession ,LogFileName , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
76 |
{ |
|
77 |
LogFile.Create(LogSession ,LogFileName , EFileWrite | EFileShareAny ) ; |
|
78 |
||
79 |
} |
|
80 |
||
81 |
TInt End = 0 ; |
|
82 |
TInt index = 0 ; |
|
83 |
const TLiwGenericParam *GenericParam = aEventParamList.FindFirst(index , KErrorCode) ; |
|
84 |
||
85 |
if(!GenericParam) |
|
86 |
{ |
|
87 |
return KErrGeneral ; |
|
88 |
} |
|
89 |
||
90 |
if((GenericParam->Value()).AsTInt32() != KErrNone) |
|
91 |
{ |
|
92 |
return (GenericParam->Value()).AsTInt32() ; |
|
93 |
} |
|
94 |
||
95 |
index = 0 ; |
|
96 |
||
97 |
LogFile.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
98 |
||
99 |
const TLiwGenericParam *MapParam = aEventParamList.FindFirst(index ,KLocationMap) ; |
|
100 |
||
101 |
if(!MapParam) |
|
102 |
{ |
|
103 |
return KErrGeneral ; |
|
104 |
} |
|
105 |
||
106 |
TLiwVariant Variant ; |
|
107 |
||
108 |
Variant = MapParam->Value() ; |
|
109 |
const CLiwMap *LocMap = Variant.AsMap() ; |
|
110 |
||
111 |
TLiwVariant PosVariant ; |
|
112 |
||
113 |
LocMap->FindL(KLongitudeKey , PosVariant) ; |
|
114 |
||
115 |
||
116 |
TReal64 LongData = (TReal64)PosVariant.AsTReal() ; //Longitude |
|
117 |
data.Num(LongData , format) ; |
|
118 |
LogFile.Write(_L8("\n")) ; |
|
119 |
LogFile.Write(_L8("Logitude = ")) ; |
|
120 |
LogFile.Write(data) ; |
|
121 |
||
122 |
LocMap->FindL(KLatitudeKey ,PosVariant) ; //Latitude |
|
123 |
||
124 |
TReal64 LatData = (TReal64)PosVariant.AsTReal() ; |
|
125 |
data.Num(LatData , format) ; |
|
126 |
LogFile.Write(_L8(" Latitude = ")) ; |
|
127 |
LogFile.Write(data) ; |
|
128 |
||
129 |
LocMap->FindL(KAltitudeKey , PosVariant) ; //Altitude |
|
130 |
TReal32 AltData = PosVariant.AsTReal() ; |
|
131 |
data.Num(AltData , format) ; |
|
132 |
||
133 |
LogFile.Write(_L8(" Altitude = ")) ; |
|
134 |
LogFile.Write(data) ; |
|
135 |
//LocMap->DecRef() ; |
|
136 |
||
137 |
||
138 |
LogFile.Close() ; |
|
139 |
LogSession.Close() ; |
|
140 |
||
141 |
if(iCount) |
|
142 |
{ |
|
143 |
iRetStatus = KErrNone ; |
|
144 |
CActiveScheduler *Current = CActiveScheduler :: Current() ; |
|
145 |
Current->Stop() ; |
|
146 |
||
147 |
} |
|
148 |
||
149 |
return KErrNone ; |
|
150 |
} |
|
151 |
||
152 |
||
153 |
TInt GetLocFunctionL() |
|
154 |
{ |
|
155 |
__UHEAP_MARK; |
|
156 |
LocUpdateCallBack MyUpdates ; |
|
157 |
||
158 |
||
159 |
||
160 |
CActiveScheduler *Scheduler = CActiveScheduler :: Current() ; |
|
161 |
||
162 |
if(!Scheduler) |
|
163 |
{ |
|
164 |
Scheduler = new CActiveScheduler ; |
|
165 |
} |
|
166 |
||
167 |
||
168 |
CActiveScheduler :: Install(Scheduler) ; |
|
169 |
||
170 |
||
171 |
||
172 |
||
173 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
174 |
||
175 |
// Input and output parameter list |
|
176 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
177 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
178 |
||
179 |
||
180 |
||
181 |
||
182 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDataSource , KService); |
|
183 |
||
184 |
||
185 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
186 |
||
187 |
RCriteriaArray a; |
|
188 |
a.AppendL(crit); |
|
189 |
||
190 |
TRAPD (err ,ServiceHandler->AttachL(a) ); |
|
191 |
||
192 |
||
193 |
||
194 |
||
195 |
||
196 |
||
197 |
||
198 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
199 |
||
200 |
||
201 |
||
202 |
||
203 |
TInt pos = 0; |
|
204 |
||
205 |
const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ; |
|
206 |
||
207 |
if(!errorprm) |
|
208 |
{ |
|
209 |
return KErrGeneral ; |
|
210 |
} |
|
211 |
||
212 |
||
213 |
_LIT8(KDataSource, "ILocation"); |
|
214 |
||
215 |
pos = 0 ; |
|
216 |
||
217 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KLocationInterface); |
|
218 |
||
219 |
if(!genericparm) |
|
220 |
{ |
|
221 |
return KErrGeneral ; |
|
222 |
} |
|
223 |
||
224 |
MLiwInterface* locinterface = (genericparm->Value()).AsInterface(); |
|
225 |
||
226 |
||
227 |
||
228 |
||
229 |
// CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ; |
|
230 |
||
231 |
||
232 |
||
233 |
CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ; |
|
234 |
CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ; |
|
235 |
TBuf8<20>CmdBuf(KCmdTraceLocation) ; |
|
236 |
||
237 |
||
238 |
locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous , &MyUpdates); |
|
239 |
||
240 |
CActiveScheduler :: Start() ; |
|
241 |
||
242 |
||
243 |
||
244 |
||
245 |
locinterface->Close(); |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
246 |
|
19 | 247 |
delete InputList ; |
248 |
delete OutParmList ; |
|
249 |
delete Scheduler ; |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
250 |
delete crit; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
251 |
a.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
252 |
a.Close(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
253 |
delete ServiceHandler ; |
19 | 254 |
__UHEAP_MARKEND; |
255 |
return 0 ; |
|
256 |
} |
|
257 |
||
258 |
TInt GetLocUpdates(TAny */*Arg*/) |
|
259 |
{ |
|
260 |
//; |
|
261 |
CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
262 |
TInt val = 0 ; |
|
263 |
||
264 |
//Install a new active scheduler to this thread |
|
265 |
TRAPD(err , (val =GetLocFunctionL())) ; |
|
266 |
||
267 |
delete cleanup ; |
|
268 |
if(err) |
|
269 |
{ |
|
270 |
return err ; |
|
271 |
} |
|
272 |
return val ; |
|
273 |
} |
|
274 |