iaupdate/IAD/firmwareupdate/src/iaupdatefwsynchandler.cpp
changeset 77 d1838696558c
parent 46 bb1748e0dd9b
equal deleted inserted replaced
75:2d2d25361590 77:d1838696558c
    17 
    17 
    18 
    18 
    19 
    19 
    20 
    20 
    21 // INCLUDES
    21 // INCLUDES
    22 #include <StringLoader.h>
       
    23 #include <e32property.h>
    22 #include <e32property.h>
    24 #include <data_caging_path_literals.hrh>  // for resource and bitmap directories
       
    25 #include <SyncMLErr.h>      // sync error codes
    23 #include <SyncMLErr.h>      // sync error codes
    26 #include <DevManInternalCRKeys.h>
    24 #include <DevManInternalCRKeys.h>
    27 #include <centralrepository.h>
    25 #include <centralrepository.h>
    28 #include <rconnmon.h>
    26 #include <rconnmon.h>
    29 #include <es_enum.h>
       
    30 
    27 
    31 #include <cmconnectionmethod.h>
    28 #include <cmconnectionmethod.h>
    32 #include <cmconnectionmethoddef.h>
    29 #include <cmconnectionmethoddef.h>
    33 #include <cmpluginpacketdatadef.h>
    30 #include <cmpluginpacketdatadef.h>
    34 
    31 
    35 #include <cmdestination.h>
    32 #include <cmdestination.h>
    36 #include <cmmanagerdef.h>
    33 #include <cmmanagerdef.h>
    37 
    34 
    38 #include <uikon.hrh>
       
    39 
    35 
    40 #include "iaupdateconnectionmethod.h"
    36 #include "iaupdateconnectionmethod.h"
    41 #include "iaupdateprivatecrkeys.h"
    37 #include "iaupdateprivatecrkeys.h"
    42 #include "iaupdatefwfotamodel.h"
    38 #include "iaupdatefwfotamodel.h"
    43 #include "iaupdatefwsyncappengine.h"
    39 #include "iaupdatefwsyncappengine.h"
    48 
    44 
    49 #include "iaupdatefwconst.h"
    45 #include "iaupdatefwconst.h"
    50 #include "iaupdatefwnsmlcrkeys.h"
    46 #include "iaupdatefwnsmlcrkeys.h"
    51 #include "iaupdatefwnsmlpskeys.h"
    47 #include "iaupdatefwnsmlpskeys.h"
    52 
    48 
       
    49 #include "iaupdatefwupdateobserver.h"
       
    50 
    53 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    54 // CIAUpdateFWSyncHandler::NewL
    52 // CIAUpdateFWSyncHandler::NewL
    55 //
    53 //
    56 // Two-phased constructor.
    54 // Two-phased constructor.
    57 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    77 // Destructor.
    75 // Destructor.
    78 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    79 //
    77 //
    80 CIAUpdateFWSyncHandler::~CIAUpdateFWSyncHandler()
    78 CIAUpdateFWSyncHandler::~CIAUpdateFWSyncHandler()
    81     {
    79     {
    82     /*if ( iWaitDialog )
    80         
    83         {
       
    84         TRAP_IGNORE( iWaitDialog->ProcessFinishedL() );
       
    85         iWaitDialog = NULL;
       
    86         }*/
       
    87     
       
    88 	delete iState;
    81 	delete iState;
    89 	delete iActiveCaller;
    82 	delete iActiveCaller;
    90 
    83 
    91 	if ( iSyncRunning )
    84 	if ( iSyncRunning )
    92 	    {
    85 	    {
   122     iSyncAppEngine( aAppEngine ),
   115     iSyncAppEngine( aAppEngine ),
   123     iFotaModel( aFotaModel )
   116     iFotaModel( aFotaModel )
   124 	{
   117 	{
   125 	}
   118 	}
   126 
   119 
   127 
   120 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   121 // CIAUpdateFWSyncHandler::SetUpdateObserver
   129 // CIAUpdateFWSyncHandler::SynchronizeL
   122 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   123 //
   131 //
   124 void CIAUpdateFWSyncHandler::SetUpdateObserver( MIAUpdateFWUpdateObserver* aObserver )
   132 void CIAUpdateFWSyncHandler::SynchronizeL( TDesC& aServerName,
   125     {
   133                                        const TInt aProfileId,
   126     iObserver = aObserver;
   134                                        const TInt aJobId,
   127     }
   135                                        const TInt aConnectionBearer,
       
   136                                        const TBool aUseFotaProgressNote )
       
   137 	{
       
   138 
       
   139 	iServerName = aServerName;
       
   140 	iConnectionBearer = aConnectionBearer;
       
   141     iProfileId = aProfileId;
       
   142     iJobId = aJobId;
       
   143     iUseFotaProgressNote = aUseFotaProgressNote;
       
   144     
       
   145     iSyncJob.OpenL( Session(), iJobId );
       
   146     iSyncJobId = iSyncJob.Identifier();
       
   147     SynchronizeL();
       
   148 	}
       
   149 	
   128 	
   150 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   151 // CIAUpdateFWSyncHandler::SynchronizeL
   130 // CIAUpdateFWSyncHandler::SynchronizeL
   152 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   153 //
   132 //
   221 		User::Leave( err );
   200 		User::Leave( err );
   222 		}
   201 		}
   223 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 16");
   202 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 16");
   224 	State()->SetSyncPhase( CIAUpdateFWSyncState::EPhaseConnecting );
   203 	State()->SetSyncPhase( CIAUpdateFWSyncState::EPhaseConnecting );
   225 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 17");
   204 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 17");
   226 	
   205 
   227 	TRAP( err, ShowProgressDialogL() );
   206 	if ( iObserver )
       
   207 	     {
       
   208 	     iObserver->PreparingStarted();
       
   209 	     }
       
   210 	
   228 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 18");
   211 	FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeL 18");
   229 	if ( err != KErrNone )
   212 	if ( err != KErrNone )
   230 		{
   213 		{
   231 		Session().CancelEvent();
   214 		Session().CancelEvent();
   232 		Session().CancelProgress();
   215 		Session().CancelProgress();
   329                     KNSmlDMNoUserInitiatedJob );
   312                     KNSmlDMNoUserInitiatedJob );
   330 	
   313 	
   331 	iSyncRunning = EFalse;
   314 	iSyncRunning = EFalse;
   332 	iSyncError = aError;
   315 	iSyncError = aError;
   333 
   316 
   334     /*if ( iWaitDialog )
   317 	if ( iObserver )
   335         {
   318 	    {
   336         
   319 	    iObserver->Prepared();
   337         iWaitDialog->ProcessFinishedL();
   320 	    }
   338         iWaitDialog = NULL;
   321     
   339         }*/
       
   340 
       
   341 	iUseFotaProgressNote = EFalse;
   322 	iUseFotaProgressNote = EFalse;
   342     iSyncJob.Close();
   323     iSyncJob.Close();
   343     FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeCompletedL 13");
   324     FLOG("[IAUPDATE] CIAUpdateFWSyncHandler::SynchronizeCompletedL 13");
   344 	// handle error in HandleActiveCallL (when active caller completes)
   325 	// handle error in HandleActiveCallL (when active caller completes)
   345 	iActiveCaller->Start( aError );
   326 	iActiveCaller->Start( aError );
   662 // CIAUpdateFWSyncHandler::HandleActiveCallL
   643 // CIAUpdateFWSyncHandler::HandleActiveCallL
   663 // -----------------------------------------------------------------------------
   644 // -----------------------------------------------------------------------------
   664 //
   645 //
   665 void CIAUpdateFWSyncHandler::HandleActiveCallL()
   646 void CIAUpdateFWSyncHandler::HandleActiveCallL()
   666 	{
   647 	{
   667 
   648     FLOG("CIAUpdateFWSyncHandler::HandleActiveCallL")
   668     FLOG("CIAUpdateFWSyncHandler::HandleActiveCallL 1")
   649 
   669     // HandleSyncErrorL will set this to true if
   650     // Inform parent that sync is done.
   670     // sync will be retried.
   651 	iSyncAppEngine->SyncCompleted( ENSmlSyncComplete );		
   671     iRetrySync = EFalse;
   652 	}
   672 
   653 
   673 	if ( (iSyncError != KErrNone) && (iSyncError != KErrCancel) )
       
   674 		{
       
   675 		 FLOG("CIAUpdateFWSyncHandler::HandleActiveCallL 2")
       
   676 		TRAP_IGNORE( HandleSyncErrorL() );
       
   677 		}
       
   678 	if ( iRetrySync == EFalse )
       
   679 		{
       
   680 		 FLOG("CIAUpdateFWSyncHandler::HandleActiveCallL 3")
       
   681 	    // Inform parent that sync is done.
       
   682 	    iSyncAppEngine->SyncCompleted( ENSmlSyncComplete );		
       
   683 		 FLOG("CIAUpdateFWSyncHandler::HandleActiveCallL 4")
       
   684 		}
       
   685 	}
       
   686 
       
   687 // -----------------------------------------------------------------------------
       
   688 // CIAUpdateFWSyncHandler::HandleSyncErrorL
       
   689 // -----------------------------------------------------------------------------
       
   690 //
       
   691 void CIAUpdateFWSyncHandler::HandleSyncErrorL()
       
   692 	{
       
   693 
       
   694 	FLOG("CIAUpdateFWSyncHandler::HandleSyncErrorL 1")
       
   695 	if ( iSyncError != KDMErr )
       
   696 		{
       
   697 		FLOG("CIAUpdateFWSyncHandler::HandleSyncErrorL 2")
       
   698 		}
       
   699 
       
   700 	   FLOG("CIAUpdateFWSyncHandler::HandleSyncErrorL 4")
       
   701 	if ( ( iSyncError == SyncMLError::KErrAuthenticationFailure ) ||
       
   702 	    ( iSyncError == SyncMLError::KErrTransportAuthenticationFailure ) )
       
   703         {
       
   704         //we don't handle this at the moment
       
   705         FLOG("CIAUpdateFWSyncHandler::HandleSyncErrorL 5")
       
   706         }
       
   707 	FLOG("CIAUpdateFWSyncHandler::HandleSyncErrorL 8")
       
   708     }
       
   709 
       
   710 // -----------------------------------------------------------------------------
       
   711 // CIAUpdateFWSyncHandler::ShowProgressDialogL
       
   712 // -----------------------------------------------------------------------------
       
   713 //
       
   714 void CIAUpdateFWSyncHandler::ShowProgressDialogL( )
       
   715 	{
       
   716         //iWaitDialog = new ( ELeave ) CAknWaitDialog(
       
   717         //    ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ) );
       
   718         //iWaitDialog->ExecuteLD( R_FOTA_CHECK_WAIT_NOTE );
       
   719         //iWaitDialog->SetCallback( this );
       
   720 	}
       
   721 
       
   722 // -----------------------------------------------------------------------------
       
   723 // CIAUpdateFWSyncHandler::HideProgressDialogL
       
   724 // -----------------------------------------------------------------------------
       
   725 //
       
   726 void CIAUpdateFWSyncHandler::HideProgressDialogL()
       
   727     {
       
   728     /*if ( iWaitDialog )
       
   729         {
       
   730         iWaitDialog->ProcessFinishedL();
       
   731         iWaitDialog = NULL;
       
   732         }*/
       
   733     }
       
   734 
   654 
   735 // -----------------------------------------------------------------------------
   655 // -----------------------------------------------------------------------------
   736 // CIAUpdateFWSyncHandler::Session
   656 // CIAUpdateFWSyncHandler::Session
   737 // -----------------------------------------------------------------------------
   657 // -----------------------------------------------------------------------------
   738 //
   658 //
   762 	__ASSERT_DEBUG(iState, TUtil::Panic(KErrGeneral));
   682 	__ASSERT_DEBUG(iState, TUtil::Panic(KErrGeneral));
   763 
   683 
   764 	return iState;
   684 	return iState;
   765 	}
   685 	}
   766 	
   686 	
   767 // -----------------------------------------------------------------------------
       
   768 // CIAUpdateFWSyncHandler::CancelSynchronizeL
       
   769 // -----------------------------------------------------------------------------
       
   770 //		
       
   771 void CIAUpdateFWSyncHandler::CancelSynchronizeL()
       
   772     { 
       
   773     if ( iSyncRunning )
       
   774         {
       
   775         iSyncJob.StopL();
       
   776         SynchronizeCompletedL( KErrCancel );
       
   777         }
       
   778     }
       
   779 
       
   780 // -----------------------------------------------------------------------------
       
   781 // CIAUpdateFWSyncHandler::DialogDismissedL
       
   782 // -----------------------------------------------------------------------------
       
   783 //		
       
   784 void CIAUpdateFWSyncHandler::DialogDismissedL( TInt aButtonId )
       
   785     {
       
   786 	if ( aButtonId == EEikBidCancel )
       
   787 		{
       
   788 
       
   789 		if ( SyncRunning() )
       
   790 			{
       
   791 
       
   792 			TRAP_IGNORE( iSyncJob.StopL() );
       
   793 		    
       
   794 		    State()->SetSyncPhase( CIAUpdateFWSyncState::EPhaseCanceling );
       
   795 			}
       
   796 		}
       
   797     }
       
   798 
       
   799 
   687 
   800 // End of File
   688 // End of File