syncmlfw/common/http/src/nsmlhttp.cpp
branchRCL_3
changeset 25 b183ec05bd8c
parent 9 57a65a3a658c
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
    20 #include "nsmlhttpclient.h"
    20 #include "nsmlhttpclient.h"
    21 #include <e32property.h> 
    21 #include <e32property.h> 
    22 #include <DevManInternalCRKeys.h>
    22 #include <DevManInternalCRKeys.h>
    23 #include <centralrepository.h>
    23 #include <centralrepository.h>
    24 #include "nsmlprivatepskeys.h"
    24 #include "nsmlprivatepskeys.h"
    25 #include <nsmlconstants.h>
       
    26 
    25 
    27 
    26 
    28 #include "nsmlerror.h"
    27 #include "nsmlerror.h"
    29 #ifdef __NSML_DEBUG__
    28 #ifdef __NSML_DEBUG__
    30 #include "wbxml2xmlconverter.h"
    29 #include "wbxml2xmlconverter.h"
    80 //
    79 //
    81 void CNSmlHTTP::ConstructL() 
    80 void CNSmlHTTP::ConstructL() 
    82 	{
    81 	{
    83 	// construct shutdown timer
    82 	// construct shutdown timer
    84 	DBG_FILE(_S8("CNSmlHTTP::ConstructL BEGIN"));
    83 	DBG_FILE(_S8("CNSmlHTTP::ConstructL BEGIN"));
    85 	TBool dmjob = EFalse;
       
    86 	FeatureManager::InitializeLibL();
    84 	FeatureManager::InitializeLibL();
    87 	iShutdown = new (ELeave) CNSmlXptShutdownTimer( this );
    85 	iShutdown = new (ELeave) CNSmlXptShutdownTimer( this );
    88 	iShutdown->ConstructL();
    86 	iShutdown->ConstructL();
    89 	iNetworkStatusEngine = NULL;
    87 	iNetworkStatusEngine = NULL;
    90 	// do this only if session is DM 
    88 	// do this only if session is DM 
    91 	TInt session=0;    
    89 	TInt session=0;    
    92     TInt r=RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, session);                       
    90     TInt r=RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, session);                       
    93     DBG_FILE_CODE(session, _S8("CNSmlHTTP::ConstructL Current Session is (DM = 2, DS = 1) "));
    91     DBG_FILE_CODE(session, _S8("CNSmlHTTP::ConstructL Current Session is (DM = 2, DS = 1) "));
    94     if( session == ESyncMLDMSession )//for dm session
    92     if( session == ESyncMLDMSession )//for dm session
    95        {
    93        {
    96        dmjob = ETrue;
       
    97 		TInt dmsessionTimeout = -1;
    94 		TInt dmsessionTimeout = -1;
    98 		CRepository *rep = NULL;
    95 		CRepository *rep = NULL;
    99 		TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ))
    96 		TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ))
   100 		DBG_FILE_CODE(err1, _S8("CNSmlHTTP::ConstructL cenrep read error code "));
    97 		DBG_FILE_CODE(err1, _S8("CNSmlHTTP::ConstructL cenrep read error code "));
   101 		if(err1 == KErrNone)
    98 		if(err1 == KErrNone)
   123 	iServerAcceptEncoding = ExptNone;
   120 	iServerAcceptEncoding = ExptNone;
   124 	iSession = ESyncMLSessionUnknown;
   121 	iSession = ESyncMLSessionUnknown;
   125     RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, iSession);                       
   122     RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, iSession);                       
   126 	// construct dialup agent
   123 	// construct dialup agent
   127 	iDialUpAgent = new (ELeave) CNSmlDialUpAgent();
   124 	iDialUpAgent = new (ELeave) CNSmlDialUpAgent();
   128 	iDialUpAgent->ConstructL(dmjob);
   125 	iDialUpAgent->ConstructL();
   129 
   126 
   130 	iEngineState = ExptIdle;
   127 	iEngineState = ExptIdle;
   131 	iTimeOut = EFalse;
   128 	iTimeOut = EFalse;
   132 	iLastPart = EFalse;
   129 	iLastPart = EFalse;
   133 	iAuthRetryCount=0;
   130 	iAuthRetryCount=0;
   144         if ( err == KErrNone )
   141         if ( err == KErrNone )
   145             {
   142             {
   146             iMaxMsgSize = value;
   143             iMaxMsgSize = value;
   147             }
   144             }
   148         }
   145         }
   149     
       
   150     CRepository* rep = CRepository::NewLC(KCRUidNSmlDSEngine);
       
   151     TInt flag(0);
       
   152     TRAPD(err, rep->Get(KNsmlDsDeflateSupport, flag));
       
   153     DBG_FILE_CODE(flag, _S8("Flag value"));
       
   154     if ( err == KErrNone )
       
   155         {
       
   156         iDeflateFlag = flag;
       
   157         }
       
   158     CleanupStack::PopAndDestroy(rep);
       
   159 	}
   146 	}
   160 
   147 
   161 // ---------------------------------------------------------
   148 // ---------------------------------------------------------
   162 // CNSmlHTTP::ReadRepositoryL(TInt aKey, TInt& aValue)
   149 // CNSmlHTTP::ReadRepositoryL(TInt aKey, TInt& aValue)
   163 // 
   150 // 
   576 #endif // __NSML_DEBUG__
   563 #endif // __NSML_DEBUG__
   577 	
   564 	
   578 	delete iReqBodySubmitBuffer;
   565 	delete iReqBodySubmitBuffer;
   579     iReqBodySubmitBuffer = NULL;
   566     iReqBodySubmitBuffer = NULL;
   580 	
   567 	
   581 	if( (iSession == ESyncMLDSSession) && (iServerAcceptEncoding == ExptDeflate) && iDeflateFlag )
   568 	if( (iSession == ESyncMLDSSession) && (iServerAcceptEncoding == ExptDeflate) )
   582 		{
   569 		{
   583 		TRAPD( err, CompressL(aStartPtr) );
   570 		TRAPD( err, CompressL(aStartPtr) );
   584 		User::LeaveIfError( err );
   571 		User::LeaveIfError( err );
   585 		}
   572 		}
   586 	else
   573 	else
  1081 	CleanupStack::PopAndDestroy( useragent );  
  1068 	CleanupStack::PopAndDestroy( useragent );  
  1082 	SetHeaderL( hdr, HTTP::ECacheControl, KSmlCacheControl );
  1069 	SetHeaderL( hdr, HTTP::ECacheControl, KSmlCacheControl );
  1083 	SetHeaderL( hdr, HTTP::EAcceptCharset, KSmlAcceptCharSet );
  1070 	SetHeaderL( hdr, HTTP::EAcceptCharset, KSmlAcceptCharSet );
  1084 	SetHeaderL( hdr, HTTP::EAcceptLanguage , KSmlAcceptLanguage );
  1071 	SetHeaderL( hdr, HTTP::EAcceptLanguage , KSmlAcceptLanguage );
  1085 		
  1072 		
  1086 	if( iSession == ESyncMLDSSession && iDeflateFlag )//for ds session
  1073 	if( iSession == ESyncMLDSSession )//for ds session
  1087 	  {
  1074 	  { 
  1088 	  if(iServerAcceptEncoding == ExptDeflate)
  1075 	  if(iServerAcceptEncoding == ExptDeflate)
  1089           {
  1076 	      {
  1090           SetHeaderL( hdr, HTTP::EContentEncoding , KSmlContentDeflate );
  1077 	      SetHeaderL( hdr, HTTP::EContentEncoding , KSmlContentDeflate );
  1091           }
  1078 	      }
  1092           SetHeaderL( hdr, HTTP::EAcceptEncoding , KSmlContentDeflate );
  1079 	      SetHeaderL( hdr, HTTP::EAcceptEncoding , KSmlContentDeflate );
  1093 	  }
  1080 	  }
  1094 
  1081 
  1095 	// Add headers and body data for methods that use request bodies
  1082 	// Add headers and body data for methods that use request bodies
  1096 	// Content type header
  1083 	// Content type header
  1097 	TBuf8<KMaxContentTypeSize> contTypeBuf;
  1084 	TBuf8<KMaxContentTypeSize> contTypeBuf;
  1146 		{	
  1133 		{	
  1147 			User::LeaveIfError( TNSmlError::ESmlStatusSizeMismatch );
  1134 			User::LeaveIfError( TNSmlError::ESmlStatusSizeMismatch );
  1148 		}
  1135 		}
  1149 		else
  1136 		else
  1150 		{
  1137 		{
  1151 		    if ( (iSession == ESyncMLDSSession) && (iServerContentEncoding == ExptDeflate) && iDeflateFlag )
  1138 		    if ( (iSession == ESyncMLDSSession) && (iServerContentEncoding == ExptDeflate) )
  1152 		        {		    
  1139 		        {		    
  1153 		        TRAPD( err, DecompressL( aStartPtr ) );		    
  1140 		        TRAPD( err, DecompressL( aStartPtr ) );		    
  1154 				User::LeaveIfError( err );
  1141 				User::LeaveIfError( err );
  1155 		        }
  1142 		        }
  1156 		    else		    
  1143 		    else