pnpmobileservices/pnpms/OnlineSupport/src/Ccmsocketsengine.cpp
changeset 18 7d11f9a6646f
parent 4 75a71fdb4c92
child 21 c707676bf59f
equal deleted inserted replaced
4:75a71fdb4c92 18:7d11f9a6646f
     1 /*
       
     2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class for the DNS query
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <in_sock.h> 
       
    23 #include <commdbconnpref.h>
       
    24 #include <http.h>
       
    25 #include <commdb.h>
       
    26 #include <ApDataHandler.h>        // for CApDataHandler
       
    27 #include <ApAccessPointItem.h>    // for EApHasProxySettings
       
    28 #include <ApUtils.h>            // for CApUtils
       
    29 #include <basched.h>            // for KLeaveExit
       
    30 #include "CCMSocketsEngine.h"
       
    31 #include "MCMSocketsEngineNotifier.h"
       
    32 #include "OnlineSupportLogger.h"
       
    33 
       
    34 // EXTERNAL DATA STRUCTURES
       
    35 // None
       
    36 
       
    37 // EXTERNAL FUNCTION PROTOTYPES  
       
    38 // None
       
    39 
       
    40 // CONSTANTS
       
    41 // None
       
    42 
       
    43 // MACROS
       
    44 // None
       
    45 
       
    46 // LOCAL CONSTANTS AND MACROS
       
    47 // None
       
    48 
       
    49 // MODULE DATA STRUCTURES
       
    50 // None
       
    51 
       
    52 // LOCAL FUNCTION PROTOTYPES
       
    53 // None
       
    54 
       
    55 // FORWARD DECLARATIONS
       
    56 // None
       
    57 
       
    58 // ============================= LOCAL FUNCTIONS ===============================
       
    59 // None
       
    60 
       
    61 // ============================ MEMBER FUNCTIONS ===============================
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CCMSocketsEngine::CCMSocketsEngine
       
    65 // C++ default constructor can NOT contain any code, that
       
    66 // might leave.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 
       
    70 CCMSocketsEngine::CCMSocketsEngine( MCMSocketsEngineNotifier& aNotifier ) 
       
    71     : CActive( CActive::EPriorityStandard ),
       
    72     iSocketsEngineNotifier( aNotifier ),
       
    73     iConnectionOpen( EFalse ),
       
    74     iResolverExsists( EFalse ),
       
    75     iLeaveOpen( EFalse ),
       
    76     iProxyPort(0),
       
    77     iProxyDefined( EFalse ),
       
    78     iHttpSessionOpen( EFalse ),
       
    79     iTransactionOpen( EFalse ),
       
    80     iIapId(0)
       
    81     {
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CCMSocketsEngine::ConstructL
       
    87 // Symbian 2nd phase constructor can leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CCMSocketsEngine::ConstructL()
       
    91     {
       
    92     // Open channel to Socket Server
       
    93     User::LeaveIfError( iSocketServ.Connect() );
       
    94     CActiveScheduler::Add(this);
       
    95     iProxyIp = HBufC::NewL(1);
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CCMSocketsEngine::NewL
       
   100 // Two-phased constructor.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CCMSocketsEngine* CCMSocketsEngine::NewL( MCMSocketsEngineNotifier& aNotifier)
       
   104     {
       
   105     LOGSTRING( "Enter to CCMSocketsEngine::NewL " );
       
   106     CCMSocketsEngine* self = new( ELeave ) CCMSocketsEngine( aNotifier );
       
   107     
       
   108     CleanupStack::PushL( self );
       
   109     self->ConstructL();
       
   110     CleanupStack::Pop();
       
   111     LOGSTRING( "Exit from CCMSocketsEngine::NewL " );
       
   112     return self;
       
   113     }
       
   114 
       
   115     
       
   116 // Destructor
       
   117 CCMSocketsEngine::~CCMSocketsEngine()
       
   118     {
       
   119     LOGSTRING( "Enter to CCMSocketsEngine::~CCMSocketsEngine()" );
       
   120     if( IsActive() )
       
   121         {
       
   122         Cancel();
       
   123         }
       
   124 
       
   125     LOGSTRING( "CCMSocketsEngine::~CCMSocketsEngine() - 2" );
       
   126 
       
   127     if( iTransactionOpen )
       
   128         {
       
   129         LOGSTRING("Canceling transaction");
       
   130         iTransaction.Cancel();
       
   131         LOGSTRING("Closing transaction");
       
   132         iTransaction.Close();
       
   133         iTransactionOpen = EFalse;
       
   134         LOGSTRING("closed");
       
   135         }
       
   136     if( iHttpSessionOpen )
       
   137         {
       
   138         LOGSTRING("Closing session");
       
   139         iSession.Close();
       
   140         iHttpSessionOpen = EFalse;
       
   141         LOGSTRING("closed");
       
   142         }
       
   143     delete iProxyIp;
       
   144     if ( !iLeaveOpen )
       
   145         {
       
   146         LOGSTRING( "CCMSocketsEngine::~CCMSocketsEngine() - 3" );
       
   147         if( iConnectionOpen )
       
   148             {
       
   149             LOGSTRING("Closing connection");
       
   150             iConnection.Close();
       
   151             iConnectionOpen = EFalse;
       
   152             LOGSTRING("closed");
       
   153             }
       
   154         LOGSTRING( "CCMSocketsEngine::~CCMSocketsEngine() - 4" );
       
   155         iSocketServ.Close();
       
   156         }
       
   157     LOGSTRING( "Exit from CCMSocketsEngine::~CCMSocketsEngine()" );
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CCMSocketsEngine::Connect( const TDesC& aAddress )
       
   162 // starts the DNS query for the address
       
   163 // (other items were commented in a header).
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CCMSocketsEngine::ConnectL( TUint32 aAp, const TDesC& aAddress )
       
   167     {
       
   168     LOGSTRING( "CCMSocketsEngine::ConnectL" );
       
   169     LOGSTRING2( "Enter iEngine.Connect() %i", aAp );
       
   170 
       
   171     if ( IsActive() )
       
   172         {
       
   173         Cancel();
       
   174         }
       
   175 
       
   176     TCommDbConnPref prefs;
       
   177     if( aAp == 0 )
       
   178         {
       
   179         prefs.SetDialogPreference(ECommDbDialogPrefPrompt);
       
   180         }
       
   181     else
       
   182         {
       
   183         prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
   184         }
       
   185     prefs.SetIapId( aAp );
       
   186 
       
   187 #ifdef __WINS__ // do not try to connect on the emulator
       
   188     TRequestStatus* status = &iStatus;
       
   189     User::RequestComplete( status, KErrNone );
       
   190 #else
       
   191     // Open connection
       
   192     TInt err;
       
   193     err = iConnection.Open( iSocketServ );
       
   194     if (err != KErrNone) // error occured
       
   195         {
       
   196         LOGSTRING2( "iConnection.Open err: %i", err );
       
   197         User::Leave( err );
       
   198         }
       
   199     iConnectionOpen = ETrue;
       
   200     iConnection.Start( prefs, iStatus );
       
   201 #endif
       
   202 
       
   203     iEngineStatus = EStatusConnecting;
       
   204     iWapPage = aAddress;
       
   205     SetActive();
       
   206 
       
   207     LOGSTRING( "Exit from CCMSocketsEngine::Connect(). " );
       
   208     }
       
   209 
       
   210 
       
   211 void CCMSocketsEngine::ConnectL( const TDesC& aAddress )
       
   212     {
       
   213     LOGSTRING( "CCMSocketsEngine::ConnectL. " );
       
   214      if ( IsActive() )
       
   215         {
       
   216         Cancel();
       
   217         }
       
   218 
       
   219 #ifdef __WINS__ // do not try to connect on the emulator
       
   220     TRequestStatus* status = &iStatus;
       
   221     User::RequestComplete( status, KErrNone );
       
   222 #else
       
   223     // Open connection
       
   224     TInt err;
       
   225     err = iConnection.Open( iSocketServ );
       
   226     if (err != KErrNone) // error occured
       
   227         {
       
   228         LOGSTRING2( "iConnection.Open err: %i", err );
       
   229         User::Leave( err );
       
   230         }
       
   231     iConnectionOpen = ETrue;
       
   232     iConnection.Start( iStatus );
       
   233 #endif
       
   234 
       
   235     iEngineStatus = EStatusConnecting;
       
   236     iWapPage = aAddress;
       
   237     SetActive();
       
   238 
       
   239     LOGSTRING( "Exit ftom CCMSocketsEngine::Connect(). " );
       
   240     }
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // CCMSocketsEngine::Disconnect()
       
   244 // Disconnects the engine
       
   245 // (other items were commented in a header).
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void CCMSocketsEngine::Disconnect()
       
   249     {
       
   250     LOGSTRING( "CCMSocketsEngine::Disconnect()" );
       
   251     if ( IsActive() )
       
   252         {
       
   253         LOGSTRING("Canceling");
       
   254         Cancel();
       
   255         LOGSTRING("Canceled");
       
   256         }
       
   257     if( iTransactionOpen )
       
   258         {
       
   259         LOGSTRING("Closing transaction");
       
   260         iTransaction.Close();
       
   261         iTransactionOpen = EFalse;
       
   262         LOGSTRING("closed");
       
   263         }
       
   264     if( iHttpSessionOpen )
       
   265         {
       
   266         LOGSTRING("Closing session");
       
   267         iSession.Close();
       
   268         iHttpSessionOpen = EFalse;
       
   269         LOGSTRING("closed");
       
   270         }
       
   271     if ( iEngineStatus == EStatusResolving || iEngineStatus == EStatusReady )
       
   272         {
       
   273         if( iResolverExsists )
       
   274             {
       
   275             LOGSTRING( "CCMSocketsEngine::Disconnect() resolver exists" );
       
   276             iResolver.Cancel();
       
   277             iResolver.Close();
       
   278             iResolverExsists = EFalse;
       
   279             }
       
   280         iEngineStatus = EStatusUnknown;
       
   281         }
       
   282     if( iConnectionOpen )
       
   283         {
       
   284         LOGSTRING("Closing connection");
       
   285         iConnection.Close();
       
   286         iConnectionOpen = EFalse;
       
   287         LOGSTRING("closed");
       
   288         }
       
   289 
       
   290     iEngineStatus = EStatusUnknown;
       
   291     LOGSTRING( "CCMSocketsEngine::Disconnect() - done" );
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CCMSocketsEngine::SetOpen()
       
   296 // (other items were commented in a header).
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 void CCMSocketsEngine::SetOpen( TBool aOpen )
       
   300     {
       
   301     iLeaveOpen = aOpen;
       
   302     }
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 // CCMSocketsEngine::DoCancel()
       
   306 // Cancels the DNS query
       
   307 // (other items were commented in a header).
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void CCMSocketsEngine::DoCancel()
       
   311     {
       
   312     LOGSTRING( "CCMSocketsEngine::DoCancel()" );
       
   313     if( iTransactionOpen )
       
   314         {
       
   315         LOGSTRING("completing requeststatus");
       
   316         TRequestStatus* status = &iStatus;
       
   317         User::RequestComplete( status, KErrCancel );
       
   318         LOGSTRING("Closing transaction");
       
   319         iTransaction.Close();
       
   320         iTransactionOpen = EFalse;
       
   321         LOGSTRING("closed");
       
   322         }
       
   323     if( iHttpSessionOpen )
       
   324         {
       
   325         LOGSTRING("Closing session");
       
   326         iSession.Close();
       
   327         iHttpSessionOpen = EFalse;
       
   328         LOGSTRING("closed");
       
   329         }
       
   330     if( iResolverExsists )
       
   331         {
       
   332         LOGSTRING( "iResolver.Cancel()" );
       
   333         iResolver.Cancel();
       
   334         LOGSTRING( "iResolver.Close()" );
       
   335         iResolver.Close();
       
   336         iResolverExsists= EFalse;
       
   337         }
       
   338     if( iConnectionOpen )
       
   339         {
       
   340         LOGSTRING("Closing connection");
       
   341         iConnection.Close();
       
   342         iConnectionOpen = EFalse;
       
   343         LOGSTRING("closed");
       
   344         }
       
   345     iEngineStatus = EStatusUnknown;
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CCMSocketsEngine::RunL()
       
   350 // Handles object’s request completion event
       
   351 // (other items were commented in a header).
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 void CCMSocketsEngine::RunL()
       
   355     {
       
   356     LOGSTRING( "CCMSocketsEngine::RunL()" );
       
   357     if ( iStatus.Int() != KErrNone )
       
   358         {
       
   359         iSocketsEngineNotifier.ConnectionResultL( iStatus.Int() );
       
   360         }
       
   361     else
       
   362         {
       
   363         switch( iEngineStatus )
       
   364             {
       
   365             case EStatusUnknown:
       
   366                 LOGSTRING( "EStatusUnknown" );
       
   367             case EStatusConnecting:
       
   368                 {
       
   369                 LOGSTRING( "EStatusConnecting" );
       
   370 #ifdef __WINS__ // do not try to connect on the emulator
       
   371                 iSocketsEngineNotifier.ConnectionResultL( iStatus.Int() );
       
   372                 iEngineStatus = EStatusReady;
       
   373                 break;
       
   374 #else
       
   375                 _LIT( KIapId, "IAP\\Id" );
       
   376                 User::LeaveIfError( iConnection.GetIntSetting( KIapId, iIapId ) );
       
   377                 const TBool proxyDefined = CheckForProxyL( iIapId );
       
   378 
       
   379                 if( proxyDefined )
       
   380                     {
       
   381                     MakeHttpHeadRequestL( *iProxyIp, iProxyPort );
       
   382                     iStatus = KRequestPending;
       
   383                     SetActive();
       
   384                     }
       
   385                 else
       
   386                     {                
       
   387                     // Initiate a DNS query
       
   388                     LOGSTRING( "opening resolver, using udp protocol" );
       
   389                     TInt errorCode = iResolver.Open( iSocketServ, KAfInet, KProtocolInetUdp, iConnection );
       
   390                     //LOGSTRING( "opening resolver, using icmp protocol" );
       
   391                     //TInt errorCode = iResolver.Open( iSocketServ, KAfInet, KProtocolInetIcmp, iConnection );
       
   392                     //LOGSTRING( "opening resolver, using tcp protocol" );
       
   393                     //TInt errorCode = iResolver.Open( iSocketServ, KAfInet, KProtocolInetTcp, iConnection );
       
   394                     
       
   395                     if ( errorCode != KErrNone )
       
   396                         {
       
   397                         LOGSTRING( "Error while opening resolver" );
       
   398                         iSocketsEngineNotifier.ConnectionResultL( errorCode );
       
   399                         break;
       
   400                         }
       
   401                     else
       
   402                         {
       
   403                         LOGSTRING( "Resolver exists" );
       
   404                         iResolverExsists = ETrue;
       
   405                         // DNS request for name resolution
       
   406                         LOGSTRING( "Querying url:" );
       
   407                         LOGTEXT( iWapPage );
       
   408                         iResolver.GetByName( iWapPage, iNameEntry, iStatus );
       
   409                         SetActive();
       
   410                         iEngineStatus = EStatusResolving;
       
   411                         }
       
   412                     }
       
   413                 break;
       
   414 #endif
       
   415                 }
       
   416             case EStatusMakingHttpHeadRequest:
       
   417                 LOGSTRING( "EStatusMakingHttpHeadRequest" );
       
   418                 iSocketsEngineNotifier.ConnectionResultL( iStatus.Int() );
       
   419                 iEngineStatus = EStatusReady;
       
   420                 break;
       
   421             case EStatusResolving:
       
   422                 LOGSTRING( "EStatusResolving" );
       
   423                 iSocketsEngineNotifier.ConnectionResultL( iStatus.Int() );
       
   424                 iEngineStatus = EStatusReady;
       
   425                 break;
       
   426             case EStatusReady:
       
   427                 LOGSTRING( "EStatusReady" );
       
   428             default:
       
   429                 break;
       
   430             };
       
   431         }   
       
   432         //iSocketsEngineNotifier.ConnectionResultL( iStatus.Int() );
       
   433     LOGSTRING( " Exit from CCMSocketsEngine::runL " );
       
   434     }
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 // CCMSocketsEngine::ReturnIAPID()
       
   438 // Returns IAPID set when user selects access point before launching browser
       
   439 // 
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 
       
   443 TUint32 CCMSocketsEngine::ReturnIAPID()
       
   444 {
       
   445 	
       
   446 	return iIapId;
       
   447 }
       
   448 
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // CCMSocketsEngine::RunError()
       
   452 // Handles leaves from RunL
       
   453 // (other items were commented in a header).
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 TInt CCMSocketsEngine::RunError(TInt aError)
       
   457     {
       
   458     LOGSTRING2( "CCMSocketsEngine::RunError: %i", aError );
       
   459     if( aError == KLeaveExit )
       
   460         {
       
   461         return aError;
       
   462         }
       
   463     iSocketsEngineNotifier.UnhandledLeave( aError );
       
   464     return KErrNone;
       
   465     }
       
   466 
       
   467 
       
   468 TBool CCMSocketsEngine::CheckForProxyL( const TUint32 aIapId )
       
   469     {
       
   470     LOGSTRING("CCMSocketsEngine::CheckForProxyL")
       
   471 
       
   472     // Check for proxy usage
       
   473     CCommsDatabase* commDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   474     CleanupStack::PushL( commDb );
       
   475 
       
   476     CApDataHandler* dataHandler = CApDataHandler::NewLC( *commDb );
       
   477     CApAccessPointItem* apItem = CApAccessPointItem::NewLC();
       
   478     CApUtils* utils = CApUtils::NewLC( *commDb );
       
   479 
       
   480     TUint32 id = utils->WapIdFromIapIdL( aIapId );
       
   481     dataHandler->AccessPointDataL( id, *apItem );
       
   482 
       
   483     TBool hasProxySettings;
       
   484     User::LeaveIfError( apItem->ReadBool( EApHasProxySettings, hasProxySettings ) );
       
   485 
       
   486     if( hasProxySettings )
       
   487         {
       
   488         LOGSTRING("HasProxySettings, reading proxy params");
       
   489 
       
   490         // Ownership not transferred
       
   491         const HBufC* proxyIp = apItem->ReadConstLongTextL( EApProxyServerAddress );
       
   492         delete iProxyIp;
       
   493         iProxyIp = 0;
       
   494         iProxyIp = HBufC::NewL( proxyIp->Length() );
       
   495         iProxyIp->Des().Copy( *proxyIp );
       
   496         LOGTEXT( *iProxyIp );
       
   497 
       
   498         TUint32 temp(0);
       
   499         apItem->ReadUint( EApProxyPortNumber, temp );
       
   500         iProxyPort = temp;
       
   501         }
       
   502 
       
   503     CleanupStack::PopAndDestroy( utils );
       
   504     CleanupStack::PopAndDestroy( apItem );
       
   505     CleanupStack::PopAndDestroy( dataHandler );
       
   506     CleanupStack::PopAndDestroy( commDb );
       
   507 
       
   508     LOGSTRING("CCMSocketsEngine::CheckForProxyL - done")
       
   509     return hasProxySettings;
       
   510     }
       
   511 
       
   512 void CCMSocketsEngine::MakeHttpHeadRequestL(
       
   513     const TDesC& aProxyAddress,
       
   514     const TUint aProxyPort )
       
   515     {
       
   516     LOGSTRING( "CCMSocketsEngine::MakeHttpHeadRequestL" );
       
   517     _LIT8( KHttpProtString, "HTTP/TCP" );
       
   518     // Opens session using protocol HTTP/TCP
       
   519     LOGSTRING( "CCMSocketsEngine: iSession.OpenL" );
       
   520     iSession.OpenL( KHttpProtString );
       
   521     iHttpSessionOpen = ETrue;
       
   522     LOGSTRING( "CCMSocketsEngine: iSession.OpenL - done" );
       
   523     iSessionStringPool = iSession.StringPool();
       
   524 
       
   525     RHTTPConnectionInfo connectionInfo = iSession.ConnectionInfo();
       
   526 
       
   527     // Set SocketServ and Connection explicitly as we do not want to show
       
   528     // the AP selection list to the user when making submit for the request
       
   529     connectionInfo.SetPropertyL(
       
   530         iSessionStringPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
       
   531         iSocketServ.Handle() );
       
   532     connectionInfo.SetPropertyL(
       
   533         iSessionStringPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
       
   534         reinterpret_cast< TInt > ( &iConnection ) );
       
   535     connectionInfo.SetPropertyL(
       
   536         iSessionStringPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ),
       
   537         iSessionStringPool.StringF( HTTP::EUseProxy, RHTTPSession::GetTable() ) );
       
   538 
       
   539     LOGSTRING("Set Proxy address");
       
   540     HBufC8* proxy = HBufC8::NewLC( 100 );
       
   541     TPtr8 proxyPtr = proxy->Des();
       
   542     proxyPtr.Copy( aProxyAddress );
       
   543     proxyPtr.Append( _L8( ":" ) );
       
   544     proxyPtr.AppendNum( aProxyPort );
       
   545     LOGTEXT( proxyPtr );
       
   546 
       
   547     RStringF proxyF = iSessionStringPool.OpenFStringL( *proxy );
       
   548     CleanupClosePushL( proxyF );
       
   549 
       
   550     connectionInfo.SetPropertyL(
       
   551         iSessionStringPool.StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ),
       
   552         proxyF );
       
   553 
       
   554     CleanupStack::PopAndDestroy(1); // proxyF.Close()
       
   555     CleanupStack::PopAndDestroy( proxy );
       
   556 
       
   557     TUriParser8 uriParser;
       
   558     LOGSTRING( "CCMSocketsEngine uri:" );
       
   559     _LIT( KHttp, "http://" );
       
   560     TBuf8<128> uri;
       
   561     if( iWapPage.Find( KHttp ) != 0 )
       
   562         {
       
   563         uri.Append( KHttp );
       
   564         }
       
   565     uri.Append( iWapPage.Left(100) );
       
   566     LOGTEXT( uri );
       
   567     User::LeaveIfError( uriParser.Parse( uri ) );
       
   568 
       
   569     LOGSTRING( "CCMSocketsEngine: iSession.OpenTransactionL" );
       
   570     iTransaction = iSession.OpenTransactionL( uriParser, *this, iSessionStringPool.StringF( HTTP::EHEAD, RHTTPSession::GetTable() ) );
       
   571     iTransactionOpen = ETrue;
       
   572     LOGSTRING( "CCMSocketsEngine: iSession.OpenTransactionL - done" );
       
   573 
       
   574     iTransaction.SubmitL();
       
   575     LOGSTRING( "CCMSocketsEngine: SubmitL - done" );
       
   576 
       
   577     iEngineStatus = EStatusMakingHttpHeadRequest;
       
   578     }
       
   579 
       
   580 
       
   581 void CCMSocketsEngine::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent &aEvent )
       
   582     {
       
   583     LOGSTRING( "CCMSocketsEngine::MHFRunL" );
       
   584 
       
   585     switch( aEvent.iStatus )
       
   586         {
       
   587         case THTTPEvent::ESubmit:
       
   588             {
       
   589             LOGSTRING( "CCMSocketsEngine::MHFRunL:ESubmit" );
       
   590             LOGTEXT( aTransaction.Request().URI().UriDes() );
       
   591             break;
       
   592             }
       
   593         case THTTPEvent::EGotResponseHeaders:
       
   594             {
       
   595             LOGSTRING( "CCMSocketsEngine::MHFRunL:EGotResponseHeaders" );
       
   596             // Success
       
   597             TRequestStatus* status = &iStatus;
       
   598             User::RequestComplete( status, KErrNone );
       
   599             break;
       
   600             }
       
   601         case THTTPEvent::EFailed:
       
   602             LOGSTRING( "CCMSocketsEngine::MHFRunL:EFailed" );
       
   603             // Failed
       
   604             User::Leave( KErrGeneral );
       
   605             break;
       
   606         default:
       
   607             {
       
   608             LOGSTRING2( "CCMSocketsEngine::MHFRunL:event: %i", aEvent.iStatus );
       
   609             break;
       
   610             }
       
   611         }
       
   612     // Keep compiler happy
       
   613     (void)aTransaction;
       
   614     LOGSTRING( "CCMSocketsEngine::MHFRunL - done" );
       
   615     }
       
   616 
       
   617 TInt CCMSocketsEngine::MHFRunError( TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/ )
       
   618     {
       
   619     LOGSTRING2( "CCMSocketsEngine::MHFRunError %i", aError );
       
   620     if( iTransactionOpen )
       
   621         {
       
   622         LOGSTRING("Closing transaction");
       
   623         iTransaction.Close();
       
   624         iTransactionOpen = EFalse;
       
   625         LOGSTRING("closed");
       
   626         }
       
   627     TRequestStatus* status = &iStatus;
       
   628     User::RequestComplete( status, aError );
       
   629     return KErrNone;
       
   630     }
       
   631 
       
   632 //  End of File