0
|
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 CRestrictedAudioOutputMessageHandler class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "RestrictedAudioOutput.h"
|
|
22 |
#include "RestrictedAudioOutputMessageHandler.h"
|
|
23 |
#include "RestrictedAudioOutputMessageTypes.h"
|
|
24 |
|
|
25 |
|
|
26 |
// ================= MEMBER FUNCTIONS =======================
|
|
27 |
|
|
28 |
// C++ default constructor can NOT contain any code, that
|
|
29 |
// might leave.
|
|
30 |
//
|
|
31 |
CRestrictedAudioOutputMessageHandler::CRestrictedAudioOutputMessageHandler(CRestrictedAudioOutput* aAudioOutput)
|
|
32 |
: CMMFObject(KUidRestrictedAudioOutput)
|
|
33 |
{
|
|
34 |
iAudioOutput = aAudioOutput;
|
|
35 |
}
|
|
36 |
|
|
37 |
// Two-phased constructor.
|
|
38 |
EXPORT_C CRestrictedAudioOutputMessageHandler* CRestrictedAudioOutputMessageHandler::NewL(TAny* aCustomInterface)
|
|
39 |
{
|
|
40 |
CRestrictedAudioOutput* audioOutput = (CRestrictedAudioOutput*)aCustomInterface;
|
|
41 |
CRestrictedAudioOutputMessageHandler* self = new (ELeave) CRestrictedAudioOutputMessageHandler(audioOutput);
|
4
|
42 |
CleanupStack::PushL(self);
|
0
|
43 |
self->ConstructL();
|
4
|
44 |
CleanupStack::Pop(self);
|
0
|
45 |
return self;
|
|
46 |
}
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CRestrictedAudioOutputMessageHandler::ConstructL
|
|
50 |
// Symbian 2nd phase constructor can leave.
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
void CRestrictedAudioOutputMessageHandler::ConstructL()
|
|
54 |
{
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
// Destructor
|
|
59 |
CRestrictedAudioOutputMessageHandler::~CRestrictedAudioOutputMessageHandler()
|
|
60 |
{
|
|
61 |
delete iAudioOutput;
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
// ---------------------------------------------------------
|
|
66 |
// CRestrictedAudioOutputMessageHandler::AudioOutputL
|
|
67 |
// ?implementation_description
|
|
68 |
// (other items were commented in a header).
|
|
69 |
// ---------------------------------------------------------
|
|
70 |
//
|
|
71 |
EXPORT_C TUid CRestrictedAudioOutputMessageHandler::Uid()
|
|
72 |
{
|
|
73 |
return KUidRestrictedAudioOutput;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
// CRestrictedAudioOutputMessageHandler::SetAudioOutputL
|
|
78 |
// ?implementation_description
|
|
79 |
// (other items were commented in a header).
|
|
80 |
// ---------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CRestrictedAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage)
|
|
83 |
{
|
|
84 |
ASSERT(aMessage.Destination().InterfaceId() == KUidRestrictedAudioOutput);
|
|
85 |
TRAPD(error,DoHandleRequestL(aMessage));
|
|
86 |
if(error)
|
|
87 |
{
|
|
88 |
aMessage.Complete(error);
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------
|
|
93 |
// CRestrictedAudioOutputMessageHandler::DoHandleRequestL
|
|
94 |
// ?implementation_description
|
|
95 |
// (other items were commented in a header).
|
|
96 |
// ---------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CRestrictedAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
|
|
99 |
{
|
|
100 |
|
|
101 |
switch(aMessage.Function())
|
|
102 |
{
|
|
103 |
case ERaofCommit:
|
|
104 |
{
|
|
105 |
DoCommitL(aMessage);
|
|
106 |
break;
|
|
107 |
}
|
|
108 |
default:
|
|
109 |
{
|
|
110 |
aMessage.Complete(KErrNotSupported);
|
|
111 |
}
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
// ---------------------------------------------------------
|
|
117 |
// CRestrictedAudioOutputMessageHandler::DoCommitL
|
|
118 |
// ?implementation_description
|
|
119 |
// (other items were commented in a header).
|
|
120 |
// ---------------------------------------------------------
|
|
121 |
//
|
|
122 |
void CRestrictedAudioOutputMessageHandler::DoCommitL(TMMFMessage& aMessage)
|
|
123 |
{
|
|
124 |
#ifdef _DEBUG
|
|
125 |
RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL"));
|
|
126 |
#endif
|
|
127 |
|
|
128 |
TPckgBuf<TInt> countPckg;
|
|
129 |
aMessage.ReadData1FromClient(countPckg);
|
|
130 |
TInt count = countPckg();
|
|
131 |
|
|
132 |
#ifdef _DEBUG
|
|
133 |
RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Count: %d"),count);
|
|
134 |
#endif
|
|
135 |
|
|
136 |
CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>* outputArray =
|
|
137 |
new(ELeave) CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>(4);
|
|
138 |
CleanupStack::PushL(outputArray);
|
|
139 |
outputArray->ResizeL(count);
|
|
140 |
|
|
141 |
TInt length = count * outputArray->Length();
|
|
142 |
TPtr8 arrayPtr((TUint8*)&(*outputArray)[0],length, length);
|
|
143 |
aMessage.ReadData2FromClient(arrayPtr);
|
|
144 |
|
|
145 |
CRestrictedAudioOutput::TAllowedOutputPreference pref;
|
|
146 |
|
|
147 |
TInt err = iAudioOutput->Reset();
|
|
148 |
|
|
149 |
for (TInt i = 0; i < count; i++)
|
|
150 |
{
|
|
151 |
pref = (outputArray->Array())[i];
|
|
152 |
#ifdef _DEBUG
|
|
153 |
RDebug::Print(_L("DoCommitL Calling Append for: %d"),pref);
|
|
154 |
#endif
|
|
155 |
TInt err = iAudioOutput->AppendAllowedOutput(pref);
|
|
156 |
}
|
|
157 |
|
|
158 |
#ifdef _DEBUG
|
|
159 |
RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Calling Commit..."));
|
|
160 |
#endif
|
|
161 |
|
|
162 |
iAudioOutput->Commit();
|
|
163 |
CleanupStack::PopAndDestroy(); //outputArray
|
|
164 |
|
|
165 |
aMessage.Complete(KErrNone);
|
|
166 |
}
|
|
167 |
|
|
168 |
|
|
169 |
// End of File
|