natfw/natfwsocketmediaconnwrapper/inc/natfwsocketsender.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:    Send data to User of NAT Connectivity Framework.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_SOCKET_SENDER_H
       
    22 #define C_SOCKET_SENDER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h> 
       
    26 #include <in_sock.h>
       
    27 #include "natfwsocketsenderobserver.h"
       
    28 #include "cnsmcwsenditem.h"
       
    29 
       
    30 /**
       
    31  *  Data sender
       
    32  *
       
    33  *  Send data to User of NAT Connectivity Framework.
       
    34  *
       
    35  *  @lib socketmediaconnwrapper.dll
       
    36  *  @since S60 v3.2
       
    37  */
       
    38 NONSHARABLE_CLASS( CNATFWSocketSender ) : public CActive
       
    39     {
       
    40     
       
    41     friend class ut_cnatfwsocketsender;
       
    42     
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Two-phased constructor.
       
    47      * @param aObserver sender observer
       
    48      * @param aProtocol used protocol
       
    49      */    
       
    50     static CNATFWSocketSender* NewL( 
       
    51         MNATFWSocketSenderObserver& aObserver, TUint aProtocol );
       
    52 
       
    53     virtual ~CNATFWSocketSender();
       
    54     
       
    55     /**
       
    56      * Set remote address
       
    57      *
       
    58      * @since S60 v3.2
       
    59      * @param aRemoteAddress remote address
       
    60      * @param aSocket        socket handle
       
    61      * @return void
       
    62      */      
       
    63     void SetRemoteAddress( const TSockAddr& aRemoteAddress, 
       
    64                            const RSocket& aSocket );
       
    65     
       
    66     /**
       
    67      * Send data to connected media engine.
       
    68      *
       
    69      * @since S60 v3.2
       
    70      * @param aStreamPortion a reference to buffer where received data put
       
    71      * @return void
       
    72      */   
       
    73     void SendL( const TDesC8& aStreamPortion );
       
    74 
       
    75 private:
       
    76 
       
    77     CNATFWSocketSender( MNATFWSocketSenderObserver& aObserver, 
       
    78                         TUint aProtocol );
       
    79     
       
    80     /**
       
    81      * Send next packet from the queue
       
    82      *
       
    83      * @since S60 v3.2
       
    84      * @return void
       
    85      */  
       
    86     void SendNextPacket();
       
    87     
       
    88     /**
       
    89      * Remove item from queue
       
    90      *
       
    91      * @since S60 v3.2
       
    92      * @return void
       
    93      */  
       
    94     void RemoveFromQueue();
       
    95     
       
    96 // from base class CActive
       
    97     
       
    98     /* From CActive
       
    99      * 
       
   100      *
       
   101      * @since S60 v3.2
       
   102      */
       
   103     void RunL();
       
   104     
       
   105     /* From CActive
       
   106      * 
       
   107      *
       
   108      * @since S60 v3.2
       
   109      */
       
   110     void DoCancel();
       
   111 
       
   112 private: // data
       
   113 
       
   114     /**
       
   115      * Socket
       
   116      */
       
   117     RSocket iSocket;
       
   118     
       
   119     /**
       
   120      * Used protocol udp or tcp.
       
   121      */
       
   122     TUint iProtocol;
       
   123     
       
   124     /**
       
   125      * Remote address
       
   126      */
       
   127     TSockAddr iRemoteAddress;
       
   128 
       
   129     /**
       
   130      * Observer
       
   131      */
       
   132     MNATFWSocketSenderObserver& iObserver;
       
   133     
       
   134     /**
       
   135      * Send queue
       
   136      */
       
   137     TSglQue <CNsmcwSendItem> iSendQueue;
       
   138     
       
   139     /**
       
   140      * List iterator which is needed to delete all the items
       
   141      */
       
   142     TSglQueIter<CNsmcwSendItem> iQueueIter;
       
   143     
       
   144     };
       
   145 
       
   146 
       
   147 #endif // C_SOCKET_SENDER_H