syncmlfw/ds/syncagent/src/nsmldsagent.cpp
branchRCL_3
changeset 61 b183ec05bd8c
parent 59 13d7c31c74e0
child 62 19bba8228ff0
equal deleted inserted replaced
59:13d7c31c74e0 61:b183ec05bd8c
    20 #include <SyncMLHistory.h>
    20 #include <SyncMLHistory.h>
    21 #include <e32property.h>
    21 #include <e32property.h>
    22 #include <DataSyncInternalPSKeys.h>
    22 #include <DataSyncInternalPSKeys.h>
    23 #include <nsmlconstants.h>
    23 #include <nsmlconstants.h>
    24 #include <nsmldebug.h>
    24 #include <nsmldebug.h>
       
    25 #include <cmpluginwlandef.h>
       
    26 #include <cmmanager.h>
       
    27 #include <cmconnectionmethod.h>
    25 
    28 
    26 // common includes with DM
    29 // common includes with DM
    27 #include "nsmlagenttestdefines.h"
    30 #include "nsmlagenttestdefines.h"
    28 #include "nsmlcliagconstants.h"
    31 #include "nsmlcliagconstants.h"
    29 #include "NSmlAgentBase.h" 
    32 #include "NSmlAgentBase.h" 
    38 #include "NSmlDSAgent.h"
    41 #include "NSmlDSAgent.h"
    39 #include "NSmlDSCmds.h"
    42 #include "NSmlDSCmds.h"
    40 #include "nsmldscontent.h"
    43 #include "nsmldscontent.h"
    41 #include "nsmldserror.h"
    44 #include "nsmldserror.h"
    42 #include "nsmldssettings.h"
    45 #include "nsmldssettings.h"
       
    46 #include "nsmldsoperatorsettings.h"
    43 #include "nsmlagentlog.h"
    47 #include "nsmlagentlog.h"
    44 #include "nsmlroam.h"
    48 #include "nsmlroam.h"
    45 #include "NsmlOperatorErrorCRKeys.h"
    49 #include "nsmloperatorerrorcrkeys.h"
    46 //RD_AUTO_RESTART
    50 //RD_AUTO_RESTART
    47 #include <e32base.h>
    51 #include <e32base.h>
    48 #include <centralrepository.h> 
    52 #include <centralrepository.h> 
    49 #include "SyncMLErr.h"
    53 #include "SyncMLErr.h"
    50 #include "nsmldsconstants.h"
    54 #include "nsmldsconstants.h"
    51 #include <featmgr.h>
       
    52 #include "nsmloperatordefines.h"
       
    53 //RD_AUTO_RESTART
    55 //RD_AUTO_RESTART
    54 _LIT( KNetMon,"\\netmon.exe" );
    56 _LIT( KNetMon,"\\netmon.exe" );
    55 _LIT( KAutoRestart,"netmon" );
    57 _LIT( KAutoRestart,"netmon" );
    56 
    58 
    57 #ifndef __WINS__
    59 #ifndef __WINS__
    60 // DBG_ARGS8 macro in no-debug builds.
    62 // DBG_ARGS8 macro in no-debug builds.
    61 #pragma diag_remark 174
    63 #pragma diag_remark 174
    62 #endif
    64 #endif
    63 
    65 
    64 // CONSTANTS
    66 // CONSTANTS
    65 const TInt KNSmlDsHTTPErrCodeBase = 1400;
    67 const TInt KGranularity = 12;
    66 const TInt KNSmlDsErrCodeFirst = 400;
    68 const TInt KErrorCodeRangeFirst = 400;
    67 const TInt KNSmlDsErrCodeLast = 516;
    69 const TInt KErrorCodeRangeLast = 516;
    68 
    70 
    69 // ============================ MEMBER FUNCTIONS ===============================
    71 // ============================ MEMBER FUNCTIONS ===============================
    70 
    72 
    71 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    72 // CNSmlDSAgent::CNSmlDSAgent
    74 // CNSmlDSAgent::CNSmlDSAgent
    73 // C++ constructor.
    75 // C++ constructor.
    74 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    75 //
    77 //
    76 CNSmlDSAgent::CNSmlDSAgent()
    78 CNSmlDSAgent::CNSmlDSAgent(): 
       
    79         iServerStatusCodeArray ( RArray< TInt >( KGranularity ) )
    77     {
    80     {
    78 	}
    81 	}
    79 
    82 
    80 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    81 // CNSmlDSAgent::ConstructL
    84 // CNSmlDSAgent::ConstructL
   115 		iDSNetmon = NULL;
   118 		iDSNetmon = NULL;
   116 		DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is not Launched"));
   119 		DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is not Launched"));
   117 	}
   120 	}
   118 	//RD_AUTO_RESTART
   121 	//RD_AUTO_RESTART
   119 	
   122 	
       
   123     iRepositorySSC = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys );
       
   124     CNSmlDSOperatorSettings* settings = CNSmlDSOperatorSettings::NewLC();
       
   125     iErrorReportingEnabled = settings->SyncErrorReportingEnabled();
       
   126     if ( iErrorReportingEnabled )
       
   127         {
       
   128         settings->PopulateStatusCodeListL( iServerStatusCodeArray );
       
   129         }
       
   130     CleanupStack::PopAndDestroy( settings );
       
   131 	
   120 	// security policies for P&S reading and writing
   132 	// security policies for P&S reading and writing
   121 	_LIT_SECURITY_POLICY_S0( KNSmlPSWritePolicy, KNSmlSOSServerPolicyUID.iUid ); // SID check (sosserver) when writing
   133 	_LIT_SECURITY_POLICY_S0( KNSmlPSWritePolicy, KNSmlSOSServerPolicyUID.iUid ); // SID check (sosserver) when writing
   122 	_LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading
   134 	_LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading
   123 	
   135 	
   124 	// Define P&S data field for sync ON/OFF flag (may fail e.g. if exists already)
   136 	// Define P&S data field for sync ON/OFF flag (may fail e.g. if exists already)
   125 	RProperty::Define( KPSUidDataSynchronizationInternalKeys, // category
   137 	RProperty::Define( KPSUidDataSynchronizationInternalKeys, // category
   126                        KDataSyncStatus, // field
   138                        KDataSyncStatus, // field
   127                        RProperty::EInt, // type
   139                        RProperty::EInt, // type
   128                        KNSmlPSReadPolicy, // read policy
   140                        KNSmlPSReadPolicy, // read policy
   129                        KNSmlPSWritePolicy ); // write policy
   141                        KNSmlPSWritePolicy ); // write policy
   130 
   142 	DBG_FILE(_S8("CNSmlDSAgent::ConstructL ends"));                        
   131 	//For Syncml Status Extended Error Codes
   143 	
   132 	FeatureManager::InitializeLibL();
       
   133 	iIsExtendedServerErrorCodesSupported = EFalse;
       
   134 	if(FeatureManager::FeatureSupported(KFeatureIdFfSyncmlStatusExtendedErrorCodes))
       
   135 	  {
       
   136       InitializeServerStatusCodeList();
       
   137 	  }
       
   138 	TRAP_IGNORE( iErrorReportingRep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) );
       
   139 	DBG_FILE(_S8("CNSmlDSAgent::ConstructL ends"));
       
   140 	}
   144 	}
   141 
   145 
   142 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   143 // CNSmlDSAgent::NewL
   147 // CNSmlDSAgent::NewL
   144 // Symbian two-phased constructor.
   148 // Symbian two-phased constructor.
   175 	{
   179 	{
   176 		delete iDSNetmon;		
   180 		delete iDSNetmon;		
   177 		iDSNetmon = NULL;
   181 		iDSNetmon = NULL;
   178 	}
   182 	}
   179     //RD_AUTO_RESTART
   183     //RD_AUTO_RESTART
   180 	if(iServerStatusCodeArray)
   184 	
   181 	    {
   185     iServerStatusCodeArray.Close();
   182 	    delete iServerStatusCodeArray;
   186     delete iRepositorySSC;
   183 	    }
       
   184 	if(iRepositorySSC)
       
   185 	    {
       
   186 	    delete iRepositorySSC;
       
   187 	    }
       
   188 	
       
   189 	if(iErrorReportingRep)
       
   190 	    {
       
   191 	    delete iErrorReportingRep;
       
   192 	    }
       
   193 	FeatureManager::UnInitializeLib();
       
   194 	}
   187 	}
   195 
   188 
   196 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   197 // CNSmlDSAgent::Synchronise
   190 // CNSmlDSAgent::Synchronise
   198 // Starts the sync, returns immediately and the initiated sync continues in the 
   191 // Starts the sync, returns immediately and the initiated sync continues in the 
   997 			case CNSmlCmdsBase::EReturnOK:
   990 			case CNSmlCmdsBase::EReturnOK:
   998 				iDSCurrClientModState = EClientModMakingUpdates;
   991 				iDSCurrClientModState = EClientModMakingUpdates;
   999 				if ( !iDSContent->ClientItemCountAsked() )
   992 				if ( !iDSContent->ClientItemCountAsked() )
  1000 					{
   993 					{
  1001 					iDSContent->SetClientItemCountAsked();
   994 					iDSContent->SetClientItemCountAsked();
  1002 					iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlSendingModificationsToServer, iDSContent->ClientItemCount(), 0 );
   995 					iDSObserver->OnSyncMLSyncProgress( MSyncMLProgressObserver::ESmlSendingModificationsToServer, iDSContent->ClientItemCount(), iDSContent->TaskId() );
  1003 					}
   996 					}
  1004 				break;
   997 				break;
  1005 			case CNSmlCmdsBase::EReturnBufferFull:
   998 			case CNSmlCmdsBase::EReturnBufferFull:
  1006 				iDSCurrClientModState = EClientModEndingMessage;
   999 				iDSCurrClientModState = EClientModEndingMessage;
  1007 				iBufferFull = ETrue;
  1000 				iBufferFull = ETrue;
  1569 		else if ( iProtocolVer == ESmlVersion1_2 )
  1562 		else if ( iProtocolVer == ESmlVersion1_2 )
  1570 			{
  1563 			{
  1571 			iSyncMLCmds = CNSmlDSCmds::NewL( this, sessionIdString, KNSmlDSAgentVerProto12, KNSmlSyncMLPublicId12, *iSyncMLUserName, iSyncServer, *iDSContent, *iDSObserver, versionCheck );		
  1564 			iSyncMLCmds = CNSmlDSCmds::NewL( this, sessionIdString, KNSmlDSAgentVerProto12, KNSmlSyncMLPublicId12, *iSyncMLUserName, iSyncServer, *iDSContent, *iDSObserver, versionCheck );		
  1572 			}
  1565 			}
  1573 			
  1566 			
  1574 	    TInt value(0); 
  1567 	    TInt value(0);
  1575 		if ( !iSyncMLCmds ) 
       
  1576 		   User::Leave( KErrGeneral );
       
  1577 		
       
  1578 	    TRAPD (err , ReadRepositoryL(KNSmlMaxMsgSizeKey, value));	    
  1568 	    TRAPD (err , ReadRepositoryL(KNSmlMaxMsgSizeKey, value));	    
  1579 	    if ( ( iMediumType == KUidNSmlMediumTypeInternet ) && ( err == KErrNone ) )
  1569 	    if ( ( iMediumType == KUidNSmlMediumTypeInternet ) && ( err == KErrNone ) )
  1580 	        {
  1570 	        {
  1581             iSyncMLCmds->SetMaximumWorkspaceSize( value );	        
  1571             iSyncMLCmds->SetMaximumWorkspaceSize( value );	        
  1582 	        }
  1572 	        }
  1658 	iSyncMLPassword = profile->StrValue( EDSProfileSyncServerPassword ).AllocL();
  1648 	iSyncMLPassword = profile->StrValue( EDSProfileSyncServerPassword ).AllocL();
  1659 	iSyncHTTPAuthUserName = profile->StrValue( EDSProfileHttpAuthUsername ).AllocL();	
  1649 	iSyncHTTPAuthUserName = profile->StrValue( EDSProfileHttpAuthUsername ).AllocL();	
  1660 	iSyncHTTPAuthPassword = profile->StrValue( EDSProfileHttpAuthPassword ).AllocL();	
  1650 	iSyncHTTPAuthPassword = profile->StrValue( EDSProfileHttpAuthPassword ).AllocL();	
  1661 	iSyncHTTPAuthUsed = profile->IntValue( EDSProfileHttpAuthUsed );						
  1651 	iSyncHTTPAuthUsed = profile->IntValue( EDSProfileHttpAuthUsed );						
  1662 	iProtocolVer = static_cast<TSmlProtocolVersion>( profile->IntValue( EDSProfileProtocolVersion ) );
  1652 	iProtocolVer = static_cast<TSmlProtocolVersion>( profile->IntValue( EDSProfileProtocolVersion ) );
  1663 
  1653 	
  1664 	//For extended error code logging
       
  1665     if(iRepositorySSC)
       
  1666         {
       
  1667         TBuf<KBufferLength> tempStr;
       
  1668         //Get the Operator server ID configured in cenrep
       
  1669         TInt error = iRepositorySSC->Get(KNsmlOperatorProfileServerId, tempStr);
       
  1670         if(error == KErrNone)
       
  1671             {
       
  1672             if(tempStr.Compare(*iDSServerId)== KErrNone)
       
  1673                 {
       
  1674                 //Extended Server Error logging supported, set the the flag
       
  1675                 iIsExtendedServerErrorCodesSupported = ETrue;
       
  1676                 }
       
  1677             }
       
  1678         }
       
  1679 	// set sync started to P&S (if fails -> sync not interrupted)
  1654 	// set sync started to P&S (if fails -> sync not interrupted)
  1680 	if ( iProtocolVer == ESmlVersion1_1_2 )
  1655 	if ( iProtocolVer == ESmlVersion1_1_2 )
  1681 	    {
  1656 	    {
  1682         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1657         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1683                         KDataSyncStatus,
  1658                         KDataSyncStatus,
  1688         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1663         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1689                         KDataSyncStatus,
  1664                         KDataSyncStatus,
  1690                         EDataSyncRunning12 );	    
  1665                         EDataSyncRunning12 );	    
  1691         }
  1666         }
  1692     
  1667     
  1693 	if ( iErrorReportingRep )
  1668     if ( iRepositorySSC )
  1694 	    {
  1669         {
  1695         iErrorReportingRep->Set( KNsmlOpDsErrorCode, KErrNone );
  1670         iRepositorySSC->Set( KNsmlOpDsSyncErrorCode, KErrNone );
  1696         iErrorReportingRep->Set( KNsmlOpDsSyncProfUid, profile->IntValue( EDSProfileId ) );
  1671         iRepositorySSC->Set( KNsmlOpDsSyncProfId, profile->IntValue( EDSProfileId ) );
  1697         iErrorReportingRep->Set( KNsmlOpDsSyncInitiation, iSyncInitiation );
  1672         iRepositorySSC->Set( KNsmlOpDsSyncInitiation, iSyncInitiation );
  1698 	    }
  1673         }
  1699 
  1674 
  1700 	TBool ifInternet = ETrue ; // CR: 403-1188
  1675 	TBool ifInternet = ETrue ; // CR: 403-1188
  1701 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1676 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1702 		{
  1677 		{
  1703 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  1678 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  1940 		{
  1915 		{
  1941 			//Read the IAPID from the Cenrep
  1916 			//Read the IAPID from the Cenrep
  1942 			profileUtil->AccessPointIdL(LastUsedIAPId);
  1917 			profileUtil->AccessPointIdL(LastUsedIAPId);
  1943 			if(LastUsedIAPId > 0)
  1918 			if(LastUsedIAPId > 0)
  1944 			{
  1919 			{
  1945 				//Check Whether the IAPID still exists
  1920                 //Check Whether the IAPID still exists
  1946 		    	TApBearerType bearertype = CheckAPBearerTypeL(LastUsedIAPId);
  1921                 RCmManager  cmmanager;
  1947 		    	if(bearertype != TApBearerType(-1))
  1922                 cmmanager.OpenL();
  1948 		    	{
  1923                 CleanupClosePushL(cmmanager);
  1949 		    		iIAPId = LastUsedIAPId;    	
  1924                 RCmConnectionMethod cm;
  1950 		    		DBG_FILE_CODE(iIAPId , _S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID Replaced from the CenRep:"));                
  1925                 TRAPD(err, cm = cmmanager.ConnectionMethodL( LastUsedIAPId ));
  1951 		    	}
  1926                 CleanupClosePushL( cm );
  1952 		    	else
  1927                 TUint32 bearer = 0;
  1953 		    	{
  1928                 if( err == KErrNone )
  1954 		    		//Stop the DS Sync Session
  1929                 {
  1955 		    		DBG_FILE(_S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID is invalid so stopping the session"));
  1930                     bearer = cm.GetIntAttributeL( CMManager::ECmBearerType );        
  1956 		    		iPacketDataUnAvailable = ETrue;
  1931                     DBG_FILE_CODE( bearer ,_S8("CNSmlDSAgent::ReadSettingsL, BearerType"));
  1957 		    		StopDSSession();
  1932                     if ( bearer == KUidWlanBearerType )
  1958 		    	}	
  1933                     {
  1959 			}
  1934                         DBG_FILE(_S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID is invalid WLAN"));
  1960 		}
  1935                         iPacketDataUnAvailable = ETrue;
  1961 		
  1936                         StopDSSession();
       
  1937                     }
       
  1938                     else
       
  1939                     {
       
  1940                         iIAPId = LastUsedIAPId;      
       
  1941                         DBG_FILE_CODE(iIAPId , _S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID Replaced from the CenRep:"));
       
  1942                     }
       
  1943                 }
       
  1944                 else
       
  1945                 {
       
  1946                     DBG_FILE_CODE( err ,_S8("CNSmlDSAgent::ReadSettingsL, The Access Point ID is invalid"));
       
  1947                     iPacketDataUnAvailable = ETrue;
       
  1948                     StopDSSession();
       
  1949                 }              
       
  1950                 CleanupStack::PopAndDestroy( 2 ); //cmmanagerext,cm			
       
  1951 			}
       
  1952 		}		
  1962 		CleanupStack::PopAndDestroy(profileUtil);
  1953 		CleanupStack::PopAndDestroy(profileUtil);
  1963 	}
  1954 	}
  1964 }
  1955 }
  1965 
  1956 
  1966 // ---------------------------------------------------------
  1957 // ---------------------------------------------------------
  2902 		{
  2893 		{
  2903 		iDSContent->FinalizeSyncLogEvents();
  2894 		iDSContent->FinalizeSyncLogEvents();
  2904 	
  2895 	
  2905 		TTime time;
  2896 		TTime time;
  2906 		time.UniversalTime();
  2897 		time.UniversalTime();
  2907 		if (iError)  
       
  2908 		iSyncLog->SetResult( time, iError->SyncLogErrorCode() );
  2898 		iSyncLog->SetResult( time, iError->SyncLogErrorCode() );
  2909 		else
       
  2910 		iSyncLog->SetResult( time, KErrGeneral );    
       
  2911 	
  2899 	
  2912 		CNSmlDSSettings* settings = CNSmlDSSettings::NewLC();
  2900 		CNSmlDSSettings* settings = CNSmlDSSettings::NewLC();
  2913 		CNSmlDSProfile* profile = settings->ProfileL( iProfileID );
  2901 		CNSmlDSProfile* profile = settings->ProfileL( iProfileID );
  2914 		CleanupStack::PushL( profile );
  2902 		CleanupStack::PushL( profile );
  2915 		CNSmlHistoryArray* array = CNSmlHistoryArray::NewL();
  2903 		CNSmlHistoryArray* array = CNSmlHistoryArray::NewL();
  2939 		}
  2927 		}
  2940     
  2928     
  2941     // Set sync stopped to P&S
  2929     // Set sync stopped to P&S
  2942     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
  2930     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
  2943   
  2931   
  2944     if ( iErrorReportingRep )
  2932     if ( iRepositorySSC )
  2945         {
  2933         {
  2946         iErrorReportingRep->Set( KNsmlOpDsSyncInitiation, EDataSyncNotRunning );
  2934         iRepositorySSC->Set( KNsmlOpDsSyncInitiation, EDataSyncNotRunning );
  2947         }
  2935         }
  2948 	
  2936 	
  2949 	ResetDSSessionInfoL();
  2937 	ResetDSSessionInfoL();
  2950 	}
  2938 	}
  2951 
  2939 
  2997 void CNSmlDSAgent::CheckServerStatusCodeL( TInt aEntryID )
  2985 void CNSmlDSAgent::CheckServerStatusCodeL( TInt aEntryID )
  2998 	{
  2986 	{
  2999 	TDesC8& cmd = iSyncMLCmds->ResponseController()->Cmd( aEntryID );
  2987 	TDesC8& cmd = iSyncMLCmds->ResponseController()->Cmd( aEntryID );
  3000 	TNSmlError::TNSmlSyncMLStatusCode status = STATIC_CAST( TNSmlError::TNSmlSyncMLStatusCode, iSyncMLCmds->ResponseController()->StatusCode( aEntryID ) );
  2988 	TNSmlError::TNSmlSyncMLStatusCode status = STATIC_CAST( TNSmlError::TNSmlSyncMLStatusCode, iSyncMLCmds->ResponseController()->StatusCode( aEntryID ) );
  3001 	TBool error( EFalse );
  2989 	TBool error( EFalse );
  3002 	if(iIsExtendedServerErrorCodesSupported)
  2990 			
  3003 	    {
  2991     // Store status code to cenrep if it is on the list
  3004 	    StoreServerStatusCode(status);
  2992     if ( iErrorReportingEnabled )
  3005 	    }
  2993         {
       
  2994         StoreServerStatusCode( status );
       
  2995         }
       
  2996         
  3006 	switch ( status )
  2997 	switch ( status )
  3007 		{
  2998 		{
  3008 		case TNSmlError::ESmlStatusInProgress:
  2999 		case TNSmlError::ESmlStatusInProgress:
  3009 			if ( cmd != KNSmlAgentSyncHdr )
  3000 			if ( cmd != KNSmlAgentSyncHdr )
  3010 				{
  3001 				{
  3102 		       }while( iDSContent->SetToNext() );
  3093 		       }while( iDSContent->SetToNext() );
  3103 		       	
  3094 		       	
  3104 			}	
  3095 			}	
  3105 			//RD_SUSPEND_RESUME	
  3096 			//RD_SUSPEND_RESUME	
  3106 			break;
  3097 			break;
  3107 
       
  3108 		/* Implementation of CMCC PIM v3 begins*/
       
  3109 		case TNSmlError::ESmlStatusDeviceFull: // 420
       
  3110 		    if ( FeatureManager::FeatureSupported(KFeatureIdFfTdCmccpimpromptserverfullwhenreceive420statuscodefromserver) )
       
  3111 		        {
       
  3112                 // CMCC server full error enabled
       
  3113                 iDSObserver->OnSyncMLSyncError( MSyncMLProgressObserver::ESmlFatalError, SyncMLError::KErrServerFull, 0, 0, 0);
       
  3114                 error = ETrue;
       
  3115 		        }
       
  3116 			break;
       
  3117 		/* Implementation of CMCC PIM v3 ends*/
       
  3118 			
  3098 			
  3119 		default:
  3099 		default:
  3120 			error = ETrue;
  3100 			error = ETrue;
  3121 		}
  3101 		}
  3122 		
  3102 		
  3123     // Store status code to cenrep in case of error
       
  3124     if ( error && iErrorReportingRep
       
  3125          && (  status >= KNSmlDsErrCodeFirst && status <= KNSmlDsErrCodeLast ) )
       
  3126         {
       
  3127         iErrorReportingRep->Set( KNsmlOpDsErrorCode, status );
       
  3128         }
       
  3129         
       
  3130 	if ( cmd == KNSmlAgentSyncHdr )
  3103 	if ( cmd == KNSmlAgentSyncHdr )
  3131 		{
  3104 		{
  3132 		SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID );
  3105 		SaveIfNonceL( *iSyncMLCmds->ResponseController(), aEntryID );
  3133 		}
  3106 		}
  3134 		
  3107 		
  3461 //
  3434 //
  3462 void CNSmlDSAgent::FinaliseWhenErrorL()
  3435 void CNSmlDSAgent::FinaliseWhenErrorL()
  3463 	{
  3436 	{
  3464 	DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins"));
  3437 	DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL begins"));
  3465 	
  3438 	
  3466 	// Store error code to cenrep
       
  3467 	if ( iErrorReportingRep )
       
  3468 	    {
       
  3469         TInt errCode = iError->SyncLogErrorCode();
       
  3470 
       
  3471         if ( errCode >= ( KNSmlDsHTTPErrCodeBase + KNSmlDsErrCodeFirst ) && 
       
  3472                 errCode <= ( KNSmlDsHTTPErrCodeBase + KNSmlDsErrCodeLast ) )
       
  3473             {
       
  3474             errCode -= KNSmlDsHTTPErrCodeBase;
       
  3475             }
       
  3476 
       
  3477         if ( errCode >= KNSmlDsErrCodeFirst && errCode <= KNSmlDsErrCodeLast )
       
  3478             {
       
  3479             iErrorReportingRep->Set( KNsmlOpDsErrorCode, errCode );    	    
       
  3480             }
       
  3481 	    }
       
  3482 
       
  3483 // <MAPINFO_RESEND_MOD_BEGIN>
  3439 // <MAPINFO_RESEND_MOD_BEGIN>
  3484 	if( iDSContent->ResendUsed() )
  3440 	if( iDSContent->ResendUsed() )
  3485 		{
  3441 		{
  3486 		DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL - calling iDSContent->PackupRequestL..."));
  3442 		DBG_FILE(_S8("CNSmlDSAgent::FinaliseWhenErrorL - calling iDSContent->PackupRequestL..."));
  3487 		iDSContent->PackupRequestL( iDSClientNextSyncAnchor );
  3443 		iDSContent->PackupRequestL( iDSClientNextSyncAnchor );
  4344     User::LeaveIfError(err);
  4300     User::LeaveIfError(err);
  4345     CleanupStack::PopAndDestroy(rep);
  4301     CleanupStack::PopAndDestroy(rep);
  4346     }
  4302     }
  4347 
  4303 
  4348 // ------------------------------------------------------------------------------------------------------------------
  4304 // ------------------------------------------------------------------------------------------------------------------
  4349 // CNSmlDSAgent::InitializeServerStatusCodeList()
       
  4350 // @description This function reads list of configured server status codes
       
  4351 //              from cenrep and stores them locally in an array for later comparision during sync
       
  4352 // ------------------------------------------------------------------------------------------------------------------
       
  4353 void CNSmlDSAgent::InitializeServerStatusCodeList()
       
  4354     {
       
  4355     DBG_FILE(_S8("CNSmlDSAgent::InitializeServerStatusCodeList() begins"));
       
  4356     TRAPD(error, iRepositorySSC = CRepository::NewL(KNsmlOperatorCenrepUID));
       
  4357     if(error == KErrNone && iRepositorySSC!= NULL)
       
  4358         {
       
  4359         TBuf<KBufferLength> tempStr;
       
  4360         error = iRepositorySSC->Get(KNsmlExtendedServerStatusCodeList, tempStr);
       
  4361         if(error == KErrNone)
       
  4362             {
       
  4363             TInt commaPos = -1;
       
  4364             TInt codesCount = 0;
       
  4365             while ((commaPos = tempStr.Locate(',')) > KErrNotFound)
       
  4366                 {
       
  4367                 ++codesCount;
       
  4368                 tempStr.Replace(commaPos,1,KSpace);
       
  4369                 }
       
  4370             TRAPD(error, iServerStatusCodeArray = new (ELeave) RArray<TInt>(codesCount));
       
  4371             if(error == KErrNone && iServerStatusCodeArray!= NULL)
       
  4372                 {
       
  4373 				TLex lex(tempStr);
       
  4374 				while(!lex.Eos())
       
  4375 					{
       
  4376 					TPtrC token=lex.NextToken();
       
  4377 					TLex temp(token);
       
  4378 					TInt val;
       
  4379 					temp.Val(val);
       
  4380 					TRAP(error, iServerStatusCodeArray->AppendL(val));
       
  4381 					if(error !=KErrNone)
       
  4382 						{
       
  4383 						DBG_FILE(_S8("Item Could not be appended to array"));
       
  4384 						}
       
  4385 					}
       
  4386                 }
       
  4387             else
       
  4388                 {
       
  4389                 iServerStatusCodeArray = NULL;
       
  4390                 DBG_FILE(_S8("Error creating iServerStatusCodeArray"));
       
  4391                 }
       
  4392             }
       
  4393         else
       
  4394             {
       
  4395 	        DBG_FILE(_S8("Could not find ServerStatusCodeList Key in cenrep"));
       
  4396             }
       
  4397         }
       
  4398     else
       
  4399         {
       
  4400         iRepositorySSC = NULL;
       
  4401         DBG_FILE(_S8("Error opening cenrep to store Server Status Codes"));
       
  4402         }
       
  4403     DBG_FILE(_S8("CNSmlDSAgent::InitializeServerStatusCodeList() ends"));
       
  4404     }
       
  4405 // ------------------------------------------------------------------------------------------------------------------
       
  4406 // CNSmlDSAgent::StoreServerStatusCode(TInt aServerStatusCode)
  4305 // CNSmlDSAgent::StoreServerStatusCode(TInt aServerStatusCode)
  4407 // @description This function stores Sync ML Server Status code to cenrep for Operator profile sync if matched with configured list of codes,
  4306 // @description This function stores Sync ML Server Status code to cenrep for Operator profile sync if matched with configured list of codes,
  4408 //              and the same code can be used by any client for error logging.
  4307 //              and the same code can be used by any client for error logging.
  4409 //              If there are multiple status codes during sync, the last server status code is stored.
  4308 //              If there are multiple status codes during sync, the last server status code is stored.
  4410 // @param aServerStatusCode Sync ML server status code while sync ongoing.
  4309 // @param aServerStatusCode Sync ML server status code while sync ongoing.
  4411 // ------------------------------------------------------------------------------------------------------------------
  4310 // ------------------------------------------------------------------------------------------------------------------
  4412 void CNSmlDSAgent::StoreServerStatusCode(TInt aServerStatusCode) const
  4311 void CNSmlDSAgent::StoreServerStatusCode( TInt aServerStatusCode ) const
  4413     {
  4312     {
  4414     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() begins"));
  4313     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() begins"));
  4415 	if(iServerStatusCodeArray)
  4314 
  4416 	    {
  4315     if( ( iServerStatusCodeArray.Count() == 0 && 
  4417 	    if(iServerStatusCodeArray->Find(aServerStatusCode) != KErrNotFound)
  4316       ( aServerStatusCode >=  KErrorCodeRangeFirst ) && 
  4418 	        {
  4317       ( aServerStatusCode <=  KErrorCodeRangeLast ) ) ||
  4419 	        if(iRepositorySSC)
  4318       ( iServerStatusCodeArray.Find( aServerStatusCode ) != KErrNotFound ) )
  4420 	            {
  4319         {
  4421 	            TInt error = iRepositorySSC->Set(KNsmlExtendedServerStatusCode, aServerStatusCode);
  4320         TInt error = iRepositorySSC->Set( KNsmlOpDsSyncErrorCode, aServerStatusCode );
  4422 	            if (error != KErrNone)
  4321         if ( error != KErrNone )
  4423 	                {
  4322             {
  4424 	                DBG_FILE(_S8("Error in storing the server status code in cenrep"));
  4323             DBG_FILE(_S8("Error in storing the server status code in cenrep"));
  4425 	                }
  4324             }
  4426 	            }
  4325         }
  4427 	        else
  4326 
  4428 	            {
       
  4429 	            DBG_FILE(_S8("Repository for SSC could not be found"));
       
  4430 	            }
       
  4431 	        }
       
  4432 	    }
       
  4433     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() ends"));
  4327     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() ends"));
  4434     }
  4328     }
  4435 // End of file  
  4329 // End of file