|
1 /* |
|
2 * Copyright (c) 1997-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 "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 <e32std.h> |
|
19 #include <d32usbc.h> |
|
20 #include "ActiveReadOneOrMoreReader.h" |
|
21 #include "AcmConstants.h" |
|
22 #include "AcmPanic.h" |
|
23 #include "AcmUtils.h" |
|
24 #include "ReadOneOrMoreObserver.h" |
|
25 #include <usb/usblogger.h> |
|
26 |
|
27 #ifdef __FLOG_ACTIVE |
|
28 _LIT8(KLogComponent, "ECACM"); |
|
29 #endif |
|
30 |
|
31 CActiveReadOneOrMoreReader::CActiveReadOneOrMoreReader( |
|
32 MReadOneOrMoreObserver& aParent, |
|
33 RDevUsbcClient& aLdd, |
|
34 TEndpointNumber aEndpoint) |
|
35 : CActive(KEcacmAOPriority), |
|
36 iParent(aParent), |
|
37 iLdd(aLdd), |
|
38 iEndpoint(aEndpoint) |
|
39 /** |
|
40 * Constructor. |
|
41 * |
|
42 * @param aParent The object that will be notified when read requests |
|
43 * complete. |
|
44 * @param aLdd The LDD handle to be used for posting read requests. |
|
45 * @param aEndpoint The endpoint to read from. |
|
46 */ |
|
47 { |
|
48 CActiveScheduler::Add(this); |
|
49 } |
|
50 |
|
51 CActiveReadOneOrMoreReader::~CActiveReadOneOrMoreReader() |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 { |
|
56 LOG_FUNC |
|
57 |
|
58 Cancel(); |
|
59 } |
|
60 |
|
61 CActiveReadOneOrMoreReader* CActiveReadOneOrMoreReader::NewL( |
|
62 MReadOneOrMoreObserver& aParent, |
|
63 RDevUsbcClient& aLdd, |
|
64 TEndpointNumber aEndpoint) |
|
65 /** |
|
66 * Standard two phase constructor. |
|
67 * |
|
68 * @param aParent The object that will be notified when read requests |
|
69 * complete. |
|
70 * @param aLdd The LDD handle to be used for posting read requests. |
|
71 * @param aEndpoint The endpoint to read from. |
|
72 * @return Ownership of a new CActiveReadOneOrMoreReader object. |
|
73 */ |
|
74 { |
|
75 LOG_STATIC_FUNC_ENTRY |
|
76 |
|
77 CActiveReadOneOrMoreReader* self = |
|
78 new(ELeave) CActiveReadOneOrMoreReader(aParent, aLdd, aEndpoint); |
|
79 return self; |
|
80 } |
|
81 |
|
82 void CActiveReadOneOrMoreReader::ReadOneOrMore(TDes8& aDes, TInt aLength) |
|
83 /** |
|
84 * Read as much data as the LDD can supply up to the given limit. |
|
85 * |
|
86 * @param aDes A descriptor into which the data will be read. |
|
87 * @param aLength The length to read. |
|
88 */ |
|
89 { |
|
90 LOGTEXT2(_L8(">>CActiveReadOneOrMoreReader::ReadOneOrMore " |
|
91 "aLength=%d"), aLength); |
|
92 |
|
93 iLdd.ReadOneOrMore(iStatus, iEndpoint, aDes, aLength); |
|
94 SetActive(); |
|
95 |
|
96 LOGTEXT(_L8("<<CActiveReadOneOrMoreReader::ReadOneOrMore")); |
|
97 } |
|
98 |
|
99 void CActiveReadOneOrMoreReader::DoCancel() |
|
100 /** |
|
101 * Cancel an outstanding request. |
|
102 */ |
|
103 { |
|
104 LOG_FUNC |
|
105 |
|
106 iLdd.ReadCancel(iEndpoint); |
|
107 } |
|
108 |
|
109 void CActiveReadOneOrMoreReader::RunL() |
|
110 /** |
|
111 * This function will be called when the request completes. It notifies the |
|
112 * parent class of the completion. |
|
113 */ |
|
114 { |
|
115 LOG_LINE |
|
116 LOGTEXT2(_L8(">>CActiveReadOneOrMoreReader::RunL iStatus=%d"), |
|
117 iStatus.Int()); |
|
118 |
|
119 iParent.ReadOneOrMoreCompleted(iStatus.Int()); |
|
120 |
|
121 LOGTEXT(_L8("<<CActiveReadOneOrMoreReader::RunL")); |
|
122 } |
|
123 |
|
124 // |
|
125 // End of file |