omadm/omadmappui/src/NSmlDMFotaModel_nofota.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Class containing the no FOTA functionality 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <sysutil.h>
       
    22 #include <centralrepository.h>
       
    23 #include <devmaninternalcrkeys.h>
       
    24 
       
    25 #include "nsmldmsyncprivatecrkeys.h"
       
    26 #include "nsmldmsyncdocument.h"
       
    27 #include "nsmldmfotamodel.h"
       
    28 //#include "nsmldmsyncdebug.h"
       
    29 
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CNSmlDMFotaModel::NewL
       
    35 // Two-phased constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CNSmlDMFotaModel* CNSmlDMFotaModel::NewL( CNSmlDMSyncDocument* aDocument )
       
    39     {
       
    40     CNSmlDMFotaModel* self = new( ELeave ) CNSmlDMFotaModel( aDocument );
       
    41     
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop();
       
    45 
       
    46     return self;
       
    47     }
       
    48 
       
    49     
       
    50 // Destructor
       
    51 CNSmlDMFotaModel::~CNSmlDMFotaModel()
       
    52     {
       
    53     }
       
    54 
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CNSmlDMFotaModel::GetProfileName
       
    58 // Changes aProfileName to KNullDesC if the profile identifier is
       
    59 // not found.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CNSmlDMFotaModel::GetProfileNameL( const TInt   aProfileId,
       
    63                                               HBufC* aProfileName ) const
       
    64     {
       
    65 
       
    66     TInt index( 0 );
       
    67     aProfileName->Des().Copy( KNullDesC );
       
    68     
       
    69     iDocument->RefreshProfileListL( ETrue ); // Include hidden profile
       
    70     CArrayFixFlat<TNSmlDMProfileItem>* profileList = iDocument->ProfileList( index );
       
    71     
       
    72     for ( index = 0; index < profileList->Count(); index++ )
       
    73         {
       
    74         if ( ( *profileList )[index].iProfileId == aProfileId )
       
    75             {
       
    76             aProfileName->Des().Copy( ( *profileList )[index].iProfileName );
       
    77             }
       
    78         }
       
    79 
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CNSmlDMFotaModel::DefaultFotaProfileIdL
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 TInt CNSmlDMFotaModel::DefaultFotaProfileIdL() const
       
    87     {
       
    88     
       
    89     TInt profileId( KErrNotFound );
       
    90     CRepository* centrep = NULL;
       
    91     TRAPD( err, centrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );
       
    92 
       
    93     User::LeaveIfError( err );
       
    94     centrep->Get( KNSmlDMDefaultFotaProfileKey, profileId );
       
    95     delete centrep;
       
    96     
       
    97     return profileId;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CNSmlDMFotaModel::SetDefaultFotaProfileIdL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CNSmlDMFotaModel::SetDefaultFotaProfileIdL( const TInt aProfileId )
       
   105     {
       
   106     
       
   107     CRepository* centrep = NULL;
       
   108     TRAPD( err, centrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );
       
   109 
       
   110     User::LeaveIfError( err );
       
   111     centrep->Set( KNSmlDMDefaultFotaProfileKey, aProfileId );
       
   112     delete centrep;
       
   113     
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CNSmlDMFotaModel::EnableFwUpdRequestL
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CNSmlDMFotaModel::EnableFwUpdRequestL( const TInt aProfileId )
       
   121     {
       
   122     /*
       
   123     CRepository* centrep = NULL;
       
   124     TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) );
       
   125     FTRACE( FPrint( _L(
       
   126         "[OMADM] CNSmlDMFotaModel::EnableFwUpdRequestL(), opening cenrep returned %d" ),
       
   127         err ) );
       
   128     User::LeaveIfError( err );
       
   129     centrep->Set( KDevManClientInitiatedFwUpdateId, aProfileId );
       
   130     delete centrep;
       
   131     */
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CNSmlDMFotaModel::ReadProfileListL
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CNSmlDMFotaModel::ReadProfileListL( CDesCArray*          aItems,
       
   139                                          CArrayFixFlat<TInt>* aProfileIdList )
       
   140     {
       
   141 
       
   142     TInt index( 0 );
       
   143 
       
   144     iDocument->RefreshProfileListL( ETrue ); // Include hidden profile
       
   145     CArrayFixFlat<TNSmlDMProfileItem>* profileList = iDocument->ProfileList( index );
       
   146 
       
   147     for ( index = 0; index < profileList->Count(); index++ )
       
   148         {
       
   149         aItems->AppendL( ( *profileList )[index].iProfileName );
       
   150         aProfileIdList->AppendL( ( *profileList )[index].iProfileId );
       
   151         }
       
   152         
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CNSmlDMFotaModel::SelectDefaultProfileFromList
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TInt CNSmlDMFotaModel::SelectDefaultProfileFromList(
       
   160     const CArrayFixFlat<TInt>* aProfileIdList ) const
       
   161     {
       
   162 
       
   163     TInt retval( KErrNotFound );
       
   164     TInt defaultId( KErrNotFound );
       
   165     
       
   166     TRAPD( err, defaultId = iDocument->FotaModel()->DefaultFotaProfileIdL() );
       
   167     
       
   168     if ( err != KErrNone )
       
   169         {
       
   170         // We do not care about the possible errors here. It only means
       
   171         // that the identifier is not found on the list.
       
   172         }
       
   173         
       
   174     for ( TInt index( 0 ); index < aProfileIdList->Count(); index++ )
       
   175         {
       
   176         if ( ( *aProfileIdList )[index] == defaultId )
       
   177             {
       
   178             retval = index;
       
   179             break;  // Jump out of the loop
       
   180             }
       
   181         }
       
   182     
       
   183     return retval;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CNSmlDMFotaModel::VerifyProfileL
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 TBool CNSmlDMFotaModel::VerifyProfileL( const TInt aProfileId ) const
       
   191     {
       
   192 
       
   193     TInt index( 0 );
       
   194     TBool retval( EFalse );
       
   195 
       
   196     iDocument->RefreshProfileListL( ETrue ); // Include hidden profile
       
   197     CArrayFixFlat<TNSmlDMProfileItem>* profileList = iDocument->ProfileList( index );
       
   198 
       
   199     for ( index = 0; index < profileList->Count(); index++ )
       
   200         {
       
   201         if ( ( *profileList )[index].iProfileId == aProfileId )
       
   202             {
       
   203             retval = ETrue;
       
   204             break;  // Jump out of the loop
       
   205             }
       
   206         }
       
   207         
       
   208     return retval;
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CNSmlDMFotaModel::RetrieveFwUpdPkgIdListL
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TInt CNSmlDMFotaModel::RetrieveFwUpdPkgIdListL(TFotaState aState)
       
   216     {
       
   217     return KErrNotFound;
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CNSmlDMFotaModel::FindFwUpdPkgWithStateL
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TInt CNSmlDMFotaModel::FindFwUpdPkgWithStateL(
       
   225     TFotaState /*aState*/ )
       
   226     {
       
   227    
       
   228     return KErrNone;    
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CNSmlDMFotaModel::InitiateFwUpdInstall
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 TInt CNSmlDMFotaModel::InitiateFwUpdInstall( TInt /*aPkgId*/, TInt /*aProfileId*/ )
       
   236     {
       
   237     return KErrGeneral;    
       
   238     }
       
   239     
       
   240 // -----------------------------------------------------------------------------
       
   241 // CNSmlDMFotaModel::ContinueFwUpdInstall
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 void CNSmlDMFotaModel::ContinueFwUpdInstall( )
       
   245 	{
       
   246 	return;
       
   247 	}
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CNSmlDMFotaModel::CurrentFwVersionString
       
   251 // If the software version retrieval fails, the aVersionstring is not modified.
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 TInt CNSmlDMFotaModel::CurrentFwVersionString( TDes& aVersionString )
       
   255     {
       
   256     TBuf< KSysUtilVersionTextLength > buf;
       
   257 
       
   258     TInt err = SysUtil::GetSWVersion( buf );
       
   259     if ( err == KErrNone )
       
   260         {
       
   261         //_LIT( separator, "\n" );
       
   262         TInt location = buf.Find( KSmlEOL );
       
   263         if ( location != KErrNotFound)
       
   264             {
       
   265             // Delete the separator and the text after it. We are
       
   266             // only interested in the first section.
       
   267             buf.Delete( location, (buf.Length() - location) );
       
   268             }
       
   269 
       
   270         aVersionString.Copy( buf.Left( aVersionString.MaxLength() ) );
       
   271         }
       
   272 
       
   273     return err;
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CNSmlDMFotaModel::LastUpdateTime
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 TInt CNSmlDMFotaModel::LastUpdateTime( TTime& /*aTime*/ )
       
   281     {
       
   282     return KErrGeneral;
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CNSmlDMFotaModel::MarkFwUpdChangesStartL
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void CNSmlDMFotaModel::MarkFwUpdChangesStartL()
       
   290     {
       
   291     return;    
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CNSmlDMFotaModel::FwUpdStatesChangedL
       
   296 // The array is reseted at the end of the execution to save memory, since at
       
   297 // the moment the information is not needed multiple times.
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 TBool CNSmlDMFotaModel::FwUpdStatesChangedL()
       
   301     {
       
   302     return EFalse;    
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CNSmlDMFotaModel::CNSmlDMFotaModel
       
   307 // C++ default constructor can NOT contain any code, that
       
   308 // might leave.
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 CNSmlDMFotaModel::CNSmlDMFotaModel( CNSmlDMSyncDocument* aDocument ) :
       
   312     iDocument( aDocument )
       
   313     {
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CNSmlDMFotaModel::ConstructL
       
   318 // Symbian 2nd phase constructor can leave.
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void CNSmlDMFotaModel::ConstructL()
       
   322     {    
       
   323     }
       
   324 
       
   325 TFotaState CNSmlDMFotaModel::GetCurrentFwUpdState()
       
   326 {
       
   327 	return EIdle;
       
   328 }
       
   329 
       
   330 //Dummy implementation just to avoid compile time errors
       
   331 
       
   332 RFotaEngineSession::RFotaEngineSession()
       
   333 {
       
   334 }
       
   335 
       
   336 void RFotaEngineSession::ExtensionInterface(TUid /*aInterfaceId*/
       
   337                                               ,TAny*& /*aImplementation*/)
       
   338     {
       
   339     /*RProcess pr; TFullName fn = pr.FullName(); 
       
   340     FLOG(_L("RFotaEngineSession::ExtensionInterface called by %S"), &fn);*/
       
   341     }
       
   342 TUid RFotaEngineSession::ServiceUid() const
       
   343 	{
       
   344    /* RProcess pr; TFullName fn = pr.FullName(); 
       
   345     FLOG(_L( "RFotaEngineSession::ServiceUid() >> called by: %S" ), &fn );
       
   346     FLOG(_L( "RFotaEngineSession::ServiceUid() << ret: 0x%X" ),
       
   347                                             KFotaServiceUid );
       
   348                                             */
       
   349 	return TUid::Uid( 0x102072c4 );
       
   350 	}  	
       
   351 //End of File