|
1 /* |
|
2 * Copyright (c) 2009 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: Implements the class TMSCenRepAudioHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32property.h> |
|
20 #include "tmstelephonycenrep.h" |
|
21 |
|
22 #ifdef _USE_TELEPHONY_CENREP_ |
|
23 #include <telmicmutestatuspskeys.h> |
|
24 #include <telincallvolcntrlcrkeys.h> |
|
25 #else |
|
26 const TUid KCRUidInCallVolume = {0x102828B1}; |
|
27 const TUint32 KTelIncallEarVolume = 0x00000001; |
|
28 const TUint32 KTelIncallLoudspeakerVolume = 0x00000002; |
|
29 #endif |
|
30 |
|
31 #include "tmscenrepaudiohandler.h" |
|
32 #include "tmscenreplistener.h" |
|
33 #include "tmspubsublistener.h" |
|
34 #include "tmsutility.h" |
|
35 |
|
36 const TInt KDefaultMaxGain = 64; |
|
37 |
|
38 using namespace TMS; |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // TMSCenRepAudioHandler::NewL. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 TMSCenRepAudioHandler* TMSCenRepAudioHandler::NewL(TMSServer* aServer) |
|
45 { |
|
46 TRACE_PRN_FN_ENT; |
|
47 TMSCenRepAudioHandler* self = new (ELeave) TMSCenRepAudioHandler(aServer); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop(self); |
|
51 TRACE_PRN_FN_EXT; |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Destructs the object by canceling first ongoing monitoring. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 TMSCenRepAudioHandler::~TMSCenRepAudioHandler() |
|
60 { |
|
61 TRACE_PRN_FN_ENT; |
|
62 delete iMuteListener; |
|
63 delete iIncallLoudspeakerVolumeListener; |
|
64 delete iIncallEarVolumeListener; |
|
65 TRACE_PRN_FN_EXT; |
|
66 } |
|
67 |
|
68 void TMSCenRepAudioHandler::HandleNotifyPSL(const TUid /*aUid*/, |
|
69 const TInt& /*aKey*/, const TRequestStatus& /*aStatus*/) |
|
70 { |
|
71 TInt muteVal; |
|
72 TInt err = KErrNotFound; |
|
73 |
|
74 if (iMuteListener) |
|
75 { |
|
76 err = iMuteListener->Get(muteVal); |
|
77 } |
|
78 if (iTMSSer && err == KErrNone && muteVal == EPSTelMicMuteOn) |
|
79 { |
|
80 #if !defined(__WINSCW__) |
|
81 iTMSSer->SetGain(NULL, 0); |
|
82 #endif //__WINSCW__ |
|
83 } |
|
84 else if (err == KErrNone) |
|
85 { |
|
86 #if !defined(__WINSCW__) |
|
87 // Change when gain is really changed |
|
88 iTMSSer->SetGain(NULL, KDefaultMaxGain); |
|
89 #endif //__WINSCW__ |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // TMSCenRepAudioHandler::SetLoudSpeakerVol |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void TMSCenRepAudioHandler::SetLoudSpeakerVol(TInt vol) |
|
98 { |
|
99 if (iIncallLoudspeakerVolumeListener) |
|
100 { |
|
101 iIncallLoudspeakerVolumeListener->Set(vol); |
|
102 } |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // TMSCenRepAudioHandler::SetEarPieceVol |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void TMSCenRepAudioHandler::SetEarPieceVol(TInt vol) |
|
110 { |
|
111 if (iIncallEarVolumeListener) |
|
112 { |
|
113 iIncallEarVolumeListener->Set(vol); |
|
114 } |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // From TMSCenRepObserver |
|
119 // TMSCenRepAudioHandler::HandleNotifyCenRepL |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void TMSCenRepAudioHandler::HandleNotifyCenRepL(const TUid /*aUid*/, |
|
123 const TUint32 aKey, TInt aVal) |
|
124 { |
|
125 TRACE_PRN_FN_ENT; |
|
126 if (iTMSSer && aKey == KTelIncallLoudspeakerVolume) |
|
127 { |
|
128 iTMSSer->SetLevel(NULL, FALSE, aVal); |
|
129 } |
|
130 else if (iTMSSer && aKey == KTelIncallEarVolume) |
|
131 { |
|
132 iTMSSer->SetLevel(NULL, FALSE, aVal); |
|
133 } |
|
134 TRACE_PRN_FN_EXT; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // Constructs the monitor. |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 TMSCenRepAudioHandler::TMSCenRepAudioHandler(TMSServer* aServer) : |
|
142 iTMSSer(aServer) |
|
143 { |
|
144 TRACE_PRN_FN_ENT; |
|
145 iCallCount = 0; // Active calls count |
|
146 TRACE_PRN_FN_EXT; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // Second phase construction. |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void TMSCenRepAudioHandler::ConstructL() |
|
154 { |
|
155 TRACE_PRN_FN_ENT; |
|
156 |
|
157 RProperty::TType type(RProperty::EInt); |
|
158 TSecurityPolicy readPolicy(ECapability_None); |
|
159 TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); |
|
160 |
|
161 RProperty::Define(KPSUidTelMicrophoneMuteStatus, KTelMicrophoneMuteState, |
|
162 type, readPolicy, writePolicy); |
|
163 |
|
164 iMuteListener = TMSPubSubListener::NewL(KPSUidTelMicrophoneMuteStatus, |
|
165 KTelMicrophoneMuteState, this); |
|
166 |
|
167 iIncallLoudspeakerVolumeListener = TMSCenRepListener::NewL( |
|
168 KCRUidInCallVolume, KTelIncallLoudspeakerVolume, this); |
|
169 |
|
170 iIncallEarVolumeListener = TMSCenRepListener::NewL(KCRUidInCallVolume, |
|
171 KTelIncallEarVolume, this); |
|
172 |
|
173 // Initialize audio volumes |
|
174 TInt volEar; |
|
175 TInt volLoud; |
|
176 |
|
177 if (iIncallEarVolumeListener) |
|
178 { |
|
179 /*TInt volGetRes =*/ iIncallEarVolumeListener->Get(volEar); |
|
180 } |
|
181 if (iIncallLoudspeakerVolumeListener) |
|
182 { |
|
183 /*volGetRes =*/ iIncallLoudspeakerVolumeListener->Get(volLoud); |
|
184 } |
|
185 |
|
186 TRACE_PRN_FN_EXT; |
|
187 } |
|
188 |
|
189 // End of file |