|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of CNcdDeviceService |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncddeviceserviceimpl.h" |
|
20 |
|
21 #include <eikenv.h> |
|
22 #include <ProEngFactory.h> // Set as ringing tone |
|
23 #include <MProEngEngine.h> // Set as ringing tone |
|
24 #include <MProEngProfile.h> // Set as ringing tone |
|
25 #include <MProEngTones.h> // Set as ringing tone |
|
26 #include <AknsWallpaperUtils.h> // Set as wallpaper |
|
27 #include <centralrepository.h> // Set as theme |
|
28 #include <AknSkinsInternalCRKeys.h> // Set as theme |
|
29 #include <etel.h> // MCC and MNC |
|
30 #include <etelmm.h> // MCC and MNC |
|
31 #include <sysutil.h> |
|
32 #include <etel3rdparty.h> |
|
33 #include <f32file.h> |
|
34 #include <apgcli.h> |
|
35 |
|
36 #if !defined( __SERIES60_31__ ) && !defined( __SERIES60_30__ ) |
|
37 #include <sysversioninfo.h> |
|
38 #endif |
|
39 |
|
40 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
|
41 #include <cuseragent.h> |
|
42 #endif |
|
43 |
|
44 #include "catalogs_device_config.h" |
|
45 #include "catalogsutils.h" |
|
46 #include "catalogsdebug.h" |
|
47 |
|
48 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
49 #include "ncdtestconfig.h" |
|
50 #endif |
|
51 |
|
52 // Make ifdeffing easier by creating a new define for product code support |
|
53 #if defined( __SERIES60_31__ ) || defined( __SERIES60_30__ ) |
|
54 #define NCD_PRODUCTCODE_NOT_SUPPORTED |
|
55 #endif |
|
56 |
|
57 #if !( defined( __WINS__ ) || defined( __SERIES60_31__ ) || defined( __SERIES60_30__ ) ) |
|
58 #define NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
59 #endif |
|
60 |
|
61 _LIT( KPhoneTsy, "PHONETSY.TSY" ); |
|
62 |
|
63 // This string is used to find Series 60 version from User Agent string |
|
64 //_LIT8( KSeries60VersionFinder, "Series60/" ); |
|
65 |
|
66 // Note: This must be a request that is not used in device interaction |
|
67 const CTelephony::TCancellationRequest KNoPhoneOperationRunning = |
|
68 CTelephony::EFlightModeChangeCancel; |
|
69 |
|
70 const TInt KFirmwareLength = 64; |
|
71 |
|
72 // Hardcoded device manufacturer string |
|
73 // <hardware><manufacturer> |
|
74 _LIT( KManufacturerNokia, "Nokia" ); |
|
75 |
|
76 _LIT8( KFlashMovieMime, "application/x-shockwave-flash" ); |
|
77 |
|
78 #ifdef __WINS__ |
|
79 _LIT( KWinsProductCode, "0000000" ); |
|
80 #endif |
|
81 |
|
82 |
|
83 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
84 _LIT( KFirmwareEol, "\n" ); |
|
85 #endif |
|
86 |
|
87 // ======== MEMBER FUNCTIONS ======== |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // Constructor. |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CNcdDeviceService* CNcdDeviceService::NewL() |
|
94 { |
|
95 CNcdDeviceService* self = NewLC(); |
|
96 CleanupStack::Pop(); |
|
97 return self; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // Constructor. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CNcdDeviceService* CNcdDeviceService::NewLC() |
|
105 { |
|
106 CNcdDeviceService* self = new (ELeave) CNcdDeviceService(); |
|
107 CleanupStack::PushL( self ); |
|
108 self->ConstructL(); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Destructor. |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CNcdDeviceService::~CNcdDeviceService() |
|
117 { |
|
118 DLTRACEIN(("")); |
|
119 delete iCurrentThemeName; |
|
120 Cancel(); |
|
121 delete iImsi; |
|
122 delete iFirmware; |
|
123 delete iDeviceManufacturer; |
|
124 delete iDeviceModel; |
|
125 Close(); |
|
126 delete iTelephony; |
|
127 |
|
128 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
129 delete iTestConfig; |
|
130 #endif |
|
131 DLTRACEOUT(("")); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // Constructor. |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 CNcdDeviceService::CNcdDeviceService() : CActive( EPriorityStandard ), |
|
139 iPhoneIdV1Pckg( iPhoneIdV1 ), |
|
140 iSubscriberIdV1Pckg( iSubscriberIdV1 ), |
|
141 iNetworkInfoV1Pckg( iNetworkInfoV1 ), |
|
142 iConnected( EFalse ), |
|
143 iCurrentCancelCode( KNoPhoneOperationRunning ), |
|
144 iError( KErrNone ) |
|
145 { |
|
146 CActiveScheduler::Add( this ); |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // ConstructL |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CNcdDeviceService::ConstructL() |
|
154 { |
|
155 DLTRACEIN(("")); |
|
156 iTelephony = CTelephony::NewL(); |
|
157 InitializeL(); |
|
158 DLTRACEOUT(("")); |
|
159 } |
|
160 |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // RunL |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CNcdDeviceService::RunL() |
|
167 { |
|
168 DLTRACEIN(( "iStatus: %d", iStatus.Int() )); |
|
169 |
|
170 // GetSubscriberId fails with KErrNotFound if there's no SIM in the device |
|
171 switch ( iState ) |
|
172 { |
|
173 case EGetPhoneId: |
|
174 { |
|
175 DLTRACE((_L("manufacturer: %S, model: %S, IMEI: %S"), |
|
176 &iPhoneIdV1.iManufacturer, &iPhoneIdV1.iModel, |
|
177 &iPhoneIdV1.iSerialNumber )); |
|
178 GetSubscriberId(); |
|
179 break; |
|
180 } |
|
181 |
|
182 case EGetSubscriberId: |
|
183 { |
|
184 if ( iStatus.Int() == KErrNone || |
|
185 iStatus.Int() == KErrNotFound ) |
|
186 { |
|
187 |
|
188 DLTRACE(("Got subscriber ID")); |
|
189 DLINFO(( _L("IMSI: %S"), &iSubscriberIdV1.iSubscriberId )) |
|
190 GetNetworkInfo(); |
|
191 } |
|
192 else |
|
193 { |
|
194 DLTRACE(("Unrecoverable error")); |
|
195 iError = iStatus.Int(); |
|
196 } |
|
197 break; |
|
198 } |
|
199 |
|
200 case EGetNetworkInfo: |
|
201 { |
|
202 DLTRACE(("EGetNetworkInfo")); |
|
203 if ( iStatus.Int() == KErrAccessDenied ) |
|
204 { |
|
205 DLTRACE(("Couldn't access network information, probably SIM is not present")); |
|
206 FinishInitialization(); |
|
207 break; |
|
208 } |
|
209 else if ( iStatus.Int() != KErrNone ) |
|
210 { |
|
211 DLTRACE(("Unrecoverable error")); |
|
212 iError = iStatus.Int(); |
|
213 break; |
|
214 } |
|
215 |
|
216 DLTRACE(("Got network info")); |
|
217 // All is well |
|
218 DLINFO(( _L("Mode: %d, Status: %d, MCC: %S, MNC: %S, DisplayTag: %S"), |
|
219 iNetworkInfoV1.iMode, iNetworkInfoV1.iStatus, |
|
220 &iNetworkInfoV1.iCountryCode, |
|
221 &iNetworkInfoV1.iNetworkId, |
|
222 &iNetworkInfoV1.iDisplayTag )); |
|
223 DLINFO(( _L("Short: %S, Long: %S, Access: %d, AreaKnown: %d"), |
|
224 &iNetworkInfoV1.iShortName, &iNetworkInfoV1.iLongName, |
|
225 iNetworkInfoV1.iAccess, iNetworkInfoV1.iAreaKnown )); |
|
226 |
|
227 if ( iNetworkInfoV1.iAreaKnown ) |
|
228 { |
|
229 DLINFO(( "LocationAreaCode: %u, CellId: %u", |
|
230 iNetworkInfoV1.iLocationAreaCode, |
|
231 iNetworkInfoV1.iCellId )); |
|
232 } |
|
233 else |
|
234 { |
|
235 DLINFO(( "Area not known" )); |
|
236 } |
|
237 |
|
238 FinishInitialization(); |
|
239 break; |
|
240 } |
|
241 |
|
242 case EInitialized: |
|
243 { |
|
244 DLTRACE(("Initialization done")); |
|
245 FinishInitialization(); |
|
246 break; |
|
247 } |
|
248 |
|
249 } |
|
250 |
|
251 |
|
252 if ( iError != KErrNone ) |
|
253 { |
|
254 DLTRACE(("Error: %d", iError)); |
|
255 DeleteWait(); |
|
256 } |
|
257 DLTRACEOUT(("")); |
|
258 } |
|
259 |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // DoCancel |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void CNcdDeviceService::DoCancel() |
|
266 { |
|
267 DLTRACEIN(("")); |
|
268 DeleteWait(); |
|
269 if ( iTelephony && iCurrentCancelCode != KNoPhoneOperationRunning ) |
|
270 { |
|
271 |
|
272 iTelephony->CancelAsync( iCurrentCancelCode ) ; |
|
273 } |
|
274 DLTRACEOUT(("")); |
|
275 } |
|
276 |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // RunError |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 TInt CNcdDeviceService::RunError( TInt aError ) |
|
283 { |
|
284 DLERROR((" Silently ignoring an error: %d", aError )); |
|
285 iError = aError; |
|
286 DeleteWait(); |
|
287 return KErrNone; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // Set sound file as ringing tone to the currently active profile. |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 void CNcdDeviceService::SetAsRingingToneL( const TDesC& aFileName ) |
|
295 { |
|
296 DLTRACEIN(("")); |
|
297 |
|
298 MProEngEngine* engine = ProEngFactory::NewEngineLC(); |
|
299 MProEngProfile* profile = engine->ActiveProfileLC(); |
|
300 MProEngTones& tones = profile->ProfileTones(); |
|
301 |
|
302 User::LeaveIfError( tones.SetRingingTone1L( aFileName ) ); |
|
303 profile->CommitChangeL(); |
|
304 |
|
305 DLINFO(("Ringing tone set")); |
|
306 |
|
307 // Can't use PopAndDestroy( 2, MProEngEngine ) etc. because |
|
308 // ProEngFactory puts a C-class in the cleanupstack but returns an M-class |
|
309 // so the pointer comparison done by PopAndDestroy will fail and cause |
|
310 // a panic with E32User-CBase 90 |
|
311 CleanupStack::PopAndDestroy( 2 ); // MProEngProfile, MProEngEngine |
|
312 |
|
313 DLTRACEOUT(("")); |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // Set graphics file as wallpaper. |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 void CNcdDeviceService::SetAsWallpaperL( const TDesC& aFileName ) |
|
321 { |
|
322 DLTRACEIN(("")); |
|
323 User::LeaveIfError( |
|
324 AknsWallpaperUtils::SetIdleWallpaper( aFileName, |
|
325 CCoeEnv::Static() ) ); |
|
326 DLTRACEOUT(("")); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // Set theme by using its name. |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 void CNcdDeviceService::SetAsThemeL( const TDesC& aThemeName ) |
|
334 { |
|
335 DLTRACEIN(("")); |
|
336 RAknsSrvSession aknsSrv; |
|
337 CleanupClosePushL( aknsSrv ); |
|
338 User::LeaveIfError( aknsSrv.Connect() ); |
|
339 |
|
340 TAknsPkgID pid; |
|
341 TAknSkinSrvSkinPackageLocation location = EAknsSrvPhone; |
|
342 |
|
343 CArrayPtr<CAknsSrvSkinInformationPkg>* skins; |
|
344 skins = aknsSrv.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
345 |
|
346 TInt i = 0; |
|
347 TInt skinCount = skins->Count(); |
|
348 for ( i = 0; i < skinCount; i++ ) |
|
349 { |
|
350 if ( skins->At( i )->Name().CompareF( aThemeName ) == 0 ) |
|
351 { |
|
352 // Name found from theme list |
|
353 pid = skins->At( i )->PID(); |
|
354 location = SkinLocationFromPath( |
|
355 skins->At( i )->IniFileDirectory() ); |
|
356 break; |
|
357 } |
|
358 } |
|
359 |
|
360 skins->ResetAndDestroy(); |
|
361 delete skins; |
|
362 skins = NULL; |
|
363 |
|
364 if ( i == skinCount ) |
|
365 { |
|
366 User::Leave( KErrNotFound ); |
|
367 } |
|
368 |
|
369 // Set all active item definition sets |
|
370 User::LeaveIfError( aknsSrv.SetAllDefinitionSets( pid ) ); |
|
371 |
|
372 TAknsPkgIDBuf pidBuf; |
|
373 pid.CopyToDes( pidBuf ); |
|
374 |
|
375 // Save settings to repository |
|
376 CRepository* skinsRepository = |
|
377 CRepository::NewLC( KCRUidPersonalisation ); |
|
378 User::LeaveIfError( skinsRepository->Set( KPslnActiveSkinUid, pidBuf ) ); |
|
379 User::LeaveIfError( skinsRepository->Set( KPslnActiveSkinLocation, |
|
380 location ) ); |
|
381 |
|
382 CleanupStack::PopAndDestroy( skinsRepository ); |
|
383 CleanupStack::PopAndDestroy( &aknsSrv ); |
|
384 DLTRACEOUT(("")); |
|
385 } |
|
386 |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // Get name of the currently active theme. |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 const TDesC& CNcdDeviceService::CurrentThemeNameL() |
|
393 { |
|
394 DLTRACEIN(("")); |
|
395 TAknsPkgIDBuf pidBuf; |
|
396 |
|
397 CRepository* skinsRepository = |
|
398 CRepository::NewLC( KCRUidPersonalisation ); |
|
399 |
|
400 User::LeaveIfError( skinsRepository->Get( KPslnActiveSkinUid, pidBuf ) ); |
|
401 |
|
402 CleanupStack::PopAndDestroy( skinsRepository ); |
|
403 |
|
404 RAknsSrvSession aknsSrv; |
|
405 CleanupClosePushL( aknsSrv ); |
|
406 User::LeaveIfError( aknsSrv.Connect() ); |
|
407 |
|
408 TAknsPkgID pid; |
|
409 pid.SetFromDesL( pidBuf ); |
|
410 |
|
411 DLTRACE(("")); |
|
412 CArrayPtr<CAknsSrvSkinInformationPkg>* skins; |
|
413 skins = aknsSrv.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
414 DLTRACE(("")); |
|
415 |
|
416 delete iCurrentThemeName; |
|
417 iCurrentThemeName = NULL; |
|
418 |
|
419 TInt skinCount = skins->Count(); |
|
420 TInt i = 0; |
|
421 for ( ; i < skinCount; i++ ) |
|
422 { |
|
423 if ( skins->At( i )->PID().iNumber == pid.iNumber && |
|
424 skins->At( i )->PID().iTimestamp == pid.iTimestamp ) |
|
425 { |
|
426 // Package ID found from theme list. |
|
427 iCurrentThemeName = skins->At( i )->Name().Alloc(); |
|
428 break; |
|
429 } |
|
430 } |
|
431 |
|
432 skins->ResetAndDestroy(); |
|
433 delete skins; |
|
434 skins = NULL; |
|
435 |
|
436 CleanupStack::PopAndDestroy( &aknsSrv ); |
|
437 |
|
438 if ( iCurrentThemeName ) |
|
439 { |
|
440 DLTRACEOUT(( _L("Theme name %S"), iCurrentThemeName )); |
|
441 return *iCurrentThemeName; |
|
442 } |
|
443 else |
|
444 { |
|
445 DLTRACEOUT(("No theme name")); |
|
446 return KNullDesC; |
|
447 } |
|
448 } |
|
449 |
|
450 |
|
451 // --------------------------------------------------------------------------- |
|
452 // Retrieves home network information. |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 void CNcdDeviceService::HomeNetworkInfoL( TDes& aMCC, TDes& aMNC ) |
|
456 { |
|
457 DLTRACEIN(("")); |
|
458 |
|
459 #ifdef CATALOGS_OVERRIDE_NETWORK |
|
460 aMCC.Copy( KCatalogsOverrideHomeMcc ); |
|
461 aMNC.Copy( KCatalogsOverrideHomeMnc ); |
|
462 |
|
463 #else // CATALOGS_OVERRIDE_NETWORK |
|
464 |
|
465 TBool neededConnect = !iConnected; |
|
466 if ( !iConnected ) |
|
467 { |
|
468 DLTRACE(("Was not connected")); |
|
469 ConnectL(); |
|
470 } |
|
471 |
|
472 RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo; |
|
473 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg info2( networkInfo ); |
|
474 |
|
475 TRequestStatus status; |
|
476 |
|
477 iPhone.GetHomeNetwork( status, info2 ); |
|
478 User::WaitForRequest( status ); |
|
479 |
|
480 if ( networkInfo.iCountryCode.Length() > KMccLength ) |
|
481 { |
|
482 aMCC.Copy( networkInfo.iCountryCode.Left( KMccLength ) ); |
|
483 } |
|
484 else |
|
485 { |
|
486 aMCC.Copy( networkInfo.iCountryCode ); |
|
487 } |
|
488 |
|
489 if ( networkInfo.iNetworkId.Length() > KMncLength ) |
|
490 { |
|
491 aMNC.Copy( networkInfo.iNetworkId.Left( KMncLength ) ); |
|
492 } |
|
493 else |
|
494 { |
|
495 aMNC.Copy( networkInfo.iNetworkId ); |
|
496 } |
|
497 |
|
498 if ( neededConnect ) |
|
499 { |
|
500 Close(); |
|
501 } |
|
502 |
|
503 |
|
504 // Test config is handled afterwards since it's just easier to |
|
505 // handle mixed cases where one param is taken from the file |
|
506 // and another from the device |
|
507 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
508 |
|
509 if ( iTestConfig ) |
|
510 { |
|
511 if ( iTestConfig->IsSet( CNcdTestConfig::EConfigHomeMcc ) ) |
|
512 { |
|
513 aMCC.Copy( iTestConfig->Value( CNcdTestConfig::EConfigHomeMcc ) ); |
|
514 } |
|
515 |
|
516 if ( iTestConfig->IsSet( CNcdTestConfig::EConfigHomeMnc ) ) |
|
517 { |
|
518 aMNC.Copy( iTestConfig->Value( CNcdTestConfig::EConfigHomeMnc ) ); |
|
519 } |
|
520 |
|
521 DLTRACE(( _L("test MCC: %S, MNC: %S"), &aMCC, &aMNC )); |
|
522 } |
|
523 |
|
524 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
525 |
|
526 #endif // CATALOGS_OVERRIDE_NETWORK |
|
527 DLTRACEOUT(( _L("MCC: %S, MNC: %S"), &aMCC, &aMNC )); |
|
528 } |
|
529 |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // MCC getter |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 const TDesC& CNcdDeviceService::CurrentMccL() |
|
536 { |
|
537 DLTRACEIN(("")); |
|
538 #ifndef CATALOGS_OVERRIDE_NETWORK |
|
539 |
|
540 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
541 |
|
542 if ( iTestConfig && |
|
543 iTestConfig->IsSet( CNcdTestConfig::EConfigCurrentMcc ) ) |
|
544 { |
|
545 DLTRACEOUT(( _L("test MCC: %S"), |
|
546 &iTestConfig->Value( CNcdTestConfig::EConfigCurrentMcc ) )); |
|
547 return iTestConfig->Value( CNcdTestConfig::EConfigCurrentMcc ); |
|
548 } |
|
549 |
|
550 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
551 |
|
552 WaitForInitL(); |
|
553 DLTRACEOUT(( _L("MCC"), &iNetworkInfoV1.iCountryCode )); |
|
554 return iNetworkInfoV1.iCountryCode; |
|
555 #else // CATALOGS_OVERRIDE_NETWORK |
|
556 return KCatalogsOverrideCurrentMcc(); |
|
557 #endif |
|
558 } |
|
559 |
|
560 // --------------------------------------------------------------------------- |
|
561 // MNC getter |
|
562 // --------------------------------------------------------------------------- |
|
563 // |
|
564 const TDesC& CNcdDeviceService::CurrentMncL() |
|
565 { |
|
566 DLTRACEIN(("")); |
|
567 #ifndef CATALOGS_OVERRIDE_NETWORK |
|
568 |
|
569 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
570 |
|
571 if ( iTestConfig && |
|
572 iTestConfig->IsSet( CNcdTestConfig::EConfigCurrentMnc ) ) |
|
573 { |
|
574 DLTRACEOUT(( _L("test MNC: %S"), |
|
575 &iTestConfig->Value( CNcdTestConfig::EConfigCurrentMnc ) )); |
|
576 return iTestConfig->Value( CNcdTestConfig::EConfigCurrentMnc ); |
|
577 } |
|
578 |
|
579 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
580 |
|
581 WaitForInitL(); |
|
582 DLTRACEOUT(( _L("MNC"), &iNetworkInfoV1.iNetworkId )); |
|
583 return iNetworkInfoV1.iNetworkId; |
|
584 #else // CATALOGS_OVERRIDE_NETWORK |
|
585 return KCatalogsOverrideCurrentMnc(); |
|
586 #endif // CATALOGS_OVERRIDE_NETWORK |
|
587 } |
|
588 |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // Retrieves service provider information. |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 void CNcdDeviceService::ServiceProviderL( TDes& aServiceProvider ) |
|
595 { |
|
596 DLTRACEIN(("")); |
|
597 |
|
598 #ifndef CATALOGS_OVERRIDE_NETWORK |
|
599 TBool neededConnect = !iConnected; |
|
600 if ( !iConnected ) |
|
601 { |
|
602 ConnectL(); |
|
603 } |
|
604 |
|
605 RMobilePhone::TMobilePhoneServiceProviderNameV2 serviceProviderName; |
|
606 RMobilePhone::TMobilePhoneServiceProviderNameV2Pckg |
|
607 serviceProviderNamePckg( serviceProviderName ); |
|
608 |
|
609 TRequestStatus status; |
|
610 |
|
611 iPhone.GetServiceProviderName( status, serviceProviderNamePckg ); |
|
612 User::WaitForRequest( status ); |
|
613 |
|
614 // Operator name, service provider |
|
615 if ( serviceProviderName.iSPName.Length() > 0 ) |
|
616 { |
|
617 aServiceProvider.Copy( serviceProviderName.iSPName ); |
|
618 } |
|
619 |
|
620 if ( neededConnect ) |
|
621 { |
|
622 Close(); |
|
623 } |
|
624 #else // CATALOGS_OVERRIDE_NETWORK |
|
625 |
|
626 aServiceProvider.Copy( KCatalogsOverrideServiceProvider ); |
|
627 |
|
628 #endif // CATALOGS_OVERRIDE_NETWORK |
|
629 DLTRACEOUT(("")); |
|
630 } |
|
631 |
|
632 |
|
633 // --------------------------------------------------------------------------- |
|
634 // IMSI getter |
|
635 // --------------------------------------------------------------------------- |
|
636 // |
|
637 const TDesC& CNcdDeviceService::ImsiL() |
|
638 { |
|
639 DLTRACEIN(( "" )); |
|
640 |
|
641 // Handle possible IMSI override from config file |
|
642 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
643 |
|
644 if ( iTestConfig && |
|
645 iTestConfig->IsSet( CNcdTestConfig::EConfigImsi ) ) |
|
646 { |
|
647 DLTRACEOUT(( _L("test IMSI: %S"), |
|
648 &iTestConfig->Value( CNcdTestConfig::EConfigImsi ) )); |
|
649 return iTestConfig->Value( CNcdTestConfig::EConfigImsi ); |
|
650 } |
|
651 |
|
652 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
653 |
|
654 WaitForInitL(); |
|
655 DLTRACEOUT(( _L("IMSI: %S"), &iSubscriberIdV1.iSubscriberId )); |
|
656 return iSubscriberIdV1.iSubscriberId; |
|
657 } |
|
658 |
|
659 |
|
660 // --------------------------------------------------------------------------- |
|
661 // IMEI getter |
|
662 // --------------------------------------------------------------------------- |
|
663 // |
|
664 const TDesC& CNcdDeviceService::ImeiL() |
|
665 { |
|
666 DLTRACEIN(( "" )); |
|
667 WaitForInitL(); |
|
668 return iPhoneIdV1.iSerialNumber; |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 HBufC* CNcdDeviceService::DeviceIdentificationLC() |
|
676 { |
|
677 DLTRACEIN(("")); |
|
678 #ifdef CATALOGS_OVERRIDE_MODEL |
|
679 return KCatalogsOverrideDeviceId().AllocLC(); |
|
680 #endif |
|
681 |
|
682 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
|
683 // Assume the device id begins with "Nokia" and ends with "/" |
|
684 HBufC8* userAgent = UserAgentL(); |
|
685 CleanupStack::PushL( userAgent ); |
|
686 TInt offset = userAgent->Find( _L8( "Nokia" )); |
|
687 if ( offset == KErrNotFound ) |
|
688 { |
|
689 DLTRACEOUT(("No Nokia")); |
|
690 CleanupStack::PopAndDestroy( userAgent ); |
|
691 return KNullDesC().AllocLC(); |
|
692 } |
|
693 TPtrC8 id = userAgent->Des().Mid( offset ); |
|
694 offset = id.Locate( '/' ); |
|
695 if ( offset == KErrNotFound ) |
|
696 { |
|
697 DLTRACEOUT(("no /")); |
|
698 CleanupStack::PopAndDestroy( userAgent ); |
|
699 return KNullDesC().AllocLC(); |
|
700 } |
|
701 TPtrC8 id2 = id.Left( offset ); |
|
702 HBufC* devId = HBufC::NewL( id2.Length() ); |
|
703 devId->Des().Copy( id2 ); |
|
704 CleanupStack::PopAndDestroy( userAgent ); |
|
705 CleanupStack::PushL( devId ); |
|
706 DLTRACEOUT(( _L("devId: %S"), devId )); |
|
707 return devId; |
|
708 |
|
709 #else // Get devId from CTelephony |
|
710 |
|
711 #error User agent must not be fetched from CTelephony! |
|
712 |
|
713 WaitForInitL(); |
|
714 |
|
715 HBufC* devId = HBufC::NewLC( iPhoneIdV1.iManufacturer.Length() + |
|
716 iPhoneIdV1.iModel.Length() ); |
|
717 devId->Des().Copy( iPhoneIdV1.iManufacturer ); |
|
718 devId->Des().Append( iPhoneIdV1.iModel ); |
|
719 DLTRACEOUT(( _L("devId: %S"), devId )); |
|
720 return devId; |
|
721 #endif |
|
722 } |
|
723 |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // Device manufacturer getter |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 const TDesC& CNcdDeviceService::DeviceManufacturerL() |
|
730 { |
|
731 DLTRACEIN(("")); |
|
732 //WaitForInitL(); |
|
733 //return iPhoneIdV1.iManufacturer; |
|
734 return KManufacturerNokia; |
|
735 } |
|
736 |
|
737 |
|
738 // --------------------------------------------------------------------------- |
|
739 // Device model getter |
|
740 // --------------------------------------------------------------------------- |
|
741 // |
|
742 const TDesC& CNcdDeviceService::DeviceModelL() |
|
743 { |
|
744 DLTRACEIN(("")); |
|
745 |
|
746 #ifdef CATALOGS_OVERRIDE_MODEL |
|
747 return KCatalogsOverrideDeviceModel(); |
|
748 #else // CATALOGS_OVERRIDE_MODEL |
|
749 |
|
750 if ( !iDeviceModel ) |
|
751 { |
|
752 // Get manufacturer |
|
753 HBufC8* manufacturer = Des16ToDes8LC( DeviceManufacturerL() ); |
|
754 |
|
755 HBufC8* userAgent = UserAgentL(); |
|
756 CleanupStack::PushL( userAgent ); |
|
757 |
|
758 TInt offset = userAgent->FindF( *manufacturer ); |
|
759 if ( offset == KErrNotFound ) |
|
760 { |
|
761 DLTRACEOUT(("Device manufacturer not found")); |
|
762 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
763 return KNullDesC(); |
|
764 } |
|
765 |
|
766 // Strip manufacturer of the string |
|
767 TPtrC8 id = userAgent->Des().Mid( offset + manufacturer->Length() ); |
|
768 |
|
769 // Locate the end of the device model |
|
770 offset = id.Locate( '/' ); |
|
771 if ( offset == KErrNotFound ) |
|
772 { |
|
773 DLTRACE(("no /")); |
|
774 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
775 return KNullDesC(); |
|
776 } |
|
777 TPtrC8 id2 = id.Left( offset ); |
|
778 iDeviceModel = Des8ToDes16L( id2 ); |
|
779 |
|
780 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
781 } |
|
782 DLTRACEOUT(( _L("device model: %S"), iDeviceModel )); |
|
783 return *iDeviceModel; |
|
784 #endif // CATALOGS_OVERRIDE_MODEL |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------------------------- |
|
788 // Returns device language |
|
789 // --------------------------------------------------------------------------- |
|
790 // |
|
791 HBufC* CNcdDeviceService::DeviceLanguageLC() |
|
792 { |
|
793 DLTRACEIN(("")); |
|
794 #ifdef CATALOGS_OVERRIDE_LANGUAGE |
|
795 return KCatalogsOverrideDeviceLanguage().AllocLC(); |
|
796 #else |
|
797 TLanguage code = User::Language(); |
|
798 return LangCodeToDescLC( code); |
|
799 #endif |
|
800 } |
|
801 |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // Returns device firmware |
|
805 // --------------------------------------------------------------------------- |
|
806 // |
|
807 const TDesC& CNcdDeviceService::FirmwareL() |
|
808 { |
|
809 DLTRACEIN(("")); |
|
810 #ifndef CATALOGS_OVERRIDE_FIRMWARE |
|
811 if ( iFirmware ) |
|
812 { |
|
813 return *iFirmware; |
|
814 } |
|
815 |
|
816 iFirmware = HBufC::NewL( KFirmwareLength ); |
|
817 TPtr ptr = iFirmware->Des(); |
|
818 #ifndef __WINS__ |
|
819 User::LeaveIfError( SysUtil::GetSWVersion( ptr ) ); |
|
820 #else |
|
821 ptr.Copy( _L( "emulator" )); |
|
822 #endif |
|
823 return *iFirmware; |
|
824 |
|
825 #else // CATALOGS_OVERRIDE_FIRMWARE |
|
826 if ( iFirmware ) |
|
827 { |
|
828 return *iFirmware; |
|
829 } |
|
830 |
|
831 iFirmware = KCatalogsOverrideFirmware().AllocL(); |
|
832 |
|
833 return *iFirmware; |
|
834 #endif |
|
835 } |
|
836 |
|
837 |
|
838 // --------------------------------------------------------------------------- |
|
839 // Parses skin package location from path. |
|
840 // --------------------------------------------------------------------------- |
|
841 // |
|
842 TAknSkinSrvSkinPackageLocation |
|
843 CNcdDeviceService::SkinLocationFromPath( const TDesC& aPath ) |
|
844 { |
|
845 DLTRACEIN(("")); |
|
846 TBuf<1> driveLetterBuf; |
|
847 driveLetterBuf.CopyUC( aPath.Left( 1 ) ); |
|
848 if ( driveLetterBuf.CompareF( _L( "e" ) ) == 0 ) |
|
849 { |
|
850 return EAknsSrvMMC; |
|
851 } |
|
852 return EAknsSrvPhone; |
|
853 } |
|
854 |
|
855 |
|
856 // --------------------------------------------------------------------------- |
|
857 // On SDK 3.0 UA looks like this: |
|
858 // Mozilla/4.0 ( compatible; MSIE 5.0; Series60/3.0 Nokia6630/4.06.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) |
|
859 // --------------------------------------------------------------------------- |
|
860 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
|
861 |
|
862 HBufC8* CNcdDeviceService::UserAgentL() const |
|
863 { |
|
864 DLTRACEIN(("")); |
|
865 #ifndef CATALOGS_OVERRIDE_USERAGENT |
|
866 CUserAgent* ua = CUserAgent::NewL(); |
|
867 CleanupStack::PushL( ua ); |
|
868 HBufC8* uas = ua->UserAgentL(); |
|
869 CleanupStack::PopAndDestroy( ua ); |
|
870 DLTRACEOUT(("UserAgent: %S", uas)); |
|
871 return uas; |
|
872 #else // CATALOGS_OVERRIDE_USERAGENT |
|
873 return KCatalogsOverrideUserAgent().AllocL(); |
|
874 #endif |
|
875 } |
|
876 |
|
877 #endif |
|
878 |
|
879 // --------------------------------------------------------------------------- |
|
880 // GetPhoneLC |
|
881 // --------------------------------------------------------------------------- |
|
882 void CNcdDeviceService::GetPhoneLC( RTelServer& aServer, RPhone& aPhone ) |
|
883 { |
|
884 DLTRACEIN(("")); |
|
885 CleanupClosePushL( aServer ); |
|
886 |
|
887 User::LeaveIfError( aServer.Connect() ); |
|
888 User::LeaveIfError( aServer.LoadPhoneModule( KPhoneTsy ) ); |
|
889 |
|
890 RTelServer::TPhoneInfo info; |
|
891 |
|
892 // Find the number of phones available from the tel server |
|
893 TInt numberPhones; |
|
894 User::LeaveIfError( aServer.EnumeratePhones( numberPhones ) ); |
|
895 |
|
896 // Check there are available phones |
|
897 if ( numberPhones < 1 ) |
|
898 { |
|
899 User::Leave( KErrNotFound ); |
|
900 } |
|
901 |
|
902 // Get the details for the first (and only) phone |
|
903 User::LeaveIfError( aServer.GetPhoneInfo( 0, info ) ); |
|
904 |
|
905 User::LeaveIfError( aPhone.Open( aServer, info.iName ) ); |
|
906 CleanupClosePushL( aPhone ); |
|
907 DLTRACEOUT(("")); |
|
908 } |
|
909 |
|
910 |
|
911 // --------------------------------------------------------------------------- |
|
912 // ConnectL |
|
913 // --------------------------------------------------------------------------- |
|
914 void CNcdDeviceService::ConnectL() |
|
915 { |
|
916 DLTRACEIN(("")); |
|
917 if ( !iConnected ) |
|
918 { |
|
919 GetPhoneLC( iServer, iPhone ); |
|
920 CleanupStack::Pop( 2 ); |
|
921 iConnected = ETrue; |
|
922 } |
|
923 DLTRACEOUT(("")); |
|
924 } |
|
925 |
|
926 |
|
927 // --------------------------------------------------------------------------- |
|
928 // Close |
|
929 // --------------------------------------------------------------------------- |
|
930 TInt CNcdDeviceService::Close() |
|
931 { |
|
932 DLTRACEIN(("")); |
|
933 TInt err = KErrNone; |
|
934 if ( iConnected ) |
|
935 { |
|
936 iPhone.Close(); |
|
937 err = iServer.UnloadPhoneModule( KPhoneTsy ); |
|
938 iServer.Close(); |
|
939 iConnected = EFalse; |
|
940 } |
|
941 DLTRACEOUT(("err: %d", err)); |
|
942 return err; |
|
943 } |
|
944 |
|
945 |
|
946 |
|
947 // --------------------------------------------------------------------------- |
|
948 // InitializeL |
|
949 // --------------------------------------------------------------------------- |
|
950 void CNcdDeviceService::InitializeL() |
|
951 { |
|
952 DLTRACEIN(("")); |
|
953 iTelephony->GetPhoneId( iStatus, iPhoneIdV1Pckg ); |
|
954 iState = EGetPhoneId; |
|
955 iCurrentCancelCode = CTelephony::EGetPhoneIdCancel; |
|
956 SetActive(); |
|
957 DLTRACEOUT(("")); |
|
958 } |
|
959 |
|
960 |
|
961 // --------------------------------------------------------------------------- |
|
962 // |
|
963 // --------------------------------------------------------------------------- |
|
964 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
965 |
|
966 void CNcdDeviceService::SetTestConfig( CNcdTestConfig* aTestConfig ) |
|
967 { |
|
968 DLTRACEIN(("")); |
|
969 delete iTestConfig; |
|
970 iTestConfig = aTestConfig; |
|
971 } |
|
972 |
|
973 #endif // CATALOGS_BUILD_CONFIG_DEBUG |
|
974 |
|
975 // --------------------------------------------------------------------------- |
|
976 // GetSubscriberId |
|
977 // --------------------------------------------------------------------------- |
|
978 void CNcdDeviceService::GetSubscriberId() |
|
979 { |
|
980 DLTRACEIN(("")); |
|
981 iTelephony->GetSubscriberId( iStatus, iSubscriberIdV1Pckg ); |
|
982 |
|
983 #ifndef __WINS__ |
|
984 iState = EGetSubscriberId; |
|
985 #else // Skip other phases since 3.2 week 50 emulator doesn't support GetNetworkInfo |
|
986 iState = EInitialized; |
|
987 #endif |
|
988 iCurrentCancelCode = CTelephony::EGetSubscriberIdCancel; |
|
989 SetActive(); |
|
990 DLTRACEOUT(("")); |
|
991 } |
|
992 |
|
993 |
|
994 // --------------------------------------------------------------------------- |
|
995 // GetNetworkInfo |
|
996 // --------------------------------------------------------------------------- |
|
997 void CNcdDeviceService::GetNetworkInfo() |
|
998 { |
|
999 DLTRACEIN(("")); |
|
1000 iTelephony->GetCurrentNetworkInfo( iStatus, iNetworkInfoV1Pckg ); |
|
1001 iState = EGetNetworkInfo; |
|
1002 iCurrentCancelCode = CTelephony::EGetCurrentNetworkInfoCancel; |
|
1003 SetActive(); |
|
1004 DLTRACEOUT(("")); |
|
1005 } |
|
1006 |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // WaitForInitL |
|
1010 // --------------------------------------------------------------------------- |
|
1011 void CNcdDeviceService::WaitForInitL() |
|
1012 { |
|
1013 if ( iState != EInitialized && iError == KErrNone ) |
|
1014 { |
|
1015 DLTRACE(("Start waiter")); |
|
1016 DASSERT( !iWaiter ); |
|
1017 iWaiter = new(ELeave) CActiveSchedulerWait; |
|
1018 iWaiter->Start(); |
|
1019 } |
|
1020 User::LeaveIfError( iError ); |
|
1021 } |
|
1022 |
|
1023 |
|
1024 // --------------------------------------------------------------------------- |
|
1025 // DeleteWait |
|
1026 // --------------------------------------------------------------------------- |
|
1027 void CNcdDeviceService::DeleteWait() |
|
1028 { |
|
1029 if ( iWaiter ) |
|
1030 { |
|
1031 DLTRACE(("Stopping and deleting wait-object")); |
|
1032 iWaiter->AsyncStop(); |
|
1033 delete iWaiter; |
|
1034 iWaiter = NULL; |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // FinishInitialization |
|
1041 // --------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CNcdDeviceService::FinishInitialization() |
|
1044 { |
|
1045 DLTRACEIN(("")); |
|
1046 |
|
1047 DeleteWait(); |
|
1048 iCurrentCancelCode = CTelephony::ECurrentNetworkInfoChangeCancel; |
|
1049 iState = EInitialized; |
|
1050 |
|
1051 // Get notifications for changes in network info |
|
1052 iTelephony->NotifyChange( iStatus, |
|
1053 CTelephony::ECurrentNetworkInfoChange, |
|
1054 iNetworkInfoV1Pckg ); |
|
1055 |
|
1056 SetActive(); |
|
1057 DLTRACEOUT(("Observing for changes in network")); |
|
1058 } |
|
1059 |
|
1060 |
|
1061 |
|
1062 // --------------------------------------------------------------------------- |
|
1063 // Appends variant information to firmware string |
|
1064 // --------------------------------------------------------------------------- |
|
1065 // |
|
1066 void CNcdDeviceService::AppendVariantToFirmwareL( RFs& aFs ) |
|
1067 { |
|
1068 DLTRACEIN(("")); |
|
1069 |
|
1070 // Don't try to append any variant information if the firmware string is |
|
1071 // overridden in catalogs_device_config.h |
|
1072 #ifndef CATALOGS_OVERRIDE_FIRMWARE |
|
1073 // Ensure that variant is not appended multiple times |
|
1074 delete iFirmware; |
|
1075 iFirmware = NULL; |
|
1076 |
|
1077 // Update firmware string |
|
1078 FirmwareL(); |
|
1079 _LIT( KLineSeparator, "\n" ); |
|
1080 HBufC* variant = ReadVariantInformationLC( aFs ); |
|
1081 iFirmware = iFirmware->ReAllocL( |
|
1082 iFirmware->Length() + |
|
1083 variant->Length() + |
|
1084 KLineSeparator().Length() ); |
|
1085 |
|
1086 DLTRACE(("Appending variant to firmware")); |
|
1087 iFirmware->Des().Append( KLineSeparator ); |
|
1088 iFirmware->Des().Append( *variant ); |
|
1089 DLINFO(( _L("Firmware now: %S"), iFirmware )); |
|
1090 CleanupStack::PopAndDestroy( variant ); |
|
1091 #endif |
|
1092 } |
|
1093 |
|
1094 TUid CNcdDeviceService::FlashPlayerUidL() |
|
1095 { |
|
1096 DLTRACEIN(("")); |
|
1097 |
|
1098 RApaLsSession session; |
|
1099 CleanupClosePushL( session ); |
|
1100 User::LeaveIfError( session.Connect() ); |
|
1101 session.GetAllApps(); |
|
1102 |
|
1103 // Get the uid of the flash player |
|
1104 TDataType flashType( KFlashMovieMime() ); |
|
1105 TUid flashUid; |
|
1106 |
|
1107 User::LeaveIfError( session.AppForDataType( flashType, flashUid ) ); |
|
1108 |
|
1109 // Calls close |
|
1110 CleanupStack::PopAndDestroy( &session ); |
|
1111 |
|
1112 DLTRACEOUT(("Flash player Uid: %d", flashUid.iUid)); |
|
1113 |
|
1114 return flashUid; |
|
1115 } |
|
1116 |
|
1117 |
|
1118 // --------------------------------------------------------------------------- |
|
1119 // Reads the variant information from the platform's depths |
|
1120 // --------------------------------------------------------------------------- |
|
1121 // |
|
1122 HBufC* CNcdDeviceService::ReadVariantInformationLC( RFs& aFs ) |
|
1123 { |
|
1124 DLTRACEIN(("")); |
|
1125 #ifndef __WINS__ |
|
1126 |
|
1127 #ifdef __SERIES60_31__ |
|
1128 |
|
1129 _LIT(KSalesModelFileName, "Z:\\resource\\versions\\model.txt"); |
|
1130 |
|
1131 // TFileText::Read Reads a single line text record into the specified descriptor. |
|
1132 // Maximum record length is described as 256 characters in the class' header. |
|
1133 const TInt KMaxRecordLength = 256; |
|
1134 |
|
1135 HBufC* phoneModel = HBufC::NewLC( KMaxRecordLength ); |
|
1136 |
|
1137 RFile file; |
|
1138 User::LeaveIfError( |
|
1139 file.Open( aFs, KSalesModelFileName, |
|
1140 EFileShareReadersOnly | EFileRead ) ); |
|
1141 |
|
1142 CleanupClosePushL( file ); |
|
1143 |
|
1144 TPtr ptr = phoneModel->Des(); |
|
1145 |
|
1146 // Read the data from file. |
|
1147 TFileText reader; |
|
1148 reader.Set( file ); |
|
1149 User::LeaveIfError( reader.Read( ptr ) ); |
|
1150 |
|
1151 CleanupStack::PopAndDestroy( &file ); // file |
|
1152 |
|
1153 // Append lang version |
|
1154 _LIT( KSpace, " " ); |
|
1155 |
|
1156 HBufC* variant = HBufC::NewLC( KSysUtilVersionTextLength ); |
|
1157 TPtr variantPtr = variant->Des(); |
|
1158 User::LeaveIfError( SysUtil::GetLangVersion( variantPtr ) ); |
|
1159 |
|
1160 phoneModel = phoneModel->ReAllocL( |
|
1161 phoneModel->Length() + |
|
1162 variant->Length() + |
|
1163 KSpace().Length() ); |
|
1164 |
|
1165 phoneModel->Des().Append( KSpace ); |
|
1166 phoneModel->Des().Append( *variant ); |
|
1167 |
|
1168 CleanupStack::PopAndDestroy( variant ); |
|
1169 |
|
1170 // ReAllocL may change the location of the descriptor so |
|
1171 // we have to pop the old phoneModel pointer |
|
1172 CleanupStack::Pop(); // phoneModel |
|
1173 CleanupStack::PushL( phoneModel ); |
|
1174 |
|
1175 DLTRACEOUT(( _L("Variant: %S"), phoneModel)); |
|
1176 return phoneModel; |
|
1177 |
|
1178 #else // __SERIES60_31__ |
|
1179 _LIT( KSpace, " " ); |
|
1180 |
|
1181 // Get model version. |
|
1182 TBuf< KSysVersionInfoTextLength > modelVersion; |
|
1183 User::LeaveIfError( SysVersionInfo::GetVersionInfo( |
|
1184 SysVersionInfo::EModelVersion, modelVersion ) ); |
|
1185 |
|
1186 // Get lang version. |
|
1187 TBuf<KSysUtilVersionTextLength> langVersion; |
|
1188 User::LeaveIfError( SysUtil::GetLangVersion( langVersion ) ); |
|
1189 |
|
1190 // Create buffer. |
|
1191 HBufC* variantInfo = HBufC::NewLC( modelVersion.Length() + |
|
1192 langVersion.Length() + |
|
1193 KSpace().Length() ); |
|
1194 variantInfo->Des().Append( modelVersion ); |
|
1195 variantInfo->Des().Append( KSpace ); |
|
1196 variantInfo->Des().Append( langVersion ); |
|
1197 DLTRACEOUT(( _L("Variant info: %S"), variantInfo )); |
|
1198 return variantInfo; |
|
1199 #endif // __SERIES60_31__ |
|
1200 |
|
1201 #else |
|
1202 (void) aFs; |
|
1203 return KNullDesC().AllocLC(); |
|
1204 #endif |
|
1205 } |
|
1206 |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // Returns device product code |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 HBufC* CNcdDeviceService::ProductCodeLC() |
|
1212 { |
|
1213 DLTRACEIN(("")); |
|
1214 |
|
1215 #ifdef NCD_PRODUCTCODE_NOT_SUPPORTED |
|
1216 // Product code information is not provided from the |
|
1217 // platform for the emulator. So, use a hard coded |
|
1218 // product code value for the emulator. |
|
1219 DLTRACEOUT(("Product code not supported")); |
|
1220 return NULL; |
|
1221 |
|
1222 #elif defined(__WINS__) |
|
1223 |
|
1224 return KWinsProductCode().AllocLC(); |
|
1225 |
|
1226 #else |
|
1227 |
|
1228 // Buffer for the product code. |
|
1229 HBufC* productCode( |
|
1230 HBufC::NewLC( KSysVersionInfoTextLength ) ); |
|
1231 TPtr productCodeDes( productCode->Des() ); |
|
1232 |
|
1233 // Get productCode to the buffer. |
|
1234 TInt errorCode( |
|
1235 SysVersionInfo::GetVersionInfo( |
|
1236 // SysVersionInfo::EProductCode, productCodeDes ) ); |
|
1237 // This is just temporary line to use before NCD gets SDK that |
|
1238 // has the EProductCode defined in the sysversioninfo.h. When correct |
|
1239 // enum is available, remove this line and use the commented line above |
|
1240 // instead. |
|
1241 static_cast<SysVersionInfo::TVersionInfoType>(SysVersionInfo::EModelVersion + 1), productCodeDes ) ); |
|
1242 |
|
1243 if ( errorCode == KErrNotSupported ) |
|
1244 { |
|
1245 // Because product code getter is not supported in the platform, |
|
1246 // return NULL. |
|
1247 DLTRACEOUT(("Product code not supported, KErrNotSupported.")); |
|
1248 CleanupStack::PopAndDestroy( productCode ); |
|
1249 return NULL; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 // Leave if error occurred. |
|
1254 // Above, KErrNotSupported was handled as |
|
1255 // a special case. |
|
1256 User::LeaveIfError( errorCode ); |
|
1257 } |
|
1258 |
|
1259 DLTRACEOUT(( _L("Product code: %S"), productCode )); |
|
1260 |
|
1261 return productCode; |
|
1262 #endif // NCD_PRODUCTCODE_NOT_SUPPORTED |
|
1263 } |
|
1264 |
|
1265 |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // Returns device product type |
|
1268 // ----------------------------------------------------------------------------- |
|
1269 // |
|
1270 TInt CNcdDeviceService::GetProductType( TDes& aType, RFs& aFs ) |
|
1271 { |
|
1272 DLTRACEIN(("")); |
|
1273 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
1274 |
|
1275 SysVersionInfo::TProductVersion productVersion; |
|
1276 TInt err = SysVersionInfo::GetVersionInfo( productVersion, aFs ); |
|
1277 aType.Copy( productVersion.iProduct ); |
|
1278 return err; |
|
1279 |
|
1280 #else |
|
1281 |
|
1282 (void) aType; |
|
1283 (void) aFs; |
|
1284 |
|
1285 return KErrNotSupported; |
|
1286 |
|
1287 #endif |
|
1288 } |
|
1289 |
|
1290 |
|
1291 // ----------------------------------------------------------------------------- |
|
1292 // Gets firmware id |
|
1293 // ----------------------------------------------------------------------------- |
|
1294 // |
|
1295 TInt CNcdDeviceService::GetFirmwareId( TDes& aId, RFs& aFs ) |
|
1296 { |
|
1297 DLTRACEIN(("")); |
|
1298 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
1299 |
|
1300 return SysVersionInfo::GetVersionInfo( |
|
1301 SysVersionInfo::EFWVersion, |
|
1302 aId, |
|
1303 aFs ); |
|
1304 |
|
1305 #else |
|
1306 |
|
1307 (void) aId; |
|
1308 (void) aFs; |
|
1309 |
|
1310 return KErrNotSupported; |
|
1311 |
|
1312 #endif |
|
1313 } |
|
1314 |
|
1315 |
|
1316 |
|
1317 void CNcdDeviceService::GetFirmwareVersion1( TDes& aTarget ) |
|
1318 { |
|
1319 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
1320 |
|
1321 DLTRACEIN(("")); |
|
1322 TBuf<KSysUtilVersionTextLength> version; |
|
1323 |
|
1324 if ( SysUtil::GetSWVersion( version ) == KErrNone ) |
|
1325 { |
|
1326 TInt len = version.Length(); |
|
1327 TInt pos1 = version.Find( KFirmwareEol ); |
|
1328 if( pos1 != KErrNotFound && len > pos1 ) |
|
1329 { |
|
1330 aTarget.Append( version.Left( pos1 ) ); |
|
1331 } |
|
1332 } |
|
1333 DLTRACE(( _L("aTarget: %S"), &aTarget )); |
|
1334 |
|
1335 #else |
|
1336 |
|
1337 (void) aTarget; |
|
1338 |
|
1339 #endif |
|
1340 } |
|
1341 |
|
1342 |
|
1343 void CNcdDeviceService::GetFirmwareVersion2( TDes& aTarget ) |
|
1344 { |
|
1345 DLTRACEIN(("")); |
|
1346 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
1347 |
|
1348 TBuf<KSysUtilVersionTextLength> version; |
|
1349 |
|
1350 if ( SysUtil::GetLangSWVersion( version ) == KErrNone ) |
|
1351 { |
|
1352 TInt len = version.Length(); |
|
1353 TInt pos1 = version.Find( KFirmwareEol ); |
|
1354 if( pos1 != KErrNotFound && len > pos1 ) |
|
1355 { |
|
1356 aTarget.Append( version.Left( pos1 ) ); |
|
1357 } |
|
1358 } |
|
1359 |
|
1360 DLTRACE(( _L("aTarget: %S"), &aTarget )); |
|
1361 |
|
1362 #else |
|
1363 |
|
1364 (void) aTarget; |
|
1365 |
|
1366 #endif |
|
1367 } |
|
1368 |
|
1369 |
|
1370 void CNcdDeviceService::GetFirmwareVersion3( TDes& aTarget, RFs& aFs ) |
|
1371 { |
|
1372 DLTRACEIN(("")); |
|
1373 #ifdef NCD_GIVE_EXTRA_FIRMWARE_DATA |
|
1374 |
|
1375 TBuf<KSysUtilVersionTextLength> version; |
|
1376 |
|
1377 if ( SysVersionInfo::GetVersionInfo( |
|
1378 SysVersionInfo::EOPVersion, |
|
1379 version, |
|
1380 aFs ) == KErrNone ) |
|
1381 { |
|
1382 TInt len = version.Length(); |
|
1383 TInt pos1 = version.Find( KFirmwareEol ); |
|
1384 if( pos1 != KErrNotFound && len > pos1 ) |
|
1385 { |
|
1386 aTarget.Append( version.Left( pos1 ) ); |
|
1387 } |
|
1388 } |
|
1389 |
|
1390 DLTRACE(( _L("aTarget: %S"), &aTarget )); |
|
1391 |
|
1392 #else |
|
1393 |
|
1394 (void) aTarget; |
|
1395 (void) aFs; |
|
1396 |
|
1397 #endif |
|
1398 } |
|
1399 |
|
1400 |
|
1401 |
|
1402 // For testing purposes only, avoiding several mmp changes by including |
|
1403 // the cpp |
|
1404 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
1405 #include "ncdtestconfig.cpp" |
|
1406 #endif |
|
1407 |