1 /* |
|
2 * Copyright (c) 2006 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 "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: Utility class for map and navigation test provider |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32file.h> |
|
20 #include <e32property.h> |
|
21 |
|
22 #include <coemain.h> |
|
23 #include <aknlists.h> |
|
24 #include <barsread2.h> |
|
25 #include <barsc2.h> |
|
26 |
|
27 #include <lbsposition.h> |
|
28 #include <lbspositioninfo.h> |
|
29 |
|
30 #include <aiwgenericparam.h> |
|
31 |
|
32 #include <epos_cposlandmark.h> |
|
33 #include <epos_cposlandmarkdatabase.h> |
|
34 #include <epos_poslandmarkserialization.h> |
|
35 |
|
36 #include <mngeocoder.h> |
|
37 #include <mnmapview.h> |
|
38 #include <mnnavigator.h> |
|
39 |
|
40 #include <mnaiwservices.h> |
|
41 |
|
42 #include <mntestprovider.rsg> |
|
43 |
|
44 #include "debug.h" |
|
45 #include "testproviderdump.h" |
|
46 |
|
47 _LIT( KDumpFileName, "c:\\mntestprovider.dump"); |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CTestProviderDump::CTestProviderDump() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CTestProviderDump::~CTestProviderDump() |
|
62 { |
|
63 delete iList; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CTestProviderDump* CTestProviderDump::NewLC() |
|
70 { |
|
71 CTestProviderDump* self = new (ELeave) CTestProviderDump(); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CTestProviderDump::ConstructL() |
|
81 { |
|
82 iList = CAiwGenericParamList::NewL(); |
|
83 AddTimeStampL(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CTestProviderDump::AddTimeStampL() |
|
90 { |
|
91 TTime now; |
|
92 now.UniversalTime(); |
|
93 |
|
94 TAiwGenericParam param( EGenericParamDateTime, TAiwVariant( now ) ); |
|
95 iList->AppendL( param ); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CTestProviderDump::AddRunModeL( TBool aIsChainedMode ) |
|
102 { |
|
103 TMnAiwCommonOptionsParam options; |
|
104 options.iRunChained = aIsChainedMode; |
|
105 |
|
106 TPckg<TMnAiwCommonOptionsParam> pack( options ); |
|
107 |
|
108 TAiwGenericParam param( EGenericParamMnCommonOptions, TAiwVariant( pack ) ); |
|
109 iList->AppendL( param ); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CTestProviderDump::AddLandmarkL( const CPosLandmark& aLandmark ) |
|
116 { |
|
117 HBufC8* lmBuf = PosLandmarkSerialization::PackL( aLandmark ); |
|
118 CleanupStack::PushL( lmBuf ); |
|
119 |
|
120 TAiwGenericParam param( EGenericParamLandmark, TAiwVariant( *lmBuf ) ); |
|
121 iList->AppendL( param ); |
|
122 |
|
123 CleanupStack::PopAndDestroy( lmBuf ); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CTestProviderDump::AddLandmarkL( const TDesC& aUri, TPosLmItemId aId ) |
|
130 { |
|
131 TAiwGenericParam uri( EGenericParamLandmarkDatabase, TAiwVariant( aUri ) ); |
|
132 iList->AppendL( uri ); |
|
133 |
|
134 TAiwGenericParam id( EGenericParamLandmarkId, TAiwVariant( aId ) ); |
|
135 iList->AppendL( id ); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CTestProviderDump::AddLandmarkListL( const TDesC& aUri, TArray<TPosLmItemId> aItemIds ) |
|
142 { |
|
143 TAiwGenericParam param( EGenericParamLandmarkDatabase, TAiwVariant( aUri ) ); |
|
144 iList->AppendL( param ); |
|
145 |
|
146 for ( TInt i = 0; i < aItemIds.Count(); i++ ) |
|
147 { |
|
148 TAiwGenericParam param( EGenericParamLandmarkId, TAiwVariant( aItemIds[i] ) ); |
|
149 iList->AppendL( param ); |
|
150 } |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CTestProviderDump::AddMapViewOptionsL( |
|
157 TUint32 aOptions, |
|
158 TUint32 aCurrentLocationOption, |
|
159 TReal aRadius, |
|
160 TCoordinate aCenterPoint ) |
|
161 { |
|
162 TMnAiwMapViewOptionsParam options; |
|
163 options.iOptions = aOptions; |
|
164 options.iCurrentLocationOption = aCurrentLocationOption; |
|
165 options.iRadius = aRadius; |
|
166 options.iCenterPoint = aCenterPoint; |
|
167 |
|
168 TPckg<TMnAiwMapViewOptionsParam> pack( options ); |
|
169 |
|
170 TAiwGenericParam param( EGenericParamMnMapViewOptions, TAiwVariant( pack ) ); |
|
171 iList->AppendL( param ); |
|
172 } |
|
173 |
|
174 #ifdef RD_MAPNAV_BITMAP_ACCESS |
|
175 // ----------------------------------------------------------------------------- |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CTestProviderDump::AddMapImageOptionsL( TMapImageOptions& aOptions ) |
|
179 { |
|
180 TPckg<TMapImageOptions> pack( aOptions ); |
|
181 TAiwGenericParam param( EGenericParamUnspecified, TAiwVariant( pack ) ); |
|
182 iList->AppendL( param ); |
|
183 } |
|
184 #endif |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CTestProviderDump::AddRequestTextL( const TDesC& aText ) |
|
190 { |
|
191 TAiwGenericParam text( EGenericParamRequestText, TAiwVariant( aText ) ); |
|
192 iList->AppendL( text ); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CTestProviderDump::AddGeocodingOptionsL( TUint32 aOptions ) |
|
199 { |
|
200 TMnAiwGeocodingOptionsParam options; |
|
201 options.iOptions = aOptions; |
|
202 |
|
203 TPckg<TMnAiwGeocodingOptionsParam> pack( options ); |
|
204 |
|
205 TAiwGenericParam param( EGenericParamMnGeocodingOptions, TAiwVariant( pack ) ); |
|
206 iList->AppendL( param ); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CTestProviderDump::AddAddressL( const TDesC& aAddress ) |
|
213 { |
|
214 TAiwGenericParam address( EGenericParamRequestText, TAiwVariant( aAddress ) ); |
|
215 iList->AppendL( address ); |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CTestProviderDump::CommitL() |
|
222 { |
|
223 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
224 |
|
225 RFileWriteStream stream; |
|
226 TInt err = KErrInUse; |
|
227 TInt attempts = 5; |
|
228 while ( err == KErrInUse && --attempts >= 0 ) |
|
229 { |
|
230 err = stream.Replace( fs, KDumpFileName, EFileStream | EFileWrite ); |
|
231 if ( err && attempts >= 0 ) |
|
232 { |
|
233 User::After( 100*1000 ); // 0.1 sec |
|
234 } |
|
235 } |
|
236 if ( err ) |
|
237 { |
|
238 LOG1("Couldn't open dump file, error %d", err); |
|
239 User::Leave( err ); |
|
240 } |
|
241 CleanupClosePushL( stream ); |
|
242 |
|
243 iList->ExternalizeL( stream ); |
|
244 |
|
245 CleanupStack::PopAndDestroy( &stream ); |
|
246 } |
|