webservices/wshttpchanneltransportplugin/src/senhttpchannelimpl.cpp
changeset 23 a1df79fa35b4
parent 15 0aea830faa24
equal deleted inserted replaced
16:abb636afedf7 23:a1df79fa35b4
    14 * Description:           
    14 * Description:           
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 #include <uri8.h>
    19 #include <uri8.h>
    29 #include <es_sock.h>
    20 #include <es_sock.h>
    30 #include <in_sock.h>
    21 #include <in_sock.h>
    31 #include <http.h>
    22 #include <http.h>
    32 
    23 
    33 #include "sendebug.h" // filelogging and debugging MACROS
    24 #include "sendebug.h" // filelogging and debugging MACROS
    34 #include <SenServiceConnection.h> // KErrSenNoHttpResponseBody
    25 #include "SenServiceConnection.h" // KErrSenNoHttpResponseBody
    35 #include <SenElement.h>
    26 #include "SenElement.h"
    36 #include <SenXmlUtils.h>
    27 #include "SenXmlUtils.h"
    37 #include <SenHttpTransportProperties.h>
    28 #include "SenHttpTransportProperties.h"
    38 #include "senhttpchannelimpl.h"
    29 #include "senhttpchannelimpl.h"
    39 #include "senhttpeventhandler.h"
    30 #include "senhttpeventhandler.h"
    40 #include "sentxnstate.h"
    31 #include "sentxnstate.h"
    41 #include "senatomtxnstate.h"
    32 #include "senatomtxnstate.h"
    42 #include "senrfiletxnstate.h"
    33 #include "senrfiletxnstate.h"
    45 #include "msenidentitymanager.h"
    36 #include "msenidentitymanager.h"
    46 #include "senlogger.h"
    37 #include "senlogger.h"
    47 
    38 
    48 #include "senhttpchanneltransportplugin.h"
    39 #include "senhttpchanneltransportplugin.h"
    49 //For HTTPProxyFilter
    40 //For HTTPProxyFilter
    50 #include <HttpFilterProxyInterface.h>
    41 #include <httpfilterproxyinterface.h>
    51 #include <HttpFilterAcceptHeaderInterface.h>
    42 #include <httpfilteracceptheaderinterface.h>
    52 #include <HttpFilterCommonStringsExt.h>
    43 #include <httpfiltercommonstringsext.h>
    53 #include <DeflateFilterInterface.h>
    44 #include <deflatefilterinterface.h>
       
    45 
       
    46 #ifndef __ENABLE_ALR__
       
    47 #include <versioninfo.h>  // VersionInfo
       
    48 #include <extendedconnpref.h>
       
    49 #endif
    54 
    50 
    55 // CONSTANTS
    51 // CONSTANTS
    56 namespace
    52 namespace
    57     {
    53     {
    58     _LIT(KTxnStateNullPanicText,            "TxnState is NULL");
    54     _LIT(KTxnStateNullPanicText,            "TxnState is NULL");
    83     iPasswordFromUser(EFalse),
    79     iPasswordFromUser(EFalse),
    84     iExplicitIapDefined(EFalse),
    80     iExplicitIapDefined(EFalse),
    85     iProxyHostPort(NULL),
    81     iProxyHostPort(NULL),
    86     iXopResponse(EFalse),
    82     iXopResponse(EFalse),
    87     iHasHttpContentType(ETrue)
    83     iHasHttpContentType(ETrue)
    88     {
    84 #ifndef __ENABLE_ALR__
       
    85     , iOCCenabled(EFalse)
       
    86 #endif    
       
    87     {
       
    88 //    IsOCCImplementedSDK();
    89     }
    89     }
    90 
    90 
    91 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager)
    91 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager)
    92     {
    92     {
    93     CSenHttpChannelImpl* pNew = NewLC(aManager);
    93     CSenHttpChannelImpl* pNew = NewLC(aManager);
   118     CleanupStack::PushL(pNew);
   118     CleanupStack::PushL(pNew);
   119     pNew->ConstructL(aIapId); 
   119     pNew->ConstructL(aIapId); 
   120     return pNew;
   120     return pNew;
   121     }
   121     }
   122 
   122 
       
   123 #ifndef __ENABLE_ALR__
       
   124 // On return, aMajor and aMinor contain the version information
       
   125 TInt CSenHttpChannelImpl::GetS60PlatformVersion(TUint& aMajor, TUint& aMinor)
       
   126 	{   
       
   127 	TInt ret = KErrNone;
       
   128 	// Connect to the file server session
       
   129 	RFs fsSession;
       
   130 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::GetS60PlatformVersion()")));	
       
   131 	ret = fsSession.Connect();
       
   132 	if(ret == KErrNone)
       
   133 		{
       
   134 		CleanupClosePushL(fsSession); // Obtain the version numberTUint major;
       
   135 		VersionInfo::TPlatformVersion platformVersion;  
       
   136 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "--- GetS60PlatformVersion getting Version info");		
       
   137 		ret = VersionInfo::GetVersion(platformVersion, fsSession);   
       
   138 		CleanupStack::PopAndDestroy();  // fsSession		
       
   139 		if (ret == KErrNone)       
       
   140 			{     
       
   141 			aMajor = platformVersion.iMajorVersion;  
       
   142 			aMinor = platformVersion.iMinorVersion;   
       
   143 		   	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("--- GetS60PlatformVersion Version: Major [%d], Minor[%d]"), aMajor, aMinor));
       
   144 			}		
       
   145 		}
       
   146 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("--- GetS60PlatformVersion returns [%d]"), ret));
       
   147 	return ret;
       
   148 	}
       
   149 
       
   150 // On return, aMajor and aMinor contain the version information
       
   151 TBool CSenHttpChannelImpl::IsOCCImplementedSDK()
       
   152 	{   
       
   153 	TBool occ = EFalse;
       
   154 	// Obtain the version number
       
   155 	TUint major;
       
   156 	TUint minor;	
       
   157 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::IsOCCImplementedSDK()")));		
       
   158 	TInt ret = GetS60PlatformVersion(major, minor);
       
   159 	if (ret == KErrNone)
       
   160 		{
       
   161 		if(major == 5 && minor == 2)
       
   162 			{
       
   163 			occ = ETrue;
       
   164 			iOCCenabled = ETrue;
       
   165 			TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("---- IsOCCImplementedSDK() returns TRUE")));
       
   166 			}
       
   167 		else
       
   168 			{
       
   169 			TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("---- IsOCCImplementedSDK() returns False")));
       
   170 			}
       
   171 		}
       
   172 	return occ;
       
   173 	}
       
   174 #endif	
       
   175 
   123 // Ask IAP from user
   176 // Ask IAP from user
   124 void CSenHttpChannelImpl::ConstructL()
   177 void CSenHttpChannelImpl::ConstructL()
   125     {
   178     {
   126     // Open connection to the file logger server
   179     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL()")));
   127     TLSLOG_OPEN(KSenHttpChannelLogChannelBase, KSenHttpChannelLogLevel, KSenHttpChannelLogDir, KSenHttpChannelLogFile);
   180     	
   128     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL - Log file opened")));
       
   129 
       
   130     // Open the RHTTPSession
   181     // Open the RHTTPSession
   131     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("- Opening HTTP/TCP session.")));
   182     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - Opening HTTP/TCP session.")));
   132 
   183 
   133     iSess.OpenL();
   184     iSess.OpenL();
   134 
   185 
   135     // Store the string pool for this HTTP session
   186     // Store the string pool for this HTTP session
   136     iStringPool = iSess.StringPool();
   187     iStringPool = iSess.StringPool();
   137 
   188 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - Calling InstallAuthenticationL()")));
   138     // Install this class as the callback for authentication requests
   189     // Install this class as the callback for authentication requests
   139     InstallAuthenticationL( iSess );
   190     InstallAuthenticationL( iSess );
       
   191     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - Completed InstallAuthenticationL()")));
   140     //Install Proxy Filter  
   192     //Install Proxy Filter  
   141     iDeflateFilter = EFalse;
   193     iDeflateFilter = EFalse;
   142 
   194 
   143 #ifdef EKA2
   195 #ifdef EKA2
   144   //#ifndef _DEBUG 
   196   //#ifndef _DEBUG 
       
   197   	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - Installing  HTTPProxyFilter for EKA2 build.")));
   145     CHttpFilterProxyInterface::InstallFilterL( iSess );
   198     CHttpFilterProxyInterface::InstallFilterL( iSess );
       
   199     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - HTTPProxyFilter installed for EKA2 build.")));
   146     iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetLanguageTable());
   200     iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetLanguageTable());
   147     iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetTable());
   201     iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetTable());
   148 
   202 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - Installing  HTTPAcceptProxyFilter for EKA2 build.")));
   149     CHttpFilterAcceptHeaderInterface::InstallFilterL(iSess);
   203     //CHttpFilterAcceptHeaderInterface::InstallFilterL(iSess); //There is issue with installing this filter. so disabling it temporarly
   150     TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPProxyFilter installed for EKA2 build.");
   204     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() - HTTPAcceptProxyFilter installed for EKA2 build.")));
   151     TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPAcceptFilter installed for EKA2 build.");
       
   152   //#else
   205   //#else
   153   //  LOG_WRITE_L("HTTPProxyFilter is NOT in use with EKA2 debug builds.");
   206   //  LOG_WRITE_L("HTTPProxyFilter is NOT in use with EKA2 debug builds.");
   154   //#endif
   207   //#endif
   155 #else // __INSTALL_HTTP_PROXY_FILTER__ is not defined by macro in .mmp
   208 #else // __INSTALL_HTTP_PROXY_FILTER__ is not defined by macro in .mmp
   156     TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPProxyFilter is NOT in use with EKA1.");
   209     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"HTTPProxyFilter is NOT in use with EKA1.");
   157     TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPAcceptProxyFilter is NOT in use with EKA1.");
   210     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"HTTPAcceptProxyFilter is NOT in use with EKA1.");
   158 #endif // __INSTALL_HTTP_PROXY_FILTER__
   211 #endif // __INSTALL_HTTP_PROXY_FILTER__
   159 
   212 
   160     iTransObs = CSenHttpEventHandler::NewL(this);//, &iLog);
   213     iTransObs = CSenHttpEventHandler::NewL(this);//, &iLog);
   161     iTxnStates =
   214     iTxnStates =
   162         new (ELeave) CArrayPtrFlat<CSenTxnState>(KMinimumArrayGranularity);
   215         new (ELeave) CArrayPtrFlat<CSenTxnState>(KMinimumArrayGranularity);
   163 
   216 
   164     iBasicConnectionTries = 0;
   217     iBasicConnectionTries = 0;
       
   218     
       
   219 #ifndef __ENABLE_ALR__
       
   220     IsOCCImplementedSDK();
       
   221 #endif    
   165 
   222 
   166 #ifdef _SENDEBUG
   223 #ifdef _SENDEBUG
   167     ListFilters();
   224     ListFilters();
   168 #endif // _SENDEBUG
   225 #endif // _SENDEBUG
       
   226 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL() Completed")));
   169     }
   227     }
   170 
   228 
   171 // Forces preselected IAP to be used!
   229 // Forces preselected IAP to be used!
   172 void CSenHttpChannelImpl::ConstructL( TUint32 aIapId )
   230 void CSenHttpChannelImpl::ConstructL( TUint32 aIapId )
   173     {
   231     {
   181 
   239 
   182 
   240 
   183 //    Use local variable (new RSocketServer each time; handle is given to RHTTPSession via RConnectionInfo..)
   241 //    Use local variable (new RSocketServer each time; handle is given to RHTTPSession via RConnectionInfo..)
   184 //    RSocketServ server; // with "anon" (local) socket servers, should we keep array of open ones in case of pending txns?
   242 //    RSocketServ server; // with "anon" (local) socket servers, should we keep array of open ones in case of pending txns?
   185 //    SetIapPrefsL(aIapId, iConnection, server);
   243 //    SetIapPrefsL(aIapId, iConnection, server);
   186 
   244 #ifndef __ENABLE_ALR__
   187     const TInt result = SetIapPrefsL(aIapId, ETrue, iConnection, iSockServ);
   245 	IsOCCImplementedSDK();
   188     User::LeaveIfError( result );
   246 #endif	
   189     
   247 	if(aIapId > 0)
       
   248 		{
       
   249     	const TInt result = SetIapPrefsL(aIapId, ETrue, iConnection, iSockServ);
       
   250     	User::LeaveIfError( result );
       
   251     	}
   190     }
   252     }
   191 
   253 
   192 CSenHttpChannelImpl::~CSenHttpChannelImpl()
   254 CSenHttpChannelImpl::~CSenHttpChannelImpl()
   193     {
   255     {
   194     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::~CSenHttpChannelImpl()");
   256     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::~CSenHttpChannelImpl()");
   221         REComSession::DestroyedImplementation(KDeflateFilterUid); 	
   283         REComSession::DestroyedImplementation(KDeflateFilterUid); 	
   222         }
   284         }
   223         
   285         
   224     iConnection.Close();
   286     iConnection.Close();
   225     iSockServ.Close();
   287     iSockServ.Close();
   226 
   288     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::~CSenHttpChannelImpl() Completed");
   227     // Close the log file and the connection to the server.
   289     }
   228     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("Log file closed.")));
   290 
   229     TLSLOG_CLOSE(KSenHttpChannelLogChannelBase);
   291 TInt CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   230     }
   292    	{
   231 
   293    	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetIapPrefsL	, aIapId (%d)"), aIapId));
   232 // This function expects that RConnection has been connected
   294    	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetIapPrefsL	, iIapId (%d)"), iIapId));
   233 // and that RConnection has already been opened!
   295    	
   234 /*
       
   235 void CSenHttpChannelImpl::SetIapPrefsL(TUint32 aIapId, 
       
   236                                        RConnection& aConnection, 
       
   237                                        RSocketServ& aSocketServer)
       
   238     {
       
   239     // Check whether IAP ID is not equal with the one that is currently in effect:
   296     // Check whether IAP ID is not equal with the one that is currently in effect:
   240     if(iExplicitIapDefined && iIapId == aIapId )
   297     if(iExplicitIapDefined || iIapId == aIapId && iIapId > 0)
   241         {
   298         {
   242         return; // nothing to do
   299         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id is same as currently in effect");
   243         }
   300         return KErrNone;
   244         
   301         }
   245     LOG_WRITEFORMAT((_L8("- SetIapPrefsL: Re-setting IAP ID (%d)"), aIapId));
   302 	else
       
   303 		{
       
   304 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id different with the currently in effect");
       
   305 		}    
       
   306     
   246 
   307 
   247     // Check if socket server (connection) is already open..
   308     // Check if socket server (connection) is already open..
   248     if( iExplicitIapDefined )
   309     if( iExplicitIapDefined )
   249         {
   310         {
   250          // Socket server opened once before for some other IAP
   311          // Socket server opened once before for some other IAP
   251         LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   312         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   252         aConnection.Stop();
   313         aConnection.Stop();
   253         }
   314         }
   254     else
   315     else
   255         {
   316         {
   256         aConnection.Stop(); // prompted from user
   317         if(aConnection.SubSessionHandle())
   257         iSess.DisconnectL();
   318         	{
   258         iSess.ConnectL();
   319             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   259 
   320         	aConnection.Stop();
   260         // Connect to a socket server    
   321         	}
   261         LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server");    
   322         else
   262         User::LeaveIfError(aSocketServer.Connect());       
   323             {
   263 
   324             // Connect to a socket server    
   264         // Open new connection
   325             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Connecting to new socket server");    
   265         LOG_WRITE_L("- SetIapPrefsL: Opening new RConnection using the socket server.");       
   326             User::LeaveIfError( aSocketServer.Connect() );       
   266         User::LeaveIfError(aConnection.Open(aSocketServer)); 
   327     
       
   328             // Open new connection
       
   329             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Opening new RConnection using the socket server.");       
       
   330             User::LeaveIfError( aConnection.Open(aSocketServer) );        
       
   331             }
   267         }
   332         }
   268         
   333         
   269     // Set the IAP selection preferences (IAP ID, do not prompt)
   334     // Set the IAP selection preferences (IAP ID, do not prompt)    
   270     TCommDbConnPref pref;
   335 	TInt retVal = SetID(aIapId, aDialogPref, aConnection, aSocketServer);	        
   271     pref.SetIapId( aIapId );    
   336 	
   272 
       
   273     TCommDbDialogPref dialogPref;
       
   274     dialogPref = ECommDbDialogPrefDoNotPrompt;
       
   275     pref.SetDialogPreference(dialogPref);
       
   276     
       
   277     // Start the connection with the new preferences
       
   278     LOG_WRITE_L("- SetIapPrefsL: Calling RConnection::Start with new IAP prefs");
       
   279     aConnection.Start(pref);
       
   280     
       
   281     // Get the connection "handle" from the HTTP session    
   337     // Get the connection "handle" from the HTTP session    
   282     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   338     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   283      
   339      
   284     // Attach socket server
   340     // Attach socket server
   285     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
   341     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
   288     
   344     
   289     // Attach connection  
   345     // Attach connection  
   290     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
   346     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
   291     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
   347     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
   292                                                 RHTTPSession::GetTable()), 
   348                                                 RHTTPSession::GetTable()), 
   293                                                 THTTPHdrVal(connPtr));
   349                                                 THTTPHdrVal(connPtr));                                                    
   294                                                 
   350     return retVal;
   295     // Remember the IAP id that is being set; there is
   351     }
   296     // no direct API to query effective IAP ID from CommsDB.
   352 
   297     iExplicitIapDefined = ETrue;
   353 TInt CSenHttpChannelImpl::SetID(TUint32 aId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer, TBool aSNAP)
   298     iIapId = aIapId;
   354 {
   299     }
   355    /*
   300 */
   356     * Single click connectivity feature has been implemented by CSock (RConnection class).
   301 
   357     * According to this client no need to set the IAP ID. 
   302 
   358     * Automatically RConnection will use the suitable IAP
   303 /*
   359     */
   304 void CSenHttpChannelImpl::SetupConnectionWithIapPrefsL( TUint32 aIapId, 
   360     TInt retVal = KErrNone;
   305                                                         RConnection& aConnection, 
   361     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl  called with ID [%d]"), aId));
   306                                                         RSocketServ& aSocketServer )
   362 	    
   307     {
   363 #ifndef __ENABLE_ALR__	    
   308     // Check whether IAP ID is not equal with the one that is currently in effect:
   364 	if (iOCCenabled == EFalse)	    
   309     if(iExplicitIapDefined && iIapId == aIapId )
   365 		{
   310         {
   366 #endif		
   311         return; // nothing to do
   367 		if (aSNAP == EFalse)
   312         }
   368 			{
   313         
   369 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- SetIAPID");
   314     LOG_WRITEFORMAT((_L8("- SetIapPrefsL, IAP ID (%d)"), aIapId));
   370 		    TCommDbConnPref pref;		
   315 
   371 			pref.SetIapId( aId );
   316     // Check if socket server (connection) is already open..
   372 			TCommDbDialogPref dialogPref;
   317     if( iExplicitIapDefined )
   373 		    if (aDialogPref)
   318         {
   374 		        {
   319          // Socket server opened once before for some other IAP
   375 		        dialogPref = ECommDbDialogPrefDoNotPrompt;
   320         LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   376 		        }
   321         aConnection.Stop();
   377 		    else
   322         }
   378 		        {
   323     else
   379 		        dialogPref = ECommDbDialogPrefPrompt;
   324         {
   380 		        }
   325         // Connect to a socket server    
   381 	    	pref.SetDialogPreference(dialogPref);
   326         LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server");    
   382 	    	retVal = aConnection.Start(pref);
   327         User::LeaveIfError( aSocketServer.Connect() );       
   383 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection->Start retVal [%d]"), retVal));
   328 
   384 			}
   329         // Open new connection
       
   330         LOG_WRITE_L("- SetIapPrefsL: Opening new RConnection using the socket server.");       
       
   331         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
       
   332         }
       
   333         
       
   334     // Set the IAP selection preferences (IAP ID, do not prompt)
       
   335     TCommDbConnPref pref;
       
   336     pref.SetIapId( aIapId );    
       
   337 
       
   338     TCommDbDialogPref dialogPref;
       
   339     dialogPref = ECommDbDialogPrefDoNotPrompt;
       
   340     pref.SetDialogPreference(dialogPref);
       
   341     
       
   342     // Start the connection with the new preferences
       
   343     LOG_WRITE_L("- SetIapPrefsL: Calling RConnection::Start with new IAP prefs");
       
   344     aConnection.Start(pref);
       
   345     }
       
   346     
       
   347 
       
   348 void CSenHttpChannelImpl::AttachSocketServerAndConnectionWithHttpSession( TUint32 aIapId, 
       
   349                                                                           RConnection& aConnection, 
       
   350                                                                           RSocketServ& aSocketServer )
       
   351     {
       
   352     if(iExplicitIapDefined && iIapId == aIapId )
       
   353         {
       
   354         return; // nothing to do
       
   355         }
       
   356 
       
   357     // Get the connection "handle" from the HTTP session    
       
   358     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
       
   359      
       
   360     // Attach socket server
       
   361     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
       
   362                                                 RHTTPSession::GetTable()),
       
   363                                                 THTTPHdrVal(aSocketServer.Handle()));
       
   364     
       
   365     // Attach connection  
       
   366     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
       
   367     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
       
   368                                                 RHTTPSession::GetTable()), 
       
   369                                                 THTTPHdrVal(connPtr));
       
   370                                                 
       
   371     // Remember the IAP id that is being set, because *at the moment*,
       
   372     // there is NO direct API to query effective IAP ID from CommsDB.
       
   373     iExplicitIapDefined = ETrue;
       
   374     iIapId = aIapId;
       
   375     }
       
   376     
       
   377 
       
   378 void CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, RConnection& aConnection, RSocketServ& aSocketServer )
       
   379     {
       
   380     SetupConnectionWithIapPrefsL( aIapId, aConnection, aSocketServer );
       
   381     AttachSocketServerAndConnectionWithHttpSession( aIapId, aConnection, aSocketServer );
       
   382     }        
       
   383 */
       
   384 
       
   385 
       
   386 TInt CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
       
   387    	{
       
   388    	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("- SetIapPrefsL, IAP ID (%d)"), aIapId));
       
   389    	
       
   390     // Check whether IAP ID is not equal with the one that is currently in effect:
       
   391     if(iExplicitIapDefined && iIapId == aIapId )
       
   392         {
       
   393         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id is same as currently in effect");
       
   394         return KErrNone;
       
   395         }
       
   396 		else
   385 		else
       
   386 			{
       
   387 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- SetSNAPID");
       
   388 			// Set the SNAP selection preferences (SNAP ID)
       
   389 		    TConnSnapPref pref;
       
   390 		    pref.SetSnap(aId);		    
       
   391 		    // Start the connection with the new preferences
       
   392 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Calling RConnection::Start with new SNAP prefs");
       
   393 		    TInt retVal = aConnection.Start(pref);
       
   394 			}
       
   395 #ifndef __ENABLE_ALR__			
       
   396 		}   
       
   397 	else
       
   398 		{
       
   399 		if (aSNAP == EFalse)
       
   400 			{
       
   401 			/* If IAP id is zero, it is interpreted as
       
   402 		    * client's request for not requesting any specific IAP.
       
   403 		    * Default value is 0.
       
   404 		    * 
       
   405 		    * If IAP id is set, SNAP id shall be zero.
       
   406 		    * If IAP id is set, SNAP purpose shall be CMManager::ESnapPurposeUnknown.
       
   407 		    * If IAP id is set, Connection selection dialog shall be disabled.
       
   408 		    * If IAP id is set, bearer set shall be EExtendedConnBearerUnknown.
       
   409 		    * If IAP id is set, forced roaming is disabled automatically.
       
   410 		    * Either SNAP purpose, SNAP id, or IAP id shall be given, or Connection
       
   411 		    * selection dialog shall be enabled.
       
   412 		    */
       
   413 		    
       
   414 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC with IAP Settings");
       
   415 			TConnPrefList prefList;
       
   416 			TExtendedConnPref extPrefs;
       
   417 			//extPrefs.SetSnapPurpose( CMManager::ESnapPurposeUnknown);
       
   418 			//TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC Silent Connection");
       
   419 			//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
       
   420 			//extPrefs.SetBearerSet(TExtendedConnBearer::EExtendedConnBearerUnknown);
       
   421 			if(aId != 0)
   397 				{
   422 				{
   398 				TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id different with the currently in effect");
   423 				extPrefs.SetIapId(aId);
   399 				}    
   424 				extPrefs.SetSnapId(0);
   400     
   425 				}
   401 
   426 			else
   402     // Check if socket server (connection) is already open..
   427 				{
   403     if( iExplicitIapDefined )
   428 				extPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
   404         {
   429 				extPrefs.SetConnSelectionDialog(ETrue);
   405          // Socket server opened once before for some other IAP
   430 				}
   406         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   431 			prefList.AppendL(&extPrefs);
   407         aConnection.Stop();
   432 			retVal = aConnection.Start(prefList);
   408         }
   433 			if(retVal == KErrNone)
   409     else
   434 			    {
   410         {
   435 			    if(aId == 0)
   411         // Connect to a socket server    
   436 			    	{
   412         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Connecting to new socket server");    
   437                     aConnection.GetIntSetting( _L("IAP\\Id"), iIapId);
   413         User::LeaveIfError( aSocketServer.Connect() );       
   438                     TName name;
   414 
   439                     retVal = aConnection.Name(name);
   415         // Open new connection
   440                     if(retVal == KErrNone)
   416         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Opening new RConnection using the socket server.");       
   441                         {
   417         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
   442                         TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP Name [%S]"), &name));
   418         }
   443                         }
   419         
   444                     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("GetIntSetting returned IAP [%d]"), iIapId));			    
   420     // Set the IAP selection preferences (IAP ID, do not prompt)
   445 			    	}
   421     /*
   446 			    else
   422     *Single click connectivity feature has been implemented by CSock (RConnection class).
   447 			    	{	
   423     *According to this client no need to set the IAP ID. 
   448 			    	iIapId = aId;
   424     *Automatically RConnection will use the suitable IAP
   449 			    	}
   425     */
   450 			    }
   426     
   451 			 else
   427 
   452 			    {
   428 	    TCommDbConnPref pref;
   453                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP ->Start retVal [%d]"), retVal));
   429     #ifndef __SINGLE_CLICK_CONNECTIVITY_ENABLED__	    
   454 			    }
   430 	    pref.SetIapId( aIapId );
   455 		    }
   431 		#else
   456 		else
   432 			pref.SetIapId( 0 );	 //By default IAP ID is "0". IAP selection will take care by RConnection
   457 		    {
   433     #endif //__SINGLE_CLICK_CONNECTIVITY_ENABLED__	    
   458 		    /**
   434 	    TCommDbDialogPref dialogPref;
   459 		    * Sets SNAP id. If SNAP id is zero, it is interpreted as 
   435 	    
   460 		    * client's request for not requesting any specific SNAP.
   436 	    if (aDialogPref)
   461 		    * Default value is 0.
   437 	        {
   462 		    *
   438 	        dialogPref = ECommDbDialogPrefDoNotPrompt;
   463 		    * If SNAP id is set, IAP id shall be zero.
   439 	        }
   464 		    * If SNAP id is set, SNAP purpose shall be CMManager::ESnapPurposeUnknown.
   440 	    else
   465 		    * If SNAP id is set, Connection selection dialog shall be disabled.
   441 	        {
   466 		    * Either SNAP purpose, SNAP id, or IAP id shall be given, or Connection
   442 	        dialogPref = ECommDbDialogPrefPrompt;
   467 		    * selection dialog shall be enabled.
   443 	        }     
   468 		    */
   444 	    pref.SetDialogPreference(dialogPref);
   469 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC with SNAP Settings");
   445     
   470 			TConnPrefList prefList;
   446   	// Start the connection with the new preferences
   471 			TExtendedConnPref extPrefs;
   447 	  TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Calling RConnection::Start with new IAP prefs");
   472 			//extPrefs.SetSnapPurpose( CMManager::ESnapPurposeUnknown);
   448 
   473 			//TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC Silent Connection");
   449     TInt retVal =aConnection.Start(pref);
   474 			//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
   450     
   475 			//extPrefs.SetBearerSet(TExtendedConnBearer::EExtendedConnBearerUnknown);
   451 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection->Start retVal [%d]"), retVal));
   476 			if(aId == 0)
   452 		        
   477 				{
   453     // Get the connection "handle" from the HTTP session    
   478 				TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting SnapPurpose Internet");
   454     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   479 				if(aDialogPref) //If it fails because of unavailibility of access points
   455      
   480 					{
   456     // Attach socket server
   481 					TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Fails because of unavailibility of access points");
   457     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
   482 					extPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
   458                                                 RHTTPSession::GetTable()),
   483 					extPrefs.SetConnSelectionDialog(ETrue);
   459                                                 THTTPHdrVal(aSocketServer.Handle()));
   484 					}
   460     
   485 				else
   461     // Attach connection  
   486 					{
   462     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
   487 					extPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
   463     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
   488 					//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);					
   464                                                 RHTTPSession::GetTable()), 
   489 					}
   465                                                 THTTPHdrVal(connPtr));
   490 				}
   466                                                 
   491 			else
   467     // Remember the IAP id that is being set, because *at the moment*,
   492 				{
   468     // there is NO direct API to query effective IAP ID from CommsDB.
   493 				extPrefs.SetSnapId(aId);
   469     if (!retVal)
   494 				extPrefs.SetIapId(0);	
   470         {
   495 				extPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
   471         #ifdef __SINGLE_CLICK_CONNECTIVITY_ENABLED__
   496 				extPrefs.SetConnSelectionDialog(EFalse);
   472         	//Since we are using by default setIapId "0".
   497 				}
   473         	//There won't be any explicitly defined Iap Id
   498 			prefList.AppendL(&extPrefs);
   474         	iExplicitIapDefined = EFalse;
   499 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "SetID: RConnection Start");
   475         	iIapId = 0;
   500 			retVal = aConnection.Start(prefList);
   476 				#else        	
   501 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection Start retval[%d]"), retVal));
   477         	iExplicitIapDefined = ETrue;
   502 			if(retVal == KErrNone)
   478         	iIapId = aIapId;
   503 				{
   479         #endif //__SINGLE_CLICK_CONNECTIVITY_ENABLED__
   504 				aConnection.GetIntSetting( _L("IAP\\Id"), iIapId);
   480         }
   505 				TName name;
   481     return retVal;
   506 				retVal = aConnection.Name(name);
   482     }
   507 				if(retVal == KErrNone)
       
   508 					{
       
   509 					TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP Name [%S]"), &name));
       
   510 					}
       
   511 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("GetIntSetting returned IAP [%d]"), iIapId));
       
   512 				}
       
   513 			 else
       
   514 			    {
       
   515 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("SNAP ->Start retVal [%d]"), retVal));
       
   516 			    }				
       
   517 		    }
       
   518 		}    
       
   519 #endif    
       
   520     if (!retVal && !aSNAP)
       
   521         {
       
   522         iExplicitIapDefined = ETrue;
       
   523         }	
       
   524 	return retVal;
       
   525 }
       
   526 
   483 TInt CSenHttpChannelImpl::SetSnapPrefsL( TUint32 aSnapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   527 TInt CSenHttpChannelImpl::SetSnapPrefsL( TUint32 aSnapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   484     {
   528     {
   485     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- CSenHttpChannelImpl::SetSnapPrefsL, SNAP ID (%d)"), aSnapId));
   529     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- CSenHttpChannelImpl::SetSnapPrefsL, SNAP ID (%d)"), aSnapId));
   486 		// Check whether SNAP ID is not equal with the one that is currently in effect:
   530 		// Check whether SNAP ID is not equal with the one that is currently in effect:
   487     if(iExplicitIapDefined && iSnapId == aSnapId )
   531     if(iExplicitIapDefined && iSnapId == aSnapId)
   488         {
   532         {
   489         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is same as currently in effect");
   533         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is same as currently in effect");
   490         return KErrNone;
   534         return KErrNone;
   491         }
   535         }
   492 		else
   536 	else
   493 			{
   537 		{
   494 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is different with currently in effect");
   538 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is different with currently in effect");
   495 			}        
   539 		}
   496 
   540 	
   497     // Check if socket server (connection) is already open..
   541     // Check if socket server (connection) is already open..
   498     if( iExplicitIapDefined )
   542     if( iExplicitIapDefined )
   499         {
   543         {
   500          // Socket server opened once before for some other IAP
   544          // Socket server opened once before for some other IAP
   501         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   545         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   502         aConnection.Stop();
   546         aConnection.Stop();
   503         }
   547         }
   504     else
   548     else
   505         {
   549         {
   506         // Connect to a socket server    
   550         if(aConnection.SubSessionHandle())
   507         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Connecting to new socket server");    
   551         	{
   508         User::LeaveIfError( aSocketServer.Connect() );       
   552             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   509 
   553         	aConnection.Stop();
   510         // Open new connection
   554         	}
   511         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Opening new RConnection using the socket server.");       
   555         else
   512         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
   556             {
       
   557             // Connect to a socket server    
       
   558             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Connecting to new socket server");    
       
   559             User::LeaveIfError( aSocketServer.Connect() );       
       
   560     
       
   561             // Open new connection
       
   562             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Opening new RConnection using the socket server.");       
       
   563             User::LeaveIfError( aConnection.Open(aSocketServer) );         
       
   564             }
   513         }
   565         }
   514         
   566         
   515     // Set the SNAP selection preferences (SNAP ID)
   567         
   516     TConnSnapPref pref;
   568 	// Set the SNAP selection preferences (SNAP ID, do not prompt)    
   517     pref.SetSnap(aSnapId);     
   569 	TInt retVal = SetID(aSnapId, aDialogPref, aConnection, aSocketServer, ETrue);
   518     
   570     
   519     // Start the connection with the new preferences
       
   520     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Calling RConnection::Start with new SNAP prefs");
       
   521     TInt retVal = aConnection.Start(pref);
       
   522     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetSnapPrefsL, RConnection::Start returned: (%d)"), retVal));
   571     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetSnapPrefsL, RConnection::Start returned: (%d)"), retVal));
   523     
   572     
   524     // Get the connection "handle" from the HTTP session    
   573     // Get the connection "handle" from the HTTP session    
   525     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   574     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   526      
   575      
   537                                                 
   586                                                 
   538     // Remember the SNAP id that is being set, because *at the moment*,
   587     // Remember the SNAP id that is being set, because *at the moment*,
   539     // there is NO direct API to query effective SNAP ID from CommsDB.
   588     // there is NO direct API to query effective SNAP ID from CommsDB.
   540     if (!retVal)
   589     if (!retVal)
   541         {
   590         {
   542         iExplicitIapDefined = ETrue;
   591         //iExplicitIapDefined = ETrue;
   543         iSnapId = aSnapId;
   592         iSnapId = aSnapId;
   544         }
   593         }
   545     return retVal;
   594     return retVal;
   546     }
   595     }
   547 
   596 
   667     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL");
   716     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL");
   668     TUriParser8 uri;
   717     TUriParser8 uri;
   669     RStringF method;
   718     RStringF method;
   670     TPtrC8 deflate;
   719     TPtrC8 deflate;
   671     // Set IAP preferences, if such exist in properties (and not already in effect):
   720     // Set IAP preferences, if such exist in properties (and not already in effect):
   672     TUint32 iapId(KErrNone);
   721     TUint32 id(KErrNone);
   673     TBool doNotPrompt(ETrue); 
   722     TBool prompt(ETrue); 
   674     
   723     
   675     TInt retVal = aProps.IAPDialogL( doNotPrompt );
   724     TInt retVal = aProps.IAPDialogL( prompt );
   676     if ( retVal != KErrNone )
   725     if ( retVal != KErrNone )
   677         {
   726         {
   678         // by default, do not prompt (even if property does not exist!) 
   727         // by default, do not prompt (even if property does not exist!) 
   679         // => only if property is set, and has value "FALSE", show PROMPT            
   728         // => only if property is set, and has value "FALSE", show PROMPT            
   680         doNotPrompt = ETrue;
   729         prompt = ETrue;
   681         }
   730         }
   682 
   731 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::InvokeHttpMethodL - iIapId [%d]"), iIapId)); 
       
   732 #ifndef __ENABLE_ALR__
       
   733 		TInt propRetVal = aProps.IapIdL(id);
   683     // Independent of dialog preference (property's existance), if IAP was predefined, it must be set        
   734     // Independent of dialog preference (property's existance), if IAP was predefined, it must be set        
   684     if(((aProps.IapIdL(iapId)) == KErrNone))
   735     if(propRetVal == KErrNone)
   685         {
   736         {
   686         retVal = SetIapPrefsL(iapId, doNotPrompt, iConnection, iSockServ);
   737         TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::InvokeHttpMethodL SetIapPrefs - id [%d]"), id));
   687         }
   738         retVal = SetIapPrefsL(id, prompt, iConnection, iSockServ);
   688     else if(((aProps.SnapIdL(iapId)) == KErrNone))
   739         }
   689         {
   740     else if(iIapId > 0)
   690         retVal = SetSnapPrefsL(iapId, doNotPrompt, iConnection, iSockServ);
   741         {
       
   742         TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::InvokeHttpMethodL SetIapPrefs - iIapId [%d]"), iIapId)); 
       
   743         retVal = SetIapPrefsL(iIapId, prompt, iConnection, iSockServ);
       
   744         }
       
   745     else if(((aProps.SnapIdL(id)) == KErrNone))
       
   746         {
       
   747         retVal = SetSnapPrefsL(id, prompt, iConnection, iSockServ);
   691         }
   748         }
   692     else//to better control RConnection, we have to call Start by ourselve
   749     else//to better control RConnection, we have to call Start by ourselve
   693         {
   750         {
   694         retVal = SetSnapPrefsL(0, EFalse, iConnection, iSockServ);
   751         retVal = SetSnapPrefsL(0, EFalse, iConnection, iSockServ);
   695         if(retVal == KErrNotFound)
   752         if(retVal == KErrNotFound)
   696             {
   753             {
   697             retVal = SetIapPrefsL(0, EFalse, iConnection, iSockServ);
   754             if(iOCCenabled == EFalse)
       
   755 		        {
       
   756 	    	    retVal = SetIapPrefsL(0, EFalse, iConnection, iSockServ);	
       
   757 	        	}
       
   758         	else
       
   759 	        	{
       
   760 	        	retVal = SetSnapPrefsL(0, prompt, iConnection, iSockServ);	
       
   761 	        	}
   698             }
   762             }
   699         }
   763         }
   700     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Set Snap/IAP prefs retVal [%d]"), retVal));    
   764     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Set Snap/IAP prefs retVal [%d]"), retVal));    
   701     User::LeaveIfError(retVal);
   765     User::LeaveIfError(retVal);
   702     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL After User::Leave");
   766     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL After User::Leave");
   703     TInt ret=iConnection.GetIntSetting(_L("IAP\\Id"), iUsedIapId);
   767     //TInt ret= iConnection.GetIntSetting(_L("IAP\\Id"), iUsedIapId);
       
   768     iUsedIapId = iIapId;
   704     // Check transport properties
   769     // Check transport properties
       
   770     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP/SNAP %d"), id));
       
   771 #else
       
   772 	retVal = SetIapPrefsL(id, prompt, iConnection, iSockServ);
       
   773 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP/SNAP %d"), id));	
       
   774 	iUsedIapId = id;
       
   775 #endif
       
   776     
   705     CSenLayeredHttpTransportProperties::TSenHttpMethod httpMethod;
   777     CSenLayeredHttpTransportProperties::TSenHttpMethod httpMethod;
   706     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP %d"), iapId));
   778     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("PROMPT %d"), prompt));
   707     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("DONT PROMPT %d"), doNotPrompt));
       
   708     TInt retValHttpMethod = aProps.HttpMethodL(httpMethod);
   779     TInt retValHttpMethod = aProps.HttpMethodL(httpMethod);
   709     
   780     
   710     
   781     
   711     /*Installing the deflate filter based on the property values */
   782     /*Installing the deflate filter based on the property values */
   712     /*Once installed, the filter will be alive for on session lifetime */   
   783     /*Once installed, the filter will be alive for on session lifetime */   
  1012         }
  1083         }
  1013 
  1084 
  1014     // It is MANDATORY, that at least one Accept header TOKEN exists:
  1085     // It is MANDATORY, that at least one Accept header TOKEN exists:
  1015   if ( tokens.Count()==0 )
  1086   if ( tokens.Count()==0 )
  1016         {
  1087         {
       
  1088         TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::AddRequestHeadersL Default Token")));
  1017         TPtrC8* pDefaultToken = new (ELeave) TPtrC8( KSenHttpChannelAcceptHeaderDefault );
  1089         TPtrC8* pDefaultToken = new (ELeave) TPtrC8( KSenHttpChannelAcceptHeaderDefault );
  1018         TInt error = tokens.Append( pDefaultToken );
  1090         TInt error = tokens.Append( pDefaultToken );
  1019         if ( error )
  1091         if ( error )
  1020             {
  1092             {
  1021             delete pDefaultToken;
  1093             delete pDefaultToken;
       
  1094             pDefaultToken = NULL;
  1022             }
  1095             }
  1023         }
  1096         }
  1024     // Http headers
  1097     // Http headers
  1025     TInt headerCount(0);
  1098     TInt headerCount(0);
  1026     RPointerArray<MSenProperty> headersArray;
  1099     RPointerArray<MSenProperty> headersArray;
  1048                     // @InvokeHttpMethodL()
  1121                     // @InvokeHttpMethodL()
  1049                     continue;
  1122                     continue;
  1050                     }
  1123                     }
  1051 
  1124 
  1052                 TPtrC8 value = property->Value();
  1125                 TPtrC8 value = property->Value();
  1053                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Adding HTTP HEADER, name: (%S), value: (%S)"),
  1126                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Adding HTTP HEADER, name: (%S), value: (%S)"), &name, &value));
  1054                     &name, &value));
       
  1055 
  1127 
  1056                 // Open stringpool strings
  1128                 // Open stringpool strings
  1057                 RStringF headerName = iStringPool.OpenFStringL(name);
  1129                 RStringF headerName = iStringPool.OpenFStringL(name);
  1058                 CleanupClosePushL(headerName);
  1130                 CleanupClosePushL(headerName);
  1059                 RStringF headerValue = iStringPool.OpenFStringL(value);
  1131                 RStringF headerValue = iStringPool.OpenFStringL(value);
  1062                 THTTPHdrVal headerFieldVal;
  1134                 THTTPHdrVal headerFieldVal;
  1063                 headerFieldVal.SetStrF(headerValue);
  1135                 headerFieldVal.SetStrF(headerValue);
  1064                 // Check if the header field value already exists
  1136                 // Check if the header field value already exists
  1065                 TBool fieldValueExists = EFalse;
  1137                 TBool fieldValueExists = EFalse;
  1066                 TInt fieldCount = aHeaders.FieldPartsL(headerName);
  1138                 TInt fieldCount = aHeaders.FieldPartsL(headerName);
  1067                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S > field count: %d"), &name,
  1139                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S > field count: %d"), &name, fieldCount));
  1068                                         fieldCount));
       
  1069 
  1140 
  1070                 for(TInt j=0; j<fieldCount; j++)
  1141                 for(TInt j=0; j<fieldCount; j++)
  1071                     {
  1142                     {
  1072                     THTTPHdrVal hVal;
  1143                     THTTPHdrVal hVal;
  1073                     TInt retCode = aHeaders.GetField(headerName, j, hVal);
  1144                     TInt retCode = aHeaders.GetField(headerName, j, hVal);
  1085 
  1156 
  1086                 // Add header field
  1157                 // Add header field
  1087                 if(!fieldValueExists)
  1158                 if(!fieldValueExists)
  1088                     {
  1159                     {
  1089                     aHeaders.SetFieldL(headerName, headerFieldVal);
  1160                     aHeaders.SetFieldL(headerName, headerFieldVal);
  1090                     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S: %S > added"),
  1161                     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S: %S > added"),&name, &value));
  1091                                        &name, &value));
       
  1092                     }
  1162                     }
  1093 
  1163 
  1094                 // Close stringpool strings
  1164                 // Close stringpool strings
  1095                 CleanupStack::PopAndDestroy(2); // headerValue, headerName
  1165                 CleanupStack::PopAndDestroy(2); // headerValue, headerName
  1096                 }
  1166                 }
  1141 
  1211 
  1142             if(KErrNotFound != retCode)
  1212             if(KErrNotFound != retCode)
  1143                 {
  1213                 {
  1144 #ifdef _SENDEBUG
  1214 #ifdef _SENDEBUG
  1145                 const TDesC8& hValStr = hVal.StrF().DesC();
  1215                 const TDesC8& hValStr = hVal.StrF().DesC();
  1146                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Accept: %S"),
  1216                 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Accept: %S"), &hValStr));
  1147                                    &hValStr));
       
  1148 #endif // _SENDEBUG
  1217 #endif // _SENDEBUG
  1149                 if(hVal == headerFieldVal)
  1218                 if(hVal == headerFieldVal)
  1150                     {
  1219                     {
  1151                     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < Accept: %S > already exists"), &token));
  1220                     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < Accept: %S > already exists"), &token));
  1152                     fieldValueExists = ETrue;
  1221                     fieldValueExists = ETrue;
  1556     }
  1625     }
  1557 
  1626 
  1558 void CSenHttpChannelImpl::HandleRunErrorL(RHTTPTransaction aTransaction,
  1627 void CSenHttpChannelImpl::HandleRunErrorL(RHTTPTransaction aTransaction,
  1559                                           TInt aError)
  1628                                           TInt aError)
  1560     {
  1629     {
       
  1630     TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"CSenHttpChannelImpl::HandleRunErrorL()");
  1561     TInt txnId = aTransaction.Id();
  1631     TInt txnId = aTransaction.Id();
  1562     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleRunErrorL( %d ): %d"),txnId, aError));
  1632     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleRunErrorL( %d ): %d"),txnId, aError));
  1563     CSenTxnState* pTxnState = FindTxnState(txnId);
  1633     CSenTxnState* pTxnState = FindTxnState(txnId);
  1564     __ASSERT_ALWAYS(pTxnState != NULL,
  1634     __ASSERT_ALWAYS(pTxnState != NULL,
  1565                     User::Panic(KTxnStateNullPanicText,
  1635                     User::Panic(KTxnStateNullPanicText,
  1566                     CSenHttpChannel::ETxnStateNull));
  1636                     CSenHttpChannel::ETxnStateNull));
  1567 
  1637 
  1568     pTxnState->ResponseErrorL(aError);
  1638     pTxnState->ResponseErrorL(aError);
  1569     DeleteTxnState(txnId);
  1639     DeleteTxnState(txnId);
  1570     aTransaction.Close();
  1640     aTransaction.Close();
       
  1641     TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"CSenHttpChannelImpl::HandleRunErrorL() Completed");
  1571     }
  1642     }
  1572 
  1643 
  1573 void CSenHttpChannelImpl::HandleRedirectRequiresConfirmationL(
  1644 void CSenHttpChannelImpl::HandleRedirectRequiresConfirmationL(
  1574                                                 RHTTPTransaction aTransaction)
  1645                                                 RHTTPTransaction aTransaction)
  1575     {
  1646     {
  1873     }
  1944     }
  1874 
  1945 
  1875 
  1946 
  1876 TBool CSenHttpChannelImpl::EffectiveIapId( TUint32 &aIapId )
  1947 TBool CSenHttpChannelImpl::EffectiveIapId( TUint32 &aIapId )
  1877     {
  1948     {
  1878 	TInt handle = iConnection.SubSessionHandle();
  1949     /*
       
  1950 		TInt handle = iConnection.SubSessionHandle();
  1879 		if (handle>0)
  1951 		if (handle>0)
  1880 	    {
  1952 		    {
       
  1953 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): Current RConnection's subsession handle(%d)"), handle ));	    
  1881         TUint connEnum(0);
  1954         TUint connEnum(0);
  1882         TInt err = iConnection.EnumerateConnections(connEnum);
  1955         TInt err = iConnection.EnumerateConnections(connEnum);
       
  1956         TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId -  EnumerateConnections retVal [%d]"), err ));
  1883         if (!err && !connEnum)
  1957         if (!err && !connEnum)
  1884             {
  1958             {
       
  1959             TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::EffectiveIapId returns");
  1885             return EFalse;
  1960             return EFalse;
  1886             }
  1961             }
  1887 	    }
  1962 		    }
  1888 
  1963 	    else
  1889 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): Current RConnection's subsession handle(%d)"), iIapId ));
  1964 		    {
  1890 #ifdef _SENDEBUG
  1965 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," -> RConnection has not been initialized.");	
       
  1966 		    }
       
  1967 		*/
  1891 	if( iExplicitIapDefined )
  1968 	if( iExplicitIapDefined )
  1892 		{
  1969 		{
  1893 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8(" - IAP ID is known: %d"), iIapId ));
  1970 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8(" - IAP ID is known: %d"), iIapId ));
  1894 		}
  1971 		}
  1895 	else
  1972 	else
  1896 		{
  1973 		{
  1897 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," - IAP ID is not known.");
  1974 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," - IAP ID is not known.");
  1898 		}
  1975 		}
  1899 		
  1976 		    
  1900 	if( handle < KErrNone )
  1977   if(/* handle && */!iExplicitIapDefined )
  1901 		{
  1978   	{
  1902 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," -> RConnection has not been initialized.");
       
  1903 		}
       
  1904 #endif // _SENDEBUG    
       
  1905     
       
  1906     if( handle && !iExplicitIapDefined )
       
  1907     	{
       
  1908 		// Eventhough IAP was not explicitely set (through Serene API), this
  1979 		// Eventhough IAP was not explicitely set (through Serene API), this
  1909 		// code can check what IAP end-user provided via IAP selection dialog:
  1980 		// code can check what IAP end-user provided via IAP selection dialog:
  1910 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::EffectiveIapId: about to call RConnection::GetIntSetting()");
  1981 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::EffectiveIapId: about to call RConnection::GetIntSetting()");
  1911 		_LIT( KIapIdKey, "IAP\\Id" );
  1982 	//_LIT( KIapIdKey, "IAP\\Id" );
  1912 	    iConnection.GetIntSetting( KIapIdKey, iIapId);
  1983     //iConnection.GetIntSetting( KIapIdKey, iIapId);
  1913 	    if ( iIapId > 0 )
  1984     if ( iIapId > 0 )
  1914 	    	{
  1985     	{
  1915 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): end-user provided IAP(%d)"), iIapId ));
  1986 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("---- GetIntSetting(): retuens IAP(%d)"), iIapId ));
  1916 	    	// Treat the end-user selection as "explicit" definition as well(!):
  1987     	// Treat the end-user selection as "explicit" definition as well(!):
  1917 	    	iExplicitIapDefined = ETrue; 
  1988     	iExplicitIapDefined = ETrue; 
  1918 	    	}
  1989     	}
  1919 	    }
  1990     }
  1920     if( iExplicitIapDefined )
  1991   if( iExplicitIapDefined )
  1921         {
  1992       {
  1922         aIapId = iIapId;
  1993       aIapId = iIapId;
  1923         }
  1994       }
       
  1995   	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId() returns(%d)"), iExplicitIapDefined ));
  1924     return iExplicitIapDefined;
  1996     return iExplicitIapDefined;
  1925     }
  1997     }
  1926 
  1998 
  1927 void CSenHttpChannelImpl::EnableTimeOutL(TInt aTxnId, TInt aTimeOutSec)
  1999 void CSenHttpChannelImpl::EnableTimeOutL(TInt aTxnId, TInt aTimeOutSec)
  1928     {
  2000     {
  1939 
  2011 
  1940 TInt32 CSenHttpChannelImpl::UsedIap()
  2012 TInt32 CSenHttpChannelImpl::UsedIap()
  1941     {
  2013     {
  1942     return iUsedIapId;
  2014     return iUsedIapId;
  1943     }
  2015     }
       
  2016     
       
  2017 void CSenHttpChannelImpl::ResetIapId()
       
  2018     {
       
  2019     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::ResetIapId()");
       
  2020     iIapId = 0; //Reset to Zero in case of errors to enable other IAP
       
  2021     }
       
  2022 		
       
  2023 void CSenHttpChannelImpl::ResetUsedIapId()
       
  2024     {
       
  2025     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::ResetUsedIapId()");
       
  2026     iUsedIapId = 0; //Reset to Zero in case of errors to enable other IAP
       
  2027     }
       
  2028     
  1944 // END OF FILE
  2029 // END OF FILE
  1945 
       
  1946