webservices/wshttpchanneltransportplugin/src/senhttpchannelimpl.cpp
changeset 15 0aea830faa24
parent 3 b5a195438f6a
child 23 a1df79fa35b4
equal deleted inserted replaced
3:b5a195438f6a 15:0aea830faa24
    29 #include <es_sock.h>
    29 #include <es_sock.h>
    30 #include <in_sock.h>
    30 #include <in_sock.h>
    31 #include <http.h>
    31 #include <http.h>
    32 
    32 
    33 #include "sendebug.h" // filelogging and debugging MACROS
    33 #include "sendebug.h" // filelogging and debugging MACROS
    34 #include "senserviceconnection.h" // KErrSenNoHttpResponseBody
    34 #include <SenServiceConnection.h> // KErrSenNoHttpResponseBody
    35 #include "senelement.h"
    35 #include <SenElement.h>
    36 #include "senxmlutils.h"
    36 #include <SenXmlUtils.h>
    37 #include "senhttptransportproperties.h"
    37 #include <SenHttpTransportProperties.h>
    38 #include "senhttpchannelimpl.h"
    38 #include "senhttpchannelimpl.h"
    39 #include "senhttpeventhandler.h"
    39 #include "senhttpeventhandler.h"
    40 #include "sentxnstate.h"
    40 #include "sentxnstate.h"
    41 #include "senatomtxnstate.h"
    41 #include "senatomtxnstate.h"
    42 #include "senrfiletxnstate.h"
    42 #include "senrfiletxnstate.h"
    45 #include "msenidentitymanager.h"
    45 #include "msenidentitymanager.h"
    46 #include "senlogger.h"
    46 #include "senlogger.h"
    47 
    47 
    48 #include "senhttpchanneltransportplugin.h"
    48 #include "senhttpchanneltransportplugin.h"
    49 //For HTTPProxyFilter
    49 //For HTTPProxyFilter
    50 #include <httpfilterproxyinterface.h>
    50 #include <HttpFilterProxyInterface.h>
    51 #include <httpfilteracceptheaderinterface.h>
    51 #include <HttpFilterAcceptHeaderInterface.h>
    52 #include <httpfiltercommonstringsext.h>
    52 #include <HttpFilterCommonStringsExt.h>
    53 #include <deflatefilterinterface.h>
    53 #include <DeflateFilterInterface.h>
    54 
       
    55 #ifndef __ENABLE_ALR__
       
    56 #include <versioninfo.h>  // VersionInfo
       
    57 #include <extendedconnpref.h>
       
    58 #endif
       
    59 
    54 
    60 // CONSTANTS
    55 // CONSTANTS
    61 namespace
    56 namespace
    62     {
    57     {
    63     _LIT(KTxnStateNullPanicText,            "TxnState is NULL");
    58     _LIT(KTxnStateNullPanicText,            "TxnState is NULL");
    88     iPasswordFromUser(EFalse),
    83     iPasswordFromUser(EFalse),
    89     iExplicitIapDefined(EFalse),
    84     iExplicitIapDefined(EFalse),
    90     iProxyHostPort(NULL),
    85     iProxyHostPort(NULL),
    91     iXopResponse(EFalse),
    86     iXopResponse(EFalse),
    92     iHasHttpContentType(ETrue)
    87     iHasHttpContentType(ETrue)
    93 #ifndef __ENABLE_ALR__
    88     {
    94     , iOCCenabled(EFalse)
       
    95 #endif    
       
    96     {
       
    97 //    IsOCCImplementedSDK();
       
    98     }
    89     }
    99 
    90 
   100 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager)
    91 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager)
   101     {
    92     {
   102     CSenHttpChannelImpl* pNew = NewLC(aManager);
    93     CSenHttpChannelImpl* pNew = NewLC(aManager);
   126     CSenHttpChannelImpl* pNew = new (ELeave) CSenHttpChannelImpl(aManager);
   117     CSenHttpChannelImpl* pNew = new (ELeave) CSenHttpChannelImpl(aManager);
   127     CleanupStack::PushL(pNew);
   118     CleanupStack::PushL(pNew);
   128     pNew->ConstructL(aIapId); 
   119     pNew->ConstructL(aIapId); 
   129     return pNew;
   120     return pNew;
   130     }
   121     }
   131 
       
   132 #ifndef __ENABLE_ALR__
       
   133 // On return, aMajor and aMinor contain the version information
       
   134 TInt CSenHttpChannelImpl::GetS60PlatformVersion(TUint& aMajor, TUint& aMinor)
       
   135 	{   
       
   136 	TInt ret = KErrNone;
       
   137 	// Connect to the file server session
       
   138 	RFs fsSession;
       
   139 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::GetS60PlatformVersion()")));	
       
   140 	ret = fsSession.Connect();
       
   141 	if(ret == KErrNone)
       
   142 		{
       
   143 		CleanupClosePushL(fsSession); // Obtain the version numberTUint major;
       
   144 		VersionInfo::TPlatformVersion platformVersion;  
       
   145 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "--- GetS60PlatformVersion getting Version info");		
       
   146 		ret = VersionInfo::GetVersion(platformVersion, fsSession);   
       
   147 		CleanupStack::PopAndDestroy();  // fsSession		
       
   148 		if (ret == KErrNone)       
       
   149 			{     
       
   150 			aMajor = platformVersion.iMajorVersion;  
       
   151 			aMinor = platformVersion.iMinorVersion;   
       
   152 		   	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("--- GetS60PlatformVersion Version: Major [%d], Minor[%d]"), aMajor, aMinor));
       
   153 			}		
       
   154 		}
       
   155 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("--- GetS60PlatformVersion returns [%d]"), ret));
       
   156 	return ret;
       
   157 	}
       
   158 
       
   159 // On return, aMajor and aMinor contain the version information
       
   160 TBool CSenHttpChannelImpl::IsOCCImplementedSDK()
       
   161 	{   
       
   162 	TBool occ = EFalse;
       
   163 	// Obtain the version number
       
   164 	TUint major;
       
   165 	TUint minor;	
       
   166 	TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::IsOCCImplementedSDK()")));		
       
   167 	TInt ret = GetS60PlatformVersion(major, minor);
       
   168 	if (ret == KErrNone)
       
   169 		{
       
   170 		if(major == 5 && minor == 2)
       
   171 			{
       
   172 			occ = ETrue;
       
   173 			iOCCenabled = ETrue;
       
   174 			TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("---- IsOCCImplementedSDK() returns TRUE")));
       
   175 			}
       
   176 		else
       
   177 			{
       
   178 			TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("---- IsOCCImplementedSDK() returns False")));
       
   179 			}
       
   180 		}
       
   181 	return occ;
       
   182 	}
       
   183 #endif	
       
   184 
   122 
   185 // Ask IAP from user
   123 // Ask IAP from user
   186 void CSenHttpChannelImpl::ConstructL()
   124 void CSenHttpChannelImpl::ConstructL()
   187     {
   125     {
   188     // Open connection to the file logger server
   126     // Open connection to the file logger server
   222     iTransObs = CSenHttpEventHandler::NewL(this);//, &iLog);
   160     iTransObs = CSenHttpEventHandler::NewL(this);//, &iLog);
   223     iTxnStates =
   161     iTxnStates =
   224         new (ELeave) CArrayPtrFlat<CSenTxnState>(KMinimumArrayGranularity);
   162         new (ELeave) CArrayPtrFlat<CSenTxnState>(KMinimumArrayGranularity);
   225 
   163 
   226     iBasicConnectionTries = 0;
   164     iBasicConnectionTries = 0;
   227     
       
   228 #ifndef __ENABLE_ALR__
       
   229     IsOCCImplementedSDK();
       
   230 #endif    
       
   231 
   165 
   232 #ifdef _SENDEBUG
   166 #ifdef _SENDEBUG
   233     ListFilters();
   167     ListFilters();
   234 #endif // _SENDEBUG
   168 #endif // _SENDEBUG
   235     }
   169     }
   247 
   181 
   248 
   182 
   249 //    Use local variable (new RSocketServer each time; handle is given to RHTTPSession via RConnectionInfo..)
   183 //    Use local variable (new RSocketServer each time; handle is given to RHTTPSession via RConnectionInfo..)
   250 //    RSocketServ server; // with "anon" (local) socket servers, should we keep array of open ones in case of pending txns?
   184 //    RSocketServ server; // with "anon" (local) socket servers, should we keep array of open ones in case of pending txns?
   251 //    SetIapPrefsL(aIapId, iConnection, server);
   185 //    SetIapPrefsL(aIapId, iConnection, server);
   252 #ifndef __ENABLE_ALR__
       
   253 	IsOCCImplementedSDK();
       
   254 #endif	
       
   255 
   186 
   256     const TInt result = SetIapPrefsL(aIapId, ETrue, iConnection, iSockServ);
   187     const TInt result = SetIapPrefsL(aIapId, ETrue, iConnection, iSockServ);
   257     User::LeaveIfError( result );
   188     User::LeaveIfError( result );
   258     
   189     
   259     }
   190     }
   296     // Close the log file and the connection to the server.
   227     // Close the log file and the connection to the server.
   297     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("Log file closed.")));
   228     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("Log file closed.")));
   298     TLSLOG_CLOSE(KSenHttpChannelLogChannelBase);
   229     TLSLOG_CLOSE(KSenHttpChannelLogChannelBase);
   299     }
   230     }
   300 
   231 
   301 TInt CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   232 // This function expects that RConnection has been connected
   302    	{
   233 // and that RConnection has already been opened!
   303    	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("- SetIapPrefsL	, IAP ID (%d)"), aIapId));
   234 /*
   304    	
   235 void CSenHttpChannelImpl::SetIapPrefsL(TUint32 aIapId, 
       
   236                                        RConnection& aConnection, 
       
   237                                        RSocketServ& aSocketServer)
       
   238     {
   305     // Check whether IAP ID is not equal with the one that is currently in effect:
   239     // Check whether IAP ID is not equal with the one that is currently in effect:
   306     if(iExplicitIapDefined && iIapId == aIapId )
   240     if(iExplicitIapDefined && iIapId == aIapId )
   307         {
   241         {
   308         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id is same as currently in effect");
   242         return; // nothing to do
   309         return KErrNone;
   243         }
   310         }
   244         
   311 	else
   245     LOG_WRITEFORMAT((_L8("- SetIapPrefsL: Re-setting IAP ID (%d)"), aIapId));
   312 		{
       
   313 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id different with the currently in effect");
       
   314 		}    
       
   315     
       
   316 
   246 
   317     // Check if socket server (connection) is already open..
   247     // Check if socket server (connection) is already open..
   318     if( iExplicitIapDefined )
   248     if( iExplicitIapDefined )
   319         {
   249         {
   320          // Socket server opened once before for some other IAP
   250          // Socket server opened once before for some other IAP
   321         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   251         LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   322         aConnection.Stop();
   252         aConnection.Stop();
   323         }
   253         }
   324     else
   254     else
   325         {
   255         {
       
   256         aConnection.Stop(); // prompted from user
       
   257         iSess.DisconnectL();
       
   258         iSess.ConnectL();
       
   259 
   326         // Connect to a socket server    
   260         // Connect to a socket server    
   327         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Connecting to new socket server");    
   261         LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server");    
   328         User::LeaveIfError( aSocketServer.Connect() );       
   262         User::LeaveIfError(aSocketServer.Connect());       
   329 
   263 
   330         // Open new connection
   264         // Open new connection
   331         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Opening new RConnection using the socket server.");       
   265         LOG_WRITE_L("- SetIapPrefsL: Opening new RConnection using the socket server.");       
   332         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
   266         User::LeaveIfError(aConnection.Open(aSocketServer)); 
   333         }
   267         }
   334         
   268         
   335     // Set the IAP selection preferences (IAP ID, do not prompt)    
   269     // Set the IAP selection preferences (IAP ID, do not prompt)
   336 	TInt retVal = SetID(aIapId, aDialogPref, aConnection, aSocketServer);	        
   270     TCommDbConnPref pref;
   337 	
   271     pref.SetIapId( aIapId );    
       
   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     
   338     // Get the connection "handle" from the HTTP session    
   281     // Get the connection "handle" from the HTTP session    
   339     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   282     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   340      
   283      
   341     // Attach socket server
   284     // Attach socket server
   342     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
   285     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
   345     
   288     
   346     // Attach connection  
   289     // Attach connection  
   347     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
   290     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
   348     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
   291     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
   349                                                 RHTTPSession::GetTable()), 
   292                                                 RHTTPSession::GetTable()), 
   350                                                 THTTPHdrVal(connPtr));                                                    
   293                                                 THTTPHdrVal(connPtr));
       
   294                                                 
       
   295     // Remember the IAP id that is being set; there is
       
   296     // no direct API to query effective IAP ID from CommsDB.
       
   297     iExplicitIapDefined = ETrue;
       
   298     iIapId = aIapId;
       
   299     }
       
   300 */
       
   301 
       
   302 
       
   303 /*
       
   304 void CSenHttpChannelImpl::SetupConnectionWithIapPrefsL( TUint32 aIapId, 
       
   305                                                         RConnection& aConnection, 
       
   306                                                         RSocketServ& aSocketServer )
       
   307     {
       
   308     // Check whether IAP ID is not equal with the one that is currently in effect:
       
   309     if(iExplicitIapDefined && iIapId == aIapId )
       
   310         {
       
   311         return; // nothing to do
       
   312         }
       
   313         
       
   314     LOG_WRITEFORMAT((_L8("- SetIapPrefsL, IAP ID (%d)"), aIapId));
       
   315 
       
   316     // Check if socket server (connection) is already open..
       
   317     if( iExplicitIapDefined )
       
   318         {
       
   319          // Socket server opened once before for some other IAP
       
   320         LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
       
   321         aConnection.Stop();
       
   322         }
       
   323     else
       
   324         {
       
   325         // Connect to a socket server    
       
   326         LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server");    
       
   327         User::LeaveIfError( aSocketServer.Connect() );       
       
   328 
       
   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
       
   397 				{
       
   398 				TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id different with the currently in effect");
       
   399 				}    
       
   400     
       
   401 
       
   402     // Check if socket server (connection) is already open..
       
   403     if( iExplicitIapDefined )
       
   404         {
       
   405          // Socket server opened once before for some other IAP
       
   406         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
       
   407         aConnection.Stop();
       
   408         }
       
   409     else
       
   410         {
       
   411         // Connect to a socket server    
       
   412         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Connecting to new socket server");    
       
   413         User::LeaveIfError( aSocketServer.Connect() );       
       
   414 
       
   415         // Open new connection
       
   416         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Opening new RConnection using the socket server.");       
       
   417         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
       
   418         }
       
   419         
       
   420     // Set the IAP selection preferences (IAP ID, do not prompt)
       
   421     /*
       
   422     *Single click connectivity feature has been implemented by CSock (RConnection class).
       
   423     *According to this client no need to set the IAP ID. 
       
   424     *Automatically RConnection will use the suitable IAP
       
   425     */
       
   426     
       
   427 
       
   428 	    TCommDbConnPref pref;
       
   429     #ifndef __SINGLE_CLICK_CONNECTIVITY_ENABLED__	    
       
   430 	    pref.SetIapId( aIapId );
       
   431 		#else
       
   432 			pref.SetIapId( 0 );	 //By default IAP ID is "0". IAP selection will take care by RConnection
       
   433     #endif //__SINGLE_CLICK_CONNECTIVITY_ENABLED__	    
       
   434 	    TCommDbDialogPref dialogPref;
       
   435 	    
       
   436 	    if (aDialogPref)
       
   437 	        {
       
   438 	        dialogPref = ECommDbDialogPrefDoNotPrompt;
       
   439 	        }
       
   440 	    else
       
   441 	        {
       
   442 	        dialogPref = ECommDbDialogPrefPrompt;
       
   443 	        }     
       
   444 	    pref.SetDialogPreference(dialogPref);
       
   445     
       
   446   	// Start the connection with the new preferences
       
   447 	  TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Calling RConnection::Start with new IAP prefs");
       
   448 
       
   449     TInt retVal =aConnection.Start(pref);
       
   450     
       
   451 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection->Start retVal [%d]"), retVal));
       
   452 		        
       
   453     // Get the connection "handle" from the HTTP session    
       
   454     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
       
   455      
       
   456     // Attach socket server
       
   457     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketServ,
       
   458                                                 RHTTPSession::GetTable()),
       
   459                                                 THTTPHdrVal(aSocketServer.Handle()));
       
   460     
       
   461     // Attach connection  
       
   462     TInt connPtr = REINTERPRET_CAST(TInt, &aConnection);
       
   463     connInfo.SetPropertyL(iStringPool.StringF(  HTTP::EHttpSocketConnection, 
       
   464                                                 RHTTPSession::GetTable()), 
       
   465                                                 THTTPHdrVal(connPtr));
       
   466                                                 
       
   467     // Remember the IAP id that is being set, because *at the moment*,
       
   468     // there is NO direct API to query effective IAP ID from CommsDB.
       
   469     if (!retVal)
       
   470         {
       
   471         #ifdef __SINGLE_CLICK_CONNECTIVITY_ENABLED__
       
   472         	//Since we are using by default setIapId "0".
       
   473         	//There won't be any explicitly defined Iap Id
       
   474         	iExplicitIapDefined = EFalse;
       
   475         	iIapId = 0;
       
   476 				#else        	
       
   477         	iExplicitIapDefined = ETrue;
       
   478         	iIapId = aIapId;
       
   479         #endif //__SINGLE_CLICK_CONNECTIVITY_ENABLED__
       
   480         }
   351     return retVal;
   481     return retVal;
   352     }
   482     }
   353 
       
   354 TInt CSenHttpChannelImpl::SetID(TUint32 aId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer, TBool aSNAP)
       
   355 {
       
   356    /*
       
   357     * Single click connectivity feature has been implemented by CSock (RConnection class).
       
   358     * According to this client no need to set the IAP ID. 
       
   359     * Automatically RConnection will use the suitable IAP
       
   360     */
       
   361     TInt retVal = KErrNone;
       
   362     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl  called with ID [%d]"), aId));
       
   363 	    
       
   364 #ifndef __ENABLE_ALR__	    
       
   365 	if (iOCCenabled == EFalse)	    
       
   366 		{
       
   367 #endif		
       
   368 		if (aSNAP == EFalse)
       
   369 			{
       
   370 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- SetIAPID");
       
   371 		    TCommDbConnPref pref;		
       
   372 			pref.SetIapId( aId );
       
   373 			TCommDbDialogPref dialogPref;
       
   374 		    if (aDialogPref)
       
   375 		        {
       
   376 		        dialogPref = ECommDbDialogPrefDoNotPrompt;
       
   377 		        }
       
   378 		    else
       
   379 		        {
       
   380 		        dialogPref = ECommDbDialogPrefPrompt;
       
   381 		        }
       
   382 	    	pref.SetDialogPreference(dialogPref);
       
   383 	    	retVal = aConnection.Start(pref);
       
   384 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection->Start retVal [%d]"), retVal));
       
   385 			}
       
   386 		else
       
   387 			{
       
   388 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- SetSNAPID");
       
   389 			// Set the SNAP selection preferences (SNAP ID)
       
   390 		    TConnSnapPref pref;
       
   391 		    pref.SetSnap(aId);		    
       
   392 		    // Start the connection with the new preferences
       
   393 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Calling RConnection::Start with new SNAP prefs");
       
   394 		    TInt retVal = aConnection.Start(pref);
       
   395 			}
       
   396 #ifndef __ENABLE_ALR__			
       
   397 		}   
       
   398 	else
       
   399 		{
       
   400 		if (aSNAP == EFalse)
       
   401 			{
       
   402 			/* If IAP id is zero, it is interpreted as
       
   403 		    * client's request for not requesting any specific IAP.
       
   404 		    * Default value is 0.
       
   405 		    * 
       
   406 		    * If IAP id is set, SNAP id shall be zero.
       
   407 		    * If IAP id is set, SNAP purpose shall be CMManager::ESnapPurposeUnknown.
       
   408 		    * If IAP id is set, Connection selection dialog shall be disabled.
       
   409 		    * If IAP id is set, bearer set shall be EExtendedConnBearerUnknown.
       
   410 		    * If IAP id is set, forced roaming is disabled automatically.
       
   411 		    * Either SNAP purpose, SNAP id, or IAP id shall be given, or Connection
       
   412 		    * selection dialog shall be enabled.
       
   413 		    */
       
   414 		    
       
   415 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC with IAP Settings");
       
   416 			TConnPrefList prefList;
       
   417 			TExtendedConnPref extPrefs;
       
   418 			//extPrefs.SetSnapPurpose( CMManager::ESnapPurposeUnknown);
       
   419 			//TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC Silent Connection");
       
   420 			//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
       
   421 			//extPrefs.SetBearerSet(TExtendedConnBearer::EExtendedConnBearerUnknown);
       
   422 			extPrefs.SetIapId(aId);
       
   423 			extPrefs.SetSnapId(0);
       
   424 			prefList.AppendL(&extPrefs);
       
   425 			retVal = aConnection.Start(prefList);
       
   426 			if(retVal == KErrNone)
       
   427 			    {
       
   428 			    iIapId = aId;
       
   429 			    }
       
   430 			 else
       
   431 			    {
       
   432 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP ->Start retVal [%d]"), retVal));
       
   433 			    }
       
   434 		    }
       
   435 		else
       
   436 		    {
       
   437 		    /**
       
   438 		    * Sets SNAP id. If SNAP id is zero, it is interpreted as 
       
   439 		    * client's request for not requesting any specific SNAP.
       
   440 		    * Default value is 0.
       
   441 		    *
       
   442 		    * If SNAP id is set, IAP id shall be zero.
       
   443 		    * If SNAP id is set, SNAP purpose shall be CMManager::ESnapPurposeUnknown.
       
   444 		    * If SNAP id is set, Connection selection dialog shall be disabled.
       
   445 		    * Either SNAP purpose, SNAP id, or IAP id shall be given, or Connection
       
   446 		    * selection dialog shall be enabled.
       
   447 		    */
       
   448 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC with SNAP Settings");
       
   449 			TConnPrefList prefList;
       
   450 			TExtendedConnPref extPrefs;
       
   451 			//extPrefs.SetSnapPurpose( CMManager::ESnapPurposeUnknown);
       
   452 			//TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting up OCC Silent Connection");
       
   453 			//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
       
   454 			//extPrefs.SetBearerSet(TExtendedConnBearer::EExtendedConnBearerUnknown);
       
   455 			if(aId == 0)
       
   456 				{
       
   457 				TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel, "- Setting SnapPurpose Internet");
       
   458 				if(aDialogPref) //If it fails because of unavailibility of access points
       
   459 					{
       
   460 					extPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
       
   461 					extPrefs.SetConnSelectionDialog(ETrue);
       
   462 					}
       
   463 				else
       
   464 					{
       
   465 					extPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet);
       
   466 					//extPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);					
       
   467 					}
       
   468 				}
       
   469 			else
       
   470 				{
       
   471 				extPrefs.SetSnapId(aId);
       
   472 				extPrefs.SetIapId(0);	
       
   473 				extPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
       
   474 				extPrefs.SetConnSelectionDialog(EFalse);
       
   475 				}
       
   476 			prefList.AppendL(&extPrefs);
       
   477 			retVal = aConnection.Start(prefList);
       
   478 			
       
   479 			if(retVal == KErrNone)
       
   480 				{
       
   481 				aConnection.GetIntSetting( _L("IAP\\Id"), iIapId);
       
   482 				TName name;
       
   483 				retVal = aConnection.Name(name);
       
   484 				if(retVal == KErrNone)
       
   485 					{
       
   486 					TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP Name [%S]"), &name));
       
   487 					}
       
   488 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("GetIntSetting returned IAP [%d]"), iIapId));
       
   489 				}
       
   490 			 else
       
   491 			    {
       
   492 				TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("SNAP ->Start retVal [%d]"), retVal));
       
   493 			    }				
       
   494 		    }
       
   495 		}    
       
   496 #endif    
       
   497     if (!retVal)
       
   498         {
       
   499         iExplicitIapDefined = ETrue;
       
   500         }	
       
   501 	return retVal;
       
   502 }
       
   503 
       
   504 TInt CSenHttpChannelImpl::SetSnapPrefsL( TUint32 aSnapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   483 TInt CSenHttpChannelImpl::SetSnapPrefsL( TUint32 aSnapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer )
   505     {
   484     {
   506     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- CSenHttpChannelImpl::SetSnapPrefsL, SNAP ID (%d)"), aSnapId));
   485     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- CSenHttpChannelImpl::SetSnapPrefsL, SNAP ID (%d)"), aSnapId));
   507 		// Check whether SNAP ID is not equal with the one that is currently in effect:
   486 		// Check whether SNAP ID is not equal with the one that is currently in effect:
   508     if(iExplicitIapDefined && iSnapId == aSnapId )
   487     if(iExplicitIapDefined && iSnapId == aSnapId )
   512         }
   491         }
   513 		else
   492 		else
   514 			{
   493 			{
   515 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is different with currently in effect");
   494 			TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is different with currently in effect");
   516 			}        
   495 			}        
   517 	
   496 
   518     // Check if socket server (connection) is already open..
   497     // Check if socket server (connection) is already open..
   519     if( iExplicitIapDefined )
   498     if( iExplicitIapDefined )
   520         {
   499         {
   521          // Socket server opened once before for some other IAP
   500          // Socket server opened once before for some other IAP
   522         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   501         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop");
   531         // Open new connection
   510         // Open new connection
   532         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Opening new RConnection using the socket server.");       
   511         TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Opening new RConnection using the socket server.");       
   533         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
   512         User::LeaveIfError( aConnection.Open(aSocketServer) ); 
   534         }
   513         }
   535         
   514         
   536         
   515     // Set the SNAP selection preferences (SNAP ID)
   537 	// Set the SNAP selection preferences (SNAP ID, do not prompt)    
   516     TConnSnapPref pref;
   538 	TInt retVal = SetID(aSnapId, aDialogPref, aConnection, aSocketServer, ETrue);
   517     pref.SetSnap(aSnapId);     
   539     
   518     
       
   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);
   540     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetSnapPrefsL, RConnection::Start returned: (%d)"), retVal));
   522     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetSnapPrefsL, RConnection::Start returned: (%d)"), retVal));
   541     
   523     
   542     // Get the connection "handle" from the HTTP session    
   524     // Get the connection "handle" from the HTTP session    
   543     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   525     RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
   544      
   526      
   685     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL");
   667     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL");
   686     TUriParser8 uri;
   668     TUriParser8 uri;
   687     RStringF method;
   669     RStringF method;
   688     TPtrC8 deflate;
   670     TPtrC8 deflate;
   689     // Set IAP preferences, if such exist in properties (and not already in effect):
   671     // Set IAP preferences, if such exist in properties (and not already in effect):
   690     TUint32 id(KErrNone);
   672     TUint32 iapId(KErrNone);
   691     TBool prompt(ETrue); 
   673     TBool doNotPrompt(ETrue); 
   692     
   674     
   693     TInt retVal = aProps.IAPDialogL( prompt );
   675     TInt retVal = aProps.IAPDialogL( doNotPrompt );
   694     if ( retVal != KErrNone )
   676     if ( retVal != KErrNone )
   695         {
   677         {
   696         // by default, do not prompt (even if property does not exist!) 
   678         // by default, do not prompt (even if property does not exist!) 
   697         // => only if property is set, and has value "FALSE", show PROMPT            
   679         // => only if property is set, and has value "FALSE", show PROMPT            
   698         prompt = ETrue;
   680         doNotPrompt = ETrue;
   699         }
   681         }
   700 
   682 
   701 #ifndef __ENABLE_ALR__
       
   702     // Independent of dialog preference (property's existance), if IAP was predefined, it must be set        
   683     // Independent of dialog preference (property's existance), if IAP was predefined, it must be set        
   703     if(((aProps.IapIdL(id)) == KErrNone))
   684     if(((aProps.IapIdL(iapId)) == KErrNone))
   704         {
   685         {
   705         retVal = SetIapPrefsL(id, prompt, iConnection, iSockServ);
   686         retVal = SetIapPrefsL(iapId, doNotPrompt, iConnection, iSockServ);
   706         }
   687         }
   707     else if(((aProps.SnapIdL(id)) == KErrNone))
   688     else if(((aProps.SnapIdL(iapId)) == KErrNone))
   708         {
   689         {
   709         retVal = SetSnapPrefsL(id, prompt, iConnection, iSockServ);
   690         retVal = SetSnapPrefsL(iapId, doNotPrompt, iConnection, iSockServ);
   710         }
   691         }
   711     else//to better control RConnection, we have to call Start by ourselve
   692     else//to better control RConnection, we have to call Start by ourselve
   712         {
   693         {
   713         retVal = SetSnapPrefsL(0, EFalse, iConnection, iSockServ);
   694         retVal = SetSnapPrefsL(0, EFalse, iConnection, iSockServ);
   714         if(retVal == KErrNotFound)
   695         if(retVal == KErrNotFound)
   715             {
   696             {
   716             if(iOCCenabled == EFalse)
   697             retVal = SetIapPrefsL(0, EFalse, iConnection, iSockServ);
   717 		        {
       
   718 	    	    retVal = SetIapPrefsL(0, EFalse, iConnection, iSockServ);	
       
   719 	        	}
       
   720         	else
       
   721 	        	{
       
   722 	        	retVal = SetSnapPrefsL(0, prompt, iConnection, iSockServ);	
       
   723 	        	}
       
   724             }
   698             }
   725         }
   699         }
   726     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Set Snap/IAP prefs retVal [%d]"), retVal));    
   700     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Set Snap/IAP prefs retVal [%d]"), retVal));    
   727     User::LeaveIfError(retVal);
   701     User::LeaveIfError(retVal);
   728     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL After User::Leave");
   702     TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL After User::Leave");
   729     TInt ret= iConnection.GetIntSetting(_L("IAP\\Id"), iUsedIapId);
   703     TInt ret=iConnection.GetIntSetting(_L("IAP\\Id"), iUsedIapId);
   730     // Check transport properties
   704     // Check transport properties
   731     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP/SNAP %d"), id));
       
   732 #else
       
   733 	retVal = SetIapPrefsL(id, prompt, iConnection, iSockServ);
       
   734 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP/SNAP %d"), id));	
       
   735 	iUsedIapId = id;
       
   736 #endif
       
   737     
       
   738     CSenLayeredHttpTransportProperties::TSenHttpMethod httpMethod;
   705     CSenLayeredHttpTransportProperties::TSenHttpMethod httpMethod;
   739     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("PROMPT %d"), prompt));
   706     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP %d"), iapId));
       
   707     TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("DONT PROMPT %d"), doNotPrompt));
   740     TInt retValHttpMethod = aProps.HttpMethodL(httpMethod);
   708     TInt retValHttpMethod = aProps.HttpMethodL(httpMethod);
   741     
   709     
   742     
   710     
   743     /*Installing the deflate filter based on the property values */
   711     /*Installing the deflate filter based on the property values */
   744     /*Once installed, the filter will be alive for on session lifetime */   
   712     /*Once installed, the filter will be alive for on session lifetime */   
  1907 
  1875 
  1908 TBool CSenHttpChannelImpl::EffectiveIapId( TUint32 &aIapId )
  1876 TBool CSenHttpChannelImpl::EffectiveIapId( TUint32 &aIapId )
  1909     {
  1877     {
  1910 	TInt handle = iConnection.SubSessionHandle();
  1878 	TInt handle = iConnection.SubSessionHandle();
  1911 		if (handle>0)
  1879 		if (handle>0)
  1912 		    {
  1880 	    {
  1913 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): Current RConnection's subsession handle(%d)"), handle ));	    
  1881         TUint connEnum(0);
  1914 	        TUint connEnum(0);
  1882         TInt err = iConnection.EnumerateConnections(connEnum);
  1915 	        TInt err = iConnection.EnumerateConnections(connEnum);
  1883         if (!err && !connEnum)
  1916 	        if (!err && !connEnum)
  1884             {
  1917 	            {
  1885             return EFalse;
  1918 	            return EFalse;
  1886             }
  1919 	            }
  1887 	    }
  1920 		    }
  1888 
  1921 	    else
  1889 	TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): Current RConnection's subsession handle(%d)"), iIapId ));
  1922 		    {
  1890 #ifdef _SENDEBUG
  1923 		    TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," -> RConnection has not been initialized.");	
       
  1924 		    }
       
  1925 
       
  1926 	if( iExplicitIapDefined )
  1891 	if( iExplicitIapDefined )
  1927 		{
  1892 		{
  1928 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8(" - IAP ID is known: %d"), iIapId ));
  1893 		TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8(" - IAP ID is known: %d"), iIapId ));
  1929 		}
  1894 		}
  1930 	else
  1895 	else
  1931 		{
  1896 		{
  1932 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," - IAP ID is not known.");
  1897 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," - IAP ID is not known.");
  1933 		}
  1898 		}
  1934 		    
  1899 		
       
  1900 	if( handle < KErrNone )
       
  1901 		{
       
  1902 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," -> RConnection has not been initialized.");
       
  1903 		}
       
  1904 #endif // _SENDEBUG    
       
  1905     
  1935     if( handle && !iExplicitIapDefined )
  1906     if( handle && !iExplicitIapDefined )
  1936     	{
  1907     	{
  1937 		// Eventhough IAP was not explicitely set (through Serene API), this
  1908 		// Eventhough IAP was not explicitely set (through Serene API), this
  1938 		// code can check what IAP end-user provided via IAP selection dialog:
  1909 		// code can check what IAP end-user provided via IAP selection dialog:
       
  1910 		TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::EffectiveIapId: about to call RConnection::GetIntSetting()");
  1939 		_LIT( KIapIdKey, "IAP\\Id" );
  1911 		_LIT( KIapIdKey, "IAP\\Id" );
  1940 	    iConnection.GetIntSetting( KIapIdKey, iIapId);
  1912 	    iConnection.GetIntSetting( KIapIdKey, iIapId);
  1941 	    if ( iIapId > 0 )
  1913 	    if ( iIapId > 0 )
  1942 	    	{
  1914 	    	{
  1943 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("---- GetIntSetting(): retuens IAP(%d)"), iIapId ));
  1915 			TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): end-user provided IAP(%d)"), iIapId ));
  1944 	    	// Treat the end-user selection as "explicit" definition as well(!):
  1916 	    	// Treat the end-user selection as "explicit" definition as well(!):
  1945 	    	iExplicitIapDefined = ETrue; 
  1917 	    	iExplicitIapDefined = ETrue; 
  1946 	    	}
  1918 	    	}
  1947 	    }
  1919 	    }
  1948     if( iExplicitIapDefined )
  1920     if( iExplicitIapDefined )
  1968 TInt32 CSenHttpChannelImpl::UsedIap()
  1940 TInt32 CSenHttpChannelImpl::UsedIap()
  1969     {
  1941     {
  1970     return iUsedIapId;
  1942     return iUsedIapId;
  1971     }
  1943     }
  1972 // END OF FILE
  1944 // END OF FILE
       
  1945 
       
  1946