|
1 /* |
|
2 * Copyright (c) 2007 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 is the implementation of the CRestrictedAudioOutputImpl class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include "RestrictedAudioOutputImpl.h" |
|
24 |
|
25 #ifdef _DEBUG |
|
26 #define DEBPRN0(str) RDebug::Print(str, this) |
|
27 #define DEBPRN1(str) RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str ); |
|
28 #else |
|
29 #define DEBPRN0 |
|
30 #define DEBPRN1(str) |
|
31 #endif |
|
32 |
|
33 const TInt KGranularity=20; |
|
34 |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CRestrictedAudioOutputImpl::CRestrictedAudioOutputImpl() |
|
43 : iAllowedOutputPrefArray(KGranularity) |
|
44 { |
|
45 DEBPRN0(_L("CRestrictedAudioOutputImpl::[0x%x]::CRestrictedAudioOutputImpl\n")); |
|
46 iAllowedOutputPrefArray.Reset(); |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CRestrictedAudioOutputImpl::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // assumes that iParent has already been set up properly |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CRestrictedAudioOutputImpl::ConstructL() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 |
|
62 // Two-phased constructor. |
|
63 CRestrictedAudioOutputImpl* CRestrictedAudioOutputImpl::NewL() |
|
64 { |
|
65 #ifdef _DEBUG |
|
66 RDebug::Print(_L("CRestrictedAudioOutputImpl::NewL\n")); |
|
67 #endif |
|
68 |
|
69 CRestrictedAudioOutputImpl* self = new(ELeave) CRestrictedAudioOutputImpl(); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl |
|
79 // Destructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CRestrictedAudioOutputImpl::~CRestrictedAudioOutputImpl() |
|
83 { |
|
84 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl\n")); |
|
85 |
|
86 iAllowedOutputPrefArray.Close(); |
|
87 |
|
88 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::~CRestrictedAudioOutputImpl:EXIT")); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------- |
|
92 // CRestrictedAudioOutputImpl::AppendAllowedOutput |
|
93 // ?implementation_description |
|
94 // (other items were commented in a header). |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 TInt CRestrictedAudioOutputImpl::AppendAllowedOutput( CRestrictedAudioOutput::TAllowedOutputPreference aOutput) |
|
98 { |
|
99 DEBPRN0(_L("CRestrictedAudioOutputImpl[0x%x]::AppendAllowedOutput\n")); |
|
100 |
|
101 #ifdef _DEBUG |
|
102 RDebug::Print(_L("Append Output: %d\n"), aOutput); |
|
103 #endif |
|
104 |
|
105 // Check to see if it's in array already |
|
106 TBool found = ExistsInArray(aOutput); |
|
107 if (found) |
|
108 { |
|
109 #ifdef _DEBUG |
|
110 RDebug::Print(_L("Append Output ERROR. Output already in List\n")); |
|
111 #endif |
|
112 return KErrAlreadyExists; |
|
113 } |
|
114 |
|
115 TInt err = KErrNone; |
|
116 TRAP(err,iAllowedOutputPrefArray.AppendL(aOutput)); |
|
117 if (err != KErrNone) |
|
118 return err; |
|
119 |
|
120 return KErrNone; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CRestrictedAudioOutputImpl::RemoveAllowedOutput |
|
125 // ?implementation_description |
|
126 // (other items were commented in a header). |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 TInt CRestrictedAudioOutputImpl::RemoveAllowedOutput(CRestrictedAudioOutput::TAllowedOutputPreference aOutput) |
|
130 { |
|
131 #ifdef _DEBUG |
|
132 RDebug::Print(_L("Remove Output: %d\n"), aOutput); |
|
133 #endif |
|
134 |
|
135 // Make sure it's in list |
|
136 TBool found = ExistsInArray(aOutput); |
|
137 if (!found) |
|
138 { |
|
139 #ifdef _DEBUG |
|
140 RDebug::Print(_L("Remove Output ERROR. Output not in List\n")); |
|
141 #endif |
|
142 return KErrNotFound; |
|
143 } |
|
144 |
|
145 for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++) |
|
146 { |
|
147 if (iAllowedOutputPrefArray[i] == aOutput) |
|
148 { |
|
149 iAllowedOutputPrefArray.Remove(i); |
|
150 #ifdef _DEBUG |
|
151 RDebug::Print(_L("RemoveAllowedOutput: Item Removed\n")); |
|
152 #endif |
|
153 break; |
|
154 } |
|
155 } |
|
156 |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CRestrictedAudioOutputImpl::GetAllowedOutput |
|
162 // ?implementation_description |
|
163 // (other items were commented in a header). |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 TInt CRestrictedAudioOutputImpl::GetAllowedOutput(TInt aIndex, CRestrictedAudioOutput::TAllowedOutputPreference& aOutput) |
|
167 { |
|
168 #ifdef _DEBUG |
|
169 RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutput for index: %d\n"), aIndex); |
|
170 #endif |
|
171 |
|
172 // Verify aIndex valid: |
|
173 if (aIndex >= iAllowedOutputPrefArray.Count()) |
|
174 { |
|
175 #ifdef _DEBUG |
|
176 RDebug::Print(_L("GetAllowedOutput ERROR. Invalid Index: %d\n"),aIndex); |
|
177 #endif |
|
178 return KErrNotFound; |
|
179 } |
|
180 aOutput = iAllowedOutputPrefArray[aIndex]; |
|
181 #ifdef _DEBUG |
|
182 RDebug::Print(_L("GetAllowedOutput: Returning %d\n"),aOutput); |
|
183 #endif |
|
184 return KErrNone; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CRestrictedAudioOutputImpl::GetAllowedOutputCount |
|
189 // ?implementation_description |
|
190 // (other items were commented in a header). |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TInt CRestrictedAudioOutputImpl::GetAllowedOutputCount(TInt& aSize) |
|
194 { |
|
195 #ifdef _DEBUG |
|
196 RDebug::Print(_L("CRestrictedAudioOutputImpl::GetAllowedOutputCount\n")); |
|
197 #endif |
|
198 aSize = iAllowedOutputPrefArray.Count(); |
|
199 return KErrNone; |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------- |
|
203 // CRestrictedAudioOutputImpl::Reset |
|
204 // ?implementation_description |
|
205 // (other items were commented in a header). |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 TInt CRestrictedAudioOutputImpl::Reset() |
|
209 { |
|
210 iAllowedOutputPrefArray.Reset(); |
|
211 return KErrNone; |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------- |
|
215 // CRestrictedAudioOutputImpl::Commit |
|
216 // ?implementation_description |
|
217 // (other items were commented in a header). |
|
218 // --------------------------------------------------------- |
|
219 // |
|
220 TInt CRestrictedAudioOutputImpl::Commit() |
|
221 { |
|
222 return KErrNone; |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------- |
|
226 // CRestrictedAudioOutputImpl::ExistsInArray |
|
227 // ?implementation_description |
|
228 // (other items were commented in a header). |
|
229 // --------------------------------------------------------- |
|
230 // |
|
231 TBool CRestrictedAudioOutputImpl::ExistsInArray(CRestrictedAudioOutput::TAllowedOutputPreference& aOutput) |
|
232 { |
|
233 |
|
234 for (TInt i = 0; i < iAllowedOutputPrefArray.Count(); i++) |
|
235 { |
|
236 if (iAllowedOutputPrefArray[i] == aOutput) |
|
237 return ETrue; |
|
238 } |
|
239 |
|
240 return EFalse; |
|
241 } |
|
242 |
|
243 // End of file |
|
244 |