|
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 CRestrictedAudioOutputProxy class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <RestrictedAudioOutput.h> |
|
23 #include <RestrictedAudioOutputProxy.h> |
|
24 #include <RestrictedAudioOutputMessageTypes.h> |
|
25 #include <CustomInterfaceUtility.h> |
|
26 |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // |
|
33 CRestrictedAudioOutputProxy::CRestrictedAudioOutputProxy( |
|
34 TMMFMessageDestinationPckg aMessageHandler, |
|
35 MCustomCommand& aCustomCommand, |
|
36 CCustomInterfaceUtility* aCustomInterfaceUtility ) |
|
37 : iCustomCommand(&aCustomCommand), |
|
38 iMessageHandler(aMessageHandler), |
|
39 iCustomInterfaceUtility(aCustomInterfaceUtility), |
|
40 iArray(4) |
|
41 |
|
42 { |
|
43 |
|
44 } |
|
45 |
|
46 // Two-phased constructor. |
|
47 EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL( |
|
48 TMMFMessageDestinationPckg aMessageHandler, |
|
49 MCustomCommand& aCustomCommand, |
|
50 CCustomInterfaceUtility* aCustomInterfaceUtility) |
|
51 { |
|
52 |
|
53 #ifdef _DEBUG |
|
54 RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL:\n")); |
|
55 #endif |
|
56 |
|
57 |
|
58 |
|
59 CRestrictedAudioOutputProxy* self = new(ELeave) CRestrictedAudioOutputProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); // Call base class ConstructL |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 |
|
65 } |
|
66 |
|
67 EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(CMMFDevSound& aDevSound) |
|
68 { |
|
69 |
|
70 #ifdef _DEBUG |
|
71 RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL (DevSound):\n")); |
|
72 #endif |
|
73 |
|
74 CRestrictedAudioOutputProxy* audioOutputProxy = (CRestrictedAudioOutputProxy*)aDevSound.CustomInterface(KUidRestrictedAudioOutput); |
|
75 |
|
76 if (audioOutputProxy == NULL) |
|
77 { |
|
78 #ifdef _DEBUG |
|
79 RDebug::Print(_L("No Adaptation Support - leaving")); |
|
80 #endif |
|
81 User::Leave(KErrNotSupported); |
|
82 } |
|
83 |
|
84 return audioOutputProxy; |
|
85 |
|
86 } |
|
87 |
|
88 // Destructor |
|
89 CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy() |
|
90 { |
|
91 #ifdef _DEBUG |
|
92 RDebug::Print(_L("CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy\n")); |
|
93 #endif |
|
94 |
|
95 iArray.Reset(); |
|
96 // Remove the custom interface message handler before we destroy the proxy. |
|
97 if (iCustomInterfaceUtility) |
|
98 { |
|
99 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); |
|
100 } |
|
101 delete iCustomInterfaceUtility; |
|
102 |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CRestrictedAudioOutput::Uid |
|
107 // ?implementation_description |
|
108 // (other items were commented in a header). |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C const TUid CRestrictedAudioOutputProxy::Uid() |
|
112 { |
|
113 return KUidRestrictedAudioOutput; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CRestrictedAudioOutputProxy::Commit |
|
118 // ?implementation_description |
|
119 // (other items were commented in a header). |
|
120 // --------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C TInt CRestrictedAudioOutputProxy::Commit() |
|
123 { |
|
124 #ifdef _DEBUG |
|
125 RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit")); |
|
126 #endif |
|
127 |
|
128 TInt count; |
|
129 TAllowedOutputPreference pref; |
|
130 iArray.Reset(); |
|
131 |
|
132 TInt err = GetAllowedOutputCount(count); |
|
133 |
|
134 #ifdef _DEBUG |
|
135 RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit: Current array count = %d"), count); |
|
136 #endif |
|
137 |
|
138 for (TInt i=0; i < count;i++) |
|
139 { |
|
140 err = GetAllowedOutput(i, pref); |
|
141 TRAP(err,iArray.AppendL(pref)); |
|
142 } |
|
143 |
|
144 TInt length = iArray.Length() * count; |
|
145 TPtrC8 arrayPtr((const TUint8*)&iArray[0], length); |
|
146 TPckgC<TInt> countPckg(count); |
|
147 |
|
148 iCustomCommand->CustomCommandSync(iMessageHandler, ERaofCommit, countPckg, arrayPtr ); |
|
149 |
|
150 |
|
151 return KErrNone; |
|
152 } |
|
153 |
|
154 |
|
155 // End of File |