sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006 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: Audio output proxy implementation
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
// INCLUDE FILES
|
sl@0
|
21 |
#include "AudioOutput.h"
|
sl@0
|
22 |
#include "AudioOutputProxyAO.h"
|
sl@0
|
23 |
#include "AudioOutputProxy.h"
|
sl@0
|
24 |
#include "AudioOutputMessageTypes.h"
|
sl@0
|
25 |
#include <CustomCommandUtility.h>
|
sl@0
|
26 |
#include "CustomInterfaceUtility.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
// ================= MEMBER FUNCTIONS =======================
|
sl@0
|
32 |
|
sl@0
|
33 |
// C++ default constructor can NOT contain any code, that
|
sl@0
|
34 |
// might leave.
|
sl@0
|
35 |
//
|
sl@0
|
36 |
CAudioOutputProxy::CAudioOutputProxy(TMMFMessageDestinationPckg aMessageHandler,
|
sl@0
|
37 |
MCustomCommand& aCustomCommand,
|
sl@0
|
38 |
CCustomInterfaceUtility* aCustomInterfaceUtility) :
|
sl@0
|
39 |
iCustomCommand(&aCustomCommand),
|
sl@0
|
40 |
iMessageHandler(aMessageHandler),
|
sl@0
|
41 |
iCustomInterfaceUtility(aCustomInterfaceUtility)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iOutput = ENoPreference;
|
sl@0
|
44 |
iDefaultOutput = ENoPreference;
|
sl@0
|
45 |
iSecureOutput = EFalse;
|
sl@0
|
46 |
iRegistered = EFalse;
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
// Two-phased constructor.
|
sl@0
|
50 |
EXPORT_C CAudioOutputProxy* CAudioOutputProxy::NewL(TMMFMessageDestinationPckg aMessageHandler,
|
sl@0
|
51 |
MCustomCommand& aCustomCommand,
|
sl@0
|
52 |
CCustomInterfaceUtility* aCustomInterfaceUtility)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
CAudioOutputProxy* self = new(ELeave) CAudioOutputProxy(aMessageHandler,aCustomCommand,aCustomInterfaceUtility);
|
sl@0
|
55 |
self->ConstructL();
|
sl@0
|
56 |
return self;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
// -----------------------------------------------------------------------------
|
sl@0
|
60 |
// CAudioOutputProxy::ConstructL
|
sl@0
|
61 |
// Symbian 2nd phase constructor can leave.
|
sl@0
|
62 |
// -----------------------------------------------------------------------------
|
sl@0
|
63 |
//
|
sl@0
|
64 |
void CAudioOutputProxy::ConstructL()
|
sl@0
|
65 |
{
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
// Destructor
|
sl@0
|
69 |
CAudioOutputProxy::~CAudioOutputProxy()
|
sl@0
|
70 |
{
|
sl@0
|
71 |
if (iRegistered != EFalse)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
if(iObserver)
|
sl@0
|
74 |
UnregisterObserver(*iObserver);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
if (iCustomCommand)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
iCustomCommand->CustomCommandSync(iMessageHandler, EAofDelete, KNullDesC8, KNullDesC8);
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
if(iAsyncSender)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
delete iAsyncSender;
|
sl@0
|
85 |
iAsyncSender = NULL;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
if(iCustomInterfaceUtility)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
|
sl@0
|
91 |
delete iCustomInterfaceUtility;
|
sl@0
|
92 |
iCustomInterfaceUtility = NULL;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
// ---------------------------------------------------------
|
sl@0
|
97 |
// CAudioOutput::Uid
|
sl@0
|
98 |
// ?implementation_description
|
sl@0
|
99 |
// (other items were commented in a header).
|
sl@0
|
100 |
// ---------------------------------------------------------
|
sl@0
|
101 |
//
|
sl@0
|
102 |
EXPORT_C const TUid CAudioOutputProxy::Uid()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
return KUidAudioOutput;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
// ---------------------------------------------------------
|
sl@0
|
108 |
// CAudioOutput::AudioOutput
|
sl@0
|
109 |
// ?implementation_description
|
sl@0
|
110 |
// (other items were commented in a header).
|
sl@0
|
111 |
// ---------------------------------------------------------
|
sl@0
|
112 |
//
|
sl@0
|
113 |
CAudioOutput::TAudioOutputPreference CAudioOutputProxy::AudioOutput()
|
sl@0
|
114 |
{
|
sl@0
|
115 |
|
sl@0
|
116 |
TPckgBuf<TAudioOutputPreference> outPutPckg;
|
sl@0
|
117 |
TInt error = iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EAofGetAudioOutput, KNullDesC8, KNullDesC8, outPutPckg);
|
sl@0
|
118 |
|
sl@0
|
119 |
if (KErrNone == error)
|
sl@0
|
120 |
iOutput = outPutPckg();
|
sl@0
|
121 |
else
|
sl@0
|
122 |
iOutput = ENoPreference;
|
sl@0
|
123 |
|
sl@0
|
124 |
return iOutput;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
// ---------------------------------------------------------
|
sl@0
|
127 |
// CAudioOutput::DefaultAudioOutput
|
sl@0
|
128 |
// ?implementation_description
|
sl@0
|
129 |
// (other items were commented in a header).
|
sl@0
|
130 |
// ---------------------------------------------------------
|
sl@0
|
131 |
//
|
sl@0
|
132 |
CAudioOutput::TAudioOutputPreference CAudioOutputProxy::DefaultAudioOutput()
|
sl@0
|
133 |
{
|
sl@0
|
134 |
return iDefaultOutput;
|
sl@0
|
135 |
}
|
sl@0
|
136 |
// ---------------------------------------------------------
|
sl@0
|
137 |
// CAudioOutput::RegisterObserverL
|
sl@0
|
138 |
// ?implementation_description
|
sl@0
|
139 |
// (other items were commented in a header).
|
sl@0
|
140 |
// ---------------------------------------------------------
|
sl@0
|
141 |
//
|
sl@0
|
142 |
void CAudioOutputProxy::RegisterObserverL(MAudioOutputObserver& aObserver)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
if(iRegistered)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
iObserver = &aObserver;
|
sl@0
|
147 |
iAsyncSender->SetObserver(aObserver);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
else
|
sl@0
|
150 |
{
|
sl@0
|
151 |
iRegistered = ETrue;
|
sl@0
|
152 |
iObserver = &aObserver;
|
sl@0
|
153 |
delete iAsyncSender;
|
sl@0
|
154 |
iAsyncSender = NULL;
|
sl@0
|
155 |
|
sl@0
|
156 |
iAsyncSender = CAudioOutputProxyAO::NewL(this,aObserver,iCustomCommand);
|
sl@0
|
157 |
iAsyncSender->SetRegisterFlag(ETrue);
|
sl@0
|
158 |
iAsyncSender->SendAsyncMessage(iMessageHandler,EAofRegisterObserver);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
// ---------------------------------------------------------
|
sl@0
|
163 |
// CAudioOutput::SecureOutput
|
sl@0
|
164 |
// ?implementation_description
|
sl@0
|
165 |
// (other items were commented in a header).
|
sl@0
|
166 |
// ---------------------------------------------------------
|
sl@0
|
167 |
//
|
sl@0
|
168 |
TBool CAudioOutputProxy::SecureOutput()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
return iSecureOutput;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
// ---------------------------------------------------------
|
sl@0
|
174 |
// CAudioOutput::SetAudioOutputL
|
sl@0
|
175 |
// ?implementation_description
|
sl@0
|
176 |
// (other items were commented in a header).
|
sl@0
|
177 |
// ---------------------------------------------------------
|
sl@0
|
178 |
//
|
sl@0
|
179 |
void CAudioOutputProxy::SetAudioOutputL(TAudioOutputPreference aAudioOutput)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
iOutput = aAudioOutput;
|
sl@0
|
182 |
TPckgC<TAudioOutputPreference> outputPckg(aAudioOutput);
|
sl@0
|
183 |
iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetAudioOutput, outputPckg, KNullDesC8);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
// ---------------------------------------------------------
|
sl@0
|
186 |
// CAudioOutput::SetAudioOutputL
|
sl@0
|
187 |
// ?implementation_description
|
sl@0
|
188 |
// (other items were commented in a header).
|
sl@0
|
189 |
// ---------------------------------------------------------
|
sl@0
|
190 |
//
|
sl@0
|
191 |
void CAudioOutputProxy::SetSecureOutputL(TBool aSecureOutput)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
iSecureOutput = aSecureOutput;
|
sl@0
|
194 |
TPckgC<TBool> outputPckg(aSecureOutput);
|
sl@0
|
195 |
TInt err = KErrNone;
|
sl@0
|
196 |
//ou1cimx1#454515 CAudioOutputConfigurator::SetSecureOutputL() is deprecated
|
sl@0
|
197 |
err = iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetSecureOutput, outputPckg, KNullDesC8);
|
sl@0
|
198 |
if(err != KErrNone)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
User::Leave(err);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
// ---------------------------------------------------------
|
sl@0
|
206 |
// CAudioOutput::RegisterObserverL
|
sl@0
|
207 |
// ?implementation_description
|
sl@0
|
208 |
// (other items were commented in a header).
|
sl@0
|
209 |
// ---------------------------------------------------------
|
sl@0
|
210 |
//
|
sl@0
|
211 |
void CAudioOutputProxy::UnregisterObserver(MAudioOutputObserver& aObserver)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
iRegistered = EFalse;
|
sl@0
|
214 |
if (iObserver == &aObserver)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
if (iAsyncSender)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iAsyncSender->SetRegisterFlag(EFalse);
|
sl@0
|
219 |
iCustomCommand->CustomCommandSync(iMessageHandler, EAofUnregisterObserver, KNullDesC8, KNullDesC8);
|
sl@0
|
220 |
iObserver = NULL;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
}
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
|
sl@0
|
226 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
|
sl@0
|
230 |
// End of File
|