|
1 /* |
|
2 * Copyright (c) 2007-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: Container implementation for accessory policy name/value pair objects. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <accpolaudiotopologyobjectcon.h> |
|
19 #include <accpolmixerunit.h> |
|
20 #include <accpolfeatureunit.h> |
|
21 #include <accpolselectorunit.h> |
|
22 #include <accpolvolumecontrol.h> |
|
23 #include <accpolmutecontrol.h> |
|
24 #include <accpolinputcontrol.h> |
|
25 |
|
26 #include "acc_debug.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CAccPolObjectCon::CAccPolObjectCon |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CAccPolAudioTopologyObjectCon::CAccPolAudioTopologyObjectCon( |
|
35 CAccPolObjectCon* aObject ) : |
|
36 CAccPolObjectCon( EAccPolTopologyObjectCon, aObject ) |
|
37 { |
|
38 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::CAccPolAudioTopologyObjectCon() - Enter" ); |
|
39 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::CAccPolAudioTopologyObjectCon() - Return" ); |
|
40 } |
|
41 |
|
42 // Destructor |
|
43 CAccPolAudioTopologyObjectCon::~CAccPolAudioTopologyObjectCon() |
|
44 { |
|
45 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::~CAccPolAudioTopologyObjectCon() - Enter" ); |
|
46 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::~CAccPolAudioTopologyObjectCon() - Return" ); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CAccPolAudioTopologyObjectCon::ConstructL |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 void CAccPolAudioTopologyObjectCon::ConstructL() |
|
54 { |
|
55 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::ConstructL() - Enter" ); |
|
56 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::ConstructL() - Return" ); |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CAccPolAudioTopologyObjectCon::GetAudioUnits() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CAccPolAudioTopologyObjectCon::GetAudioUnitsL( |
|
64 RPointerArray<CAccPolAudioUnitBase>& aAudioUnits ) const |
|
65 { |
|
66 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::GetAudioUnitsL() - Enter" ); |
|
67 TInt count( Count() ); |
|
68 CAccPolObjectBase* ptr = NULL; |
|
69 for( TInt i = 0; i < count; i++ ) |
|
70 { |
|
71 ptr = AtL( i ); |
|
72 if( ptr->ObjectType() == EAccPolAudioInputTerminalObject |
|
73 || ptr->ObjectType() == EAccPolAudioOutputTerminalObject |
|
74 || ptr->ObjectType() == EAccPolAudioMixerUnitObject |
|
75 || ptr->ObjectType() == EAccPolAudioFeatureUnitObject |
|
76 || ptr->ObjectType() == EAccPolAudioSelectorUnitObject ) |
|
77 { |
|
78 aAudioUnits.AppendL( reinterpret_cast<CAccPolAudioUnitBase*> ( ptr ) ); |
|
79 } |
|
80 } |
|
81 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::GetAudioUnitsL() - Return" ); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CAccPolObjectCon::NewL() |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CAccPolAudioTopologyObjectCon* CAccPolAudioTopologyObjectCon::NewL( |
|
89 CAccPolObjectCon* aObject ) |
|
90 { |
|
91 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::NewL() - Enter" ); |
|
92 CAccPolAudioTopologyObjectCon* self = CAccPolAudioTopologyObjectCon::NewLC( |
|
93 aObject ); |
|
94 CleanupStack::Pop( self ); |
|
95 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::NewL() - Return" ); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CAccPolObjectCon::NewLC() |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C CAccPolAudioTopologyObjectCon* CAccPolAudioTopologyObjectCon::NewLC( |
|
104 CAccPolObjectCon* aObject ) |
|
105 { |
|
106 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::NewLC() - Enter" ); |
|
107 CAccPolAudioTopologyObjectCon* self = |
|
108 new ( ELeave ) CAccPolAudioTopologyObjectCon( aObject ); |
|
109 CleanupStack::PushL( self ); |
|
110 self->ConstructL(); |
|
111 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::NewLC() - Return" ); |
|
112 return self; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CAccPolObjectCon::GetObjects() |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C void CAccPolAudioTopologyObjectCon::GetObjectsByTypeL( |
|
120 TTopologyConObjectType aObjectType, |
|
121 RPointerArray<CAccPolObjectBase>& aObjects ) const |
|
122 { |
|
123 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::GetObjectsByTypeL() - Enter" ); |
|
124 |
|
125 CAccPolObjectBase* ptr = NULL; |
|
126 TInt count( Count() ); |
|
127 |
|
128 for( TInt i = 0; i < count; i++ ) |
|
129 { |
|
130 ptr = AtL( i ); |
|
131 if( ptr->ObjectType() == aObjectType ) |
|
132 { |
|
133 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::GetObjectsByTypeL() - add object - type=%d ", ptr->ObjectType() ); |
|
134 aObjects.AppendL( ptr ); |
|
135 } |
|
136 } |
|
137 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::GetObjectsByTypeL() - return void" ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CAccPolObjectCon::InputTerminalL() |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C TBool CAccPolAudioTopologyObjectCon::InputTerminalL( |
|
145 CAccPolInputTerminal::TInputTerminalType aType, |
|
146 CAccPolAudioUnitBase*& aObject ) const |
|
147 { |
|
148 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::InputTerminalL() - Enter " ); |
|
149 |
|
150 TInt count( Count() ); |
|
151 TInt index( 0 ); |
|
152 TBool bFound( EFalse ); |
|
153 |
|
154 CAccPolObjectBase* ptr = NULL; |
|
155 for( index = 0; index < count; index++ ) |
|
156 { |
|
157 ptr = AtL( index ); |
|
158 if( ptr->ObjectType() == EAccPolAudioInputTerminalObject |
|
159 && reinterpret_cast<CAccPolInputTerminal*> ( ptr )->InputTerminalType() |
|
160 == aType ) |
|
161 { |
|
162 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::InputTerminalL() - Object found" ); |
|
163 aObject = reinterpret_cast<CAccPolInputTerminal*> ( ptr ); |
|
164 bFound = ETrue; |
|
165 break; |
|
166 } |
|
167 } |
|
168 |
|
169 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::InputTerminalL() - Return" ); |
|
170 |
|
171 return bFound; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CAccPolObjectCon::OuputTerminalL() |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 EXPORT_C TBool CAccPolAudioTopologyObjectCon::OutputTerminalL( |
|
179 CAccPolOutputTerminal::TOutputTerminalType aType, |
|
180 CAccPolAudioUnitBase*& aObject ) const |
|
181 { |
|
182 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::OuputTerminalL() - Enter " ); |
|
183 |
|
184 TInt count( Count() ); |
|
185 TInt index( 0 ); |
|
186 TBool bFound( EFalse ); |
|
187 |
|
188 CAccPolObjectBase* ptr = NULL; |
|
189 for( index = 0; index < count; index++ ) |
|
190 { |
|
191 ptr = AtL( index ); |
|
192 if( ptr->ObjectType() == EAccPolAudioOutputTerminalObject |
|
193 && reinterpret_cast<CAccPolOutputTerminal*> ( ptr )->OutputTerminalType() |
|
194 == aType ) |
|
195 { |
|
196 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::OuputTerminalL() - Object found" ); |
|
197 aObject = reinterpret_cast<CAccPolOutputTerminal*> ( ptr ); |
|
198 bFound = ETrue; |
|
199 break; |
|
200 } |
|
201 } |
|
202 |
|
203 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::OuputTerminalL() - Return" ); |
|
204 |
|
205 return bFound; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CAccPolObjectCon::ObjectL() |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C TBool CAccPolAudioTopologyObjectCon::ObjectL( TUint8 aUnitId, |
|
213 CAccPolAudioUnitBase*& aObject ) const |
|
214 { |
|
215 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::ObjectL() - Enter " ); |
|
216 |
|
217 TInt count( Count() ); |
|
218 CAccPolObjectBase* ptr = NULL; |
|
219 TInt index = 0; |
|
220 TBool bFound( EFalse ); |
|
221 |
|
222 if( count == 0 ) |
|
223 { |
|
224 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::ObjectL - Container is empty!" ); |
|
225 User::Leave( KErrGeneral ); |
|
226 } |
|
227 else |
|
228 { |
|
229 for( index = 0; index < count; index++ ) |
|
230 { |
|
231 ptr = AtL( index ); |
|
232 |
|
233 if( ptr->ObjectType() == EAccPolAudioInputTerminalObject |
|
234 || ptr->ObjectType() == EAccPolAudioOutputTerminalObject |
|
235 || ptr->ObjectType() == EAccPolAudioMixerUnitObject |
|
236 || ptr->ObjectType() == EAccPolAudioFeatureUnitObject |
|
237 || ptr->ObjectType() == EAccPolAudioSelectorUnitObject ) |
|
238 { |
|
239 CAccPolAudioUnitBase* audioUnitPtr = |
|
240 reinterpret_cast<CAccPolAudioUnitBase*> ( ptr ); |
|
241 if( audioUnitPtr->UnitId() == aUnitId ) |
|
242 { |
|
243 aObject = audioUnitPtr; |
|
244 bFound = ETrue; |
|
245 break; |
|
246 } |
|
247 } |
|
248 } |
|
249 } |
|
250 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::ObjectL() - Return" ); |
|
251 return bFound; |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CAccPolAudioTopologyObjectCon::InternalizeL() |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C void CAccPolAudioTopologyObjectCon::InternalizeL( RReadStream& aStream ) |
|
259 { |
|
260 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::InternalizeL() - Enter" ); |
|
261 |
|
262 TUint8 objectType; |
|
263 TUint32 count; |
|
264 |
|
265 // This object |
|
266 SetObjectType( aStream.ReadUint8L() ); |
|
267 |
|
268 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectBase::InternalizeBaseL - Object Type=%d", ObjectType() ); |
|
269 |
|
270 count = aStream.ReadUint8L();//Number of objects inside this container |
|
271 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::InternalizeL - object count = %d",count ); |
|
272 |
|
273 for( TInt i = 0; i < count; i++ ) |
|
274 { |
|
275 objectType = aStream.ReadUint8L(); |
|
276 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::InternalizeL - object type = %d",objectType ); |
|
277 |
|
278 switch( objectType ) |
|
279 { |
|
280 case EAccPolAudioInputTerminalObject: |
|
281 { |
|
282 CAccPolInputTerminal *inputTerminal = |
|
283 CAccPolInputTerminal::NewLC(); |
|
284 inputTerminal->InternalizeL( aStream ); |
|
285 AddL( *inputTerminal ); |
|
286 CleanupStack::PopAndDestroy( inputTerminal ); |
|
287 } |
|
288 break; |
|
289 |
|
290 case EAccPolAudioOutputTerminalObject: |
|
291 { |
|
292 CAccPolOutputTerminal *outputTerminal = |
|
293 CAccPolOutputTerminal::NewLC(); |
|
294 outputTerminal->InternalizeL( aStream ); |
|
295 AddL( *outputTerminal ); |
|
296 CleanupStack::PopAndDestroy( outputTerminal ); |
|
297 } |
|
298 break; |
|
299 |
|
300 case EAccPolAudioMixerUnitObject: |
|
301 { |
|
302 CAccPolMixerUnit *mixerUnit = CAccPolMixerUnit::NewLC(); |
|
303 mixerUnit->InternalizeL( aStream ); |
|
304 AddL( *mixerUnit ); |
|
305 CleanupStack::PopAndDestroy( mixerUnit ); |
|
306 } |
|
307 break; |
|
308 |
|
309 case EAccPolAudioFeatureUnitObject: |
|
310 { |
|
311 CAccPolFeatureUnit *featureUnit = CAccPolFeatureUnit::NewLC(); |
|
312 featureUnit->InternalizeL( aStream ); |
|
313 AddL( *featureUnit ); |
|
314 CleanupStack::PopAndDestroy( featureUnit ); |
|
315 } |
|
316 break; |
|
317 |
|
318 case EAccPolAudioSelectorUnitObject: |
|
319 { |
|
320 CAccPolSelectorUnit *selectorUnit = |
|
321 CAccPolSelectorUnit::NewLC(); |
|
322 selectorUnit->InternalizeL( aStream ); |
|
323 AddL( *selectorUnit ); |
|
324 CleanupStack::PopAndDestroy( selectorUnit ); |
|
325 } |
|
326 break; |
|
327 |
|
328 case EAccPolAudioVolumeControlObject: |
|
329 { |
|
330 CAccPolVolumeControl *volumeControl = |
|
331 CAccPolVolumeControl::NewLC(); |
|
332 volumeControl->InternalizeL( aStream ); |
|
333 AddL( *volumeControl ); |
|
334 CleanupStack::PopAndDestroy( volumeControl ); |
|
335 } |
|
336 break; |
|
337 |
|
338 case EAccPolAudioMuteControlObject: |
|
339 { |
|
340 CAccPolMuteControl *muteControl = CAccPolMuteControl::NewLC(); |
|
341 muteControl->InternalizeL( aStream ); |
|
342 AddL( *muteControl ); |
|
343 CleanupStack::PopAndDestroy( muteControl ); |
|
344 } |
|
345 break; |
|
346 case EAccPolAudioInputControlObject: |
|
347 { |
|
348 CAccPolInputControl *inputControl = |
|
349 CAccPolInputControl::NewLC(); |
|
350 inputControl->InternalizeL( aStream ); |
|
351 AddL( *inputControl ); |
|
352 CleanupStack::PopAndDestroy( inputControl ); |
|
353 } |
|
354 break; |
|
355 default: |
|
356 { |
|
357 User::Leave( KErrNotSupported ); |
|
358 } |
|
359 break; |
|
360 } |
|
361 } |
|
362 |
|
363 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::InternalizeL - Return" ); |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // CAccPolAudioTopologyObjectCon::ExternalizeL() |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 EXPORT_C void CAccPolAudioTopologyObjectCon::ExternalizeL( |
|
371 RWriteStream& aStream ) const |
|
372 { |
|
373 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::ExternalizeL() - Enter" ); |
|
374 TInt count( Count() ); |
|
375 |
|
376 aStream.WriteUint8L( ObjectType() );// Type of object |
|
377 aStream.WriteUint8L( Count() );//Count |
|
378 |
|
379 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::ExternalizeL - object type = %d", ObjectType() ); |
|
380 API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::ExternalizeL - object count = %d", count ); |
|
381 |
|
382 for( TInt i = 0; i < count; i++ ) |
|
383 { |
|
384 AtL( i )->ExternalizeL( aStream ); |
|
385 } |
|
386 |
|
387 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolObjectCon::ExternalizeL - Return" ); |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // CAccPolAudioTopologyObjectCon::DuplicateLC() |
|
392 // --------------------------------------------------------------------------- |
|
393 // |
|
394 CAccPolObjectBase* CAccPolAudioTopologyObjectCon::DuplicateLC( |
|
395 CAccPolObjectCon* aObject ) |
|
396 { |
|
397 |
|
398 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::DublicateL() - Enter" ); |
|
399 CAccPolAudioTopologyObjectCon* aContainer = |
|
400 CAccPolAudioTopologyObjectCon::NewLC( aObject ); |
|
401 TInt count( Count() ); |
|
402 for( TInt i = 0; i < count; i++ ) |
|
403 { |
|
404 aContainer->AddL( *AtL( i ) ); |
|
405 } |
|
406 API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioTopologyObjectCon::DublicateL() - Return" ); |
|
407 return aContainer; |
|
408 } |
|
409 |
|
410 // End of File |