36 #if !defined( __SERIES60_31__ ) && !defined( __SERIES60_30__ ) |
36 #if !defined( __SERIES60_31__ ) && !defined( __SERIES60_30__ ) |
37 #include <sysversioninfo.h> |
37 #include <sysversioninfo.h> |
38 #endif |
38 #endif |
39 |
39 |
40 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
40 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
41 #include <sysversioninfo.h> |
41 #include <cuseragent.h> |
42 #endif |
42 #endif |
43 |
43 |
44 #include "catalogs_device_config.h" |
44 #include "catalogs_device_config.h" |
45 #include "catalogsutils.h" |
45 #include "catalogsutils.h" |
46 #include "catalogsdebug.h" |
46 #include "catalogsdebug.h" |
679 DLTRACEIN(("")); |
679 DLTRACEIN(("")); |
680 #ifdef CATALOGS_OVERRIDE_MODEL |
680 #ifdef CATALOGS_OVERRIDE_MODEL |
681 return KCatalogsOverrideDeviceId().AllocLC(); |
681 return KCatalogsOverrideDeviceId().AllocLC(); |
682 #endif |
682 #endif |
683 |
683 |
684 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
684 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
685 |
685 // Assume the device id begins with "Nokia" and ends with "/" |
686 // Get model version. |
686 HBufC8* userAgent = UserAgentL(); |
687 TBuf< KSysVersionInfoTextLength > modelVersion; |
687 CleanupStack::PushL( userAgent ); |
688 User::LeaveIfError( SysVersionInfo::GetVersionInfo( |
688 TInt offset = userAgent->Find( _L8( "Nokia" )); |
689 SysVersionInfo::EModelVersion, modelVersion ) ); |
689 if ( offset == KErrNotFound ) |
690 |
690 { |
691 // Create buffer. |
691 DLTRACEOUT(("No Nokia")); |
692 HBufC* devId = HBufC::NewLC( modelVersion.Length() ); |
692 CleanupStack::PopAndDestroy( userAgent ); |
693 devId->Des().Append( modelVersion ); |
693 return KNullDesC().AllocLC(); |
|
694 } |
|
695 TPtrC8 id = userAgent->Des().Mid( offset ); |
|
696 offset = id.Locate( '/' ); |
|
697 if ( offset == KErrNotFound ) |
|
698 { |
|
699 DLTRACEOUT(("no /")); |
|
700 CleanupStack::PopAndDestroy( userAgent ); |
|
701 return KNullDesC().AllocLC(); |
|
702 } |
|
703 TPtrC8 id2 = id.Left( offset ); |
|
704 HBufC* devId = HBufC::NewL( id2.Length() ); |
|
705 devId->Des().Copy( id2 ); |
|
706 CleanupStack::PopAndDestroy( userAgent ); |
|
707 CleanupStack::PushL( devId ); |
694 DLTRACEOUT(( _L("devId: %S"), devId )); |
708 DLTRACEOUT(( _L("devId: %S"), devId )); |
695 return devId; |
709 return devId; |
696 |
710 |
697 #else // Get devId from CTelephony |
711 #else // Get devId from CTelephony |
698 |
712 |
735 return KCatalogsOverrideDeviceModel(); |
749 return KCatalogsOverrideDeviceModel(); |
736 #else // CATALOGS_OVERRIDE_MODEL |
750 #else // CATALOGS_OVERRIDE_MODEL |
737 |
751 |
738 if ( !iDeviceModel ) |
752 if ( !iDeviceModel ) |
739 { |
753 { |
740 // Get model version. |
754 // Get manufacturer |
741 TBuf< KSysVersionInfoTextLength > modelVersion; |
755 HBufC8* manufacturer = Des16ToDes8LC( DeviceManufacturerL() ); |
742 User::LeaveIfError( SysVersionInfo::GetVersionInfo( |
756 |
743 SysVersionInfo::EModelVersion, modelVersion ) ); |
757 HBufC8* userAgent = UserAgentL(); |
744 |
758 CleanupStack::PushL( userAgent ); |
745 // Create buffer. |
759 |
746 iDeviceModel = HBufC::NewL( modelVersion.Length() ); |
760 TInt offset = userAgent->FindF( *manufacturer ); |
747 iDeviceModel->Des().Append( modelVersion ); |
761 if ( offset == KErrNotFound ) |
748 } |
762 { |
749 |
763 DLTRACEOUT(("Device manufacturer not found")); |
|
764 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
765 return KNullDesC(); |
|
766 } |
|
767 |
|
768 // Strip manufacturer of the string |
|
769 TPtrC8 id = userAgent->Des().Mid( offset + manufacturer->Length() ); |
|
770 |
|
771 // Locate the end of the device model |
|
772 offset = id.Locate( '/' ); |
|
773 if ( offset == KErrNotFound ) |
|
774 { |
|
775 DLTRACE(("no /")); |
|
776 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
777 return KNullDesC(); |
|
778 } |
|
779 TPtrC8 id2 = id.Left( offset ); |
|
780 iDeviceModel = Des8ToDes16L( id2 ); |
|
781 |
|
782 CleanupStack::PopAndDestroy( 2, manufacturer ); // manufacturer, useragent |
|
783 } |
750 DLTRACEOUT(( _L("device model: %S"), iDeviceModel )); |
784 DLTRACEOUT(( _L("device model: %S"), iDeviceModel )); |
751 return *iDeviceModel; |
785 return *iDeviceModel; |
752 #endif // CATALOGS_OVERRIDE_MODEL |
786 #endif // CATALOGS_OVERRIDE_MODEL |
753 } |
787 } |
754 |
788 |
817 { |
851 { |
818 return EAknsSrvMMC; |
852 return EAknsSrvMMC; |
819 } |
853 } |
820 return EAknsSrvPhone; |
854 return EAknsSrvPhone; |
821 } |
855 } |
|
856 |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // On SDK 3.0 UA looks like this: |
|
860 // Mozilla/4.0 ( compatible; MSIE 5.0; Series60/3.0 Nokia6630/4.06.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) |
|
861 // --------------------------------------------------------------------------- |
|
862 #ifdef GET_DEVICE_ID_FROM_USERAGENT |
|
863 |
|
864 HBufC8* CNcdDeviceService::UserAgentL() const |
|
865 { |
|
866 DLTRACEIN(("")); |
|
867 #ifndef CATALOGS_OVERRIDE_USERAGENT |
|
868 CUserAgent* ua = CUserAgent::NewL(); |
|
869 CleanupStack::PushL( ua ); |
|
870 HBufC8* uas = ua->UserAgentL(); |
|
871 CleanupStack::PopAndDestroy( ua ); |
|
872 DLTRACEOUT(("UserAgent: %S", uas)); |
|
873 return uas; |
|
874 #else // CATALOGS_OVERRIDE_USERAGENT |
|
875 return KCatalogsOverrideUserAgent().AllocL(); |
|
876 #endif |
|
877 } |
|
878 |
|
879 #endif |
822 |
880 |
823 // --------------------------------------------------------------------------- |
881 // --------------------------------------------------------------------------- |
824 // GetPhoneLC |
882 // GetPhoneLC |
825 // --------------------------------------------------------------------------- |
883 // --------------------------------------------------------------------------- |
826 void CNcdDeviceService::GetPhoneLC( RTelServer& aServer, RPhone& aPhone ) |
884 void CNcdDeviceService::GetPhoneLC( RTelServer& aServer, RPhone& aPhone ) |