iaupdate/IAD/engine/controller/src/iaupdateplatformdependency.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // For the system version info
       
    21 #include <versioninfo.h>
       
    22 
       
    23 #include "iaupdateplatformdependency.h"
       
    24 #include "iaupdateversion.h"
       
    25 #include "iaupdateprotocolconsts.h"
       
    26 
       
    27 #include "iaupdatedebug.h"
       
    28 
       
    29 
       
    30 CIAUpdatePlatformDependency* CIAUpdatePlatformDependency::NewL()
       
    31     {
       
    32     CIAUpdatePlatformDependency* self =
       
    33         CIAUpdatePlatformDependency::NewLC();
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37     
       
    38     
       
    39 CIAUpdatePlatformDependency* CIAUpdatePlatformDependency::NewLC()
       
    40     {
       
    41     CIAUpdatePlatformDependency* self =
       
    42         new( ELeave ) CIAUpdatePlatformDependency();
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     return self;
       
    46     }
       
    47 
       
    48 
       
    49 CIAUpdatePlatformDependency::CIAUpdatePlatformDependency()
       
    50 : CBase()
       
    51     {
       
    52     Reset();
       
    53     }
       
    54 
       
    55 void CIAUpdatePlatformDependency::ConstructL()
       
    56     {
       
    57     // Nothing to do here.
       
    58     }
       
    59 
       
    60 
       
    61 CIAUpdatePlatformDependency::~CIAUpdatePlatformDependency()
       
    62     {
       
    63     delete iPlatform;
       
    64     }
       
    65 
       
    66 
       
    67 TBool CIAUpdatePlatformDependency::AcceptablePlatformL() const
       
    68     {
       
    69     IAUPDATE_TRACE("[IAUPDATE] CIAUpdatePlatformDependency::AcceptablePlatformL() begin");
       
    70     
       
    71     // Get the platform version
       
    72     VersionInfo::TPlatformVersion platformVersion;
       
    73     User::LeaveIfError( VersionInfo::GetVersion( platformVersion ) );
       
    74 
       
    75     IAUPDATE_TRACE_2("Platform version major: %d, minor: %d",
       
    76                      platformVersion.iMajorVersion,
       
    77                      platformVersion.iMinorVersion);
       
    78     IAUPDATE_TRACE_2("Node version floor major: %d, minor: %d",
       
    79                      iVersionFloor.iMajor,
       
    80                      iVersionFloor.iMinor);
       
    81     IAUPDATE_TRACE_2("Node version roof major: %d, minor: %d",
       
    82                      iVersionRoof.iMajor,
       
    83                      iVersionRoof.iMinor);
       
    84                                           
       
    85     // Create TIAUpdateVersion for comparing purposes. 
       
    86     // Notice, that platform version does not have build value.
       
    87     TVersion tmpVersion( platformVersion.iMajorVersion, platformVersion.iMinorVersion, 0 );
       
    88     TIAUpdateVersion iaPlatformVersion( tmpVersion );
       
    89 
       
    90     // Create temporary version infos.
       
    91     // Notice, here we ignore build values, because platform version
       
    92     // does not support them. So, set build to extreame values.
       
    93     TIAUpdateVersion floor;
       
    94     floor.SetToFloor();
       
    95     floor.iMajor = iVersionFloor.iMajor;
       
    96     floor.iMinor = iVersionFloor.iMinor;
       
    97     TIAUpdateVersion roof;
       
    98     roof.SetToRoof();
       
    99     roof.iMajor = iVersionRoof.iMajor;
       
   100     roof.iMinor = iVersionRoof.iMinor;
       
   101     
       
   102     // Now compare the version ranges.
       
   103     TBool correctVersion(  
       
   104         floor <= iaPlatformVersion && iaPlatformVersion <= roof );
       
   105    
       
   106     // Check if the platform description and versions are acceptable.
       
   107     if ( ( !iPlatform 
       
   108            || iPlatform->CompareF( IAUpdateProtocolConsts::KPlatformDescriptionValue() ) == 0 )
       
   109          && correctVersion )
       
   110         {
       
   111         IAUPDATE_TRACE("[IAUPDATE] CIAUpdatePlatformDependency::AcceptablePlatformL() end: Acceptable");
       
   112         return ETrue;
       
   113         }
       
   114     else
       
   115         {
       
   116         IAUPDATE_TRACE("[IAUPDATE] CIAUpdatePlatformDependency::AcceptablePlatformL() end: Not Acceptable");
       
   117         return EFalse; 
       
   118         }
       
   119     }
       
   120     
       
   121     
       
   122 void CIAUpdatePlatformDependency::SetPlatformL( const TDesC8& aPlatform )
       
   123     {
       
   124     HBufC8* tmp( aPlatform.AllocL() );
       
   125     delete iPlatform;
       
   126     iPlatform = tmp;
       
   127     }
       
   128     
       
   129 
       
   130 const TIAUpdateVersion& CIAUpdatePlatformDependency::VersionFloor() const
       
   131     {
       
   132     return iVersionFloor;
       
   133     }
       
   134     
       
   135     
       
   136 void CIAUpdatePlatformDependency::SetVersionFloor( const TVersion& aVersion )
       
   137     {
       
   138     iVersionFloor = aVersion;
       
   139     }
       
   140     
       
   141     
       
   142 const TIAUpdateVersion& CIAUpdatePlatformDependency::VersionRoof() const
       
   143     {
       
   144     return iVersionRoof;
       
   145     }
       
   146     
       
   147     
       
   148 void CIAUpdatePlatformDependency::SetVersionRoof( const TVersion& aVersion )
       
   149     {
       
   150     iVersionRoof = aVersion;    
       
   151     }
       
   152     
       
   153     
       
   154 void CIAUpdatePlatformDependency::Reset()
       
   155     {
       
   156     iVersionFloor.SetToFloor();
       
   157     iVersionRoof.SetToRoof();
       
   158 
       
   159     delete iPlatform;
       
   160     iPlatform = NULL;    
       
   161     }