webservices/wshttpchanneltransportplugin/src/senhttpchanneltransportplugin.cpp
branchRCL_3
changeset 19 9e96e2676219
parent 13 bf3935de63a1
child 36 c5fabff9b552
equal deleted inserted replaced
17:48e9d43c1d7f 19:9e96e2676219
   102     iRequester(NULL),
   102     iRequester(NULL),
   103     iHttpChannel(NULL),
   103     iHttpChannel(NULL),
   104     iProperties(NULL),
   104     iProperties(NULL),
   105     iConsumerMap(EFalse, ETrue), 
   105     iConsumerMap(EFalse, ETrue), 
   106     iSessionMap(EFalse, EFalse), // iConsumerMap deletes the txnIds (using same "new reserved" TInt here!)
   106     iSessionMap(EFalse, EFalse), // iConsumerMap deletes the txnIds (using same "new reserved" TInt here!)
   107     iStatusCode(0)
   107     iStatusCode(0),
       
   108     iIsConnectionFailed(EFalse)
   108     {
   109     {
   109     }
   110     }
   110 
   111 
   111 CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()
   112 CSenHttpChannelTransportPlugin::~CSenHttpChannelTransportPlugin()
   112     {
   113     {
   122     iProperties = NULL;
   123     iProperties = NULL;
   123 
   124 
   124     delete ipCtx;
   125     delete ipCtx;
   125     ipCtx = NULL;
   126     ipCtx = NULL;
   126 
   127 
       
   128     // Close the log file and the connection to the server.
       
   129     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("SenHttpChannel - Log file closed.")));
       
   130     TLSLOG_CLOSE(KSenHttpChannelLogChannelBase);
       
   131 
   127     TLSLOG(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,(_L("Got last data chunk.")));
   132     TLSLOG(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,(_L("Got last data chunk.")));
   128     TLSLOG_CLOSE(KSenHttpChannelObserverLogChannelBase);
   133     TLSLOG_CLOSE(KSenHttpChannelObserverLogChannelBase);
   129     }
   134     }
   130 
   135 
   131 void CSenHttpChannelTransportPlugin::ConstructL()
   136 void CSenHttpChannelTransportPlugin::ConstructL()
   132     {
   137     {
   133     TLSLOG_OPEN(KSenHttpChannelObserverLogChannelBase,KSenHttpChannelObserverLogLevel,KSenHttpChannelObserverLogDir,KSenHttpChannelObserverLogFile	);
   138     TLSLOG_OPEN(KSenHttpChannelObserverLogChannelBase,KSenHttpChannelObserverLogLevel,KSenHttpChannelObserverLogDir,KSenHttpChannelObserverLogFile	);
   134     // Open connection to the file logger server
   139     // Open connection to the file logger server
   135     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL(): log file opened.");
   140     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL(): log file opened.");
   136     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL - Version 2 [2006-05-09]");
   141     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ConstructL - Version 2 [2006-05-09]");
       
   142 
       
   143     // Open connection to the file logger server
       
   144     TLSLOG_OPEN(KSenHttpChannelLogChannelBase, KSenHttpChannelLogLevel, KSenHttpChannelLogDir, KSenHttpChannelLogFile);
       
   145     TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("SenHttpChannel - Log file opened")));
   137 
   146 
   138     if( ipCtx )
   147     if( ipCtx )
   139         {
   148         {
   140         // Attempt to find pre-defined IAP ID from transport context
   149         // Attempt to find pre-defined IAP ID from transport context
   141         CSenWSDescription& initializer = ipCtx->GetInitializerL();
   150         CSenWSDescription& initializer = ipCtx->GetInitializerL();
   453     }
   462     }
   454 
   463 
   455 // Method to catch async error responses from httpchannel
   464 // Method to catch async error responses from httpchannel
   456 void CSenHttpChannelTransportPlugin::ResponseErrorL(TInt aRequestId, TInt aErrorCode, HBufC8* apErrorBody,CSenHttpTransportProperties* aHttpProperties)
   465 void CSenHttpChannelTransportPlugin::ResponseErrorL(TInt aRequestId, TInt aErrorCode, HBufC8* apErrorBody,CSenHttpTransportProperties* aHttpProperties)
   457     {
   466     {
       
   467     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("CSenHttpChannelTransportPlugin::ResponseErrorL() - aErrorCode [%d]"), aErrorCode));
   458     CleanupStack::PushL(apErrorBody);
   468     CleanupStack::PushL(apErrorBody);
   459     iHttpChannel->DisableTimeOutL(aRequestId);
   469     if( (aErrorCode < KErrNone) && (apErrorBody == NULL) || aErrorCode == KErrAbort)
       
   470     	{
       
   471     	TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResponseErrorL() Set iIsConnectionFailed True");
       
   472     	iHttpChannel->ResetIapId();
       
   473     	iHttpChannel->ResetUsedIapId();
       
   474     	iHttpChannel->SetExplicitIapDefined(EFalse);
       
   475     	iIsConnectionFailed = ETrue;
       
   476     	TUint32 zeroIap = 0;
       
   477 			TBuf8<128> buf;
       
   478 	    buf.AppendFormat(_L8("%u"), zeroIap);
       
   479     	LayeredPropertiesL().SetPropertyL(KIapIdLocalName, buf); //Reset the layered properties in case of wrong IAP
       
   480     	}
       
   481     else
       
   482     	{
       
   483     	iHttpChannel->SetExplicitIapDefined(ETrue);
       
   484     	}	
       
   485     if(iHttpChannel)
       
   486     	{
       
   487     	iHttpChannel->DisableTimeOutL(aRequestId);
       
   488     	}
   460 #ifdef _SENDEBUG    
   489 #ifdef _SENDEBUG    
   461     TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResponseErrorL:");
       
   462     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- Request's txnID: %d"), aRequestId));
   490     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- Request's txnID: %d"), aRequestId));
   463     if ( apErrorBody )
   491     if ( apErrorBody )
   464         {
   492         {
   465         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMaxLogLevel, _L8("- apErrorBody:")));
   493         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMaxLogLevel, _L8("- apErrorBody:")));
   466         TLSLOG_ALL(KSenHttpChannelObserverLogChannelBase,KMaxLogLevel,(*apErrorBody));
   494         TLSLOG_ALL(KSenHttpChannelObserverLogChannelBase,KMaxLogLevel,(*apErrorBody));
   556     TInt retVal(KErrNone);
   584     TInt retVal(KErrNone);
   557 
   585 
   558     // ALWAYS HANDLE IAP ID FIRST, SINCE IT *CAN RESET* HTTPCHANNEL!
   586     // ALWAYS HANDLE IAP ID FIRST, SINCE IT *CAN RESET* HTTPCHANNEL!
   559     
   587     
   560     TUint32 iapId(KErrNone);
   588     TUint32 iapId(KErrNone);
   561 
       
   562     retVal = LayeredPropertiesL().IapIdL(iapId);
   589     retVal = LayeredPropertiesL().IapIdL(iapId);
   563     if(retVal==KErrNone)
   590     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- CSenHttpChannelTransportPlugin::ApplyPropertiesL() - iapId [%d]"), iapId));
   564         {
   591 	TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- LayeredPropertiesL() retVal [%d]"), retVal)); 
   565         TInt resetPerformed = ResetHttpChannelByIapIdL(iapId);
   592     if(iIsConnectionFailed)
       
   593         {
       
   594 		TInt resetPerformed = ResetHttpChannelByIapIdL(0); //Incase of connection error set Iap ID 0
   566 #ifdef _SENDEBUG
   595 #ifdef _SENDEBUG
   567         if(resetPerformed == KErrNone)
   596         if(resetPerformed == KErrNone)
   568             {
   597             {
   569             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), iapId));
   598             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), iapId));
   570             }
   599             }
   571 #endif // _SENDEBUG
   600 #endif // _SENDEBUG
       
   601         }
       
   602     else if(retVal==KErrNone)
       
   603         {
       
   604        	TInt resetPerformed = ResetHttpChannelByIapIdL(iapId);
       
   605 #ifdef _SENDEBUG
       
   606         if(resetPerformed == KErrNone)
       
   607             {
       
   608             TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KNormalLogLevel, _L8("- IAP re-set performed: (%d)"), 0));
       
   609             }
       
   610 #endif // _SENDEBUG				
   572         }
   611         }
   573 
   612 
   574     // Handle ProxyHost and ProxyPort
   613     // Handle ProxyHost and ProxyPort
   575     TPtrC8 proxyHost;
   614     TPtrC8 proxyHost;
   576     retVal = LayeredPropertiesL().ProxyHostL(proxyHost);
   615     retVal = LayeredPropertiesL().ProxyHostL(proxyHost);
   619         explicitIapIdDefined = iHttpChannel->EffectiveIapId(effectiveIapId);
   658         explicitIapIdDefined = iHttpChannel->EffectiveIapId(effectiveIapId);
   620         }
   659         }
   621 
   660 
   622     TInt retVal(KErrNone);
   661     TInt retVal(KErrNone);
   623     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- explicitIapIdDefined[%d], effectiveIapId[%d], aIapId[%d]"), explicitIapIdDefined, effectiveIapId, aIapId));
   662     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- explicitIapIdDefined[%d], effectiveIapId[%d], aIapId[%d]"), explicitIapIdDefined, effectiveIapId, aIapId));
   624     if(!explicitIapIdDefined || (explicitIapIdDefined && (effectiveIapId != aIapId) ))
   663     if(!explicitIapIdDefined || (explicitIapIdDefined && (effectiveIapId != aIapId) ) || iIsConnectionFailed)
   625         {
   664         {
   626         TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResetHttpChannel():");
   665         TLSLOG_L(KSenHttpChannelObserverLogChannelBase,KMinLogLevel,"CSenHttpChannelTransportPlugin::ResetHttpChannel():");
   627 
   666         iIsConnectionFailed = EFalse;
   628         delete iHttpChannel;
   667         delete iHttpChannel;
   629         iHttpChannel = NULL;
   668         iHttpChannel = NULL;
   630         delete iRequester;
   669         delete iRequester;
   631         iRequester = NULL;
   670         iRequester = NULL;
   632         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- New IAP ID: %d"), aIapId));
   671         TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("- New IAP ID: %d"), aIapId));
   643         }
   682         }
   644     else
   683     else
   645         {
   684         {
   646         retVal = KErrAlreadyExists;
   685         retVal = KErrAlreadyExists;
   647         }
   686         }
       
   687     TLSLOG_FORMAT((KSenHttpChannelObserverLogChannelBase,KMinLogLevel, _L8("CSenHttpChannelTransportPlugin::ResetHttpChannelByIapIdL() - returns [%d]"), retVal));
   648     return retVal;
   688     return retVal;
   649     }
   689     }
   650 
   690 
   651 TInt CSenHttpChannelTransportPlugin::CompleteTransaction(const TInt aTxnId,
   691 TInt CSenHttpChannelTransportPlugin::CompleteTransaction(const TInt aTxnId,
   652                                                          const TInt /* aCompletionCode */)
   692                                                          const TInt /* aCompletionCode */)