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