fotaapplication/fotacustcmds/src/fotacustcmdfirmwareupdate.cpp
branchRCL_3
changeset 26 19bba8228ff0
parent 25 b183ec05bd8c
child 27 5cc2995847ea
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
     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:
       
    15 * Implementation of CFotaCustCmdFirmwareUpdate class.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "fotacustcmdfirmwareupdate.h"
       
    20 #ifdef __SYNCML_DM_FOTA
       
    21 #include <fotaengine.h>
       
    22 #include "fmsclient.h"
       
    23 #include "fotaserverPrivateCRKeys.h"
       
    24 #include "FotaIPCTypes.h"
       
    25 #include "fmsclientserver.h"
       
    26 #endif
       
    27 #include "fotastartupDebug.h"
       
    28 #include <centralrepository.h>
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CFotaCustCmdFirmwareUpdate::NewL
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CFotaCustCmdFirmwareUpdate* CFotaCustCmdFirmwareUpdate::NewL()
       
    36 	{
       
    37     FLOG( _L( "CFotaCustCmdFirmwareUpdate::NewL()  " ) );
       
    38 	return new ( ELeave ) CFotaCustCmdFirmwareUpdate;
       
    39 	}
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CFotaCustCmdFirmwareUpdate::~CFotaCustCmdFirmwareUpdate
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CFotaCustCmdFirmwareUpdate::~CFotaCustCmdFirmwareUpdate()
       
    47     {
       
    48      FLOG( _L( "CFotaCustCmdFirmwareUpdate::~CFotaCustCmdFirmwareUpdate()  " ) );
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CFotaCustCmdFirmwareUpdate::Initialize
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TInt CFotaCustCmdFirmwareUpdate::Initialize( CSsmCustomCommandEnv* /*aCmdEnv*/ )
       
    57     {
       
    58     
       
    59      FLOG( _L( "CFotaCustCmdFirmwareUpdate::Initialize()  " ) );
       
    60     
       
    61     return KErrNone;
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CFotaCustCmdFirmwareUpdate::Execute
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CFotaCustCmdFirmwareUpdate::Execute(
       
    70     const TDesC8& /*aParams*/,
       
    71     TRequestStatus& aRequest )
       
    72     {
       
    73      aRequest = KRequestPending;
       
    74        FLOG( _L( "CFotaCustCmdFirmwareUpdate::Execute() BEGIN " ) );
       
    75      #ifdef __SYNCML_DM_FOTA
       
    76      TRAP_IGNORE(ExecuteL());
       
    77      #endif
       
    78      TRequestStatus* request = &aRequest;
       
    79      User::RequestComplete( request, KErrNone );
       
    80      FLOG( _L( "CFotaCustCmdFirmwareUpdate::Execute() END " ) );
       
    81      
       
    82 
       
    83     }
       
    84 // ---------------------------------------------------------------------------
       
    85 // CFotaCustCmdFirmwareUpdate::ExecuteL
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CFotaCustCmdFirmwareUpdate::ExecuteL( )
       
    89     
       
    90    {
       
    91    	FLOG( _L( "CFotaCustCmdFirmwareUpdate::ExecuteL( ) Boot reason KFirmwareUpdateReason BEGIN " ) );
       
    92 
       
    93     CRepository*    centrep( NULL);
       
    94     RFotaEngineSession fotaEngine;
       
    95     TInt err= KErrNone;
       
    96     TRAP( err, centrep = CRepository::NewL( KCRUidFotaServer ) );
       
    97     TInt sendGAAfterrebootfeature = 0;
       
    98     	if( err == KErrNone && centrep )
       
    99     	{
       
   100     	  err = centrep->Get(  KGenericAlertResendAfterBoot, sendGAAfterrebootfeature );
       
   101     	}
       
   102     	 FTRACE(RDebug::Print(_L("[CFotaCustCmdFirmwareUpdate] feature sendGenericAlert is %d"), sendGAAfterrebootfeature));        
       
   103         if( sendGAAfterrebootfeature != 1 )
       
   104         {
       
   105    	        FLOG( _L( "[CFotaCustCmdFirmwareUpdate] FirmwareUpdateReason: Starting fota server  " ) );
       
   106             TRAPD(oError,fotaEngine.OpenL());
       
   107             if(oError == KErrNone)
       
   108             {
       
   109             fotaEngine.Close();
       
   110             FLOG( _L( "[CFotaCustCmdFirmwareUpdate] FirmwareUpdateReason: Closing fota server  " ) );
       
   111             }
       
   112        
       
   113         }
       
   114         
       
   115         if(centrep)
       
   116         {
       
   117         	delete centrep;
       
   118         }
       
   119     
       
   120   	FLOG( _L( "CFotaCustCmdFirmwareUpdate::ExecuteL( ) Boot reason KFirmwareUpdateReason END " ) );
       
   121 
       
   122    }
       
   123 // ---------------------------------------------------------------------------
       
   124 // CFotaCustCmdFirmwareUpdate::ExecuteCancel
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void CFotaCustCmdFirmwareUpdate::ExecuteCancel()
       
   128     {
       
   129   
       
   130       FLOG( _L( "CFotaCustCmdFirmwareUpdate::ExecuteCancel() " ) );
       
   131     
       
   132     }
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CFotaCustCmdFirmwareUpdate::Close
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 void CFotaCustCmdFirmwareUpdate::Close()
       
   140     {
       
   141     
       
   142        FLOG( _L( "CFotaCustCmdFirmwareUpdate::Close() " ) );
       
   143     
       
   144     }
       
   145 
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CFotaCustCmdFirmwareUpdate::Release
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CFotaCustCmdFirmwareUpdate::Release()
       
   152     {
       
   153     FLOG( _L( "CFotaCustCmdFirmwareUpdate::Release() " ) );
       
   154 
       
   155 	delete this;
       
   156     }