natfw/natfwsocketmediaconnwrapper/inc/natfwsocketreceiver.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:    Receive data from User of NAT Connectivity Framework.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_SOCKET_RECEIVER_H
       
    22 #define C_SOCKET_RECEIVER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h> 
       
    26 #include <in_sock.h>
       
    27 #include "natfwconnectivityapidefs.h"
       
    28 #include "natfwsocketreceiverobserver.h"
       
    29 
       
    30 const TUint KReceiveBuffer = 8192;
       
    31  
       
    32 /**
       
    33  *  Data receiver
       
    34  *
       
    35  *  Receive data from User of NAT Connectivity Framework.
       
    36  *
       
    37  *  @lib socketmediaconnwrapper.dll
       
    38  *  @since S60 v3.2
       
    39  */
       
    40 NONSHARABLE_CLASS( CNATFWSocketReceiver ) : public CActive
       
    41     {
       
    42     
       
    43     friend class ut_cnatfwsocketreceiver;
       
    44 
       
    45 public:
       
    46 
       
    47     /**
       
    48      * Two-phased constructor.
       
    49      * @param aRecObs reveive observer
       
    50      * @param aProtocol used protocol
       
    51      */       
       
    52     static CNATFWSocketReceiver* NewL( MNATFWSocketReceiverObserver& aRecObs,
       
    53                                        TUint aProtocol );
       
    54 
       
    55     virtual ~CNATFWSocketReceiver();
       
    56     
       
    57     /**
       
    58      * Starts listening data from remote address.
       
    59      * 
       
    60      * @since S60 v3.2
       
    61      * @param aSocket socket handle
       
    62      * @return void
       
    63      */  
       
    64     void StartListening( const RSocket& aSocket );
       
    65 
       
    66     /**
       
    67      * Enables wrapper to forward packets from mediaengine to connection
       
    68      * multiplexer.
       
    69      * 
       
    70      * @since S60 v3.2
       
    71      * @param   aState          The sending state
       
    72      * @return void
       
    73      */     
       
    74     void SetReceivingStateForMuxWrapper( TNATFWStreamingState aState );    
       
    75 
       
    76     
       
    77 private:
       
    78 
       
    79     CNATFWSocketReceiver( MNATFWSocketReceiverObserver& aRecObs, 
       
    80                           TUint aProtocol );
       
    81 
       
    82 // from base class CActive
       
    83     
       
    84     /* From CActive
       
    85      * 
       
    86      *
       
    87      * @since S60 v3.2
       
    88      */
       
    89     void RunL();
       
    90     
       
    91     /* From CActive
       
    92      * 
       
    93      *
       
    94      * @since S60 v3.2
       
    95      */
       
    96     void DoCancel();
       
    97     
       
    98     /* From CActive
       
    99      * 
       
   100      *
       
   101      * @since S60 v3.2
       
   102      */
       
   103     TInt RunError( TInt aError );
       
   104 
       
   105 private: // data
       
   106     
       
   107     /**
       
   108      * Used protocol udp or tcp
       
   109      */
       
   110     TUint iProtocol;
       
   111 
       
   112     /**
       
   113      * Socket
       
   114      */
       
   115     RSocket iSocket;
       
   116         
       
   117     /**
       
   118      * Observer
       
   119      * Not own.
       
   120      */
       
   121     MNATFWSocketReceiverObserver& iObserver;
       
   122     
       
   123     /**
       
   124      * Data buffer
       
   125      */
       
   126     TBuf8<KReceiveBuffer> iBuffer;
       
   127     
       
   128     /**
       
   129      * Remote address
       
   130      */
       
   131     TSockAddr iRemoteAddress;
       
   132      
       
   133     /**
       
   134      * Data length
       
   135      */    
       
   136     TSockXfrLength iSockDataLength;
       
   137 
       
   138     /**
       
   139      * Receiving state for wrapper mux datapath
       
   140      */
       
   141     TNATFWStreamingState iWrapperMuxReceiveState; 
       
   142 
       
   143     };
       
   144 
       
   145 
       
   146 #endif // C_SOCKET_RECEIVER_H