omadm/omadmappui/src/NSmlDMSyncHandler.cpp
changeset 8 0a8136f75056
parent 0 3ce708148e4d
child 40 f2101057ffeb
equal deleted inserted replaced
4:75a71fdb4c92 8:0a8136f75056
    26 #include <e32property.h>
    26 #include <e32property.h>
    27 
    27 
    28 #include <data_caging_path_literals.hrh>  // for resource and bitmap directories
    28 #include <data_caging_path_literals.hrh>  // for resource and bitmap directories
    29 #include <SyncMLErr.h>      // sync error codes
    29 #include <SyncMLErr.h>      // sync error codes
    30 
    30 
    31 
    31 #include <e32property.h>
    32 #include <AknsUtils.h>
    32 #include <AknsUtils.h>
    33 #include <DevManInternalCRKeys.h>
    33 #include <DevManInternalCRKeys.h>
    34 #include <centralrepository.h>
    34 #include <centralrepository.h>
    35 
    35 
    36 #include "NSmlDMSyncDocument.h"
    36 #include "NSmlDMSyncDocument.h"
    47 _LIT( KBitmapFileName,  "z:nsmldmsync.mif" );
    47 _LIT( KBitmapFileName,  "z:nsmldmsync.mif" );
    48 #else
    48 #else
    49 _LIT( KBitmapFileName,  "z:nsmldmsync.mbm" );
    49 _LIT( KBitmapFileName,  "z:nsmldmsync.mbm" );
    50 #endif
    50 #endif
    51 
    51 
       
    52 const TInt KRequestTriggerWaitTime(1000);
    52 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    53 // CNSmlDMSyncHandler::NewL
    54 // CNSmlDMSyncHandler::NewL
    54 //
    55 //
    55 // Two-phased constructor.
    56 // Two-phased constructor.
    56 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
   161 	        UpdateDialogL();
   162 	        UpdateDialogL();
   162 			}
   163 			}
   163 		}
   164 		}
   164     FLOG( "CNSmlDMSyncHandler::HandleDialogEventL() completed" );
   165     FLOG( "CNSmlDMSyncHandler::HandleDialogEventL() completed" );
   165     }
   166     }
   166 
   167 // ----------------------------------------------------------------------------------------
       
   168 // StaticSynchronizeRequestL() called to start Synchronization
       
   169 // ----------------------------------------------------------------------------------------
       
   170 static TInt StaticSynchronizeRequestL(TAny* aPtr)
       
   171     {
       
   172     CNSmlDMSyncHandler* ptr = (CNSmlDMSyncHandler*) aPtr;
       
   173     FLOG("StaticSynchronizeRequestL");   
       
   174     TRAPD(err, ptr->StartSynchronizeL() );  
       
   175     FLOG("StaticSynchronizeRequestL completed");
       
   176     return err;
       
   177     }
   167 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   168 // CNSmlDMSyncHandler::SynchronizeL
   179 // CNSmlDMSyncHandler::SynchronizeL
   169 // -----------------------------------------------------------------------------
   180 // -----------------------------------------------------------------------------
   170 //
   181 //
   171 void CNSmlDMSyncHandler::SynchronizeL( TDesC& aServerName,
   182 void CNSmlDMSyncHandler::SynchronizeL( TDesC& aServerName,
   172                                        const TInt aProfileId,
   183                                        const TInt aProfileId,
   173                                        const TInt aJobId,
   184                                        const TInt aJobId,
   174                                        const TInt aConnectionBearer,
   185                                        const TInt aConnectionBearer,
   175                                        const TBool aUseFotaProgressNote )
   186                                        const TBool aUseFotaProgressNote, 
       
   187                                        const TBool aSilent)
   176 	{
   188 	{
   177 	FLOG( "CNSmlDMSyncHandler::SynchronizeL Server alert" );
   189 	FLOG( "CNSmlDMSyncHandler::SynchronizeL Server alert" );
   178 	
   190 	
   179 	iServerName = aServerName;
   191 	iServerName = aServerName;
   180 	iConnectionBearer = aConnectionBearer;
   192 	iConnectionBearer = aConnectionBearer;
   181     iProfileId = aProfileId;
   193     iProfileId = aProfileId;
   182     iJobId = aJobId;
   194     iJobId = aJobId;
   183     iUseFotaProgressNote = aUseFotaProgressNote;
   195     iUseFotaProgressNote = aUseFotaProgressNote;
   184     
   196     iSilent = aSilent;
   185     iSyncJob.OpenL( Session(), iJobId );
   197     iSyncJob.OpenL( Session(), iJobId );
   186     iSyncJobId = iSyncJob.Identifier();
   198     iSyncJobId = iSyncJob.Identifier();
   187     FTRACE( FPrint( _L(
   199     FTRACE( FPrint( _L(
   188 	    "[OMADM]\tCNSmlDMSyncHandler::SynchronizeL--server alert, iSyncJobId = %d" ),
   200 	    "[OMADM]\tCNSmlDMSyncHandler::SynchronizeL--server alert, iSyncJobId = %d" ),
   189 	     iSyncJobId ) ); 
   201 	     iSyncJobId ) ); 
   242 	     iSyncJobId ) );    
   254 	     iSyncJobId ) );    
   243     RProperty::Set( KPSUidNSmlDMSyncApp,
   255     RProperty::Set( KPSUidNSmlDMSyncApp,
   244                     KNSmlDMSyncUiInitiatedJobKey,
   256                     KNSmlDMSyncUiInitiatedJobKey,
   245                     iSyncJobId );
   257                     iSyncJobId );
   246 	}
   258 	}
   247 	
   259 
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CNSmlDMSyncHandler::StartSynchronizeL
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 void CNSmlDMSyncHandler::StartSynchronizeL()
       
   266     {
       
   267     FLOG( "CNSmlDMSyncHandler::StartSynchronizeL" );
       
   268     if(iPeriodic)
       
   269        {
       
   270        delete iPeriodic;
       
   271        iPeriodic = NULL;
       
   272        FLOG("CNSmlDMSyncHandler::iPeriodic-deleted");
       
   273        }
       
   274     const TUid KDisclaimerProperty = {0x101F8769};
       
   275     const TUint32 KInteger = 0x00000001;
       
   276     TInt propValue;
       
   277     TInt err = KErrNone;
       
   278     
       
   279     if(iSilent == EFalse)   //disclaimer shown for non silent session
       
   280         {
       
   281         if(TUtil::ShowNativeDialogL(EPrivacyPolicy)==KErrNone)
       
   282             {
       
   283             TRAP( err, ShowProgressDialogL() );
       
   284             if ( err != KErrNone )
       
   285                 {
       
   286                 Session().CancelEvent();
       
   287                 Session().CancelProgress();
       
   288                 iSyncJob.StopL();
       
   289                 iSyncJob.Close();
       
   290                 propValue = 0;
       
   291                 RProperty::Set(KDisclaimerProperty, KInteger, propValue);
       
   292                 User::Leave( err );
       
   293                 }
       
   294             FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" );
       
   295 
       
   296             // Publish key here; set to 1
       
   297             propValue = 1;
       
   298             RProperty::Set(KDisclaimerProperty, KInteger, propValue);
       
   299             }
       
   300         else
       
   301             {
       
   302             Session().CancelEvent();
       
   303             Session().CancelProgress();
       
   304             propValue = 0;
       
   305             RProperty::Set(KDisclaimerProperty, KInteger, propValue);            
       
   306             }
       
   307         }
       
   308     else    //for silent session, disclaimer not shown
       
   309         {
       
   310         TRAP( err, ShowProgressDialogL() );
       
   311         if ( err != KErrNone )
       
   312             {
       
   313             Session().CancelEvent();
       
   314             Session().CancelProgress();
       
   315             iSyncJob.StopL();
       
   316             iSyncJob.Close();
       
   317             propValue = 0;
       
   318             RProperty::Set(KDisclaimerProperty, KInteger, propValue);
       
   319             User::Leave( err );
       
   320             }
       
   321          FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" );
       
   322 
       
   323             // Publish key here; set to 1
       
   324          propValue = 1;
       
   325          RProperty::Set(KDisclaimerProperty, KInteger, propValue);
       
   326         }
       
   327      
       
   328      iSyncDocument->MarkFwUpdChangesStartL();
       
   329      
       
   330      iSyncRunning = ETrue;
       
   331      iSyncError = KErrNone;
       
   332      FLOG( "CNSmlDMSyncHandler::StartSynchronizeL completed" );
       
   333     }
   248 // -----------------------------------------------------------------------------
   334 // -----------------------------------------------------------------------------
   249 // CNSmlDMSyncHandler::SynchronizeL
   335 // CNSmlDMSyncHandler::SynchronizeL
   250 // -----------------------------------------------------------------------------
   336 // -----------------------------------------------------------------------------
   251 //
   337 //
   252 void CNSmlDMSyncHandler::SynchronizeL()
   338 void CNSmlDMSyncHandler::SynchronizeL()
   280 	if (IsDMBusy)
   366 	if (IsDMBusy)
   281 	   iNotinFotaView = 1;    //Not in fota view 
   367 	   iNotinFotaView = 1;    //Not in fota view 
   282 	else
   368 	else
   283 	   iNotinFotaView = 0;    //already busy because in other view
   369 	   iNotinFotaView = 0;    //already busy because in other view
   284 	IsDMBusy =ETrue; 
   370 	IsDMBusy =ETrue; 
   285   r2=RProperty::Set(KUidSmlSyncApp,KDMIdle,IsDMBusy);	   
   371   r2=RProperty::Set(KUidSmlSyncApp,KDMIdle,IsDMBusy);	
   286 	
   372   
   287 	TRAP( err, ShowProgressDialogL() );
   373 	if(iServerAlertedSync)
   288 	if ( err != KErrNone )
   374 		{
   289 		{
   375         iPeriodic = CPeriodic::NewL (EPriorityNormal) ;
   290 		Session().CancelEvent();
   376         FLOG("CNSmlDMSyncHandler::SynchronizeL: iPeriodic created)");
   291 		Session().CancelProgress();
   377         iPeriodic->Start(TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*20)
   292 		iSyncJob.StopL();
   378                   , TTimeIntervalMicroSeconds32(KRequestTriggerWaitTime*2500)
   293 		iSyncJob.Close();
   379                   , TCallBack(StaticSynchronizeRequestL,this) ) ;
   294 		User::Leave( err );
   380 		}
   295 		}
   381 	else
   296 	FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" );
   382 	    {//For user initiated session
   297 
   383 		TRAP( err, ShowProgressDialogL() );
   298     iSyncDocument->MarkFwUpdChangesStartL();
   384 		if ( err != KErrNone )
   299 	
   385 		    {
   300 	iSyncRunning = ETrue;
   386             Session().CancelEvent();
   301 	iSyncError = KErrNone;
   387             Session().CancelProgress();
       
   388             iSyncJob.StopL();
       
   389             iSyncJob.Close();
       
   390             User::Leave( err );
       
   391 		    }
       
   392 		FLOG( "CNSmlDMSyncHandler::SynchronizeL Sync is running" );
       
   393 	    iSyncDocument->MarkFwUpdChangesStartL();
       
   394 	    
       
   395 	    iSyncRunning = ETrue;
       
   396 	    iSyncError = KErrNone;
       
   397 		}
       
   398 
   302 	}
   399 	}
   303 
   400 
   304 // -----------------------------------------------------------------------------
   401 // -----------------------------------------------------------------------------
   305 // CNSmlDMSyncHandler::SynchronizeCompletedL
   402 // CNSmlDMSyncHandler::SynchronizeCompletedL
   306 // -----------------------------------------------------------------------------
   403 // -----------------------------------------------------------------------------