omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp
branchRCL_3
changeset 15 3f1ffafb31ec
parent 0 dab8a81a92de
child 47 8d171aa39c3f
equal deleted inserted replaced
14:b922b9936679 15:3f1ffafb31ec
    28 
    28 
    29 #include <ecom/ecom.h>
    29 #include <ecom/ecom.h>
    30 #include <ecom/implementationinformation.h>
    30 #include <ecom/implementationinformation.h>
    31 #include <rconnmon.h>
    31 #include <rconnmon.h>
    32 #include <e32std.h> //For TRequestStatus
    32 #include <e32std.h> //For TRequestStatus
       
    33 #include <e32property.h>
    33 #include "CPreSyncPlugin.h"
    34 #include "CPreSyncPlugin.h"
    34 #include "AspPreSyncPluginInterface.h"
    35 #include "AspPreSyncPluginInterface.h"
    35 
    36 
       
    37 #include <DataSyncInternalPSKeys.h>
    36 
    38 
    37 
    39 
    38 /******************************************************************************
    40 /******************************************************************************
    39  * class TAspSyncParam
    41  * class TAspSyncParam
    40  ******************************************************************************/
    42  ******************************************************************************/
    98         {
   100         {
    99         iWait->AsyncStop();
   101         iWait->AsyncStop();
   100         }
   102         }
   101 	delete iWait;
   103 	delete iWait;
   102 	
   104 	
       
   105 	RProperty::Delete(KPSUidNSmlDSSyncApp, KDsJobCancel);
   103 	
   106 	
   104 	CloseSyncSession();
   107 	CloseSyncSession();
   105 	
   108 	
   106 	FLOG( _L("CAspSyncHandler::~CAspSyncHandler END") );
   109 	FLOG( _L("CAspSyncHandler::~CAspSyncHandler END") );
   107     }
   110     }
   126 	iSyncError = KErrNone;
   129 	iSyncError = KErrNone;
   127 	iCurrentSyncJobId = KErrNotFound;
   130 	iCurrentSyncJobId = KErrNotFound;
   128 	iSyncSessionOpen = EFalse;
   131 	iSyncSessionOpen = EFalse;
   129 	
   132 	
   130 	iWait = new (ELeave) CActiveSchedulerWait();
   133 	iWait = new (ELeave) CActiveSchedulerWait();
   131 	
   134 	//Define property for cancel operation.
       
   135     static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
   136     static _LIT_SECURITY_POLICY_C1(KAllowWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
       
   137 	RProperty::Define( KPSUidNSmlDSSyncApp,KDsJobCancel,RProperty::EInt,
       
   138 	        KAllowAllPolicy,KAllowWriteDeviceDataPolicy); 
       
   139 	RProperty::Set( KPSUidNSmlDSSyncApp,
       
   140 	            KDsJobCancel, KErrNone );   
   132 	FLOG( _L("CAspSyncHandler::ConstructL END") );
   141 	FLOG( _L("CAspSyncHandler::ConstructL END") );
   133     }
   142     }
   134 
   143 
   135 
   144 
   136 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   177     TBool syncRunning = SyncRunning();
   186     TBool syncRunning = SyncRunning();
   178     
   187     
   179 	//  close handling (eg. end key)
   188 	//  close handling (eg. end key)
   180 	if (aButtonId == EKeyPhoneEnd && syncRunning)
   189 	if (aButtonId == EKeyPhoneEnd && syncRunning)
   181 		{
   190 		{
       
   191         //Set Cancel  property when user cancel the Caopy All from Server. 
       
   192 		RProperty::Set( KPSUidNSmlDSSyncApp,
       
   193 		                KDsJobCancel, KErrCancel );
   182 		TRAPD(err, iSyncJob.StopL());
   194 		TRAPD(err, iSyncJob.StopL());
   183 
   195 
   184 		if (err != KErrNone)
   196 		if (err != KErrNone)
   185 			{
   197 			{
   186 			FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err );
   198 			FLOG( _L("### RSyncMLDataSyncJob::StopL failed (%d) ###"), err );
   204 		}
   216 		}
   205 		
   217 		
   206 	// cancel key handling
   218 	// cancel key handling
   207 	if (aButtonId == EEikBidCancel && syncRunning)
   219 	if (aButtonId == EEikBidCancel && syncRunning)
   208 		{
   220 		{
       
   221         RProperty::Set( KPSUidNSmlDSSyncApp,
       
   222                 KDsJobCancel, KErrCancel );
       
   223     
   209 		if (iStopEventReceived)
   224 		if (iStopEventReceived)
   210 			{
   225 			{
   211 			CompleteWithDelay(KErrNone);
   226 			CompleteWithDelay(KErrNone);
   212         	FLOG( _L("### EJobStop already received ###") );
   227         	FLOG( _L("### EJobStop already received ###") );
   213         	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
   228         	FLOG( _L("CAspSyncHandler::HandleDialogEventL END") );
   417 //
   432 //
   418 void CAspSyncHandler::DoSynchronizeL(TAspSyncParam& aSyncParam)
   433 void CAspSyncHandler::DoSynchronizeL(TAspSyncParam& aSyncParam)
   419 	{
   434 	{
   420 	FLOG( _L("CAspSyncHandler::DoSynchronizeL START") );
   435 	FLOG( _L("CAspSyncHandler::DoSynchronizeL START") );
   421     
   436     
       
   437 	 //set the cancel Pub sub key to none
       
   438 	if(aSyncParam.iSyncDirection == ESyncDirectionRefreshFromServer)
       
   439 	    {
       
   440 	    RProperty::Set( KPSUidNSmlDSSyncApp,
       
   441 	            KDsJobCancel, KErrNone );
       
   442 	    }
   422 	iApplicationId = aSyncParam.iApplicationId;
   443 	iApplicationId = aSyncParam.iApplicationId;
   423 	iProfileId = aSyncParam.iProfileId;
   444 	iProfileId = aSyncParam.iProfileId;
   424 	if (aSyncParam.iDialogMode == EModeDialogWait)
   445 	if (aSyncParam.iDialogMode == EModeDialogWait)
   425 		{
   446 		{
   426 		iIsSynchronousOperation = ETrue; // email 3.2 needs synchronous syncing
   447 		iIsSynchronousOperation = ETrue; // email 3.2 needs synchronous syncing
   489 void CAspSyncHandler::SynchronizeCompleted(TInt aError)
   510 void CAspSyncHandler::SynchronizeCompleted(TInt aError)
   490 	{
   511 	{
   491 	FLOG( _L("CAspSyncHandler::SynchronizeCompleted START") );
   512 	FLOG( _L("CAspSyncHandler::SynchronizeCompleted START") );
   492 	
   513 	
   493 	iSyncRunning = EFalse;
   514 	iSyncRunning = EFalse;
   494 	
   515 	RProperty::Set( KPSUidNSmlDSSyncApp,
       
   516 	                           KDsJobCancel, KErrNone ); 
   495 	if (aError != KErrNone)
   517 	if (aError != KErrNone)
   496 		{
   518 		{
   497 		iSyncError = aError;
   519 		iSyncError = aError;
   498 		}
   520 		}
   499    	
   521    	
   548     	return; // not our sync job
   570     	return; // not our sync job
   549     	}
   571     	}
   550 	
   572 	
   551 	if (aEvent == EJobStop)
   573 	if (aEvent == EJobStop)
   552 		{
   574 		{
       
   575 		RProperty::Set( KPSUidNSmlDSSyncApp,
       
   576 		                            KDsJobCancel, KErrNone );   
       
   577 		
   553 		iStopEventReceived = ETrue;
   578 		iStopEventReceived = ETrue;
   554 		if (aError != KErrNone)
   579 		if (aError != KErrNone)
   555 			{
   580 			{
   556 			iSyncError = aError;
   581 			iSyncError = aError;
   557 			}
   582 			}
   566 		    }
   591 		    }
   567 		}
   592 		}
   568     	
   593     	
   569 	if (aEvent == EJobStartFailed || aEvent == EJobRejected)
   594 	if (aEvent == EJobStartFailed || aEvent == EJobRejected)
   570 		{
   595 		{
       
   596 		RProperty::Set( KPSUidNSmlDSSyncApp,
       
   597 		                            KDsJobCancel, KErrNone );   
   571 		CompleteWithDelay(aError);
   598 		CompleteWithDelay(aError);
   572 		}
   599 		}
   573 		
   600 		
   574 	FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") );
   601 	FLOG( _L("CAspSyncHandler::OnSyncMLSessionEvent END") );
   575     }
   602     }