syncmlfw/ds/syncagent/src/nsmldsagent.cpp
changeset 60 eb6690d0d439
parent 51 2e64dc50f295
equal deleted inserted replaced
55:1c556dee8eb1 60:eb6690d0d439
    41 #include "NSmlDSAgent.h"
    41 #include "NSmlDSAgent.h"
    42 #include "NSmlDSCmds.h"
    42 #include "NSmlDSCmds.h"
    43 #include "nsmldscontent.h"
    43 #include "nsmldscontent.h"
    44 #include "nsmldserror.h"
    44 #include "nsmldserror.h"
    45 #include "nsmldssettings.h"
    45 #include "nsmldssettings.h"
       
    46 #include "nsmldsoperatorsettings.h"
    46 #include "nsmlagentlog.h"
    47 #include "nsmlagentlog.h"
    47 #include "nsmlroam.h"
    48 #include "nsmlroam.h"
       
    49 #include "nsmloperatorerrorcrkeys.h"
    48 //RD_AUTO_RESTART
    50 //RD_AUTO_RESTART
    49 #include <e32base.h>
    51 #include <e32base.h>
    50 #include <centralrepository.h> 
    52 #include <centralrepository.h> 
    51 #include "SyncMLErr.h"
    53 #include "SyncMLErr.h"
    52 #include "nsmldsconstants.h"
    54 #include "nsmldsconstants.h"
    59 // "Warning:  #174-D: expression has no effect..." is caused by 
    61 // "Warning:  #174-D: expression has no effect..." is caused by 
    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 
       
    66 // CONSTANTS
       
    67 const TInt KGranularity = 12;
       
    68 const TInt KErrorCodeRangeFirst = 400;
       
    69 const TInt KErrorCodeRangeLast = 516;
       
    70 
    64 // ============================ MEMBER FUNCTIONS ===============================
    71 // ============================ MEMBER FUNCTIONS ===============================
    65 
    72 
    66 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    67 // CNSmlDSAgent::CNSmlDSAgent
    74 // CNSmlDSAgent::CNSmlDSAgent
    68 // C++ constructor.
    75 // C++ constructor.
    69 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    70 //
    77 //
    71 CNSmlDSAgent::CNSmlDSAgent()
    78 CNSmlDSAgent::CNSmlDSAgent(): 
       
    79         iServerStatusCodeArray ( RArray< TInt >( KGranularity ) )
    72     {
    80     {
    73 	}
    81 	}
    74 
    82 
    75 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    76 // CNSmlDSAgent::ConstructL
    84 // CNSmlDSAgent::ConstructL
   110 		iDSNetmon = NULL;
   118 		iDSNetmon = NULL;
   111 		DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is not Launched"));
   119 		DBG_FILE(_S8("CNSmlDSAgent::ConstructL DSNetmon is not Launched"));
   112 	}
   120 	}
   113 	//RD_AUTO_RESTART
   121 	//RD_AUTO_RESTART
   114 	
   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 	
   115 	// security policies for P&S reading and writing
   132 	// security policies for P&S reading and writing
   116 	_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
   117 	_LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading
   134 	_LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading
   118 	
   135 	
   119 	// 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)
   160 	//RD_AUTO_RESTART
   177 	//RD_AUTO_RESTART
   161 	if(iDSNetmon)
   178 	if(iDSNetmon)
   162 	{
   179 	{
   163 		delete iDSNetmon;		
   180 		delete iDSNetmon;		
   164 		iDSNetmon = NULL;
   181 		iDSNetmon = NULL;
   165 	}	
   182 	}
   166 	//RD_AUTO_RESTART	
   183     //RD_AUTO_RESTART
       
   184 	
       
   185     iServerStatusCodeArray.Close();
       
   186     delete iRepositorySSC;
   167 	}
   187 	}
   168 
   188 
   169 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   170 // CNSmlDSAgent::Synchronise
   190 // CNSmlDSAgent::Synchronise
   171 // 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 
  1643         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1663         RProperty::Set( KPSUidDataSynchronizationInternalKeys,
  1644                         KDataSyncStatus,
  1664                         KDataSyncStatus,
  1645                         EDataSyncRunning12 );	    
  1665                         EDataSyncRunning12 );	    
  1646         }
  1666         }
  1647     
  1667     
       
  1668     if ( iRepositorySSC )
       
  1669         {
       
  1670         iRepositorySSC->Set( KNsmlOpDsSyncErrorCode, KErrNone );
       
  1671         iRepositorySSC->Set( KNsmlOpDsSyncProfId, profile->IntValue( EDSProfileId ) );
       
  1672         iRepositorySSC->Set( KNsmlOpDsSyncInitiation, iSyncInitiation );
       
  1673         }
  1648 
  1674 
  1649 	TBool ifInternet = ETrue ; // CR: 403-1188
  1675 	TBool ifInternet = ETrue ; // CR: 403-1188
  1650 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1676 	if ( iMediumType == KUidNSmlMediumTypeInternet )
  1651 		{
  1677 		{
  1652 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  1678 		iSyncServer = CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL ), ETrue );
  2900 		iSyncLog = NULL;
  2926 		iSyncLog = NULL;
  2901 		}
  2927 		}
  2902     
  2928     
  2903     // Set sync stopped to P&S
  2929     // Set sync stopped to P&S
  2904     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
  2930     RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
       
  2931   
       
  2932     if ( iRepositorySSC )
       
  2933         {
       
  2934         iRepositorySSC->Set( KNsmlOpDsSyncInitiation, EDataSyncNotRunning );
       
  2935         }
  2905 	
  2936 	
  2906 	ResetDSSessionInfoL();
  2937 	ResetDSSessionInfoL();
  2907 	}
  2938 	}
  2908 
  2939 
  2909 // -----------------------------------------------------------------------------
  2940 // -----------------------------------------------------------------------------
  2955 	{
  2986 	{
  2956 	TDesC8& cmd = iSyncMLCmds->ResponseController()->Cmd( aEntryID );
  2987 	TDesC8& cmd = iSyncMLCmds->ResponseController()->Cmd( aEntryID );
  2957 	TNSmlError::TNSmlSyncMLStatusCode status = STATIC_CAST( TNSmlError::TNSmlSyncMLStatusCode, iSyncMLCmds->ResponseController()->StatusCode( aEntryID ) );
  2988 	TNSmlError::TNSmlSyncMLStatusCode status = STATIC_CAST( TNSmlError::TNSmlSyncMLStatusCode, iSyncMLCmds->ResponseController()->StatusCode( aEntryID ) );
  2958 	TBool error( EFalse );
  2989 	TBool error( EFalse );
  2959 			
  2990 			
       
  2991     // Store status code to cenrep if it is on the list
       
  2992     if ( iErrorReportingEnabled )
       
  2993         {
       
  2994         StoreServerStatusCode( status );
       
  2995         }
       
  2996         
  2960 	switch ( status )
  2997 	switch ( status )
  2961 		{
  2998 		{
  2962 		case TNSmlError::ESmlStatusInProgress:
  2999 		case TNSmlError::ESmlStatusInProgress:
  2963 			if ( cmd != KNSmlAgentSyncHdr )
  3000 			if ( cmd != KNSmlAgentSyncHdr )
  2964 				{
  3001 				{
  4262     err = rep->Set(EDSSessionServerId, _L(""));
  4299     err = rep->Set(EDSSessionServerId, _L(""));
  4263     User::LeaveIfError(err);
  4300     User::LeaveIfError(err);
  4264     CleanupStack::PopAndDestroy(rep);
  4301     CleanupStack::PopAndDestroy(rep);
  4265     }
  4302     }
  4266 
  4303 
       
  4304 // ------------------------------------------------------------------------------------------------------------------
       
  4305 // CNSmlDSAgent::StoreServerStatusCode(TInt aServerStatusCode)
       
  4306 // @description This function stores Sync ML Server Status code to cenrep for Operator profile sync if matched with configured list of codes,
       
  4307 //              and the same code can be used by any client for error logging.
       
  4308 //              If there are multiple status codes during sync, the last server status code is stored.
       
  4309 // @param aServerStatusCode Sync ML server status code while sync ongoing.
       
  4310 // ------------------------------------------------------------------------------------------------------------------
       
  4311 void CNSmlDSAgent::StoreServerStatusCode( TInt aServerStatusCode ) const
       
  4312     {
       
  4313     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() begins"));
       
  4314 
       
  4315     if( ( iServerStatusCodeArray.Count() == 0 && 
       
  4316       ( aServerStatusCode >=  KErrorCodeRangeFirst ) && 
       
  4317       ( aServerStatusCode <=  KErrorCodeRangeLast ) ) ||
       
  4318       ( iServerStatusCodeArray.Find( aServerStatusCode ) != KErrNotFound ) )
       
  4319         {
       
  4320         TInt error = iRepositorySSC->Set( KNsmlOpDsSyncErrorCode, aServerStatusCode );
       
  4321         if ( error != KErrNone )
       
  4322             {
       
  4323             DBG_FILE(_S8("Error in storing the server status code in cenrep"));
       
  4324             }
       
  4325         }
       
  4326 
       
  4327     DBG_FILE(_S8("CNSmlDSAgent::StoreServerStatusCode() ends"));
       
  4328     }
  4267 // End of file  
  4329 // End of file