15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // ==================== INCLUDE FILES ==================== |
19 // ==================== INCLUDE FILES ==================== |
|
20 #include <mpecallhandling.h> |
|
21 #include <mpedatastore.h> |
|
22 #include <talogger.h> |
20 #include "cpeparsermanufacturerhandler.h" |
23 #include "cpeparsermanufacturerhandler.h" |
21 #include "mpephonemodelinternal.h" |
24 #include "mpephonemodelinternal.h" |
22 #include <mpecallhandling.h> |
|
23 #include <mpedatastore.h> |
|
24 #include <sysutil.h> |
|
25 #include <talogger.h> |
|
26 |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KPESwVersionLineCount = 3; |
|
30 const TInt KPEVersionLineFeed = '\n'; |
|
31 const TInt KPESalesModelNameMaxLength = 20; |
|
32 _LIT( KPESalesModelFileName, "Z:\\resource\\versions\\model.txt"); |
|
33 |
25 |
34 // ================= MEMBER FUNCTIONS ======================= |
26 // ================= MEMBER FUNCTIONS ======================= |
35 |
27 |
36 // C++ default constructor can NOT contain any code, that |
28 // C++ default constructor can NOT contain any code, that |
37 // might leave. |
29 // might leave. |
62 { |
54 { |
63 TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL" ); |
55 TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL" ); |
64 |
56 |
65 switch ( aCommand ) |
57 switch ( aCommand ) |
66 { |
58 { |
67 case EShowVersion: // *#0000# |
|
68 { |
|
69 TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::ProcessCommandL, EShowVersion" ); |
|
70 |
|
71 TPEPhoneIdentityParameters phoneIdentity; |
|
72 phoneIdentity = iModel.DataStore()->PhoneIdentityParameters(); |
|
73 if ( GetSwVersionAndPhoneModelL( phoneIdentity.iRevision ) == KErrNone ) |
|
74 { |
|
75 iModel.DataStore()->SetPhoneIdentityParameters( phoneIdentity ); |
|
76 iModel.SendMessage( MEngineMonitor::EPEMessageShowVersion ); |
|
77 } |
|
78 else |
|
79 { |
|
80 iModel.SendMessage( MEngineMonitor::EPEMessageError ); |
|
81 TEFLOGSTRING( KTAERROR, |
|
82 "PE CPEGSMPARSERMANUFACTURERHANDLER::PROCESSCOMMANDL: FAILED TO RETRIEVE SW VERSION" ); |
|
83 } |
|
84 break; |
|
85 } |
|
86 case EBadPinChange: |
59 case EBadPinChange: |
87 { |
60 { |
88 iModel.SendMessage( MEngineMonitor::EPEMessageBadPin1Change ); |
61 iModel.SendMessage( MEngineMonitor::EPEMessageBadPin1Change ); |
89 break; |
62 break; |
90 } |
63 } |
111 case EActivateRfsDeep: |
84 case EActivateRfsDeep: |
112 { |
85 { |
113 iModel.SendMessage( MEngineMonitor::EPEMessageActivateRfsDeep ); |
86 iModel.SendMessage( MEngineMonitor::EPEMessageActivateRfsDeep ); |
114 break; |
87 break; |
115 } |
88 } |
116 case EActivateWarranty: |
|
117 //lint -fallthrough |
|
118 case ELifeTimer: |
|
119 { |
|
120 iModel.SendMessage( MEngineMonitor::EPEMessageActivateWarrantyMode ); |
|
121 break; |
|
122 } |
|
123 case EShowBtAddress: // *#2820# |
89 case EShowBtAddress: // *#2820# |
124 { |
90 { |
125 iModel.SendMessage( MEngineMonitor::EPEMessageShowBTDeviceAddress ); |
91 iModel.SendMessage( MEngineMonitor::EPEMessageShowBTDeviceAddress ); |
126 break; |
92 break; |
127 } |
93 } |
202 break; |
163 break; |
203 } |
164 } |
204 } |
165 } |
205 } |
166 } |
206 |
167 |
207 // ----------------------------------------------------------------------------- |
|
208 // CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL |
|
209 // Gets sw version from SysUtil::GetSwVersion and loads phone model information |
|
210 // from file. This information is set to aSwVersion. |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL( |
|
214 TDes& aSwVersion ) |
|
215 { |
|
216 TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL" ); |
|
217 |
|
218 TInt errorCode = SysUtil::GetSWVersion( aSwVersion ) ; |
|
219 |
|
220 TEFLOGSTRING2( KTAINT, |
|
221 "PE CPEParserManufacturerHandler::GetSwVersionAndPhoneModelL > SysUtil::GetSWVersion, error code: %d", |
|
222 errorCode ); |
|
223 |
|
224 if ( errorCode == KErrNone ) |
|
225 { |
|
226 // Remove needless lines |
|
227 RemoveLinesAfterThreeLines( aSwVersion ); |
|
228 // Add phone model |
|
229 AppendPhoneModelL( aSwVersion ); |
|
230 } |
|
231 |
|
232 return errorCode; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CPEParserManufacturerHandler::RemoveNeedlessLinesL |
|
237 // Removes lines after 3 end-of-line (\n) chars. |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CPEParserManufacturerHandler::RemoveLinesAfterThreeLines( |
|
241 TDes& aSwVersion ) |
|
242 { |
|
243 TEFLOGSTRING( KTAINT, "PE CPEParserManufacturerHandler::RemoveLinesAfterThreeLines" ); |
|
244 |
|
245 TInt lineFeedCount = 0; |
|
246 |
|
247 const TInt swVersionLength( aSwVersion.Length() ); |
|
248 for( TInt i = 0; i < swVersionLength ; i++ ) |
|
249 { |
|
250 if( aSwVersion[i] == KPEVersionLineFeed ) |
|
251 { |
|
252 lineFeedCount++; |
|
253 if( lineFeedCount == KPESwVersionLineCount ) |
|
254 { |
|
255 const TInt charsToDelete( aSwVersion.Length() - i ); |
|
256 |
|
257 // Dont delete the last line feed characted, thats why |
|
258 // i + 1. |
|
259 aSwVersion.Delete( i + 1, charsToDelete ); |
|
260 return; |
|
261 } |
|
262 } |
|
263 } |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CPEParserManufacturerHandler::AppendPhoneModelL |
|
268 // Reads phone model info from disk and appends it to aSwVersion. |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CPEParserManufacturerHandler::AppendPhoneModelL( |
|
272 TDes& aSwVersion ) |
|
273 { |
|
274 RFile file; |
|
275 User::LeaveIfError( file.Open( iFsSession, |
|
276 KPESalesModelFileName, |
|
277 EFileShareReadersOnly | EFileRead ) ); |
|
278 CleanupClosePushL( file ); |
|
279 |
|
280 HBufC* model = HBufC::NewLC( KPESalesModelNameMaxLength ); |
|
281 TPtr ptr = model->Des(); |
|
282 |
|
283 // Read the data from file. |
|
284 TFileText reader; |
|
285 reader.Set( file ); |
|
286 User::LeaveIfError( reader.Read( ptr ) ); |
|
287 |
|
288 // Append the phone model to aSwVersion |
|
289 aSwVersion.Append( *model ); |
|
290 |
|
291 CleanupStack::PopAndDestroy( 2 ); // model, file |
|
292 } |
|
293 |
|
294 // End of File |
168 // End of File |