|
1 /* |
|
2 * Copyright (c) 2004 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: This file contains the implementation of the File Audio Output Event |
|
15 * Generator. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "FileOutputAO.h" |
|
23 #ifdef _DEBUG |
|
24 #include <e32svr.h> |
|
25 #endif |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CFAOEventGenerator::CFAOEventGenerator |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CFAOEventGenerator::CFAOEventGenerator(MFAOEventGeneratorObserver& aObserver) |
|
36 : CActive(CActive::EPriorityStandard), |
|
37 iEvent(0), |
|
38 iObserver(&aObserver) |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CFAOEventGenerator::ConstructL |
|
44 // Symbian 2nd phase constructor can leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CFAOEventGenerator::ConstructL() |
|
48 { |
|
49 CActiveScheduler::Add(this); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CFAOEventGenerator::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CFAOEventGenerator* CFAOEventGenerator::NewL( |
|
58 MFAOEventGeneratorObserver& aObserver ) |
|
59 { |
|
60 CFAOEventGenerator* self = new(ELeave) CFAOEventGenerator(aObserver); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CFAOEventGenerator::~CFAOEventGenerator |
|
70 // Destructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CFAOEventGenerator::~CFAOEventGenerator() |
|
74 { |
|
75 Cancel(); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CFAOEventGenerator::GenerateEvent |
|
80 // Generate the specified event. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CFAOEventGenerator::GenerateEvent( |
|
84 TInt aEvent, TInt aError) |
|
85 { |
|
86 #ifdef _DEBUG |
|
87 RDebug::Print(_L("[%x] CFAOEventGenerator::GenerateEvent()\n"), this); |
|
88 #endif |
|
89 // save arguments and set code |
|
90 if (!IsActive()) |
|
91 { |
|
92 iEvent = aEvent; |
|
93 iError = aError; |
|
94 iStatus = KRequestPending; // service request would be made here and pending set by service provider |
|
95 SetActive(); |
|
96 Ready(KErrNone); |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CFAOEventGenerator::Ready |
|
103 // Utility function to post a request complete |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CFAOEventGenerator::Ready( |
|
107 const TInt aStatus) |
|
108 { |
|
109 TRequestStatus* stat = &iStatus; |
|
110 User::RequestComplete(stat, aStatus); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CFAOEventGenerator::RunL |
|
116 // Invoke by the active scheduler when a request completes |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CFAOEventGenerator::RunL() |
|
120 { |
|
121 switch(iEvent) |
|
122 { |
|
123 case KIOError: |
|
124 iObserver->IOError(iError); |
|
125 break; |
|
126 |
|
127 default: |
|
128 break; |
|
129 }; |
|
130 |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CFAOEventGenerator::DoCancel |
|
135 // Cancels the current and any on going requests/tasks. |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CFAOEventGenerator::DoCancel() |
|
139 { |
|
140 #ifdef _DEBUG |
|
141 RDebug::Print(_L("[%x] CFAOEventGenerator::DoCancel()\n"), this); |
|
142 #endif |
|
143 } |
|
144 |
|
145 // End of file |
|
146 |