|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of Stream Source Reader active object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #ifdef _DEBUG |
|
22 #include <e32svr.h> |
|
23 #endif |
|
24 |
|
25 #include "ReadRequest.h" |
|
26 #include <mmfdatasource.h> |
|
27 #include <mmfdatasink.h> |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CReadRequest::CReadRequest |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CReadRequest::CReadRequest( |
|
39 CS60StreamingSource& aCallback, |
|
40 CMMFBuffer* aBuffer, |
|
41 MDataSink* aConsumer ) |
|
42 : CActive(CActive::EPriorityStandard), |
|
43 iCallback(aCallback), |
|
44 iBuffer(aBuffer), |
|
45 iConsumer(aConsumer) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CReadRequest::ConstructL |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CReadRequest::ConstructL() |
|
55 { |
|
56 CActiveScheduler::Add(this); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CReadRequest::NewL |
|
61 // Two-phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CReadRequest* CReadRequest::NewL( |
|
65 CS60StreamingSource& aCallback, |
|
66 CMMFBuffer* aBuffer, |
|
67 MDataSink* aConsumer ) |
|
68 { |
|
69 CReadRequest* self = new(ELeave) CReadRequest(aCallback, aBuffer, aConsumer); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CReadRequest::~CReadRequest |
|
79 // Destructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CReadRequest::~CReadRequest() |
|
83 { |
|
84 // We should not have to cancel the outstanding request because the message |
|
85 // handler will complete our request with KErrCancel in its destructor. |
|
86 Cancel(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CReadRequest::HandleRequest |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CReadRequest::HandleRequest() |
|
94 { |
|
95 if (!IsActive()) |
|
96 { |
|
97 TRequestStatus* s = &iStatus; |
|
98 SetActive(); |
|
99 User::RequestComplete(s, KErrNone); |
|
100 } |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CReadRequest::RunL |
|
105 // Invoke by the active scheduler when a request completes -- the buffer has been |
|
106 // processed. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CReadRequest::RunL() |
|
110 { |
|
111 #ifdef _DEBUG |
|
112 RDebug::Print(_L("CReadRequest::RunL()\n")); |
|
113 #endif |
|
114 |
|
115 iCallback.HandleFillBuffer(iBuffer, iConsumer); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CReadRequest::DoCancel |
|
120 // Cancels the current and any on going requests/tasks. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CReadRequest::DoCancel() |
|
124 { |
|
125 #ifdef _DEBUG |
|
126 RDebug::Print(_L("CReadRequest::DoCancel()\n")); |
|
127 #endif |
|
128 } |
|
129 |
|
130 // End of file |
|
131 |