syncmlfw/ds/syncagent/src/nsmldsagent.cpp
branchRCL_3
changeset 11 06f47423ecee
parent 9 57a65a3a658c
child 18 2de6635c154b
--- a/syncmlfw/ds/syncagent/src/nsmldsagent.cpp	Fri Feb 19 23:41:35 2010 +0200
+++ b/syncmlfw/ds/syncagent/src/nsmldsagent.cpp	Fri Mar 12 15:46:48 2010 +0200
@@ -42,6 +42,7 @@
 #include "nsmldssettings.h"
 #include "nsmlagentlog.h"
 #include "nsmlroam.h"
+#include "NsmlOperatorErrorCRKeys.h"
 //RD_AUTO_RESTART
 #include <e32base.h>
 #include <centralrepository.h> 
@@ -60,6 +61,11 @@
 #pragma diag_remark 174
 #endif
 
+// CONSTANTS
+const TInt KNSmlDsHTTPErrCodeBase = 1400;
+const TInt KNSmlDsHTTPErrCodeRangeFirst = 1800;
+const TInt KNSmlDsHTTPErrCodeRangeLast = 1905;
+
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -1678,6 +1684,16 @@
                         EDataSyncRunning12 );	    
         }
     
+	CRepository* rep = NULL;
+	TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
+	if ( err == KErrNone )
+	    {
+	    rep->Set( KNsmlOpDsErrorCode, KErrNone );
+	    rep->Set( KNsmlOpDsSyncProfUid, profile->IntValue( EDSProfileId ) );
+	    rep->Set( KNsmlOpDsSyncInitiation, iSyncInitiation );
+
+	    delete rep;
+	    }
 
 	TBool ifInternet = ETrue ; // CR: 403-1188
 	if ( iMediumType == KUidNSmlMediumTypeInternet )
@@ -2922,6 +2938,14 @@
     
     // Set sync stopped to P&S
     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
+  
+    CRepository* rep = NULL;
+    TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
+    if ( err == KErrNone )
+        {
+        rep->Set( KNsmlOpDsSyncInitiation, EDataSyncNotRunning );
+        delete rep;
+        }
 	
 	ResetDSSessionInfoL();
 	}
@@ -3086,6 +3110,18 @@
 			error = ETrue;
 		}
 		
+    // Store status code to cenrep in case of error
+    if ( error )
+        {
+        CRepository* rep = NULL;
+        TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
+        if ( err == KErrNone )
+            {
+            rep->Set( KNsmlOpDsErrorCode, status );
+            delete rep;
+            }       
+        }
+        
 	if ( cmd == KNSmlAgentSyncHdr )
 		{
 		SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID );
@@ -3422,6 +3458,23 @@
 	{
 	DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins"));
 	
+	// Store error code to cenrep
+	CRepository* rep = NULL;
+	TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
+	if ( err == KErrNone )
+	    {
+	    TInt errCode = iError->SyncLogErrorCode();
+
+	    if ( errCode >= KNSmlDsHTTPErrCodeRangeFirst && 
+	       errCode <= KNSmlDsHTTPErrCodeRangeLast )
+	       {
+	       errCode -= KNSmlDsHTTPErrCodeBase;
+	       }
+
+	    rep->Set( KNsmlOpDsErrorCode, errCode );
+	    delete rep;
+	    }
+
 // <MAPINFO_RESEND_MOD_BEGIN>
 	if( iDSContent->ResendUsed() )
 		{