mmsengine/mmshttptransport/inc/mmssession.h
changeset 0 72b543305e3a
child 1 d09ac5c1e252
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  
       
    15 *     MMS transport session
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MMSSESSION_H
       
    22 #define MMSSESSION_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <http/rhttpsession.h>
       
    27 #include <mhttpsessioneventcallback.h>
       
    28 #include <rhttpheaders.h>
       
    29 
       
    30 // CONSTANTS
       
    31 _LIT8( KProtocolHTTP, "HTTP/TCP" );
       
    32 _LIT8( KXProfile, "x-wap-profile");
       
    33 
       
    34 // MACROS
       
    35 // DATA TYPES
       
    36 // FUNCTION PROTOTYPES
       
    37 // FORWARD DECLARATIONS
       
    38 class CMmsTransaction;
       
    39 class CMmsBearerStatus;
       
    40 class RSocketServ;
       
    41 class RConnection;
       
    42 class MMmsCodecDataSupplier;
       
    43 class MMmsCodecDataSink;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48 * Class for MMS server MTM to send and fetch messages
       
    49 * @since 2.0
       
    50 * @lib mmstransport.lib
       
    51 */
       
    52 class CMmsSession : public CActive, public MHTTPSessionEventCallback
       
    53     {
       
    54     public:  // Constructors and destructor
       
    55      
       
    56         /**
       
    57         * Two-phased constructor.
       
    58         * @param aPriority Priority for this active object
       
    59         * @param aSocketServ opened socket server session
       
    60         * @param aConnection opened connection
       
    61         */
       
    62         IMPORT_C static CMmsSession* NewL(
       
    63             TInt aPriority,
       
    64             RSocketServ& aSocketServ,
       
    65             RConnection& aConnection );
       
    66         
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~CMmsSession();
       
    71 
       
    72     public: // New functions
       
    73        
       
    74         /**
       
    75         * Initializes session headers for HTTP protocol.
       
    76         * @param aProxyAddress Proxy address: ip address + port
       
    77         * @param aUseProxy is a proxy to be used with this access point
       
    78         * @param aMaxReceiveSize maximum size of incoming message that can be accepted
       
    79         * @param aMaxSendSize maximum size of message to be sent ( needed for WAP only )
       
    80         * @param aStatus Status of the calling active object
       
    81         */
       
    82         IMPORT_C void OpenL(
       
    83             const TDesC8& aProxyAddress,
       
    84             const TBool aUseProxy,
       
    85             const TInt32 aMaxReceiveSize,
       
    86             const TInt32 aMaxSendSize,
       
    87             TRequestStatus& aStatus );
       
    88 
       
    89         /**
       
    90         * Delivers the message to MMSC.
       
    91         * @param aUri Uri of the MMSC
       
    92         * @param aMessageBuffer In/Out parameter. In: message to posted
       
    93         *    Out: response from MMSC
       
    94         * @param aDataSupplier The class that will serve as data supplier
       
    95         *        for chunked transfer.
       
    96         * @param aDataSink The class that will serve as data sink for chunked receive
       
    97         * @param aStatus Status of the calling active object
       
    98         */
       
    99         IMPORT_C void SendMessageL( 
       
   100             const TDesC& aUri,    
       
   101             CBufFlat& aMessageBuffer, 
       
   102             MMmsCodecDataSupplier&  aDataSupplier,
       
   103             MMmsCodecDataSink&      aDataSink,
       
   104             TRequestStatus& aStatus );
       
   105 
       
   106         /**
       
   107         * Get message from MMSC.
       
   108         * @param aUri URI of the message to fetch
       
   109         * @param aMessageBuffer Buffer for the message 
       
   110         * @param aDataSupplier The class that will serve as data supplier
       
   111         *        for chunked transfer.
       
   112         * @param aDataSink The class that will serve as data sink for chunked receive
       
   113         * @param aStatus Status of the calling active object
       
   114         */
       
   115         IMPORT_C void FetchMessageL( 
       
   116             const TDesC& aUri,
       
   117             CBufFlat& aMessageBuffer,
       
   118             TInt32 aExpectedReceiveSize,
       
   119             MMmsCodecDataSupplier&  aDataSupplier,
       
   120             MMmsCodecDataSink&      aDataSink,
       
   121             TRequestStatus& aStatus );
       
   122 
       
   123     public: // Functions from base classes
       
   124 
       
   125         /**
       
   126         * Session event Callback
       
   127         * from MHTTPSessionEventCallback
       
   128         * Called when the filters registration conditions are satisfied for events that occur
       
   129         * on the session.
       
   130         * @ param aEvent The session event that has occured.
       
   131         * @ exception Any leaves must be handled by the appropriate MHFRunError.
       
   132         */
       
   133         void MHFSessionRunL( const THTTPSessionEvent& aEvent );
       
   134 
       
   135         /**
       
   136         * Session event error Callback
       
   137         * from MHTTPSessionEventCallback
       
   138         * Called when MHFRunL leaves from a session event. This works in the same
       
   139         * way as CActve::RunError
       
   140         * @param aError The leave code that RunL left with.
       
   141         * @param aEvent The Event that was being processed.
       
   142         * @return KErrNone if the error has been cancelled or the code
       
   143         * of the continuing error otherwise.    
       
   144         */
       
   145         TInt MHFSessionRunError( TInt aError, const THTTPSessionEvent& aEvent );
       
   146 
       
   147     protected:  // New functions
       
   148  
       
   149     protected:  // Functions from base classes
       
   150         
       
   151         /**
       
   152         * From CActive 
       
   153         */
       
   154         virtual void DoCancel();
       
   155 
       
   156         /**
       
   157         * From CActive 
       
   158         */
       
   159         virtual void RunL();
       
   160 
       
   161     private:
       
   162 
       
   163         /**
       
   164         * C++ default constructor.
       
   165         */
       
   166         CMmsSession( TInt aPriority );
       
   167 
       
   168         /**
       
   169         * By default Symbian OS constructor is private.
       
   170         * @param aSocketServ opened socket server session
       
   171         * @param aConnection opened connection
       
   172         */
       
   173         void ConstructL( RSocketServ& aSocketServ, RConnection& aConnection );
       
   174         
       
   175         // By default, prohibit copy constructor
       
   176         CMmsSession( const CMmsSession& );
       
   177         // Prohibit assignment operator
       
   178         CMmsSession& operator= ( const CMmsSession& );
       
   179 
       
   180         /**
       
   181         * Set UserAgent string to a fixed value.
       
   182         * FOR TESTING PURPOSES ONLY.
       
   183         */
       
   184         void SetFixedUserAgentL();
       
   185 
       
   186         /**
       
   187         * Sets a header to be used throughout all transactions
       
   188         * @param aHeaders the header collection where the new header is inserted
       
   189         * @param aHdrField enumeration of the header field
       
   190         * @param aHdsValue the string value of the header to be set
       
   191         */
       
   192         void SetHeaderL(
       
   193             RHTTPHeaders aHeaders,
       
   194             TInt aHdrField,
       
   195             const TDesC8& aHdrValue );
       
   196 
       
   197     public:     // Data
       
   198     protected:  // Data
       
   199     private:    // Data
       
   200         
       
   201         enum TSessionStatus
       
   202             {
       
   203             ESessionIdle = 0,
       
   204             ESessionSending,
       
   205             ESessionFetching
       
   206             };
       
   207         
       
   208         TBool               iConnected;         // Do we have a connection to WAP GW       
       
   209         CMmsTransaction*    iTransaction;       // state machine for making transactions
       
   210         TRequestStatus*     iRequestStatus;     // status of the calling program        
       
   211         TSessionStatus      iSessionStatus;     // Status of the session object                                  
       
   212         RHTTPSession        iHTTPSession;       // transport session
       
   213         THTTPSessionEvent   iHTTPEvent;         // event from HTTP
       
   214         RHTTPHeaders        iSessionHeaders;    // headers common to all transactions
       
   215         TBool               iHeadersCreated;    // if headers have not been created, they cannot be deleted
       
   216         TBool               iSessionOpened;     // if HTTP session has not been opened, it cannot be closed
       
   217         CMmsBearerStatus*   iTransferControl;
       
   218         TInt                iTransactionTimeout;
       
   219         TInt                iMaxReceiveSize;
       
   220         TInt                iMaxSendSize;
       
   221         TInt                iError;
       
   222         RSocketServ*        iSocketServ;
       
   223         RConnection*        iConnection;
       
   224         HBufC8*             iUserAgent;
       
   225         HBufC8*             iUaProf;
       
   226         // pointer to the class that will serve as data supplier for chunked transfer.
       
   227         // pointer is owned by caller - we don't delete it
       
   228         MMmsCodecDataSupplier*  iDataSupplier;
       
   229         // pointer to the class that will serve as data sink for chunked receive.
       
   230         // pointer is owned by caller - we don't delete it
       
   231         MMmsCodecDataSink*      iDataSink;
       
   232 
       
   233     public:     // Friend classes
       
   234     protected:  // Friend classes
       
   235     private:    // Friend classes
       
   236     };
       
   237 
       
   238 #endif      // MMSSESSION_H   
       
   239             
       
   240 // End of File