diff -r 75a71fdb4c92 -r db6d61d7814f omadm/omadmappui/src/NSmlDMSyncHandler.cpp --- a/omadm/omadmappui/src/NSmlDMSyncHandler.cpp Tue Feb 02 00:03:17 2010 +0200 +++ b/omadm/omadmappui/src/NSmlDMSyncHandler.cpp Fri Feb 19 22:41:42 2010 +0200 @@ -28,7 +28,7 @@ #include // for resource and bitmap directories #include // sync error codes - +#include #include #include #include @@ -49,6 +49,7 @@ _LIT( KBitmapFileName, "z:nsmldmsync.mbm" ); #endif +const TInt KRequestTriggerWaitTime(1000); // ----------------------------------------------------------------------------- // CNSmlDMSyncHandler::NewL // @@ -163,7 +164,17 @@ } FLOG( "CNSmlDMSyncHandler::HandleDialogEventL() completed" ); } - +// ---------------------------------------------------------------------------------------- +// StaticSynchronizeRequestL() called to start Synchronization +// ---------------------------------------------------------------------------------------- +static TInt StaticSynchronizeRequestL(TAny* aPtr) + { + CNSmlDMSyncHandler* ptr = (CNSmlDMSyncHandler*) aPtr; + FLOG("StaticSynchronizeRequestL"); + TRAPD(err, ptr->StartSynchronizeL() ); + FLOG("StaticSynchronizeRequestL completed"); + return err; + } // ----------------------------------------------------------------------------- // CNSmlDMSyncHandler::SynchronizeL // ----------------------------------------------------------------------------- @@ -172,7 +183,8 @@ const TInt aProfileId, const TInt aJobId, const TInt aConnectionBearer, - const TBool aUseFotaProgressNote ) + const TBool aUseFotaProgressNote, + const TBool aSilent) { FLOG( "CNSmlDMSyncHandler::SynchronizeL Server alert" ); @@ -181,7 +193,7 @@ iProfileId = aProfileId; iJobId = aJobId; iUseFotaProgressNote = aUseFotaProgressNote; - + iSilent = aSilent; iSyncJob.OpenL( Session(), iJobId ); iSyncJobId = iSyncJob.Identifier(); FTRACE( FPrint( _L( @@ -244,7 +256,81 @@ KNSmlDMSyncUiInitiatedJobKey, iSyncJobId ); } - + + +// ----------------------------------------------------------------------------- +// CNSmlDMSyncHandler::StartSynchronizeL +// ----------------------------------------------------------------------------- +// +void CNSmlDMSyncHandler::StartSynchronizeL() + { + FLOG( "CNSmlDMSyncHandler::StartSynchronizeL" ); + if(iPeriodic) + { + delete iPeriodic; + iPeriodic = NULL; + FLOG("CNSmlDMSyncHandler::iPeriodic-deleted"); + } + const TUid KDisclaimerProperty = {0x101F8769}; + const TUint32 KInteger = 0x00000001; + TInt propValue; + TInt err = KErrNone; + + if(iSilent == EFalse) //disclaimer shown for non silent session + { + if(TUtil::ShowNativeDialogL(EPrivacyPolicy)==KErrNone) + { + TRAP( err, ShowProgressDialogL() ); + if ( err != KErrNone ) + { + Session().CancelEvent(); + Session().CancelProgress(); + iSyncJob.StopL(); + iSyncJob.Close(); + propValue = 0; + RProperty::Set(KDisclaimerProperty, KInteger, propValue); + User::Leave( err ); + } + FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" ); + + // Publish key here; set to 1 + propValue = 1; + RProperty::Set(KDisclaimerProperty, KInteger, propValue); + } + else + { + Session().CancelEvent(); + Session().CancelProgress(); + propValue = 0; + RProperty::Set(KDisclaimerProperty, KInteger, propValue); + } + } + else //for silent session, disclaimer not shown + { + TRAP( err, ShowProgressDialogL() ); + if ( err != KErrNone ) + { + Session().CancelEvent(); + Session().CancelProgress(); + iSyncJob.StopL(); + iSyncJob.Close(); + propValue = 0; + RProperty::Set(KDisclaimerProperty, KInteger, propValue); + User::Leave( err ); + } + FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" ); + + // Publish key here; set to 1 + propValue = 1; + RProperty::Set(KDisclaimerProperty, KInteger, propValue); + } + + iSyncDocument->MarkFwUpdChangesStartL(); + + iSyncRunning = ETrue; + iSyncError = KErrNone; + FLOG( "CNSmlDMSyncHandler::StartSynchronizeL completed" ); + } // ----------------------------------------------------------------------------- // CNSmlDMSyncHandler::SynchronizeL // ----------------------------------------------------------------------------- @@ -282,23 +368,34 @@ else iNotinFotaView = 0; //already busy because in other view IsDMBusy =ETrue; - r2=RProperty::Set(KUidSmlSyncApp,KDMIdle,IsDMBusy); - - TRAP( err, ShowProgressDialogL() ); - if ( err != KErrNone ) + r2=RProperty::Set(KUidSmlSyncApp,KDMIdle,IsDMBusy); + + if(iServerAlertedSync) { - Session().CancelEvent(); - Session().CancelProgress(); - iSyncJob.StopL(); - iSyncJob.Close(); - User::Leave( err ); + iPeriodic = CPeriodic::NewL (EPriorityNormal) ; + FLOG("CNSmlDMSyncHandler::SynchronizeL: iPeriodic created)"); + iPeriodic->Start(TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*20) + , TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*2500) + , TCallBack(StaticSynchronizeRequestL,this) ) ; } - FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" ); + else + {//For user initiated session + TRAP( err, ShowProgressDialogL() ); + if ( err != KErrNone ) + { + Session().CancelEvent(); + Session().CancelProgress(); + iSyncJob.StopL(); + iSyncJob.Close(); + User::Leave( err ); + } + FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" ); + iSyncDocument->MarkFwUpdChangesStartL(); + + iSyncRunning = ETrue; + iSyncError = KErrNone; + } - iSyncDocument->MarkFwUpdChangesStartL(); - - iSyncRunning = ETrue; - iSyncError = KErrNone; } // -----------------------------------------------------------------------------