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 |
// INCLUDE FILES
|
|
19 |
#include "cusbpnpacket.h"
|
|
20 |
#include "usbpndefinitions.h"
|
|
21 |
#include "usbpntrace.h"
|
|
22 |
|
|
23 |
#include "osttracedefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "cusbpnpacketTraces.h"
|
|
26 |
#endif
|
|
27 |
|
|
28 |
// EXTERNAL DATA STRUCTURES
|
|
29 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
30 |
// CONSTANTS
|
|
31 |
// MACROS
|
|
32 |
// LOCAL CONSTANTS AND MACROS
|
|
33 |
// MODULE DATA STRUCTURES
|
|
34 |
// LOCAL FUNCTION PROTOTYPES
|
|
35 |
// FORWARD DECLARATIONS
|
|
36 |
|
|
37 |
|
|
38 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
39 |
|
|
40 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CUsbPnPacket::CUsbPnPacket
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
CUsbPnPacket::CUsbPnPacket( CUsbPnPacket* aPacket, TInt aNum )
|
|
46 |
|
|
47 |
/*lint -e1927 disabled because all variables are initialized after construction */
|
|
48 |
: iBuffer(NULL)
|
|
49 |
, iNumber( aNum )
|
|
50 |
/*lint -restore */
|
|
51 |
|
|
52 |
{
|
|
53 |
OstTraceExt2( TRACE_NORMAL, CUSBPNPACKET_CUSBPNPACKET_ENTRY, "CUsbPnPacket::CUsbPnPacket;aPacket=%x;aNum=%d", ( TUint )( aPacket ), aNum );
|
|
54 |
C_TRACE((_T("CUsbPnPacket::CUsbPnPacket(0x%x, aNum %d)"), aPacket, aNum));
|
|
55 |
|
|
56 |
if(aPacket != NULL)
|
|
57 |
{
|
|
58 |
// Link the packet to the list.
|
|
59 |
iNextPacket = aPacket->iNextPacket;
|
|
60 |
aPacket->iNextPacket = this;
|
|
61 |
}
|
|
62 |
else
|
|
63 |
{
|
|
64 |
// Create a circular buffer.
|
|
65 |
iNextPacket = this;
|
|
66 |
}
|
|
67 |
|
|
68 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_CUSBPNPACKET_EXIT, "CUsbPnPacket::CUsbPnPacket - return void" );
|
|
69 |
C_TRACE((_T("CUsbPnPacket::CUsbPnPacket - return void")));
|
|
70 |
}
|
|
71 |
|
|
72 |
// -----------------------------------------------------------------------------
|
|
73 |
// CUsbPnPacket::ConstructL
|
|
74 |
// Symbian 2nd phase constructor can leave.
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
void CUsbPnPacket::ConstructL()
|
|
78 |
{
|
|
79 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_CONSTRUCTL_ENTRY, "CUsbPnPacket::ConstructL" );
|
|
80 |
C_TRACE( ( _T( "CUsbPnPacket::ConstructL()" ) ) );
|
|
81 |
|
|
82 |
iBuffer = HBufC8::NewL( KPnPacketSize );
|
|
83 |
|
|
84 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_CONSTRUCTL_EXIT, "CUsbPnPacket::ConstructL - return void" );
|
|
85 |
C_TRACE( ( _T( "CUsbPnPacket::ConstructL() - return void" ) ) );
|
|
86 |
}
|
|
87 |
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
// CUsbPnPacket::NewL
|
|
90 |
// Two-phased constructor.
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
CUsbPnPacket* CUsbPnPacket::NewL( CUsbPnPacket* aPacket, TInt aNum )
|
|
94 |
{
|
|
95 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_NEWL_ENTRY, "CUsbPnPacket::NewL" );
|
|
96 |
C_TRACE( ( _T( "CUsbPnPacket::NewL( )" ) ) );
|
|
97 |
|
|
98 |
CUsbPnPacket* self = new( ELeave ) CUsbPnPacket( aPacket, aNum );
|
|
99 |
|
|
100 |
CleanupStack::PushL( self );
|
|
101 |
self->ConstructL();
|
|
102 |
CleanupStack::Pop();
|
|
103 |
|
|
104 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_NEWL_EXIT, "CUsbPnPacket::NewL - return;self=%x", self );
|
|
105 |
C_TRACE( ( _T( "CUsbPnPacket::NewL() - return 0x%x" ), self ) );
|
|
106 |
return self;
|
|
107 |
}
|
|
108 |
|
|
109 |
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
// CUsbPnPacket::~CUsbPnPacket
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
CUsbPnPacket::~CUsbPnPacket()
|
|
114 |
{
|
|
115 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_CUSBPNPACKET_DESTRUCTOR_ENTRY, "CUsbPnPacket::~CUsbPnPacket" );
|
|
116 |
C_TRACE((_T("CUsbPnPacket::~CUsbPnPacket()")));
|
|
117 |
|
|
118 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_CUSBPNPACKET_DESTRUCTOR, "CUsbPnPacket::~CUsbPnPacket deleting packet: %d", iNumber );
|
|
119 |
C_TRACE((_T("CUsbPnPacket::~CUsbPnPacket() deleting packet: %d"), iNumber));
|
|
120 |
|
|
121 |
if( iBuffer )
|
|
122 |
{
|
|
123 |
delete iBuffer;
|
|
124 |
}
|
|
125 |
|
|
126 |
iBuffer = NULL;
|
|
127 |
iNextPacket = NULL;
|
|
128 |
|
|
129 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_CUSBPNPACKET_DESTRUCTOR_EXIT, "CUsbPnPacket::~CUsbPnPacket - return void" );
|
|
130 |
C_TRACE((_T("CUsbPnPacket::~CUsbPnPacket - return void")));
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// CUsbPnPacket::NextPacket
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
CUsbPnPacket& CUsbPnPacket::NextPacket() const
|
|
137 |
{
|
|
138 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_NEXTPACKET_ENTRY, "CUsbPnPacket::NextPacket" );
|
|
139 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_NEXTPACKET_EXIT, "CUsbPnPacket::NextPacket - return;CUsbPnPacket*=%x", iNextPacket );
|
|
140 |
C_TRACE((_T("CUsbPnPacket::NextPacket()")));
|
|
141 |
C_TRACE((_T("CUsbPnPacket::NextPacket - return CUsbPnPacket* 0x%x"), iNextPacket));
|
|
142 |
return *iNextPacket;
|
|
143 |
}
|
|
144 |
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
// CUsbPnPacket::Buffer
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
HBufC8& CUsbPnPacket::Buffer() const
|
|
149 |
{
|
|
150 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_BUFFER_ENTRY, "CUsbPnPacket::Buffer" );
|
|
151 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_BUFFER_EXIT, "CUsbPnPacket::Buffer - return;HBufC8* iBuffer=%x", iBuffer );
|
|
152 |
C_TRACE((_T("CUsbPnPacket::Buffer()")));
|
|
153 |
C_TRACE((_T("CUsbPnPacket::Buffer - return HBufC8* iBuffer 0x%x"), iBuffer));
|
|
154 |
return *iBuffer;
|
|
155 |
}
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CUsbPnPacket::PacketInUse
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
TBool CUsbPnPacket::PacketInUse() const
|
|
161 |
{
|
|
162 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_PACKETINUSE_ENTRY, "CUsbPnPacket::PacketInUse" );
|
|
163 |
C_TRACE((_T("CUsbPnPacket::PacketInUse()")));
|
|
164 |
|
|
165 |
TBool isInUse( EFalse );
|
|
166 |
TPtr8 ptr(iBuffer->Des());
|
|
167 |
if( ptr.Length() > 0 )
|
|
168 |
{
|
|
169 |
isInUse = ETrue;
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
isInUse = EFalse;
|
|
174 |
}
|
|
175 |
|
|
176 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_PACKETINUSE_EXIT, "CUsbPnPacket::PacketInUse - return TBool %d", isInUse );
|
|
177 |
C_TRACE((_T("CUsbPnPacket::PacketInUse - return TBool %d"), isInUse));
|
|
178 |
return isInUse;
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
// CUsbPnPacket::PacketNumber
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
TInt CUsbPnPacket::PacketNumber() const
|
|
185 |
{
|
|
186 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_PACKETNUMBER_ENTRY, "CUsbPnPacket::PacketNumber" );
|
|
187 |
OstTrace1( TRACE_NORMAL, CUSBPNPACKET_PACKETNUMBER_EXIT, "CUsbPnPacket::PacketNumber - return TInt %d", iNumber );
|
|
188 |
C_TRACE((_T("CUsbPnPacket::PacketNumber()")));
|
|
189 |
C_TRACE((_T("CUsbPnPacket::PacketNumber - return TInt %d"),iNumber));
|
|
190 |
return iNumber;
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// CUsbPnPacket::ReleaseL
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
void CUsbPnPacket::ReleaseL()
|
|
197 |
{
|
|
198 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_RELEASEL_ENTRY, "CUsbPnPacket::ReleaseL" );
|
|
199 |
C_TRACE((_T("CUsbPnPacket::ReleaseL()")));
|
|
200 |
|
|
201 |
TPtr8 ptr(iBuffer->Des());
|
|
202 |
if(ptr.Length() > KPnPacketSize )
|
|
203 |
{
|
|
204 |
OstTrace0( TRACE_DETAILED, CUSBPNPACKET_RELEASEL, "CUsbPnPacket::ReleaseL - Returning to normal size" );
|
|
205 |
E_TRACE((_T("CUsbPnPacket::ReleaseL() - Returning to normal size")));
|
|
206 |
delete iBuffer;
|
|
207 |
iBuffer = NULL;
|
|
208 |
iBuffer = HBufC8::NewL( KPnPacketSize );
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
ptr.FillZ();
|
|
213 |
ptr.SetLength( 0 );
|
|
214 |
}
|
|
215 |
|
|
216 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_RELEASEL_EXIT, "CUsbPnPacket::ReleaseL - return void" );
|
|
217 |
C_TRACE((_T("CUsbPnPacket::ReleaseL() - return void")));
|
|
218 |
}
|
|
219 |
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
// CUsbPnPacket::ReallocBufferL
|
|
222 |
// -----------------------------------------------------------------------------
|
|
223 |
void CUsbPnPacket::ReallocBufferL( const TInt aNeededLength )
|
|
224 |
{
|
|
225 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_REALLOCBUFFERL_ENTRY, "CUsbPnPacket::ReallocBufferL" );
|
|
226 |
C_TRACE((_T("CUsbPnPacket::ReallocBufferL()")));
|
|
227 |
|
|
228 |
if(iBuffer)
|
|
229 |
{
|
|
230 |
delete iBuffer;
|
|
231 |
iBuffer = NULL;
|
|
232 |
}
|
|
233 |
|
|
234 |
iBuffer = HBufC8::NewL( aNeededLength );
|
|
235 |
|
|
236 |
OstTrace0( TRACE_NORMAL, CUSBPNPACKET_REALLOCBUFFERL_EXIT, "CUsbPnPacket::ReallocBufferL - return void" );
|
|
237 |
C_TRACE((_T("CUsbPnPacket::ReallocBufferL() - return void")));
|
|
238 |
}
|