browserutilities/feedsengine/FeedsServer/UrlHandler/src/HttpConnection.cpp
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 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 the License "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:  A class that fetches resources via HTTP 1.1.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <http.h>
       
    20 #include <HttpFilterCommonStringsExt.h>
       
    21 #include <HttpFilterConnHandlerInterface.h>
       
    22 #include <InternetConnectionManager.h>
       
    23 #include <HttpFilterCommonStringsAddition.h>
       
    24 
       
    25 #include "HttpConnection.h"
       
    26 #include "LeakTracker.h"
       
    27 #include "Logger.h"
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CHttpConnection::CHttpConnection
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CHttpConnection::CHttpConnection()
       
    37     {
       
    38     }
       
    39         
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CHttpConnection::BaseConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CHttpConnection::BaseConstructL()
       
    47     {
       
    48     // Open the session
       
    49     iSession.OpenL();
       
    50 
       
    51     // Get the connection info
       
    52     const TStringTable& stringTable = RHTTPSession::GetTable();
       
    53 
       
    54     // Install the necessary http-filters.
       
    55     CHttpFilterConnHandlerInterface::InstallFilterL(iSession, this);
       
    56     iAutoDelete = CIdle::NewL(CActive::EPriorityIdle);
       
    57     }        
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CHttpConnection::~CHttpConnection
       
    62 // Deconstructor.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CHttpConnection::~CHttpConnection()
       
    66     {
       
    67     if(iAutoDelete)
       
    68         delete iAutoDelete;
       
    69     // move the iSession close to subclass because:
       
    70     // the close of iSession should happend before
       
    71     // the close of RConnection, RSocketServer, CInternetConnectionManager
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CHttpConnection::CoverageEvent
       
    77 //
       
    78 // This function cancel outstanding transactions and notify a 
       
    79 // user with the message "Out of coverage" 
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CHttpConnection::CoverageEvent(TInt /*aError*/)
       
    83     {
       
    84     // Ignore...
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CHttpConnection::SetObserver
       
    90 // 
       
    91 // Sets the observer.  In practice this is only set once during the lifetime 
       
    92 // of the instance.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CHttpConnection::SetObserver(MHttpConnectionObserver* aObserver)
       
    96     {
       
    97     iObserver = aObserver;
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CHttpConnection::Session
       
   103 //
       
   104 // Returns the session.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 RHTTPSession& CHttpConnection::Session()
       
   108     {
       
   109     return iSession;
       
   110     }
       
   111 
       
   112 
       
   113 //--------------------------------------------------------------------------
       
   114 //CHttpConnection::AutoDelete()
       
   115 //--------------------------------------------------------------------------
       
   116 void CHttpConnection::AutoDelete()
       
   117     {
       
   118     iObserver = NULL;
       
   119     iAutoDelete->Start(TCallBack(DelayedDelete, this));
       
   120     }
       
   121 
       
   122 //--------------------------------------------------------------------------
       
   123 //CHttpConnection::DelayedDelete()
       
   124 //--------------------------------------------------------------------------
       
   125 TInt CHttpConnection::DelayedDelete(TAny* aPtr)
       
   126     {
       
   127     CHttpConnection*  self = static_cast<CHttpConnection*>(aPtr);
       
   128     
       
   129     delete self;    
       
   130     return EFalse;
       
   131     }