syncmlfw/common/sosserver/src/nsmlsosthread.cpp
branchRCL_3
changeset 24 13d7c31c74e0
parent 0 b497e44ab2fc
child 25 b183ec05bd8c
equal deleted inserted replaced
23:4af31167ea77 24:13d7c31c74e0
   145 void CNSmlThreadEngine::ConstructL()
   145 void CNSmlThreadEngine::ConstructL()
   146 	{
   146 	{
   147 		FeatureManager::InitializeLibL();
   147 		FeatureManager::InitializeLibL();
   148 	iThreadParams.iThreadEngine = this;
   148 	iThreadParams.iThreadEngine = this;
   149 	iContentArray = new(ELeave) CArrayFixFlat<TNSmlContentSpecificSyncType>(1);
   149 	iContentArray = new(ELeave) CArrayFixFlat<TNSmlContentSpecificSyncType>(1);
   150 	
   150 	// Fix for cancel not happening when cancel key is
       
   151 	// pressed .
       
   152 	iSyncCancelled = EFalse;
   151 	if ( iThreadParams.iCSArray )
   153 	if ( iThreadParams.iCSArray )
   152 		{
   154 		{
   153 		for (TInt i = 0; i < iThreadParams.iCSArray->Count(); i++)
   155 		for (TInt i = 0; i < iThreadParams.iCSArray->Count(); i++)
   154 			{
   156 			{
   155 			TNSmlContentSpecificSyncType type;
   157 			TNSmlContentSpecificSyncType type;
   335 		}
   337 		}
   336 		
   338 		
   337 	TInt status( KErrNone );			
   339 	TInt status( KErrNone );			
   338 	if ( iThreadParams.iCurrentJob.UsageType() == ESmlDevMan )
   340 	if ( iThreadParams.iCurrentJob.UsageType() == ESmlDevMan )
   339 		{
   341 		{
       
   342 		CRepository* centrep = NULL;
       
   343 		TRAPD( err, centrep = CRepository::NewL(KCRUidDeviceManagementInternalKeys));  
       
   344 		TInt phoneLock(0);
       
   345 		TInt factoryProfileID(0);
       
   346 		if (err==KErrNone ) 
       
   347 		{
       
   348 			TInt err = centrep->Get( KLAWMOPhoneLock , phoneLock );
       
   349 			err = centrep->Get( KLAWMOfactoryDmProfileID , factoryProfileID );
       
   350 			delete centrep;
       
   351 			centrep = NULL;
       
   352 		}
       
   353 		if(phoneLock != 30)
       
   354 		{
       
   355 			_DBG_FILE("CNSmlThreadEngine phonelock != 30");
       
   356 			if(factoryProfileID>0)   
       
   357 			{   
       
   358 
       
   359 				TInt profileId = iThreadParams.iCurrentJob.ProfileId();    
       
   360 	
       
   361 				if(profileId!= factoryProfileID) 
       
   362 					{
       
   363 					   _DBG_FILE("CNSmlThreadEngine profid doesnt match with factory");
       
   364 					   TRequestStatus* stat = &iStatus;
       
   365 					   User::RequestComplete( stat, KErrNone );
       
   366 					   return;
       
   367 					}   
       
   368 			
       
   369 			}
       
   370 			else
       
   371 				{
       
   372 				    _DBG_FILE("CNSmlThreadEngine factoryprofileid<0");
       
   373 				    TRequestStatus* stat = &iStatus;
       
   374 					User::RequestComplete( stat, KErrNone );
       
   375 					return;	
       
   376 				}
       
   377 		}
       
   378 		_DBG_FILE("CNSmlThreadEngine startDMSessionL");
   340 		TRAP( status, StartDMSessionL() );
   379 		TRAP( status, StartDMSessionL() );
   341 		}
   380 		}
   342 	else
   381 	else
   343 		{
   382 		{
   344 		TRAP( status, StartDSSessionL() );	
   383 		// Scenario 1:
       
   384 		// Fix for cancel not happening when cancel key is
       
   385 		// pressed .
       
   386         if(!iSyncCancelled)
       
   387             {
       
   388             TRAP( status, StartDSSessionL() );	
       
   389             }
       
   390         else
       
   391             {
       
   392 			// Sync is cancelled from the UI before the
       
   393 			// the job session has started.
       
   394 			// Fix for cancel not happening when cancel key is
       
   395 			// pressed .
       
   396             status = KErrCancel;
       
   397             iSyncCancelled = EFalse;
       
   398             }
   345 		}
   399 		}
   346 	
   400 	
   347 	if ( status != KErrNone )
   401 	if ( status != KErrNone )
   348 	    {
   402 	    {
   349 	   	TRequestStatus* sStatus = &iStatus;
   403 	   	TRequestStatus* sStatus = &iStatus;
   357 // Cancel current running job
   411 // Cancel current running job
   358 // --------------------------------------------------------------------------
   412 // --------------------------------------------------------------------------
   359 //
   413 //
   360 void CNSmlThreadEngine::CancelJob()
   414 void CNSmlThreadEngine::CancelJob()
   361 	{
   415 	{
       
   416 	// Fix for cancel not happening when cancel key is
       
   417 	// pressed .
       
   418     // job has been created but it is not running and from ui
       
   419     // Cancel has been called
       
   420     iSyncCancelled = ETrue;
   362 	if ( iCancelTimeout )
   421 	if ( iCancelTimeout )
   363 	    {
   422 	    {
   364 		iCancelTimeout->SetJobCancelled( iThreadParams.iCurrentJob.UsageType() );
   423 		iCancelTimeout->SetJobCancelled( iThreadParams.iCurrentJob.UsageType() );
   365 	    }	
   424 	    }	
   366 	}
   425 	}
   407 	
   466 	
   408 	iCancelTimeout = new (ELeave) CNSmlCancelTimeOut( *iDMAgent, *iDSAgent );
   467 	iCancelTimeout = new (ELeave) CNSmlCancelTimeOut( *iDMAgent, *iDSAgent );
   409 	
   468 	
   410 	// Select correct sync method and start sync
   469 	// Select correct sync method and start sync
   411 	TNSmlSyncInitiation syncInit = (TNSmlSyncInitiation)iThreadParams.iSyncInit;
   470 	TNSmlSyncInitiation syncInit = (TNSmlSyncInitiation)iThreadParams.iSyncInit;
   412 	
   471 	// Scenario 2:
       
   472 	// Fix for cancel not happening when cancel key is
       
   473 	// pressed .
       
   474 	if(iSyncCancelled)
       
   475 	    {
       
   476 	    iSyncCancelled = EFalse;
       
   477         User::Leave( KErrCancel );
       
   478 	    }
       
   479 
   413     switch ( iThreadParams.iCurrentJob.JobType() )
   480     switch ( iThreadParams.iCurrentJob.JobType() )
   414         {
   481         {
   415         case EDSJobProfile:
   482         case EDSJobProfile:
   416             iDSAgent->Synchronise( iStatus, iThreadParams.iCurrentJob.ProfileId(), KNSmlNullId, NULL, syncInit );
   483             iDSAgent->Synchronise( iStatus, iThreadParams.iCurrentJob.ProfileId(), KNSmlNullId, NULL, syncInit );
   417             break;           
   484             break;