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