syncmlfw/ds/syncagent/src/nsmldsagent.cpp
branchRCL_3
changeset 13 06f47423ecee
parent 9 57a65a3a658c
child 30 2de6635c154b
equal deleted inserted replaced
9:57a65a3a658c 13:06f47423ecee
    40 #include "nsmldscontent.h"
    40 #include "nsmldscontent.h"
    41 #include "nsmldserror.h"
    41 #include "nsmldserror.h"
    42 #include "nsmldssettings.h"
    42 #include "nsmldssettings.h"
    43 #include "nsmlagentlog.h"
    43 #include "nsmlagentlog.h"
    44 #include "nsmlroam.h"
    44 #include "nsmlroam.h"
       
    45 #include "NsmlOperatorErrorCRKeys.h"
    45 //RD_AUTO_RESTART
    46 //RD_AUTO_RESTART
    46 #include <e32base.h>
    47 #include <e32base.h>
    47 #include <centralrepository.h> 
    48 #include <centralrepository.h> 
    48 #include "SyncMLErr.h"
    49 #include "SyncMLErr.h"
    49 #include "nsmldsconstants.h"
    50 #include "nsmldsconstants.h"
    57 // This lowers the unnecessary compiler warning (armv5) to remark.
    58 // This lowers the unnecessary compiler warning (armv5) to remark.
    58 // "Warning:  #174-D: expression has no effect..." is caused by 
    59 // "Warning:  #174-D: expression has no effect..." is caused by 
    59 // DBG_ARGS8 macro in no-debug builds.
    60 // DBG_ARGS8 macro in no-debug builds.
    60 #pragma diag_remark 174
    61 #pragma diag_remark 174
    61 #endif
    62 #endif
       
    63 
       
    64 // CONSTANTS
       
    65 const TInt KNSmlDsHTTPErrCodeBase = 1400;
       
    66 const TInt KNSmlDsHTTPErrCodeRangeFirst = 1800;
       
    67 const TInt KNSmlDsHTTPErrCodeRangeLast = 1905;
    62 
    68 
    63 // ============================ MEMBER FUNCTIONS ===============================
    69 // ============================ MEMBER FUNCTIONS ===============================
    64 
    70 
    65 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    66 // CNSmlDSAgent::CNSmlDSAgent
    72 // CNSmlDSAgent::CNSmlDSAgent
  1676         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1682         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1677                         KDataSyncStatus,
  1683                         KDataSyncStatus,
  1678                         EDataSyncRunning12 );	    
  1684                         EDataSyncRunning12 );	    
  1679         }
  1685         }
  1680     
  1686     
       
  1687 	CRepository* rep = NULL;
       
  1688 	TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
       
  1689 	if ( err == KErrNone )
       
  1690 	    {
       
  1691 	    rep->Set( KNsmlOpDsErrorCode, KErrNone );
       
  1692 	    rep->Set( KNsmlOpDsSyncProfUid, profile->IntValue( EDSProfileId ) );
       
  1693 	    rep->Set( KNsmlOpDsSyncInitiation, iSyncInitiation );
       
  1694 
       
  1695 	    delete rep;
       
  1696 	    }
  1681 
  1697 
  1682 	TBool ifInternet = ETrue ; // CR: 403-1188
  1698 	TBool ifInternet = ETrue ; // CR: 403-1188
  1683 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1699 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1684 		{
  1700 		{
  1685 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  1701 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  2920 		iSyncLog = NULL;
  2936 		iSyncLog = NULL;
  2921 		}
  2937 		}
  2922     
  2938     
  2923     // Set sync stopped to P&S
  2939     // Set sync stopped to P&S
  2924     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
  2940     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
       
  2941   
       
  2942     CRepository* rep = NULL;
       
  2943     TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
       
  2944     if ( err == KErrNone )
       
  2945         {
       
  2946         rep->Set( KNsmlOpDsSyncInitiation, EDataSyncNotRunning );
       
  2947         delete rep;
       
  2948         }
  2925 	
  2949 	
  2926 	ResetDSSessionInfoL();
  2950 	ResetDSSessionInfoL();
  2927 	}
  2951 	}
  2928 
  2952 
  2929 // -----------------------------------------------------------------------------
  2953 // -----------------------------------------------------------------------------
  3084 			
  3108 			
  3085 		default:
  3109 		default:
  3086 			error = ETrue;
  3110 			error = ETrue;
  3087 		}
  3111 		}
  3088 		
  3112 		
       
  3113     // Store status code to cenrep in case of error
       
  3114     if ( error )
       
  3115         {
       
  3116         CRepository* rep = NULL;
       
  3117         TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
       
  3118         if ( err == KErrNone )
       
  3119             {
       
  3120             rep->Set( KNsmlOpDsErrorCode, status );
       
  3121             delete rep;
       
  3122             }       
       
  3123         }
       
  3124         
  3089 	if ( cmd == KNSmlAgentSyncHdr )
  3125 	if ( cmd == KNSmlAgentSyncHdr )
  3090 		{
  3126 		{
  3091 		SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID );
  3127 		SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID );
  3092 		}
  3128 		}
  3093 		
  3129 		
  3420 //
  3456 //
  3421 void CNSmlDSAgent::FinaliseWhenErrorL()
  3457 void CNSmlDSAgent::FinaliseWhenErrorL()
  3422 	{
  3458 	{
  3423 	DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins"));
  3459 	DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins"));
  3424 	
  3460 	
       
  3461 	// Store error code to cenrep
       
  3462 	CRepository* rep = NULL;
       
  3463 	TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
       
  3464 	if ( err == KErrNone )
       
  3465 	    {
       
  3466 	    TInt errCode = iError->SyncLogErrorCode();
       
  3467 
       
  3468 	    if ( errCode >= KNSmlDsHTTPErrCodeRangeFirst && 
       
  3469 	       errCode <= KNSmlDsHTTPErrCodeRangeLast )
       
  3470 	       {
       
  3471 	       errCode -= KNSmlDsHTTPErrCodeBase;
       
  3472 	       }
       
  3473 
       
  3474 	    rep->Set( KNsmlOpDsErrorCode, errCode );
       
  3475 	    delete rep;
       
  3476 	    }
       
  3477 
  3425 // <MAPINFO_RESEND_MOD_BEGIN>
  3478 // <MAPINFO_RESEND_MOD_BEGIN>
  3426 	if( iDSContent->ResendUsed() )
  3479 	if( iDSContent->ResendUsed() )
  3427 		{
  3480 		{
  3428 		DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL - calling iDSContent->PackupRequestL..."));
  3481 		DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL - calling iDSContent->PackupRequestL..."));
  3429 		iDSContent->PackupRequestL( iDSClientNextSyncAnchor );
  3482 		iDSContent->PackupRequestL( iDSClientNextSyncAnchor );