connectivitymodules/SeCon/services/csc/src/sconversioninfo.cpp
branchRCL_3
changeset 19 0aa8cc770c8a
parent 18 453dfc402455
child 20 4a793f564d72
equal deleted inserted replaced
18:453dfc402455 19:0aa8cc770c8a
     1 /*
       
     2 * Copyright (c) 2008-2010 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:  CSconVersionInfo implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "sconversioninfo.h"
       
    20 
       
    21 #include <centralrepository.h>
       
    22 #include <DSCapabilityManagementCRKeys.h>
       
    23 #include <etel3rdparty.h> // read imsi
       
    24 #include <etel.h>
       
    25 #include <etelmm.h>
       
    26 #include <hal.h>
       
    27 
       
    28 #include "caputils.h"
       
    29 #include "debug.h"
       
    30 
       
    31 CSconVersionInfo::CSconVersionInfo()
       
    32     {
       
    33     iSymbianVersionError = KErrNotReady;
       
    34     iS60VersionError = KErrNotReady;
       
    35     }
       
    36 
       
    37 CSconVersionInfo::~CSconVersionInfo()
       
    38     {
       
    39     delete iManufacturer;
       
    40     delete iModel;
       
    41     delete iProduct;
       
    42     delete iRevision;
       
    43     delete iSWVersion;
       
    44     delete iSerialNumber;
       
    45     delete iSysVersionInfo;
       
    46     delete iLangVersion;
       
    47     delete iLangSWVersion;
       
    48     delete iOPVersion;
       
    49     delete iProductCode;
       
    50     }
       
    51 
       
    52 CSconVersionInfo* CSconVersionInfo::NewL()
       
    53     {
       
    54     CSconVersionInfo* self = new (ELeave) CSconVersionInfo;
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSconVersionInfo::FetchInfoL()
       
    60 // fetch device info
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CSconVersionInfo::FetchInfoL( RFs& aFs )
       
    64     {
       
    65     TRACE_FUNC_ENTRY;
       
    66     
       
    67     iSymbianVersionError = SysVersionInfo::GetVersionInfo( iSymbianVersion, aFs );
       
    68     iS60VersionError = VersionInfo::GetVersion( iS60Version, aFs );
       
    69     
       
    70     TBuf<KSysVersionInfoTextLength> info;
       
    71     TBuf<KSysVersionInfoTextLength> productBuf;
       
    72     TInt err(KErrNone);
       
    73     delete iSWVersion;
       
    74     iSWVersion = NULL;
       
    75     delete iProduct;
       
    76     iProduct = NULL;
       
    77     // get SW version, SW version date and model
       
    78     TRAP( err, CapUtil::GetSWVersionL( info, iDate, productBuf ) );
       
    79     iSWVersion = info.AllocL();
       
    80     iProduct = productBuf.AllocL();
       
    81     LOGGER_WRITE_1("CapUtil::GetSWVersionL err: %d", err);
       
    82     
       
    83     
       
    84     SysVersionInfo::TProductVersion productVersion;
       
    85     TInt sysVersionError = SysVersionInfo::GetVersionInfo( productVersion, aFs );
       
    86     LOGGER_WRITE_1( "SysVersionInfo::GetVersionInfo returned : %d", sysVersionError );
       
    87     
       
    88     // Use TelServer to get IMEI and also other info if SysVersionInfo is not supported
       
    89     RTelServer telServer;
       
    90     User::LeaveIfError( telServer.Connect() );
       
    91     CleanupClosePushL( telServer );
       
    92     RTelServer::TPhoneInfo teleinfo;
       
    93     User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
       
    94     RMobilePhone phone;
       
    95     User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
       
    96     CleanupClosePushL( phone );
       
    97     User::LeaveIfError(phone.Initialise()); 
       
    98     TUint32 teleidentityCaps;
       
    99     phone.GetIdentityCaps( teleidentityCaps );
       
   100     RMobilePhone::TMobilePhoneIdentityV1 telid;
       
   101     TRequestStatus status;
       
   102     phone.GetPhoneId( status, telid );
       
   103     User::WaitForRequest( status );
       
   104     if ( status == KErrNone )
       
   105         {
       
   106         if ( sysVersionError )
       
   107             {
       
   108             LOGGER_WRITE("Use info from TMobilePhoneIdentityV1");
       
   109             delete iModel;
       
   110             iModel = NULL;
       
   111             delete iRevision;
       
   112             iRevision = NULL;
       
   113             
       
   114             // phone model sales name. For example "N01".
       
   115             iModel = telid.iModel.AllocL();
       
   116             // product revision. For example "01"
       
   117             iRevision = telid.iRevision.AllocL();
       
   118             }
       
   119         delete iSerialNumber;
       
   120         iSerialNumber = NULL;
       
   121         // Phone serial number (IMEI or ESN), in character string format.
       
   122         iSerialNumber = telid.iSerialNumber.AllocL();
       
   123         }
       
   124     
       
   125     CleanupStack::PopAndDestroy( &phone );
       
   126     CleanupStack::PopAndDestroy( &telServer );
       
   127         
       
   128     if ( sysVersionError == KErrNone )
       
   129         {
       
   130         // use information from SysVersionInfo instead of previous APIs.
       
   131         LOGGER_WRITE("Using SysVersionInfo");
       
   132         
       
   133         // phone model sales name. For example "N01".
       
   134         delete iModel;
       
   135         iModel = NULL;
       
   136         iModel = productVersion.iModel.AllocL();
       
   137         // product revision. For example "01"
       
   138         delete iRevision;
       
   139         iRevision = NULL;
       
   140         iRevision = productVersion.iRevision.AllocL();
       
   141         // manufacturer name. For example "Nokia"
       
   142         delete iManufacturer;
       
   143         iManufacturer = NULL;
       
   144         iManufacturer = productVersion.iManufacturer.AllocL();
       
   145         // product code name. For example "RM-1"
       
   146         delete iProduct;
       
   147         iProduct = NULL;
       
   148         iProduct = productVersion.iProduct.AllocL();
       
   149         }
       
   150     else
       
   151         {
       
   152         CapUtil::GetManufacturer( info );
       
   153         delete iManufacturer;
       
   154         iManufacturer = NULL;
       
   155         iManufacturer = info.AllocL();
       
   156         }
       
   157         
       
   158     CapUtil::GetLanguage( iLanguage );
       
   159     
       
   160     
       
   161     err = SysVersionInfo::GetVersionInfo( SysVersionInfo::EFWVersion, info, aFs );
       
   162     delete iSysVersionInfo;
       
   163     iSysVersionInfo = NULL;
       
   164     if ( !err )
       
   165         {
       
   166         iSysVersionInfo = info.AllocL();
       
   167         }
       
   168     
       
   169     err = SysUtil::GetLangVersion( info );
       
   170     delete iLangVersion;
       
   171     iLangVersion = NULL;
       
   172     if ( !err )
       
   173         {
       
   174         iLangVersion = info.AllocL();
       
   175         }
       
   176     
       
   177     sysVersionError = SysUtil::GetLangSWVersion( info );
       
   178     delete iLangSWVersion;
       
   179     iLangSWVersion = NULL;
       
   180     if ( !sysVersionError )
       
   181         {
       
   182         iLangSWVersion = info.AllocL();
       
   183         }
       
   184                 
       
   185     sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EOPVersion, info, aFs );
       
   186     delete iOPVersion;
       
   187     iOPVersion = NULL;
       
   188     if ( !sysVersionError )
       
   189         {
       
   190         iOPVersion = info.AllocL();
       
   191         }
       
   192     
       
   193     
       
   194     sysVersionError = SysVersionInfo::GetVersionInfo( SysVersionInfo::EProductCode, info, aFs );
       
   195     delete iProductCode;
       
   196     iProductCode = NULL;
       
   197     if ( !sysVersionError )
       
   198         {
       
   199         iProductCode = info.AllocL();
       
   200         }
       
   201     
       
   202     // read DesktopSync key value
       
   203     CRepository* repository(NULL);
       
   204     TRAP( iDesktopSyncError, repository = CRepository::NewL( KCRUidDSDCMOConfig ));
       
   205     if ( !iDesktopSyncError )
       
   206         {
       
   207         iDesktopSyncError = repository->Get( KNsmlDesktopSync, iDesktopSync );
       
   208         LOGGER_WRITE_1("iDesktopSyncError: %d", iDesktopSyncError );
       
   209         LOGGER_WRITE_1("iDesktopSync: %d", iDesktopSync );
       
   210         delete repository;
       
   211         }
       
   212     else
       
   213         {
       
   214         LOGGER_WRITE_1("Could not create CRepository, err: %d", iDesktopSyncError );
       
   215         }
       
   216     
       
   217     // screen size
       
   218     HAL::Get(HAL::EDisplayXPixels, iScreenSize.iWidth);
       
   219     HAL::Get(HAL::EDisplayYPixels, iScreenSize.iHeight);
       
   220     
       
   221     iInfoFetched = ETrue;
       
   222     TRACE_FUNC_EXIT;   
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CSconVersionInfo::IsReady()
       
   227 // 
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 TBool CSconVersionInfo::IsReady()
       
   231     {
       
   232     return iInfoFetched;
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CSconVersionInfo::GetSymbianVersion()
       
   237 // Get Symbian OS version
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 TInt CSconVersionInfo::GetSymbianVersion( SysVersionInfo::TSymbianOSVersion& aSymbianVersion )
       
   241     {
       
   242     if ( iSymbianVersionError )
       
   243         {
       
   244         return iSymbianVersionError;
       
   245         }
       
   246     else
       
   247         {
       
   248         aSymbianVersion = iSymbianVersion;
       
   249         return KErrNone;
       
   250         }
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CSconVersionInfo::GetS60Version()
       
   255 // Get S60 platform version
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 TInt CSconVersionInfo::GetS60Version( VersionInfo::TPlatformVersion& aS60Version )
       
   259     {
       
   260     if ( iS60VersionError )
       
   261         {
       
   262         return iS60VersionError;
       
   263         }
       
   264     else
       
   265         {
       
   266         aS60Version = iS60Version;
       
   267         return KErrNone;
       
   268         }
       
   269     }
       
   270