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