|
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 "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file contains testclass implementation. |
|
15 * This file containts the test blocks that tests the encoder functionality. |
|
16 * |
|
17 */ |
|
18 |
|
19 // [INCLUDE FILES] - do not remove |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include <LbsPosition.h> |
|
24 #include <LbsFieldIds.h> |
|
25 #include <BAUTILS.h> |
|
26 #include <EPos_CPosLmCategoryManager.h> |
|
27 #include <e32math.h> |
|
28 #include <gulutil.h> |
|
29 |
|
30 #include "CUTLandmarkURL.h" |
|
31 #include "EPos_LandmarksErrors.h" |
|
32 |
|
33 |
|
34 |
|
35 // EXTERNAL DATA STRUCTURES |
|
36 //extern ?external_data; |
|
37 |
|
38 // EXTERNAL FUNCTION PROTOTYPES |
|
39 //extern ?external_function( ?arg_type,?arg_type ); |
|
40 |
|
41 // CONSTANTS |
|
42 //const ?type ?constant_var = ?constant; |
|
43 |
|
44 // MACROS |
|
45 //#define ?macro ?macro_def |
|
46 |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 //const ?type ?constant_var = ?constant; |
|
49 //#define ?macro_name ?macro_def |
|
50 |
|
51 // MODULE DATA STRUCTURES |
|
52 //enum ?declaration |
|
53 //typedef ?declaration |
|
54 |
|
55 // LOCAL FUNCTION PROTOTYPES |
|
56 //?type ?function_name( ?arg_type, ?arg_type ); |
|
57 |
|
58 // FORWARD DECLARATIONS |
|
59 //class ?FORWARD_CLASSNAME; |
|
60 |
|
61 //Tags used in cfg file |
|
62 _LIT(KName, "NAME= "); |
|
63 _LIT(KLandmarkDescription, "LMDESCRIPTION= "); |
|
64 _LIT(KVerticalAccuracy, "VERT_ACC= "); |
|
65 _LIT(KHorizontalAccuracy, "HACCURACY= "); |
|
66 _LIT(KLatitude, "LATITUDE= "); |
|
67 _LIT(KLongitude, "LONGITUDE= "); |
|
68 _LIT(KCountry, "COUNTRY= "); |
|
69 _LIT(KState, "STATE= "); |
|
70 _LIT(KStreet, "STREET= "); |
|
71 _LIT(KHouseNumber, "HOUSENO.= "); |
|
72 _LIT(KPostalCode, "POSTALCODE= "); |
|
73 _LIT(KCity, "CITY= "); |
|
74 _LIT(KTelephone, "TELEPHONE= "); |
|
75 _LIT(KWeb, "WEB= "); |
|
76 _LIT(KAltitude, "ALTITUDE= "); |
|
77 _LIT(KSpeed, "SPEED= "); |
|
78 _LIT(KHeading, "HEADING= "); |
|
79 _LIT(KCategory, "CATEGORY= "); |
|
80 _LIT(K2ndCategory, "CATEGORYTWO= "); |
|
81 _LIT(KPID, "PID= "); |
|
82 _LIT(KTS, "TS= "); |
|
83 |
|
84 _LIT(KOutputFilePath, "c:\\testframework\\EncodedLandmarks.txt"); |
|
85 _LIT(KInputFile, "c:\\testframework\\URLParser.txt"); |
|
86 _LIT(KInputFileHandle, "c:\\testframework\\InputFilehandle.txt"); |
|
87 |
|
88 //255 |
|
89 _LIT(KMAXSTRING, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"); |
|
90 //254 |
|
91 _LIT(KMAXSTRING1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"); |
|
92 //256 |
|
93 _LIT(KMAXSTRING2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"); |
|
94 |
|
95 //4095 |
|
96 _LIT(KMAXDESSTRING, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"); |
|
97 //4094 |
|
98 _LIT(KMAXDESSTRING1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"); |
|
99 //4096 |
|
100 _LIT(KMAXDESSTRING2, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"); |
|
101 |
|
102 //124 |
|
103 _LIT(KMAXCAT, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234"); |
|
104 //123 |
|
105 _LIT(KMAXCAT1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123"); |
|
106 //125 |
|
107 _LIT(KMAXCAT2, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"); |
|
108 |
|
109 // ============================ MEMBER FUNCTIONS =============================== |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CCUTLandmarkURL::Delete |
|
113 // Delete here all resources allocated and opened from test methods. |
|
114 // Called from destructor. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CCUTLandmarkURL::Delete() |
|
118 { |
|
119 |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CCUTLandmarkURL::RunMethodL |
|
124 // Run specified method. Contains also table of test mothods and their names. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CCUTLandmarkURL::RunMethodL( |
|
128 CStifItemParser& aItem ) |
|
129 { |
|
130 |
|
131 static TStifFunctionInfo const KFunctions[] = |
|
132 { |
|
133 // Copy this line for every implemented function. |
|
134 // First string is the function name used in TestScripter script file. |
|
135 // Second is the actual implementation member function. |
|
136 ENTRY( "CreateInstanceL", CCUTLandmarkURL::CreateInstanceL ), |
|
137 ENTRY( "CleanUp", CCUTLandmarkURL::CleanUp ), |
|
138 ENTRY( "CreateLandmarkL", CCUTLandmarkURL::CreateLandmarkL ), |
|
139 |
|
140 //Test Methods for parsing |
|
141 ENTRY( "SetInputBuffer", CCUTLandmarkURL::SetInputBufferL ), |
|
142 ENTRY( "SetInputFile", CCUTLandmarkURL::SetInputFile ), |
|
143 ENTRY( "SetInputFileHandle", CCUTLandmarkURL::SetInputFileHandleL ), |
|
144 ENTRY( "ParseContent", CCUTLandmarkURL::ParseContent ), |
|
145 ENTRY( "NumOfParsedLandmarks", CCUTLandmarkURL::NumOfParsedLandmarksL ), |
|
146 ENTRY( "Landmark", CCUTLandmarkURL::LandmarkL ), |
|
147 ENTRY( "LandmarkCategory", CCUTLandmarkURL::LandmarkCategoryL ), |
|
148 ENTRY( "TestMisc", CCUTLandmarkURL::MiscL ), |
|
149 |
|
150 |
|
151 //Test methods for encoder |
|
152 ENTRY( "SetOutputFileHandle", CCUTLandmarkURL::SetOutputFileHandle ), |
|
153 ENTRY( "SetOutputBuffer", CCUTLandmarkURL::SetOutputBuffer ), |
|
154 ENTRY( "AddLandmark", CCUTLandmarkURL::AddLandmark ), |
|
155 ENTRY( "AddCategoryForLatestLandmark", CCUTLandmarkURL::AddCategoryForLatestLandmarkL), |
|
156 ENTRY( "FinalizeEncoding", CCUTLandmarkURL::FinalizeEncoding ), |
|
157 ENTRY( "VerifyEncoding", CCUTLandmarkURL::VerifyEncodingL ), |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 //ADD NEW ENTRY HERE |
|
163 // [test cases entries] - Do not remove |
|
164 |
|
165 }; |
|
166 |
|
167 const TInt count = sizeof( KFunctions ) / |
|
168 sizeof( TStifFunctionInfo ); |
|
169 |
|
170 return RunInternalL( KFunctions, count, aItem ); |
|
171 |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CCUTLandmarkURL::CreateInstanceL |
|
176 // This function creates instances for URL parser and encoder |
|
177 // (other items were commented in a header). |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TInt CCUTLandmarkURL::CreateInstanceL( CStifItemParser& aItem ) |
|
181 { |
|
182 TInt result = KErrNone; |
|
183 TInt Case; |
|
184 RArray<CPosLandmarkEncoder> ArrayOfEncoders; |
|
185 RArray<CPosLandmarkParser> ArrayOfParsers; |
|
186 |
|
187 aItem.GetNextInt(Case); |
|
188 _LIT8( KUrlMIMEType, "maps.ovi.com" ); |
|
189 |
|
190 switch(Case) |
|
191 { |
|
192 case CREATE_PARSER: |
|
193 iLog->Log(_L("Creating Instance of parser.....")); |
|
194 TRAP(result, iPosLandmarkParser = CPosLandmarkParser::NewL(KUrlMIMEType)); |
|
195 if(result != KErrNone || !(iPosLandmarkParser)) |
|
196 { |
|
197 iLog->Log(_L("FAILED: Creating instance for Parser fails, error = %d"),result); |
|
198 result = KErrGeneral; |
|
199 } |
|
200 else |
|
201 iLog->Log(_L("PASSED: Creating instance for Parser passes")); |
|
202 |
|
203 break; |
|
204 |
|
205 case CREATE_ENCODER: |
|
206 iLog->Log(_L("Creating Instance of encoder.....")); |
|
207 TRAP(result, iPosLandmarkEncoder = CPosLandmarkEncoder::NewL(KUrlMIMEType)); |
|
208 if(result != KErrNone || !(iPosLandmarkEncoder)) |
|
209 { |
|
210 iLog->Log(_L("FAILED: Creating instance for encoder fails, error = %d"),result); |
|
211 result = KErrGeneral; |
|
212 } |
|
213 else |
|
214 iLog->Log(_L("PASSED: Creating instance for Encoder passes ")); |
|
215 break; |
|
216 |
|
217 |
|
218 case MULTIPLE_ENCODER: |
|
219 TRAPD(err, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
220 TRAPD(err1, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
221 TRAPD(err2, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
222 TRAPD(err3, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
223 TRAPD(err4, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
224 TRAPD(err5, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
225 TRAPD(err6, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
226 TRAPD(err7, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
227 TRAPD(err8, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
228 TRAPD(err9, ArrayOfEncoders.AppendL(*CPosLandmarkEncoder::NewL(KUrlMIMEType))); |
|
229 if((ArrayOfEncoders.Count() != 10)||(err||err1||err2||err3||err4||err5||err6||err7||err8||err9 != KErrNone)) |
|
230 result = KErrNone; |
|
231 break; |
|
232 |
|
233 case MULTIPLE_PARSER: |
|
234 TRAPD(parseerr, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
235 TRAPD(parseerr1, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
236 TRAPD(parseerr2, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
237 TRAPD(parseerr3, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
238 TRAPD(parseerr4, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
239 TRAPD(parseerr5, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
240 TRAPD(parseerr6, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
241 TRAPD(parseerr7, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
242 TRAPD(parseerr8, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
243 TRAPD(parseerr9, ArrayOfParsers.AppendL(*CPosLandmarkParser::NewL(KUrlMIMEType))); |
|
244 if((ArrayOfParsers.Count() != 10)||(parseerr||parseerr1||parseerr2||parseerr3||parseerr4||parseerr5||parseerr6||parseerr7||parseerr8||parseerr9 != KErrNone)) |
|
245 result = KErrNone; |
|
246 break; |
|
247 |
|
248 |
|
249 default: |
|
250 break; |
|
251 } |
|
252 return result; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CCUTLandmarkURL::CleanUp |
|
257 // Releases memory and other resources |
|
258 // (other items were commented in a header). |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 TInt CCUTLandmarkURL::CleanUp( CStifItemParser& /*aItem*/ ) |
|
262 { |
|
263 ReleaseLandmarkResources(); |
|
264 if(iPosLandmark) |
|
265 { |
|
266 delete iPosLandmark; |
|
267 iPosLandmark = NULL; |
|
268 } |
|
269 |
|
270 if(iEncoderBuffer) |
|
271 { |
|
272 delete iEncoderBuffer; |
|
273 iEncoderBuffer = NULL; |
|
274 } |
|
275 |
|
276 if(iDatabase) |
|
277 { |
|
278 delete iDatabase; |
|
279 iDatabase = NULL; |
|
280 } |
|
281 |
|
282 if(iOperation) |
|
283 { |
|
284 delete iOperation; |
|
285 iOperation = NULL; |
|
286 } |
|
287 |
|
288 if(iPosLandmarkParser) |
|
289 { |
|
290 delete iPosLandmarkParser; |
|
291 iPosLandmarkParser = NULL; |
|
292 } |
|
293 |
|
294 if(iPosLandmarkEncoder) |
|
295 { |
|
296 delete iPosLandmarkEncoder; |
|
297 iPosLandmarkEncoder = NULL; |
|
298 } |
|
299 |
|
300 iFile.Close(); |
|
301 iFileSession.Close(); |
|
302 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); |
|
303 User::After( 20000 ); |
|
304 iLog->Log(_L("PASSED: Cleanup Succesful")); |
|
305 return KErrNone; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CCUTLandmarkURL::CreateLandmark |
|
310 // This functions creates landmarks |
|
311 // (other items were commented in a header). |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 TInt CCUTLandmarkURL::CreateLandmarkL( CStifItemParser& aItem ) |
|
315 { |
|
316 TInt result = KErrNone; |
|
317 TInt Case = 0; |
|
318 TRAP(result, iPosLandmark = CPosLandmark::NewL()); |
|
319 User::LeaveIfError(result); |
|
320 aItem.GetNextInt(Case); |
|
321 |
|
322 //Reading location values from the cfg files |
|
323 GetStringAfterTag(aItem, KName, iName); |
|
324 GetStringAfterTag(aItem, KLandmarkDescription, iDescription); |
|
325 aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); |
|
326 aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); |
|
327 aItem.GetNextString(KLatitude,iLatitude); |
|
328 aItem.GetNextString(KLongitude,iLongitude); |
|
329 aItem.GetNextString(KAltitude,iAltitude); |
|
330 |
|
331 |
|
332 //Reading postion fields from cfg fields |
|
333 aItem.GetNextString(KSpeed,iSpeed); |
|
334 aItem.GetNextString(KHeading,iHeading); |
|
335 GetStringAfterTag(aItem, KCountry,iCountry); |
|
336 GetStringAfterTag(aItem, KState,iState); |
|
337 GetStringAfterTag(aItem, KCity,iCity); |
|
338 GetStringAfterTag(aItem, KStreet ,iStreet); |
|
339 GetStringAfterTag(aItem, KPostalCode,iPostalCode); |
|
340 GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); |
|
341 GetStringAfterTag(aItem, KTelephone,iTelephone); |
|
342 aItem.GetNextString(KCategory,iCategory); |
|
343 GetStringAfterTag(aItem, KWeb,iWeb); |
|
344 GetStringAfterTag(aItem, KPID,iPID); |
|
345 GetStringAfterTag(aItem, KTS,iTS); |
|
346 |
|
347 |
|
348 //Converting string to TReal |
|
349 TReal32 VA = 0; |
|
350 TLex16 VerticalAcc(iVerticalAccuracy); |
|
351 VerticalAcc.Val(VA); |
|
352 |
|
353 TReal32 HA= 0; |
|
354 TLex16 HorizontalAcc(iHorizontalAccuracy); |
|
355 HorizontalAcc.Val(HA); |
|
356 |
|
357 TReal64 RLat = 0; |
|
358 TLex16 Lat(iLatitude); |
|
359 Lat.Val(RLat); |
|
360 |
|
361 TReal64 RLong = 0; |
|
362 TLex16 Long(iLongitude); |
|
363 Long.Val(RLong); |
|
364 |
|
365 TReal64 RAlt = 0; |
|
366 TLex16 Alt(iAltitude); |
|
367 Alt.Val(RAlt); |
|
368 |
|
369 //This part of the code sets the position params to the landmark |
|
370 TLocality Locality; |
|
371 if (!iAltitude.Compare(_L(""))) |
|
372 Locality.SetCoordinate(RLat, RLong); |
|
373 else |
|
374 Locality.SetCoordinate(RLat,RLong, RAlt); |
|
375 |
|
376 if (iHorizontalAccuracy.Compare(_L(""))) |
|
377 Locality.SetHorizontalAccuracy(HA); |
|
378 |
|
379 if (iVerticalAccuracy.Compare(_L(""))) |
|
380 Locality.SetVerticalAccuracy(VA); |
|
381 |
|
382 TUint Cat; |
|
383 TLex16 Categ(iCategory); |
|
384 Categ.Val(Cat, EDecimal); |
|
385 |
|
386 //Sets the time stamp to the landmark |
|
387 TTime TS; |
|
388 TS.Set(iTS); |
|
389 |
|
390 if (iTS.Compare(_L(""))) |
|
391 { |
|
392 TRAP(result ,iPosLandmark->SetTimeStampL(TS)); |
|
393 User::LeaveIfError(result); |
|
394 } |
|
395 |
|
396 switch(Case) |
|
397 { |
|
398 //This case tests the normal condition for all the landmark param fields |
|
399 default: |
|
400 //fall through |
|
401 case 0: |
|
402 |
|
403 if (iDescription.Compare(_L(""))) |
|
404 { |
|
405 TRAP(result, iPosLandmark->SetLandmarkDescriptionL(iDescription)); |
|
406 User::LeaveIfError(result); |
|
407 } |
|
408 if (iName.Compare(_L(""))) |
|
409 { |
|
410 TRAP(result ,iPosLandmark->SetLandmarkNameL(iName)); |
|
411 User::LeaveIfError(result); |
|
412 } |
|
413 |
|
414 //Setting positions fields |
|
415 if (iSpeed.Compare(_L(""))) |
|
416 { |
|
417 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, iSpeed)); |
|
418 User::LeaveIfError(result); |
|
419 } |
|
420 if (iHeading.Compare(_L(""))) |
|
421 { |
|
422 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHeading, iHeading)); |
|
423 User::LeaveIfError(result); |
|
424 } |
|
425 if (iCountry.Compare(_L(""))) |
|
426 { |
|
427 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, iCountry)); |
|
428 User::LeaveIfError(result); |
|
429 } |
|
430 if (iState.Compare(_L(""))) |
|
431 { |
|
432 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, iState)); |
|
433 User::LeaveIfError(result); |
|
434 } |
|
435 if (iCity.Compare(_L(""))) |
|
436 { |
|
437 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, iCity)); |
|
438 User::LeaveIfError(result); |
|
439 } |
|
440 if (iStreet.Compare(_L(""))) |
|
441 { |
|
442 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, iStreet)); |
|
443 User::LeaveIfError(result); |
|
444 } |
|
445 if (iPostalCode.Compare(_L(""))) |
|
446 { |
|
447 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, iPostalCode)); |
|
448 User::LeaveIfError(result); |
|
449 } |
|
450 if (iHouseNumber.Compare(_L(""))) |
|
451 { |
|
452 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, iHouseNumber)); |
|
453 User::LeaveIfError(result); |
|
454 } |
|
455 if (iTelephone.Compare(_L(""))) |
|
456 { |
|
457 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, iTelephone)); |
|
458 User::LeaveIfError(result); |
|
459 } |
|
460 if (iWeb.Compare(_L(""))) |
|
461 { |
|
462 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, iWeb)); |
|
463 User::LeaveIfError(result); |
|
464 } |
|
465 if (iPID.Compare(_L(""))) |
|
466 { |
|
467 TRAP(result ,iPosLandmark->SetPlaceIdL(iPID)); |
|
468 User::LeaveIfError(result); |
|
469 } |
|
470 break; |
|
471 |
|
472 //The following cases sets the location params to test the boundry and error cases |
|
473 case TEST_NULL_NAME: |
|
474 TRAP(result ,iPosLandmark->SetLandmarkNameL(iName)); |
|
475 User::LeaveIfError(result); |
|
476 break; |
|
477 |
|
478 case TEST_NULL_STREET: |
|
479 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, iStreet)); |
|
480 User::LeaveIfError(result); |
|
481 break; |
|
482 |
|
483 case TEST_NULL_HNO: |
|
484 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, iHouseNumber)); |
|
485 User::LeaveIfError(result); |
|
486 break; |
|
487 |
|
488 case TEST_NULL_POSTALCODE: |
|
489 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, iPostalCode)); |
|
490 User::LeaveIfError(result); |
|
491 break; |
|
492 |
|
493 case TEST_NULL_CITY: |
|
494 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, iCity)); |
|
495 User::LeaveIfError(result); |
|
496 break; |
|
497 |
|
498 case TEST_NULL_STATE: |
|
499 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, iState)); |
|
500 User::LeaveIfError(result); |
|
501 break; |
|
502 |
|
503 case TEST_NULL_COUNTRY: |
|
504 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, iCountry)); |
|
505 User::LeaveIfError(result); |
|
506 break; |
|
507 |
|
508 case TEST_NULL_TELEPHONE: |
|
509 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, iTelephone)); |
|
510 User::LeaveIfError(result); |
|
511 break; |
|
512 |
|
513 case TEST_NULL_WEB: |
|
514 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, iWeb)); |
|
515 User::LeaveIfError(result); |
|
516 break; |
|
517 |
|
518 case TEST_NULL_DESCRIPTION: |
|
519 TRAP(result, iPosLandmark->SetLandmarkDescriptionL(iDescription)); |
|
520 User::LeaveIfError(result); |
|
521 break; |
|
522 |
|
523 case TEST_NULL_SPEED: |
|
524 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHorizontalSpeed, iSpeed)); |
|
525 User::LeaveIfError(result); |
|
526 break; |
|
527 |
|
528 case TEST_NULL_HEADING: |
|
529 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldHeading, iHeading)); |
|
530 User::LeaveIfError(result); |
|
531 break; |
|
532 |
|
533 case TEST_NULL_PID: |
|
534 TRAP(result ,iPosLandmark->SetPlaceIdL(iPID)); |
|
535 User::LeaveIfError(result); |
|
536 break; |
|
537 |
|
538 case TEST_MAXLENGTH_NAME: |
|
539 TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING)); |
|
540 User::LeaveIfError(result); |
|
541 break; |
|
542 |
|
543 case TEST_MAXLENGTH1_NAME: |
|
544 TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING1)); |
|
545 User::LeaveIfError(result); |
|
546 break; |
|
547 |
|
548 case TEST_MAXLENGTH2_NAME: |
|
549 TRAP(result ,iPosLandmark->SetLandmarkNameL(KMAXSTRING2)); |
|
550 if(result != KErrArgument) |
|
551 User::Leave(result); |
|
552 else |
|
553 result = KErrNone; |
|
554 break; |
|
555 |
|
556 case TEST_MAXLENGTH_STREET: |
|
557 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING)); |
|
558 User::LeaveIfError(result); |
|
559 break; |
|
560 |
|
561 case TEST_MAXLENGTH1_STREET: |
|
562 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING1)); |
|
563 User::LeaveIfError(result); |
|
564 break; |
|
565 |
|
566 case TEST_MAXLENGTH2_STREET: |
|
567 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreet, KMAXSTRING2)); |
|
568 if(result != KErrArgument) |
|
569 User::Leave(result); |
|
570 else |
|
571 result = KErrNone; |
|
572 break; |
|
573 |
|
574 case TEST_MAXLENGTH_HNO: |
|
575 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING)); |
|
576 User::LeaveIfError(result); |
|
577 break; |
|
578 |
|
579 case TEST_MAXLENGTH1_HNO: |
|
580 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING1)); |
|
581 User::LeaveIfError(result); |
|
582 break; |
|
583 |
|
584 case TEST_MAXLENGTH2_HNO: |
|
585 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldStreetExtension, KMAXSTRING2)); |
|
586 if(result != KErrArgument) |
|
587 User::Leave(result); |
|
588 else |
|
589 result = KErrNone; |
|
590 break; |
|
591 |
|
592 case TEST_MAXLENGTH_POSTALCODE: |
|
593 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING)); |
|
594 User::LeaveIfError(result); |
|
595 break; |
|
596 |
|
597 case TEST_MAXLENGTH1_POSTALCODE: |
|
598 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING1)); |
|
599 User::LeaveIfError(result); |
|
600 break; |
|
601 |
|
602 case TEST_MAXLENGTH2_POSTALCODE: |
|
603 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldPostalCode, KMAXSTRING2)); |
|
604 if(result != KErrArgument) |
|
605 User::Leave(result); |
|
606 else |
|
607 result = KErrNone; |
|
608 break; |
|
609 |
|
610 case TEST_MAXLENGTH_CITY: |
|
611 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING)); |
|
612 User::LeaveIfError(result); |
|
613 break; |
|
614 |
|
615 case TEST_MAXLENGTH1_CITY: |
|
616 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING1)); |
|
617 User::LeaveIfError(result); |
|
618 break; |
|
619 |
|
620 case TEST_MAXLENGTH2_CITY: |
|
621 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCity, KMAXSTRING2)); |
|
622 if(result != KErrArgument) |
|
623 User::Leave(result); |
|
624 else |
|
625 result = KErrNone; |
|
626 break; |
|
627 |
|
628 case TEST_MAXLENGTH_STATE: |
|
629 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING)); |
|
630 User::LeaveIfError(result); |
|
631 break; |
|
632 |
|
633 case TEST_MAXLENGTH1_STATE: |
|
634 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING1)); |
|
635 User::LeaveIfError(result); |
|
636 break; |
|
637 |
|
638 case TEST_MAXLENGTH2_STATE: |
|
639 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldState, KMAXSTRING2)); |
|
640 if(result != KErrArgument) |
|
641 User::Leave(result); |
|
642 else |
|
643 result = KErrNone; |
|
644 break; |
|
645 |
|
646 case TEST_MAXLENGTH_COUNTRY: |
|
647 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING)); |
|
648 User::LeaveIfError(result); |
|
649 break; |
|
650 |
|
651 case TEST_MAXLENGTH1_COUNTRY: |
|
652 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING1)); |
|
653 User::LeaveIfError(result); |
|
654 break; |
|
655 |
|
656 case TEST_MAXLENGTH2_COUNTRY: |
|
657 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldCountry, KMAXSTRING2)); |
|
658 if(result != KErrArgument) |
|
659 User::Leave(result); |
|
660 else |
|
661 result = KErrNone; |
|
662 break; |
|
663 |
|
664 case TEST_MAXLENGTH_TELEPHONE: |
|
665 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING)); |
|
666 User::LeaveIfError(result); |
|
667 break; |
|
668 |
|
669 case TEST_MAXLENGTH1_TELEPHONE: |
|
670 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING1)); |
|
671 User::LeaveIfError(result); |
|
672 break; |
|
673 |
|
674 case TEST_MAXLENGTH2_TELEPHONE: |
|
675 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, KMAXSTRING2)); |
|
676 if(result != KErrArgument) |
|
677 User::Leave(result); |
|
678 else |
|
679 result = KErrNone; |
|
680 break; |
|
681 |
|
682 case TEST_MAXLENGTH_WEB: |
|
683 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING)); |
|
684 User::LeaveIfError(result); |
|
685 break; |
|
686 |
|
687 case TEST_MAXLENGTH1_WEB: |
|
688 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING1)); |
|
689 User::LeaveIfError(result); |
|
690 break; |
|
691 |
|
692 case TEST_MAXLENGTH2_WEB: |
|
693 TRAP(result, iPosLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, KMAXSTRING2)); |
|
694 if(result != KErrArgument) |
|
695 User::Leave(result); |
|
696 else |
|
697 result = KErrNone; |
|
698 break; |
|
699 |
|
700 case TEST_MAXLENGTH_DESCRIPTION: |
|
701 TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING)); |
|
702 User::LeaveIfError(result); |
|
703 break; |
|
704 |
|
705 case TEST_MAXLENGTH1_DESCRIPTION: |
|
706 TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING1)); |
|
707 User::LeaveIfError(result); |
|
708 break; |
|
709 |
|
710 case TEST_MAXLENGTH2_DESCRIPTION: |
|
711 TRAP(result, iPosLandmark->SetLandmarkDescriptionL(KMAXDESSTRING2)); |
|
712 if(result != KErrArgument) |
|
713 User::Leave(result); |
|
714 else |
|
715 result = KErrNone; |
|
716 break; |
|
717 |
|
718 case TEST_MAXLENGTH_PID: |
|
719 TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING)); |
|
720 User::LeaveIfError(result); |
|
721 break; |
|
722 |
|
723 case TEST_MAXLENGTH1_PID: |
|
724 TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING1)); |
|
725 User::LeaveIfError(result); |
|
726 break; |
|
727 |
|
728 case TEST_MAXLENGTH2_PID: |
|
729 TRAP(result ,iPosLandmark->SetPlaceIdL(KMAXSTRING2)); |
|
730 if(result != KErrArgument) |
|
731 User::Leave(result); |
|
732 else |
|
733 result = KErrNone; |
|
734 break; |
|
735 |
|
736 case TEST_MAX_HA: |
|
737 Locality.SetHorizontalAccuracy(KMaxTReal32); |
|
738 break; |
|
739 |
|
740 case TEST_MAX_VA: |
|
741 Locality.SetVerticalAccuracy(KMaxTReal32-1); |
|
742 break; |
|
743 } |
|
744 |
|
745 //Adding Global Category |
|
746 iDatabase = CPosLandmarkDatabase::OpenL(); |
|
747 if (iDatabase->IsInitializingNeeded()) |
|
748 { |
|
749 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
750 } |
|
751 |
|
752 if (iCategory.Compare(_L(""))) |
|
753 { |
|
754 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
755 CleanupStack::PushL(categoryManager); |
|
756 TUint16 id = categoryManager->GetGlobalCategoryL(Cat); |
|
757 CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(id); |
|
758 TRAP(result, iPosLandmark->AddCategoryL(id)); |
|
759 CleanupStack::PopAndDestroy(landmarkCategory); |
|
760 CleanupStack::PopAndDestroy(categoryManager); |
|
761 User::LeaveIfError(result); |
|
762 } |
|
763 |
|
764 TRAP(result, iPosLandmark->SetPositionL(Locality)); |
|
765 if(result!= KErrNone) |
|
766 { |
|
767 result = KErrGeneral; |
|
768 iLog->Log(_L("FAILED: Creating Landmark fails!!")); |
|
769 } |
|
770 else |
|
771 iLog->Log(_L("PASSED: Creating Landmark Success!!")); |
|
772 return result; |
|
773 } |
|
774 |
|
775 // ----------------------------------------------------------------------------- |
|
776 // CCUTLandmarkURL::SetOutputFileHandle |
|
777 // This function sets the output file to which the encoded URLs will be written |
|
778 // (other items were commented in a header). |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 TInt CCUTLandmarkURL::SetOutputFileHandle( CStifItemParser& aItem ) |
|
782 { |
|
783 TInt result = KErrNone; |
|
784 TInt caseno = 0; |
|
785 aItem.GetNextInt(result); |
|
786 |
|
787 switch(caseno) |
|
788 { |
|
789 default: |
|
790 //fall through |
|
791 case 0: |
|
792 if ( BaflUtils::FileExists(iFileSession, KOutputFilePath)) |
|
793 { |
|
794 BaflUtils :: DeleteFile( iFileSession, KOutputFilePath ); |
|
795 } |
|
796 TRAP(result,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); |
|
797 if(result != KErrNone) |
|
798 { |
|
799 iLog->Log(_L("FAILED: Setting output file fails with error %d"), result); |
|
800 result = KErrGeneral; |
|
801 } |
|
802 else |
|
803 iLog->Log(_L("PASSED: Setting output file passes")); |
|
804 break; |
|
805 |
|
806 case ERROR_VERIFICATION_OPFILE: |
|
807 if ( BaflUtils::FileExists(iFileSession, KOutputFilePath)) |
|
808 { |
|
809 BaflUtils ::DeleteFile( iFileSession, KOutputFilePath ); |
|
810 } |
|
811 TRAP(result,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); |
|
812 TRAPD(err,iPosLandmarkEncoder->SetOutputFileL(KOutputFilePath)); |
|
813 |
|
814 if(err != KErrAlreadyExists) |
|
815 { |
|
816 iLog->Log(_L("FAILED: Error verification for setting output file fails with %d"), err); |
|
817 result = KErrGeneral; |
|
818 } |
|
819 else |
|
820 iLog->Log(_L("PASSED: Error Verification for setting output file passed!!")); |
|
821 |
|
822 break; |
|
823 } |
|
824 |
|
825 return result; |
|
826 } |
|
827 |
|
828 // ----------------------------------------------------------------------------- |
|
829 // CCUTLandmarkURL::SetOutputFileHandle |
|
830 // This function sets the output buffer to which the encoded URLs will be written |
|
831 // (other items were commented in a header). |
|
832 // ----------------------------------------------------------------------------- |
|
833 // |
|
834 TInt CCUTLandmarkURL::SetOutputBuffer( CStifItemParser& /*aItem*/ ) |
|
835 { |
|
836 TInt result = KErrNone; |
|
837 |
|
838 TRAP(result, iEncoderBuffer = iPosLandmarkEncoder->SetUseOutputBufferL()); |
|
839 if(result != KErrNone) |
|
840 iLog->Log(_L("FAILED: Setting Output buffer fails with error %d"), result); |
|
841 |
|
842 else |
|
843 iLog->Log(_L("PASSED: Setting Output buffer passed")); |
|
844 |
|
845 return result; |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // CCUTLandmarkURL::AddLandmark |
|
850 // This function adds the landmark to be encoded |
|
851 // (other items were commented in a header). |
|
852 // ----------------------------------------------------------------------------- |
|
853 // |
|
854 TInt CCUTLandmarkURL::AddLandmark( CStifItemParser& aItem ) |
|
855 { |
|
856 TInt result = KErrNone; |
|
857 TInt caseno = 0; |
|
858 aItem.GetNextInt(caseno); |
|
859 |
|
860 switch(caseno) |
|
861 { |
|
862 default: |
|
863 //fall through |
|
864 case 0: |
|
865 TRAP(result, iPosLandmarkEncoder->AddLandmarkL(* iPosLandmark)); |
|
866 if(result != KErrNone) |
|
867 iLog->Log(_L("FAILED: Adding Landmark for encoding fails with error %d"), result); |
|
868 |
|
869 else |
|
870 iLog->Log(_L("PASSED: Adding Landmark for encoding passed")); |
|
871 break; |
|
872 |
|
873 case PANIC_CODE_VERIIFCATION: |
|
874 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); |
|
875 TRAP(result, iPosLandmarkEncoder->AddLandmarkL(* iPosLandmark)); |
|
876 break; |
|
877 } |
|
878 |
|
879 return result; |
|
880 } |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CCUTLandmarkURL::AddCategoryForLatestLandmark |
|
884 // This function adds category to the latest landmark |
|
885 // (other items were commented in a header). |
|
886 // ----------------------------------------------------------------------------- |
|
887 // |
|
888 TInt CCUTLandmarkURL::AddCategoryForLatestLandmarkL( CStifItemParser& aItem ) |
|
889 { |
|
890 TInt result = KErrNone; |
|
891 TInt Category; |
|
892 TInt caseno = 0; |
|
893 |
|
894 aItem.GetNextInt(Category); |
|
895 aItem.GetNextInt(caseno); |
|
896 |
|
897 iDatabase = CPosLandmarkDatabase::OpenL(); |
|
898 if (iDatabase->IsInitializingNeeded()) |
|
899 { |
|
900 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
901 } |
|
902 |
|
903 CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL(*iDatabase); |
|
904 CleanupStack::PushL(categoryManager); |
|
905 TUint16 id = categoryManager->GetGlobalCategoryL(Category); |
|
906 CPosLandmarkCategory* landmarkCategory = categoryManager->ReadCategoryLC(id); |
|
907 |
|
908 switch(caseno) |
|
909 { |
|
910 default: |
|
911 //fall through |
|
912 case 0: |
|
913 TRAP(result, iPosLandmarkEncoder->AddCategoryForLatestLandmarkL(* landmarkCategory)); |
|
914 if(result != KErrNone) |
|
915 iLog->Log(_L("FAILED: Adding Category for latest landmark fails with error %d"), result); |
|
916 |
|
917 else |
|
918 iLog->Log(_L("PASSED: Adding Category for latest landmark passed")); |
|
919 break; |
|
920 |
|
921 case PANIC_CODE_VERIIFCATION: |
|
922 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); |
|
923 TRAP(result, iPosLandmarkEncoder->AddCategoryForLatestLandmarkL(* landmarkCategory)); |
|
924 break; |
|
925 } |
|
926 CleanupStack::PopAndDestroy(landmarkCategory); |
|
927 CleanupStack::PopAndDestroy(categoryManager); |
|
928 return result; |
|
929 } |
|
930 // ----------------------------------------------------------------------------- |
|
931 // CCUTLandmarkURL::FinalizeEncoding |
|
932 // This function finalizes the encoding |
|
933 // (other items were commented in a header). |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 TInt CCUTLandmarkURL::FinalizeEncoding( CStifItemParser& /*aItem*/ ) |
|
937 { |
|
938 TInt result = KErrNone; |
|
939 TRAP(result, iOperation = iPosLandmarkEncoder->FinalizeEncodingL()); |
|
940 TRAPD(result1, iOperation->ExecuteL()); |
|
941 if(result != KErrNone||result1 != KErrNone) |
|
942 iLog->Log(_L("FAILED: Finalize Encoding fails with error %d"), result); |
|
943 |
|
944 else |
|
945 iLog->Log(_L("PASSED: Encoding Completed Successfully")); |
|
946 |
|
947 return result; |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // CCUTLandmarkURL::SetInputBuffer |
|
952 // This function sets the input buffer containing the URL to be parsed |
|
953 // (other items were commented in a header). |
|
954 // ----------------------------------------------------------------------------- |
|
955 // |
|
956 TInt CCUTLandmarkURL::SetInputBufferL( CStifItemParser& aItem ) |
|
957 { |
|
958 TInt result = KErrNone; |
|
959 TInt caseno = 0; |
|
960 TPtrC inputBuffer = _L(""); |
|
961 aItem.GetNextInt(caseno); |
|
962 aItem.GetNextString(inputBuffer); |
|
963 |
|
964 HBufC *buffer = HBufC::NewLC(inputBuffer.Size()); |
|
965 *buffer = inputBuffer; |
|
966 |
|
967 HBufC8 *urlBuffer = HBufC8::NewL((inputBuffer.Size() + 25)); |
|
968 |
|
969 switch(caseno) |
|
970 { |
|
971 default: |
|
972 //fall through |
|
973 case 0: |
|
974 urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com/?")); |
|
975 break; |
|
976 |
|
977 case NOPROTOCOL: |
|
978 urlBuffer->Des().Copy(_L8("maps.ovi.com/?")); |
|
979 break; |
|
980 |
|
981 case HTTPS: |
|
982 urlBuffer->Des().Copy(_L8("https://maps.ovi.com/?")); |
|
983 break; |
|
984 |
|
985 case INVALIDPROTOCOL: |
|
986 urlBuffer->Des().Copy(_L8("ftp://maps.ovi.com/?")); |
|
987 break; |
|
988 |
|
989 case NOHOSTNAME: |
|
990 urlBuffer->Des().Copy(_L8("/?")); |
|
991 break; |
|
992 |
|
993 case INVALIDHOSTNAME: |
|
994 urlBuffer->Des().Copy(_L8("http://www.maps.google.com/?")); |
|
995 break; |
|
996 |
|
997 case INVALIDHOSTNAME1: |
|
998 urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com?/")); |
|
999 break; |
|
1000 |
|
1001 case INVALIDHOSTNAME2: |
|
1002 urlBuffer->Des().Copy(_L8("http://www.maps.ovi.com/")); |
|
1003 break; |
|
1004 } |
|
1005 |
|
1006 urlBuffer->Des().Append(*buffer); |
|
1007 iPosLandmarkParser->SetInputBuffer(* urlBuffer); |
|
1008 |
|
1009 CleanupStack::PopAndDestroy(buffer); |
|
1010 return result; |
|
1011 } |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // CCUTLandmarkURL::SetInputFile |
|
1014 // This function sets the input file containing the URL to be parsed |
|
1015 // (other items were commented in a header). |
|
1016 // ----------------------------------------------------------------------------- |
|
1017 // |
|
1018 TInt CCUTLandmarkURL::SetInputFile( CStifItemParser& aItem ) |
|
1019 { |
|
1020 TInt result = KErrNone; |
|
1021 TInt caseno = 0; |
|
1022 aItem.GetNextInt(caseno); |
|
1023 |
|
1024 if(BaflUtils::FileExists(iFileSession, KInputFile)) |
|
1025 { |
|
1026 TRAP(result,iPosLandmarkParser->SetInputFileL(KInputFile)); |
|
1027 if(result != KErrNone) |
|
1028 iLog->Log(_L("FAILED: Setting Input File Fails with error, %d"), result); |
|
1029 |
|
1030 else |
|
1031 iLog->Log(_L("PASSED: Setting Input File passes")); |
|
1032 } |
|
1033 else |
|
1034 result = KErrNotFound; |
|
1035 |
|
1036 if(caseno == DELETEFILE) |
|
1037 { |
|
1038 result = BaflUtils::DeleteFile(iFileSession, KInputFile); |
|
1039 if (result != KErrInUse) |
|
1040 iLog->Log(_L("FAILED: Input File Deleted after Setting")); |
|
1041 else |
|
1042 { |
|
1043 iLog->Log(_L("PASSED: Input File cannot be deleted after Setting")); |
|
1044 result = KErrNone; |
|
1045 } |
|
1046 } |
|
1047 return result; |
|
1048 } |
|
1049 |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // CCUTLandmarkURL::SetInputFileHandle |
|
1052 // This function sets the handle of file containing the URL to be parsed |
|
1053 // (other items were commented in a header). |
|
1054 // ----------------------------------------------------------------------------- |
|
1055 // |
|
1056 TInt CCUTLandmarkURL::SetInputFileHandleL( CStifItemParser& aItem ) |
|
1057 { |
|
1058 TInt result = KErrNone; |
|
1059 _LIT(KTestMode, "TESTMODE= " ); |
|
1060 if(BaflUtils::FileExists(iFileSession, KInputFileHandle)) |
|
1061 { |
|
1062 BaflUtils::DeleteFile(iFileSession, KInputFileHandle); |
|
1063 } |
|
1064 TInt caseno = 0; |
|
1065 aItem.GetNextInt(caseno); |
|
1066 |
|
1067 TPtrC inputURL; |
|
1068 aItem.GetNextString(inputURL); |
|
1069 |
|
1070 TInt testmode = 0; |
|
1071 aItem.GetInt(KTestMode, testmode); |
|
1072 |
|
1073 |
|
1074 HBufC *url = HBufC::NewLC(inputURL.Size()); |
|
1075 *url = inputURL; |
|
1076 |
|
1077 HBufC8 *urlfile = HBufC8::NewLC(inputURL.Size()); |
|
1078 urlfile->Des().Copy(*url); |
|
1079 |
|
1080 User::LeaveIfError(iFile.Create(iFileSession,KInputFileHandle, EFileWrite)); |
|
1081 switch(caseno) |
|
1082 { |
|
1083 default: |
|
1084 //fall through |
|
1085 case 0: |
|
1086 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?"))); |
|
1087 break; |
|
1088 |
|
1089 case NOPROTOCOL: |
|
1090 User::LeaveIfError(iFile.Write(0, _L8("maps.ovi.com/?"))); |
|
1091 break; |
|
1092 |
|
1093 case HTTPS: |
|
1094 User::LeaveIfError(iFile.Write(0, _L8("https://maps.ovi.com/?"))); |
|
1095 break; |
|
1096 |
|
1097 case INVALIDPROTOCOL: |
|
1098 User::LeaveIfError(iFile.Write(0, _L8("ftp://maps.ovi.com/?"))); |
|
1099 break; |
|
1100 |
|
1101 case NOHOSTNAME: |
|
1102 User::LeaveIfError(iFile.Write(0, _L8("/?"))); |
|
1103 break; |
|
1104 |
|
1105 case INVALIDHOSTNAME: |
|
1106 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.google.com/?"))); |
|
1107 break; |
|
1108 |
|
1109 case INVALIDHOSTNAME1: |
|
1110 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com?/"))); |
|
1111 break; |
|
1112 |
|
1113 case INVALIDHOSTNAME2: |
|
1114 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/"))); |
|
1115 break; |
|
1116 |
|
1117 case DESC_BV1: |
|
1118 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906789012345678901234567890123456789012345678901234567890"))); |
|
1119 break; |
|
1120 |
|
1121 case DESC_BV2: |
|
1122 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890678901234567890123456789012345678901234567890123456789"))); |
|
1123 break; |
|
1124 |
|
1125 case DESC_BV3: |
|
1126 User::LeaveIfError(iFile.Write(0, _L8("http://www.maps.ovi.com/?lo=-179.99999&la=-89.99999&d=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789067890123456789012345678901234567890123456789012345678901"))); |
|
1127 break; |
|
1128 |
|
1129 } |
|
1130 |
|
1131 User::LeaveIfError(iFile.Write(25, *urlfile)); |
|
1132 |
|
1133 CleanupStack::PopAndDestroy(urlfile); |
|
1134 CleanupStack::PopAndDestroy(url); |
|
1135 |
|
1136 //Closing the file and opening in ReadMode |
|
1137 TInt expectedResult = KErrNone; |
|
1138 if(testmode == KRead) |
|
1139 { |
|
1140 iFile.Close(); |
|
1141 User::LeaveIfError(iFile.Open(iFileSession, KInputFileHandle, EFileRead)); |
|
1142 expectedResult = KErrNone; |
|
1143 } |
|
1144 if(testmode == KReadWrite) |
|
1145 expectedResult = KErrAccessDenied; |
|
1146 |
|
1147 |
|
1148 TRAP(result,iPosLandmarkParser->SetInputFileHandleL(iFile)); |
|
1149 { |
|
1150 if(result != expectedResult) |
|
1151 { |
|
1152 iLog->Log(_L("FAILED: Setting Input File Handle Fails with error, %d"), result); |
|
1153 result = KErrGeneral; |
|
1154 } |
|
1155 else |
|
1156 iLog->Log(_L("PASSED: Setting Input File Handle passes")); |
|
1157 } |
|
1158 return result; |
|
1159 } |
|
1160 |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // CCUTLandmarkURL::ParseContent |
|
1163 // This function calls the parser method to parse the URL set either in buffer or file |
|
1164 // (other items were commented in a header). |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // |
|
1167 TInt CCUTLandmarkURL::ParseContent( CStifItemParser& aItem ) |
|
1168 { |
|
1169 TInt result = KErrNone; |
|
1170 TInt caseno = 0; |
|
1171 aItem.GetNextInt(caseno); |
|
1172 TReal32 progress; |
|
1173 TRequestStatus status; |
|
1174 |
|
1175 switch(caseno) |
|
1176 { |
|
1177 default: |
|
1178 //fall through |
|
1179 case 0: |
|
1180 TRAP(result, iOperation = iPosLandmarkParser->ParseContentL(EFalse)); |
|
1181 TRAPD(error, iOperation->NextStep(status, progress)); |
|
1182 User::WaitForRequest(status); |
|
1183 if(result != KErrNone || error != KErrNone && status != KPosLmOperationNotComplete) |
|
1184 { |
|
1185 iLog->Log(_L("FAILED: ParseContent Fails with Error: %d and %d"), result, error); |
|
1186 result = KErrGeneral; |
|
1187 } |
|
1188 else |
|
1189 iLog->Log(_L("PASSED: ParseContent passes")); |
|
1190 break; |
|
1191 |
|
1192 case UNKNOWNFORMAT: |
|
1193 TRAP(result, iOperation = iPosLandmarkParser->ParseContentL(EFalse)); |
|
1194 TRAP(result, iOperation->ExecuteL()); |
|
1195 if(result != KErrPosLmUnknownFormat && status == KErrNone) |
|
1196 { |
|
1197 iLog->Log(_L("FAILED:Parse Content fails for unknown format with error, %d"), result); |
|
1198 result = KErrGeneral; |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 iLog->Log(_L("PASSED: Parse Content passes for unknown format")); |
|
1203 result = KErrNone; |
|
1204 } |
|
1205 break; |
|
1206 |
|
1207 case PANIC_CODE_VERIIFCATION: |
|
1208 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosLmProtocolBreak ); |
|
1209 TRAP(result, iPosLandmarkParser->ParseContentL(EFalse)); |
|
1210 break; |
|
1211 } |
|
1212 return result; |
|
1213 } |
|
1214 |
|
1215 // ----------------------------------------------------------------------------- |
|
1216 // CCUTLandmarkURL::NumOfParsedLandmarks |
|
1217 // This function gives the number of parsed landmarks |
|
1218 // (other items were commented in a header). |
|
1219 // ----------------------------------------------------------------------------- |
|
1220 // |
|
1221 TInt CCUTLandmarkURL::NumOfParsedLandmarksL( CStifItemParser& aItem ) |
|
1222 { |
|
1223 TInt result = KErrNone; |
|
1224 TInt value = 0; |
|
1225 User::LeaveIfError(aItem.GetNextInt(value)); |
|
1226 |
|
1227 if(iPosLandmarkParser->NumOfParsedLandmarks() != value) |
|
1228 { |
|
1229 iLog->Log(_L("FAILED: Number of parsed Landmark does not matches")); |
|
1230 result = KErrGeneral; |
|
1231 } |
|
1232 |
|
1233 else |
|
1234 iLog->Log(_L("PASSED: NumOfParsedLandmarks returns the correct value")); |
|
1235 |
|
1236 return result; |
|
1237 } |
|
1238 |
|
1239 // ----------------------------------------------------------------------------- |
|
1240 // CCUTLandmarkURL::Landmark |
|
1241 // This function returns the landmark that is parsed from the URL |
|
1242 // (other items were commented in a header). |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // |
|
1245 TInt CCUTLandmarkURL::LandmarkL( CStifItemParser& aItem ) |
|
1246 { |
|
1247 TInt result = KErrNone; |
|
1248 TInt caseno = 0; |
|
1249 |
|
1250 aItem.GetNextInt(caseno); |
|
1251 |
|
1252 CPosLandmark* landmark = NULL; |
|
1253 |
|
1254 switch(caseno) |
|
1255 { |
|
1256 default: |
|
1257 //fall through |
|
1258 case 0: |
|
1259 landmark = iPosLandmarkParser->LandmarkLC(); |
|
1260 TRAP(result, VerifyParsingL(aItem, landmark)); |
|
1261 if(result != KErrNone) |
|
1262 { |
|
1263 iLog->Log(_L("FAILED: Verification of Parsing Failed with error %d"), result); |
|
1264 result = KErrGeneral; |
|
1265 } |
|
1266 else |
|
1267 iLog->Log(_L("PASSED: Verification of parsing passed")); |
|
1268 |
|
1269 |
|
1270 iDatabase = CPosLandmarkDatabase::OpenL(); |
|
1271 if (iDatabase->IsInitializingNeeded()) |
|
1272 { |
|
1273 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
1274 } |
|
1275 iPosLandmark = CPosLandmark::NewL(*landmark); |
|
1276 CleanupStack::PopAndDestroy(landmark); |
|
1277 |
|
1278 break; |
|
1279 |
|
1280 case NOLANDMARK: |
|
1281 TRAP(result, landmark = iPosLandmarkParser->LandmarkLC(); CleanupStack::PopAndDestroy(landmark)); |
|
1282 if(result != KErrNotFound) |
|
1283 { |
|
1284 iLog->Log(_L("FAILED:LandmarkLC fails for no landmark parsed, %d"), result); |
|
1285 result = KErrGeneral; |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 iLog->Log(_L("PASSED: LandmarkLC passes no landmark parsed")); |
|
1290 result = KErrNone; |
|
1291 } |
|
1292 break; |
|
1293 |
|
1294 case PANIC_CODE_VERIIFCATION: |
|
1295 TestModuleIf().SetExitReason( CTestModuleIf::EPanic, EPosInvalidIndex ); |
|
1296 TRAP(result, iPosLandmarkParser->LandmarkLC(4); CleanupStack::PopAndDestroy(landmark)); |
|
1297 break; |
|
1298 } |
|
1299 |
|
1300 return result; |
|
1301 } |
|
1302 |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // CCUTLandmarkURL::LandmarkCategory |
|
1305 // This function returns the category of the landmark that was most recently parsed |
|
1306 // (other items were commented in a header). |
|
1307 // ----------------------------------------------------------------------------- |
|
1308 // |
|
1309 TInt CCUTLandmarkURL::LandmarkCategoryL( CStifItemParser& aItem ) |
|
1310 { |
|
1311 TInt result = KErrGeneral; |
|
1312 TInt caseno = 0; |
|
1313 |
|
1314 aItem.GetNextInt(caseno); |
|
1315 |
|
1316 GetStringAfterTag(aItem, KCategory,iMatchCategory); |
|
1317 GetStringAfterTag(aItem, K2ndCategory,iMatchCategory2); |
|
1318 |
|
1319 RArray<TPosLmItemId> array; |
|
1320 CPosLandmark* landmark = NULL; |
|
1321 landmark = iPosLandmarkParser->LandmarkLC(); |
|
1322 TRAP(result, landmark->GetCategoriesL(array)); |
|
1323 switch(caseno) |
|
1324 { |
|
1325 default: |
|
1326 //fall through |
|
1327 case 0: |
|
1328 for (TInt i=0;i<array.Count();i++) |
|
1329 { |
|
1330 TBuf<150> buf; |
|
1331 CPosLandmarkCategory* category = iPosLandmarkParser->LandmarkCategoryLC(array[i]); |
|
1332 |
|
1333 if (category->GlobalCategory()) buf.Append(_L("Global category: ")); |
|
1334 else buf.Append(_L("Local category: ")); |
|
1335 TPtrC catName; |
|
1336 User::LeaveIfError(category->GetCategoryName(catName)); |
|
1337 result = (catName.Compare(iMatchCategory)); |
|
1338 if (result == KErrNone) |
|
1339 goto CONTINUE; |
|
1340 result = (catName.Compare(iMatchCategory2)); |
|
1341 if (result == KErrNone) |
|
1342 goto CONTINUE; |
|
1343 result = (catName.Compare(KMAXCAT)); |
|
1344 if (result == KErrNone) |
|
1345 goto CONTINUE; |
|
1346 result = (catName.Compare(KMAXCAT1)); |
|
1347 if (result == KErrNone) |
|
1348 goto CONTINUE; |
|
1349 result = (catName.Compare(KMAXCAT2)); |
|
1350 if (result == KErrNone) |
|
1351 goto CONTINUE; |
|
1352 CONTINUE: |
|
1353 { |
|
1354 buf.Append(catName); |
|
1355 iLog->Log(buf); |
|
1356 CleanupStack::PopAndDestroy(category); |
|
1357 if (result != KErrNone) |
|
1358 break; |
|
1359 } |
|
1360 } |
|
1361 break; |
|
1362 |
|
1363 case NULLCAT: |
|
1364 if(array.Count()== 0) |
|
1365 result = KErrNone; |
|
1366 |
|
1367 } |
|
1368 if(result == KErrNone) |
|
1369 iLog->Log(_L("PASSED: LandmarkLC Passed!!")); |
|
1370 else |
|
1371 iLog->Log(_L("FAILED: LandmarkLC fails!!")); |
|
1372 CleanupStack::PopAndDestroy(landmark); |
|
1373 return result; |
|
1374 } |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // CCUTLandmarkURL::Misc |
|
1377 // This method verifies the encoded url as follows: |
|
1378 // 1. Complies with the URL grammer |
|
1379 // 2. Compares the parameters are same as they were set |
|
1380 // (other items were commented in a header). |
|
1381 // ----------------------------------------------------------------------------- |
|
1382 // |
|
1383 void CCUTLandmarkURL::MiscL( CStifItemParser& /*aItem*/) |
|
1384 { |
|
1385 TInt result = KErrNone; |
|
1386 TPosLmCollectionDataId collectionDataId; |
|
1387 |
|
1388 //Testing CPosLandmarkParser::CollectionData() |
|
1389 if( iPosLandmarkParser->CollectionData(EPosLmCollDataNone)!= KNullDesC) |
|
1390 { |
|
1391 iLog->Log(_L("FAILED: CollectionData fails")); |
|
1392 User::Leave(KErrGeneral); |
|
1393 } |
|
1394 else |
|
1395 iLog->Log(_L("PASSED: Collection Data passed")); |
|
1396 |
|
1397 //Testing CPosLandmarkParser::FirstCollectionDataId() |
|
1398 collectionDataId= iPosLandmarkParser->FirstCollectionDataId(); |
|
1399 if(collectionDataId != EPosLmCollDataNone) |
|
1400 { |
|
1401 iLog->Log(_L("FAILED: FirstCollectionDataId fails")); |
|
1402 User::Leave(KErrGeneral); |
|
1403 } |
|
1404 else |
|
1405 iLog->Log(_L("PASSED: FirstCollectionDataId Data passed")); |
|
1406 |
|
1407 //Testing CPosLandmarkParser::NextCollectionDataId() |
|
1408 collectionDataId = iPosLandmarkParser->NextCollectionDataId(EPosLmCollDataNone); |
|
1409 if(collectionDataId != EPosLmCollDataNone) |
|
1410 { |
|
1411 iLog->Log(_L("FAILED: NextCollectionDataId fails")); |
|
1412 User::Leave(KErrGeneral); |
|
1413 } |
|
1414 else |
|
1415 iLog->Log(_L("PASSED: NextCollectionDataId Data passed")); |
|
1416 TBuf<16> collectionData; |
|
1417 TRAP(result,iPosLandmarkEncoder->AddCollectionDataL(EPosLmCollDataNone,collectionData)); |
|
1418 User::Leave(result); |
|
1419 } |
|
1420 // ----------------------------------------------------------------------------- |
|
1421 // CCUTLandmarkURL::VerifyEncoding |
|
1422 // This method verifies the encoded url as follows: |
|
1423 // 1. Complies with the URL grammer |
|
1424 // 2. Compares the parameters are same as they were set |
|
1425 // (other items were commented in a header). |
|
1426 // ----------------------------------------------------------------------------- |
|
1427 // |
|
1428 TInt CCUTLandmarkURL::VerifyEncodingL( CStifItemParser& aItem) |
|
1429 { |
|
1430 TInt result = KErrNone; |
|
1431 TInt caseno = 0; |
|
1432 TInt NumberofParams = 0; |
|
1433 aItem.GetNextInt(caseno); |
|
1434 aItem.GetNextInt(NumberofParams); |
|
1435 |
|
1436 HBufC8* aDes = NULL; |
|
1437 HBufC8 *BufferedURL = HBufC8::NewLC(KMaxTestBuf); |
|
1438 TInt size = 0; |
|
1439 |
|
1440 switch(caseno) |
|
1441 { |
|
1442 default: |
|
1443 case BUFFER_OUTPUT: |
|
1444 TRAP(result, aDes = HBufC8::NewL(iEncoderBuffer->Size())); |
|
1445 CleanupStack::PushL(aDes); |
|
1446 TPtr8 ptr = aDes->Des(); |
|
1447 iEncoderBuffer->Read(0, ptr, iEncoderBuffer->Size()); |
|
1448 result = ParseURL(_L8("?"),ptr ,aItem); |
|
1449 iEncoderBuffer->Reset(); |
|
1450 CleanupStack::PopAndDestroy(aDes); |
|
1451 break; |
|
1452 |
|
1453 case FILE_OUTPUT: |
|
1454 User::LeaveIfError(iFile.Open(iFileSession, KOutputFilePath,EFileRead)); |
|
1455 TPtr8 fileptr = BufferedURL->Des(); |
|
1456 User::LeaveIfError(iFile.Read(fileptr)); |
|
1457 result = ParseURL(_L8("?"),fileptr,aItem); |
|
1458 break; |
|
1459 |
|
1460 case NO_ENCODING_FILE: |
|
1461 User::LeaveIfError(iFile.Open(iFileSession, KOutputFilePath,EFileRead)); |
|
1462 User::LeaveIfError(iFile.Size(size)); |
|
1463 iLog->Log(_L("Size of the file is %d"), size); |
|
1464 if (size != -1) |
|
1465 User::Leave(KErrGeneral); |
|
1466 else |
|
1467 User::Leave(KErrNone); |
|
1468 break; |
|
1469 |
|
1470 case NO_ENCODING_BUFFER: |
|
1471 size = iEncoderBuffer->Size(); |
|
1472 if (size != -1) |
|
1473 User::Leave(KErrGeneral); |
|
1474 else |
|
1475 User::Leave(KErrNone); |
|
1476 break; |
|
1477 } |
|
1478 iLog->Log(_L("PASSED: All the location params values matches!!")); |
|
1479 if(iCount != (NumberofParams)) |
|
1480 { |
|
1481 result = KErrGeneral; |
|
1482 iLog->Log(_L("FAILED: number of location params encoded does not match with the cfg file!!")); |
|
1483 } |
|
1484 CleanupStack::PopAndDestroy(BufferedURL); |
|
1485 return result; |
|
1486 } |
|
1487 // ----------------------------------------------------------------------------- |
|
1488 // CCUTLandmarkURL::ParseURL |
|
1489 // This method parses the URL obtained after encoding the landmark |
|
1490 // (other items were commented in a header). |
|
1491 // ----------------------------------------------------------------------------- |
|
1492 // |
|
1493 TInt CCUTLandmarkURL::ParseURL(const TDesC8 & aDelimiter, TPtr8 aBufferedURL, CStifItemParser& aItem) |
|
1494 { |
|
1495 TInt result = KErrNone; |
|
1496 TInt ParamStart = 0; |
|
1497 TInt column = 0; |
|
1498 TPtrC parsedURL; |
|
1499 HBufC * bufferedURL = HBufC::NewLC(KMaxTestBuf); |
|
1500 HBufC * remainingURL = HBufC::NewLC(KMaxTestBuf); |
|
1501 ParamStart = aBufferedURL.Find(aDelimiter); |
|
1502 if(ParamStart != -1) |
|
1503 { |
|
1504 remainingURL->Des().Copy(aBufferedURL.Mid((ParamStart+1),aBufferedURL.Length() -(ParamStart+1) )); |
|
1505 bufferedURL->Des().Copy(remainingURL->Des()); |
|
1506 while(result != KErrNotFound) |
|
1507 { |
|
1508 result = TextUtils::ColumnText(parsedURL, column, bufferedURL, KColumnSeperator); |
|
1509 HBufC8 *parsedURL8 = HBufC8::NewLC(parsedURL.Length()); |
|
1510 parsedURL8->Des().Copy(parsedURL); |
|
1511 ParseValueL(parsedURL8->Des(), aItem); |
|
1512 column++; |
|
1513 CleanupStack::PopAndDestroy(parsedURL8); |
|
1514 } |
|
1515 } |
|
1516 CleanupStack::PopAndDestroy(2); |
|
1517 return KErrNone; |
|
1518 } |
|
1519 |
|
1520 // ----------------------------------------------------------------------------- |
|
1521 // CCUTLandmarkURL::ParseValue |
|
1522 // This method obtains the value of the location parameters in the URL |
|
1523 // (other items were commented in a header). |
|
1524 // ----------------------------------------------------------------------------- |
|
1525 // |
|
1526 |
|
1527 TInt CCUTLandmarkURL::ParseValueL(TPtr8 aBufferedURL, CStifItemParser& aItem) |
|
1528 { |
|
1529 TInt result = KErrNone; |
|
1530 TInt paramStart = 0; |
|
1531 paramStart = aBufferedURL.Find(_L8("=")); |
|
1532 TBuf8<KMaxTagName> tagName; |
|
1533 HBufC8* temp = HBufC8::NewLC(KMaxTestBuf); |
|
1534 TPtr8 temp8 = temp->Des(); |
|
1535 if(paramStart != -1) |
|
1536 { |
|
1537 tagName .Copy(aBufferedURL.Mid(0,paramStart )) ; |
|
1538 temp8.Copy(aBufferedURL .Mid((paramStart+1),aBufferedURL .Length() -(paramStart+1) )); |
|
1539 temp8.TrimAll(); |
|
1540 TPtrC8 Value(temp8); |
|
1541 result = CompareParamValueL(tagName, Value, aItem); |
|
1542 } |
|
1543 CleanupStack::PopAndDestroy(temp); |
|
1544 return result; |
|
1545 } |
|
1546 |
|
1547 // ----------------------------------------------------------------------------- |
|
1548 // CCUTLandmarkURL::CompareParamValue |
|
1549 // This method compares the values of the parameters in the URL and in the cfg file |
|
1550 // (other items were commented in a header). |
|
1551 // ----------------------------------------------------------------------------- |
|
1552 // |
|
1553 TInt CCUTLandmarkURL::CompareParamValueL(TBuf8<KMaxTagName> aTagName , TPtrC8 aValue, CStifItemParser& aItem) |
|
1554 { |
|
1555 TInt result = KErrGeneral; |
|
1556 TInt tagCompare = -1; |
|
1557 |
|
1558 HBufC *value = HBufC::NewLC(aValue.Length()); |
|
1559 value->Des().Copy(aValue); |
|
1560 aTagName.TrimAll(); |
|
1561 |
|
1562 //Reading location values from the cfg files |
|
1563 GetStringAfterTag(aItem, KName, iName); |
|
1564 GetStringAfterTag(aItem, KLandmarkDescription, iDescription); |
|
1565 aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); |
|
1566 aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); |
|
1567 aItem.GetNextString(KLatitude,iLatitude); |
|
1568 aItem.GetNextString(KLongitude,iLongitude); |
|
1569 aItem.GetNextString(KAltitude,iAltitude); |
|
1570 |
|
1571 |
|
1572 //Reading postion fields from cfg fields |
|
1573 aItem.GetNextString(KSpeed,iSpeed); |
|
1574 aItem.GetNextString(KHeading,iHeading); |
|
1575 GetStringAfterTag(aItem, KCountry,iCountry); |
|
1576 GetStringAfterTag(aItem, KState,iState); |
|
1577 GetStringAfterTag(aItem, KCity,iCity); |
|
1578 GetStringAfterTag(aItem, KStreet ,iStreet); |
|
1579 GetStringAfterTag(aItem, KPostalCode,iPostalCode); |
|
1580 GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); |
|
1581 GetStringAfterTag(aItem, KTelephone,iTelephone); |
|
1582 GetStringAfterTag(aItem, KCategory,iMatchCategory); |
|
1583 GetStringAfterTag(aItem, KWeb,iWeb); |
|
1584 GetStringAfterTag(aItem, K2ndCategory,iMatchCategory2); |
|
1585 GetStringAfterTag(aItem, KPID,iPID); |
|
1586 GetStringAfterTag(aItem, KTS,iTS); |
|
1587 |
|
1588 |
|
1589 |
|
1590 tagCompare = aTagName.Compare(_L8("la")); |
|
1591 if(tagCompare == 0) |
|
1592 result = value->Compare(iLatitude); |
|
1593 |
|
1594 tagCompare = aTagName.Compare(_L8("lo")); |
|
1595 if(tagCompare == 0) |
|
1596 result = value->Compare(iLongitude); |
|
1597 |
|
1598 tagCompare = aTagName.Compare(_L8("n")); |
|
1599 if(tagCompare == 0) |
|
1600 result = value->Compare(iName); |
|
1601 |
|
1602 tagCompare = aTagName.Compare(_L8("s")); |
|
1603 if(tagCompare == 0) |
|
1604 result = value->Compare(iStreet); |
|
1605 |
|
1606 tagCompare = aTagName.Compare(_L8("sn")); |
|
1607 if(tagCompare == 0) |
|
1608 result = value->Compare(iHouseNumber); |
|
1609 |
|
1610 tagCompare = aTagName.Compare(_L8("pz")); |
|
1611 if(tagCompare == 0) |
|
1612 result = value->Compare(iPostalCode); |
|
1613 |
|
1614 tagCompare = aTagName.Compare(_L8("c")); |
|
1615 if(tagCompare == 0) |
|
1616 result = value->Compare(iCity); |
|
1617 |
|
1618 tagCompare = aTagName.Compare(_L8("sp")); |
|
1619 if(tagCompare == 0) |
|
1620 result = value->Compare(iState); |
|
1621 |
|
1622 tagCompare = aTagName.Compare(_L8("cr")); |
|
1623 if(tagCompare == 0) |
|
1624 result = value->Compare(iCountry); |
|
1625 |
|
1626 tagCompare = aTagName.Compare(_L8("t")); |
|
1627 if(tagCompare == 0) |
|
1628 result = value->Compare(iTelephone); |
|
1629 |
|
1630 tagCompare = aTagName.Compare(_L8("w")); |
|
1631 if(tagCompare == 0) |
|
1632 result = value->Compare(iWeb); |
|
1633 |
|
1634 tagCompare = aTagName.Compare(_L8("cat")); |
|
1635 if(tagCompare == 0) |
|
1636 result = value->Compare(iMatchCategory); |
|
1637 if (result != KErrNone) |
|
1638 result = value->Compare(iMatchCategory2); |
|
1639 |
|
1640 tagCompare = aTagName.Compare(_L8("d")); |
|
1641 if(tagCompare == 0) |
|
1642 result = value->Compare(iDescription); |
|
1643 |
|
1644 tagCompare = aTagName.Compare(_L8("pa")); |
|
1645 if(tagCompare == 0) |
|
1646 result = value->Compare(iHorizontalAccuracy); |
|
1647 |
|
1648 tagCompare = aTagName.Compare(_L8("a")); |
|
1649 if(tagCompare == 0) |
|
1650 result = value->Compare(iAltitude); |
|
1651 |
|
1652 tagCompare = aTagName.Compare(_L8("aa")); |
|
1653 if(tagCompare == 0) |
|
1654 result = value->Compare(iVerticalAccuracy); |
|
1655 |
|
1656 tagCompare = aTagName.Compare(_L8("v")); |
|
1657 if(tagCompare == 0) |
|
1658 result = value->Compare(iSpeed); |
|
1659 |
|
1660 tagCompare = aTagName.Compare(_L8("h")); |
|
1661 if(tagCompare == 0) |
|
1662 result = value->Compare(iHeading); |
|
1663 |
|
1664 tagCompare = aTagName.Compare(_L8("pid")); |
|
1665 if(tagCompare == 0) |
|
1666 result = value->Compare(iPID); |
|
1667 |
|
1668 tagCompare = aTagName.Compare(_L8("ts")); |
|
1669 if(tagCompare == 0) |
|
1670 result = value->Compare(iTS); |
|
1671 |
|
1672 if (result != 0) |
|
1673 { |
|
1674 result = value->Compare(KMAXSTRING); |
|
1675 } |
|
1676 if (result != 0) |
|
1677 { |
|
1678 result = value->Compare(KMAXSTRING1); |
|
1679 } |
|
1680 if (result != 0) |
|
1681 { |
|
1682 result = value->Compare(KMAXSTRING2); |
|
1683 } |
|
1684 if (result != 0) |
|
1685 { |
|
1686 result = value->Compare(KMAXDESSTRING); |
|
1687 } |
|
1688 if (result != 0) |
|
1689 { |
|
1690 result = value->Compare(KMAXDESSTRING1); |
|
1691 } |
|
1692 if (result != 0) |
|
1693 { |
|
1694 result = value->Compare(KMAXDESSTRING2); |
|
1695 } |
|
1696 |
|
1697 |
|
1698 iCount++; |
|
1699 if(result != KErrNone) |
|
1700 { |
|
1701 iLog->Log(_L("FAILED: Params Values in the URL and cfg file does not match, Param: %S"),&aTagName); |
|
1702 User::Leave(KErrGeneral); |
|
1703 } |
|
1704 CleanupStack::PopAndDestroy(value); |
|
1705 return KErrNone; |
|
1706 } |
|
1707 |
|
1708 // ----------------------------------------------------------------------------- |
|
1709 // CCUTLandmarkURL::CompareParamValue |
|
1710 // This method compares the values of the parameters in the URL and in the cfg file |
|
1711 // (other items were commented in a header). |
|
1712 // ----------------------------------------------------------------------------- |
|
1713 // |
|
1714 TInt CCUTLandmarkURL::GetStringTillQuote(CStifItemParser& aItem, TName& aName) |
|
1715 { |
|
1716 TPtrC temp; |
|
1717 |
|
1718 |
|
1719 //Assuming that a " has already been seen. |
|
1720 if(aItem.GetNextString(temp) != KErrNone) |
|
1721 { |
|
1722 return KErrArgument; |
|
1723 } |
|
1724 |
|
1725 //The name should have atleast one word. |
|
1726 if(temp == _L("\"")) |
|
1727 { |
|
1728 return KErrArgument; |
|
1729 } |
|
1730 |
|
1731 |
|
1732 //Append the first word. |
|
1733 aName.Append(temp); |
|
1734 |
|
1735 if(aItem.GetNextString(temp) != KErrNone) |
|
1736 { |
|
1737 return KErrArgument; |
|
1738 } |
|
1739 |
|
1740 |
|
1741 while(temp!=_L("\"")) |
|
1742 { |
|
1743 //Append a space at the beginning |
|
1744 aName.Append(_L(" ")); |
|
1745 aName.Append(temp); |
|
1746 |
|
1747 //Keep on appending the next words. |
|
1748 if(aItem.GetNextString(temp) != KErrNone) |
|
1749 { |
|
1750 return KErrArgument; |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 return KErrNone; |
|
1755 } |
|
1756 |
|
1757 |
|
1758 // ----------------------------------------------------------------------------- |
|
1759 // CCUTLandmarkURL::CompareParamValue |
|
1760 // This method compares the values of the parameters in the URL and in the cfg file |
|
1761 // (other items were commented in a header). |
|
1762 // ----------------------------------------------------------------------------- |
|
1763 // |
|
1764 |
|
1765 TInt CCUTLandmarkURL::GetStringAfterTag(CStifItemParser& aItem, const TDesC& aTag, TName& aString) |
|
1766 { |
|
1767 TPtrC temp; |
|
1768 aString.Delete(0,aString.Length()); |
|
1769 |
|
1770 if(aItem.GetString(aTag, temp) != KErrNone) |
|
1771 { |
|
1772 return KErrArgument; |
|
1773 } |
|
1774 |
|
1775 //Now temp should contain a " |
|
1776 if(temp != _L("\"")) |
|
1777 { |
|
1778 return KErrArgument; |
|
1779 } |
|
1780 |
|
1781 //Get the Country name till a " is found. |
|
1782 if(GetStringTillQuote(aItem, aString) != KErrNone) |
|
1783 { |
|
1784 return KErrArgument; |
|
1785 } |
|
1786 |
|
1787 return KErrNone; |
|
1788 } |
|
1789 // ----------------------------------------------------------------------------- |
|
1790 // CCUTLandmarkURL::VerifyParsing |
|
1791 // This method verifies the parsed url as follows: |
|
1792 // 1. Compares with the URL grammer |
|
1793 // 2. Compares the parameters are set properly in the landmark object |
|
1794 // (other items were commented in a header). |
|
1795 // ----------------------------------------------------------------------------- |
|
1796 // |
|
1797 void CCUTLandmarkURL::VerifyParsingL( CStifItemParser& aItem,CPosLandmark* aPosLandmark ) |
|
1798 { |
|
1799 TInt result = KErrGeneral; |
|
1800 |
|
1801 //Reading location values from the cfg files |
|
1802 GetStringAfterTag(aItem, KName, iName); |
|
1803 GetStringAfterTag(aItem, KLandmarkDescription, iDescription); |
|
1804 aItem.GetNextString(KVerticalAccuracy,iVerticalAccuracy); |
|
1805 aItem.GetNextString(KHorizontalAccuracy,iHorizontalAccuracy); |
|
1806 aItem.GetNextString(KLatitude,iLatitude); |
|
1807 aItem.GetNextString(KLongitude,iLongitude); |
|
1808 aItem.GetNextString(KAltitude,iAltitude); |
|
1809 |
|
1810 |
|
1811 //Reading postion fields from cfg fields |
|
1812 aItem.GetNextString(KSpeed,iSpeed); |
|
1813 aItem.GetNextString(KHeading,iHeading); |
|
1814 |
|
1815 GetStringAfterTag(aItem, KCountry,iCountry); |
|
1816 GetStringAfterTag(aItem, KState,iState); |
|
1817 GetStringAfterTag(aItem, KCity,iCity); |
|
1818 GetStringAfterTag(aItem, KStreet ,iStreet); |
|
1819 GetStringAfterTag(aItem, KPostalCode,iPostalCode); |
|
1820 GetStringAfterTag(aItem, KHouseNumber,iHouseNumber); |
|
1821 GetStringAfterTag(aItem, KTelephone,iTelephone); |
|
1822 GetStringAfterTag(aItem, KWeb,iWeb); |
|
1823 GetStringAfterTag(aItem, KPID,iPID); |
|
1824 GetStringAfterTag(aItem, KTS,iTS); |
|
1825 |
|
1826 |
|
1827 |
|
1828 //Converting string to TReal |
|
1829 TRealX floatX; |
|
1830 floatX.SetNaN(); |
|
1831 |
|
1832 TReal32 VA = 0; |
|
1833 if(iVerticalAccuracy != _L("")) |
|
1834 { |
|
1835 TLex16 VerticalAcc(iVerticalAccuracy); |
|
1836 VerticalAcc.Val(VA); |
|
1837 } |
|
1838 else |
|
1839 VA = floatX; |
|
1840 |
|
1841 TReal32 HA= 0; |
|
1842 if(iHorizontalAccuracy != _L("")) |
|
1843 { |
|
1844 TLex16 HorizontalAcc(iHorizontalAccuracy); |
|
1845 HorizontalAcc.Val(HA); |
|
1846 } |
|
1847 else |
|
1848 HA = floatX; |
|
1849 |
|
1850 TReal64 RLat = 0; |
|
1851 TLex16 Lat(iLatitude); |
|
1852 Lat.Val(RLat); |
|
1853 |
|
1854 TReal64 RLong = 0; |
|
1855 TLex16 Long(iLongitude); |
|
1856 Long.Val(RLong); |
|
1857 |
|
1858 TReal64 RAlt = 0; |
|
1859 if(iAltitude != _L("")) |
|
1860 { |
|
1861 TLex16 Alt(iAltitude); |
|
1862 Alt.Val(RAlt); |
|
1863 } |
|
1864 else |
|
1865 RAlt = floatX; |
|
1866 |
|
1867 |
|
1868 TPtrC landmarkDescription; |
|
1869 aPosLandmark->GetLandmarkDescription(landmarkDescription); |
|
1870 result = landmarkDescription.Compare(iDescription); |
|
1871 if(result != KErrNone) |
|
1872 result = landmarkDescription.Compare(KMAXDESSTRING); |
|
1873 if(result != KErrNone) |
|
1874 result = landmarkDescription.Compare(KMAXDESSTRING1); |
|
1875 if(result != KErrNone) |
|
1876 result = landmarkDescription.Compare(KMAXDESSTRING2); |
|
1877 |
|
1878 TPtrC name; |
|
1879 aPosLandmark->GetLandmarkName(name); |
|
1880 result = name.Compare(iName); |
|
1881 if(result != KErrNone) |
|
1882 result = name.Compare(KMAXSTRING); |
|
1883 if(result != KErrNone) |
|
1884 result = name.Compare(KMAXSTRING1); |
|
1885 if(result != KErrNone) |
|
1886 result = name.Compare(KMAXSTRING2); |
|
1887 |
|
1888 TPtrC pid; |
|
1889 aPosLandmark->GetPlaceId(pid); |
|
1890 result = pid.Compare(iPID); |
|
1891 if(result != KErrNone) |
|
1892 result = pid.Compare(KMAXSTRING); |
|
1893 if(result != KErrNone) |
|
1894 result = pid.Compare(KMAXSTRING1); |
|
1895 if(result != KErrNone) |
|
1896 result = pid.Compare(KMAXSTRING2); |
|
1897 |
|
1898 TLocality position; |
|
1899 TReal64 latitude, longitude = 0; |
|
1900 TReal32 altitude, pa, aa = 0; |
|
1901 aPosLandmark->GetPosition(position); |
|
1902 latitude = position.Latitude(); |
|
1903 if(latitude != RLat) |
|
1904 User::Leave(KErrGeneral); |
|
1905 longitude = position.Longitude(); |
|
1906 if(longitude != RLong) |
|
1907 User::Leave(KErrGeneral); |
|
1908 altitude = position.Altitude(); |
|
1909 if(Math::IsNaN(altitude)!= Math::IsNaN(RAlt) ) |
|
1910 { |
|
1911 if(altitude != RAlt) |
|
1912 User::Leave(KErrGeneral); |
|
1913 } |
|
1914 |
|
1915 pa = position.HorizontalAccuracy(); |
|
1916 if(Math::IsNaN(pa)!= Math::IsNaN(HA) ) |
|
1917 { |
|
1918 if(pa != HA) |
|
1919 User::Leave(KErrGeneral); |
|
1920 } |
|
1921 |
|
1922 aa = position.VerticalAccuracy(); |
|
1923 if(Math::IsNaN(aa)!= Math::IsNaN(VA) ) |
|
1924 { |
|
1925 if(aa != VA) |
|
1926 User::Leave(KErrGeneral); |
|
1927 } |
|
1928 |
|
1929 TPtrC speed; |
|
1930 aPosLandmark->GetPositionField(EPositionFieldHorizontalSpeed, speed); |
|
1931 result = speed.Compare(iSpeed); |
|
1932 if(result != KErrNone) |
|
1933 result = speed.Compare(KMAXSTRING); |
|
1934 if(result != KErrNone) |
|
1935 result = speed.Compare(KMAXSTRING1); |
|
1936 if(result != KErrNone) |
|
1937 result = speed.Compare(KMAXSTRING2); |
|
1938 |
|
1939 |
|
1940 |
|
1941 TPtrC heading; |
|
1942 aPosLandmark->GetPositionField(EPositionFieldHeading, heading); |
|
1943 result = heading.Compare(iHeading); |
|
1944 if(result != KErrNone) |
|
1945 result = heading.Compare(KMAXSTRING); |
|
1946 if(result != KErrNone) |
|
1947 result = heading.Compare(KMAXSTRING1); |
|
1948 if(result != KErrNone) |
|
1949 result = heading.Compare(KMAXSTRING2); |
|
1950 |
|
1951 TPtrC country; |
|
1952 aPosLandmark->GetPositionField(EPositionFieldCountry, country); |
|
1953 result = country.Compare(iCountry); |
|
1954 if(result != KErrNone) |
|
1955 result = country.Compare(KMAXSTRING); |
|
1956 if(result != KErrNone) |
|
1957 result = country.Compare(KMAXSTRING1); |
|
1958 if(result != KErrNone) |
|
1959 result = country.Compare(KMAXSTRING2); |
|
1960 |
|
1961 TPtrC state; |
|
1962 aPosLandmark->GetPositionField(EPositionFieldState, state); |
|
1963 result = state.Compare(iState); |
|
1964 if(result != KErrNone) |
|
1965 result = state.Compare(KMAXSTRING); |
|
1966 if(result != KErrNone) |
|
1967 result = state.Compare(KMAXSTRING1); |
|
1968 if(result != KErrNone) |
|
1969 result = state.Compare(KMAXSTRING2); |
|
1970 |
|
1971 TPtrC city; |
|
1972 aPosLandmark->GetPositionField(EPositionFieldCity, city); |
|
1973 result = city.Compare(iCity); |
|
1974 if(result != KErrNone) |
|
1975 result = city.Compare(KMAXSTRING); |
|
1976 if(result != KErrNone) |
|
1977 result = city.Compare(KMAXSTRING1); |
|
1978 if(result != KErrNone) |
|
1979 result = city.Compare(KMAXSTRING2); |
|
1980 |
|
1981 |
|
1982 TPtrC street; |
|
1983 aPosLandmark->GetPositionField(EPositionFieldStreet, street); |
|
1984 result = street.Compare(iStreet); |
|
1985 if(result != KErrNone) |
|
1986 result = street.Compare(KMAXSTRING); |
|
1987 if(result != KErrNone) |
|
1988 result = street.Compare(KMAXSTRING1); |
|
1989 if(result != KErrNone) |
|
1990 result = street.Compare(KMAXSTRING2); |
|
1991 |
|
1992 TPtrC postalCode; |
|
1993 aPosLandmark->GetPositionField(EPositionFieldPostalCode, postalCode); |
|
1994 result = postalCode.Compare(iPostalCode); |
|
1995 if(result != KErrNone) |
|
1996 result = postalCode.Compare(KMAXSTRING); |
|
1997 if(result != KErrNone) |
|
1998 result = postalCode.Compare(KMAXSTRING1); |
|
1999 if(result != KErrNone) |
|
2000 result = postalCode.Compare(KMAXSTRING2); |
|
2001 |
|
2002 TPtrC houseNumber; |
|
2003 aPosLandmark->GetPositionField(EPositionFieldStreetExtension, houseNumber); |
|
2004 result = houseNumber.Compare(iHouseNumber); |
|
2005 if(result != KErrNone) |
|
2006 result = houseNumber.Compare(KMAXSTRING); |
|
2007 if(result != KErrNone) |
|
2008 result = houseNumber.Compare(KMAXSTRING1); |
|
2009 if(result != KErrNone) |
|
2010 result = houseNumber.Compare(KMAXSTRING2); |
|
2011 |
|
2012 TPtrC telephone; |
|
2013 aPosLandmark->GetPositionField(EPositionFieldBuildingTelephone, telephone); |
|
2014 result = telephone.Compare(iTelephone); |
|
2015 if(result != KErrNone) |
|
2016 result = telephone.Compare(KMAXSTRING); |
|
2017 if(result != KErrNone) |
|
2018 result = telephone.Compare(KMAXSTRING1); |
|
2019 if(result != KErrNone) |
|
2020 result = telephone.Compare(KMAXSTRING2); |
|
2021 |
|
2022 TPtrC web; |
|
2023 aPosLandmark->GetPositionField(EPositionFieldMediaLinksStart, web); |
|
2024 result = web.Compare(iWeb); |
|
2025 if(result != KErrNone) |
|
2026 result = web.Compare(KMAXSTRING); |
|
2027 if(result != KErrNone) |
|
2028 result = web.Compare(KMAXSTRING1); |
|
2029 if(result != KErrNone) |
|
2030 result = web.Compare(KMAXSTRING2); |
|
2031 |
|
2032 User::LeaveIfError(result); |
|
2033 |
|
2034 // This part of the code Tests the timestamp |
|
2035 TTime timeStamp; |
|
2036 result = aPosLandmark->GetTimeStamp(timeStamp); |
|
2037 TTime ts; |
|
2038 if(iTS != _L("")) |
|
2039 ts.Set(iTS); |
|
2040 if(result != KErrNotFound && iTS != _L("")) |
|
2041 { |
|
2042 if(timeStamp != ts) |
|
2043 User::Leave(KErrGeneral); |
|
2044 } |
|
2045 } |
|
2046 |
|
2047 |
|
2048 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
2049 // None |
|
2050 |
|
2051 // [End of File] - Do not remove |