browserutilities/feedsengine/FeedsServer/UrlHandler/inc/HttpConnection.h
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 holds the shared connection to a access point.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HTTP_CONNECTION_H
       
    20 #define HTTP_CONNECTION_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <http/RHTTPSession.h>
       
    26 #include <mconnectioncallback.h>
       
    27 
       
    28 #include "LeakTracker.h"
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // DATA TYPES
       
    35 
       
    36 // FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 
       
    43 /**
       
    44 *  In interface which is called when the access point becomes available.
       
    45 *
       
    46 *  \b Library: FeedsEngine.lib
       
    47 *
       
    48 *  @since 3.0
       
    49 */
       
    50 class MHttpConnectionObserver
       
    51     {
       
    52     public:
       
    53         /**
       
    54         * Notifies the observer that the connection is available.
       
    55         * 
       
    56         * @since 3.0
       
    57         * @return 
       
    58         */
       
    59         virtual void ConnectionAvailable() = 0; 
       
    60 
       
    61         /**
       
    62         * Notifies the observer that the establishment of the connection failed.
       
    63         * 
       
    64         * @since 3.0
       
    65         * @param aStatus The reason for the failure.
       
    66         * @return 
       
    67         */
       
    68         virtual void ConnectionFailed(TInt aStatus) = 0; 
       
    69     };
       
    70 
       
    71 
       
    72 /**
       
    73 *  A base class for http connection.
       
    74 *
       
    75 *  \b Library: FeedsEngine.lib
       
    76 *
       
    77 *  @since 3.0
       
    78 */
       
    79 class CHttpConnection: public CBase, public MConnectionCallback
       
    80     {
       
    81     public:  // Destructor
       
    82         /**
       
    83         * Destructor.
       
    84         */        
       
    85         virtual ~CHttpConnection();
       
    86         
       
    87         
       
    88     public: // From MConnectionCallback        
       
    89         /**
       
    90         * This function cancel outstanding transactions and notify a user 
       
    91         * with the message "Out of coverage"
       
    92         * 
       
    93         * @since 3.0
       
    94         * @param aError Timeout error etc
       
    95         * @return 
       
    96         */
       
    97         virtual void CoverageEvent(TInt aError); 
       
    98 
       
    99         
       
   100     public:  // New methods.
       
   101         /**
       
   102         * Sets the observer.  In practice this is only set 
       
   103         * once during the lifetime of the instance.
       
   104         *
       
   105         * @since 3.0
       
   106         * @param aObserver The observer -- NULL is a valid value.
       
   107         * @return void.
       
   108         */
       
   109         void SetObserver(MHttpConnectionObserver* aObserver);
       
   110 
       
   111         /**
       
   112         * Returns the session.
       
   113         *
       
   114         * @since 3.0
       
   115         * @return The session.
       
   116         */
       
   117         RHTTPSession& Session();
       
   118 
       
   119         /**
       
   120         * Returns whether or not the connection is active.
       
   121         *
       
   122         * @since 3.0
       
   123         * @return void.
       
   124         */
       
   125         virtual TBool IsConnected() = 0;
       
   126 
       
   127         /**
       
   128         * Closes the connection.
       
   129         *
       
   130         * @since 3.0
       
   131         * @return void.
       
   132         */
       
   133         virtual void Disconnect() = 0;
       
   134 
       
   135 		public: // New method for proper object deletion
       
   136         /**
       
   137         * Calls delete when stack is unrolled
       
   138         *
       
   139         * @since 5.0
       
   140         * @return void
       
   141         */
       
   142         void AutoDelete();
       
   143         
       
   144         /**
       
   145         * Callback function to delete object
       
   146         *
       
   147         * @since 5.0
       
   148         * @return TInt (EFalse)
       
   149         */
       
   150         static TInt DelayedDelete(TAny* aPtr);
       
   151 
       
   152     protected:
       
   153         /**
       
   154         * C++ default constructor.
       
   155         */
       
   156         CHttpConnection();
       
   157         
       
   158         /**
       
   159         * By default Symbian 2nd phase constructor is private.
       
   160         */
       
   161         void BaseConstructL();
       
   162 
       
   163 
       
   164     protected:
       
   165         RHTTPSession                 iSession;
       
   166         CIdle*                       iAutoDelete;
       
   167 
       
   168         MHttpConnectionObserver*     iObserver;
       
   169     };
       
   170 
       
   171 #endif      // HTTP_CONNECTION_H
       
   172             
       
   173 // End of File