connectivitylayer/usbphonetlink/usbpnserver_exe/inc/cusbpnusbreceiver.h
changeset 0 63b37f68c1ce
child 7 fa67e03b87df
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CUSBPNUSBRECEIVER_H
       
    20 #define CUSBPNUSBRECEIVER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>                // For CActive
       
    24 
       
    25 #include "musbpnbufferlistener.h"
       
    26 
       
    27 // CONSTANTS
       
    28 // MACROS
       
    29 // DATA TYPES
       
    30 // FUNCTION PROTOTYPES
       
    31 // FORWARD DECLARATIONS
       
    32 class CUsbPnIsaSender;
       
    33 class MUsbPnControlObserver;
       
    34 class CUsbPnPacket;
       
    35 class RDevUsbcClient;
       
    36 class RIscApi;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  Receiver for data coming from USB.
       
    42 */
       
    43 class CUsbPnUsbReceiver : public CActive, public MUsbPnBufferListener
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48         * Two-phased constructor.
       
    49         */
       
    50         static CUsbPnUsbReceiver* NewL( RDevUsbcClient& aLdd, RIscApi& aIsc );
       
    51 
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         ~CUsbPnUsbReceiver();
       
    56 
       
    57     public: // New functions
       
    58 
       
    59         /**
       
    60         * Get pointer for sending control messages.
       
    61         * @return pointer to control observer API
       
    62         */
       
    63         MUsbPnControlObserver* IsaSender();
       
    64 
       
    65         /**
       
    66         * Sets state to enumerated.
       
    67         * @param aState ETrue says usb is enumerated
       
    68         */
       
    69         void SetEnumerated( TBool aState );
       
    70 
       
    71     public: // Functions from base classes
       
    72 
       
    73         /**
       
    74         * From MUsbPnBufferListener. Called by CUsbPnInterface when initialised
       
    75         * or by sender when reactivating receive.
       
    76         * @param TBool aDiscard. Flag for determining if data can be transmitted to USB.
       
    77         */
       
    78         void Receive( TBool aDiscard );
       
    79 
       
    80 
       
    81     protected:  // Functions from base classes
       
    82 
       
    83         /**
       
    84         * From CActive.
       
    85         */
       
    86         void DoCancel();
       
    87 
       
    88         /**
       
    89         * From CActive.
       
    90         */
       
    91         void RunL();
       
    92 
       
    93         /**
       
    94         * From CActive.
       
    95         */
       
    96         TInt RunError( TInt );
       
    97 
       
    98 
       
    99     private:
       
   100 
       
   101         /**
       
   102         * C++ default constructor.
       
   103         */
       
   104         CUsbPnUsbReceiver( RDevUsbcClient& aLdd );
       
   105 
       
   106         /**
       
   107         * By default Symbian 2nd phase constructor is private.
       
   108         */
       
   109         void ConstructL( RIscApi& aIscApi );
       
   110 
       
   111 
       
   112         /**
       
   113         * Construct message as needed by receiver.
       
   114         */
       
   115         void ConstructMessageL();
       
   116 
       
   117 
       
   118     private:    // Data
       
   119 
       
   120         // Ownership. Object for forwarding received data.
       
   121         CUsbPnIsaSender*        iIsaSender;
       
   122 
       
   123         // Reference to USB driver ldd.
       
   124         RDevUsbcClient&         iLdd;
       
   125 
       
   126         // Not owned. Pointer to receivable packet
       
   127         CUsbPnPacket*           iPacket;
       
   128 
       
   129         // Modifiable ptr for receiving
       
   130         TPtr8                   iRecvPtr;
       
   131 
       
   132         // Whole message received
       
   133         TBool                   iMessageComplete;
       
   134 
       
   135         // ISI message length
       
   136         TUint                   iMessageLength;
       
   137 
       
   138         // Whole message length
       
   139         TUint                   iByteCount;
       
   140 
       
   141         // Ownership. Temporary buffer for first part of exceptionally big message
       
   142         HBufC8*                 iStorage;
       
   143 
       
   144         TBool                   iEnumerated;
       
   145 
       
   146     };
       
   147 
       
   148 #endif      // CUSBPNUSBRECEIVER_H
       
   149 
       
   150 // End of File