0
|
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 CUSBPNUSBSENDER_H
|
|
20 |
#define CUSBPNUSBSENDER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h> // For CActive
|
|
24 |
|
|
25 |
// CONSTANTS
|
|
26 |
// MACROS
|
|
27 |
// DATA TYPES
|
|
28 |
// FUNCTION PROTOTYPES
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
class RDevUsbcClient;
|
|
31 |
class MUsbPnBufferListener;
|
|
32 |
class CUsbPnPacket;
|
|
33 |
|
|
34 |
// CLASS DECLARATION
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Sends received messages to USB
|
|
38 |
*/
|
|
39 |
class CUsbPnUsbSender : public CActive
|
|
40 |
{
|
|
41 |
public: // Constructors and destructor
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Two-phased constructor.
|
|
45 |
*/
|
|
46 |
static CUsbPnUsbSender* NewL( MUsbPnBufferListener&, RDevUsbcClient& );
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Destructor.
|
|
50 |
*/
|
|
51 |
~CUsbPnUsbSender();
|
|
52 |
|
|
53 |
public: // New functions
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Adds message to sending queue.
|
|
57 |
* @param CUsbPnPacket& aPacket. Cell of circular buffer holding received data.
|
|
58 |
*/
|
|
59 |
void Send( CUsbPnPacket& aPacket );
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Get next free packet from pool.
|
|
63 |
* @return reference to usable packet for receiver.
|
|
64 |
*/
|
|
65 |
CUsbPnPacket& PacketL();
|
|
66 |
|
|
67 |
|
|
68 |
protected: // Functions from base classes
|
|
69 |
|
|
70 |
/**
|
|
71 |
* From CActive
|
|
72 |
*/
|
|
73 |
void DoCancel();
|
|
74 |
|
|
75 |
/**
|
|
76 |
* From CActive
|
|
77 |
*/
|
|
78 |
void RunL();
|
|
79 |
|
|
80 |
/**
|
|
81 |
* From CActive
|
|
82 |
*/
|
|
83 |
TInt RunError( TInt );
|
|
84 |
|
|
85 |
|
|
86 |
private:
|
|
87 |
|
|
88 |
/**
|
|
89 |
* C++ default constructor.
|
|
90 |
*/
|
|
91 |
CUsbPnUsbSender( MUsbPnBufferListener&, RDevUsbcClient& );
|
|
92 |
|
|
93 |
/**
|
|
94 |
* By default Symbian 2nd phase constructor is private.
|
|
95 |
*/
|
|
96 |
void ConstructL();
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Creates packet object.
|
|
100 |
*/
|
|
101 |
void AddPacketBufferL( TInt );
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Writes oldest message from queue.
|
|
105 |
*/
|
|
106 |
void TryToSendPacket( const CUsbPnPacket& );
|
|
107 |
|
|
108 |
|
|
109 |
private: // Data
|
|
110 |
|
|
111 |
// Transfer mechanism observer
|
|
112 |
MUsbPnBufferListener& iBufferListener;
|
|
113 |
|
|
114 |
// Reference to USB driver LDD.
|
|
115 |
RDevUsbcClient& iLdd;
|
|
116 |
|
|
117 |
// Number of packets in queue
|
|
118 |
TUint iPacketCount;
|
|
119 |
|
|
120 |
// Ownership. Newest packet -marker of circular buffer. Packets added to this 'end' of pool.
|
|
121 |
CUsbPnPacket* iPacket;
|
|
122 |
|
|
123 |
// Pointer to oldest packet -marker of circular buffer. Packets written from this 'end' of pool.
|
|
124 |
CUsbPnPacket* iCurrentPacket;
|
|
125 |
|
|
126 |
};
|
|
127 |
|
|
128 |
#endif // CUSBPNUSBSENDER_H
|
|
129 |
|
|
130 |
// End of File
|