|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MUSENGTELEPHONEUTILS_H |
|
20 #define MUSENGTELEPHONEUTILS_H |
|
21 |
|
22 |
|
23 #include "musunittesting.h" |
|
24 |
|
25 // SYSTEM |
|
26 #include <e32base.h> |
|
27 #include <MTelephonyAudioRoutingObserver.h> |
|
28 #include <TelephonyAudioRouting.h> |
|
29 #include <RPhCltServer.h> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CRepository; |
|
33 class CTelephonyAudioRouting; |
|
34 class CPhCltCommandHandler; |
|
35 class MMusEngAudioRoutingObserver; |
|
36 |
|
37 /** |
|
38 * Utility class to handle all phone related requests: |
|
39 * Audio routing, volume control and microphone muting. |
|
40 */ |
|
41 class CMusEngTelephoneUtils : public CActive, |
|
42 public MTelephonyAudioRoutingObserver |
|
43 { |
|
44 MUS_UNITTEST( UT_CMusEngTelephoneUtils ) |
|
45 MUS_UNITTEST( UT_CMusEngSession ) |
|
46 |
|
47 public: |
|
48 |
|
49 /** |
|
50 * |
|
51 */ |
|
52 static CMusEngTelephoneUtils* NewL(); |
|
53 |
|
54 /** |
|
55 * |
|
56 */ |
|
57 ~CMusEngTelephoneUtils(); |
|
58 |
|
59 |
|
60 public: // API |
|
61 |
|
62 /** |
|
63 * Checks if audio routing can be changed using LoudspeakerL |
|
64 * |
|
65 * @return ETrue if audio routing can be changed using LoudspeakerL |
|
66 */ |
|
67 TBool AudioRoutingCanBeChanged(); |
|
68 |
|
69 /** |
|
70 * Changes the audio routing between loudspeaker and handset. |
|
71 * |
|
72 * @param aShowDialog if ETrue, user is notified about new audio routing |
|
73 */ |
|
74 void LoudspeakerL( TBool aEnable, TBool aShowDialog ); |
|
75 |
|
76 /** |
|
77 * |
|
78 */ |
|
79 TBool IsLoudSpeakerEnabled() const; |
|
80 |
|
81 /** |
|
82 * |
|
83 */ |
|
84 TInt GetVolumeL() const; |
|
85 |
|
86 /** |
|
87 * |
|
88 */ |
|
89 void SetVolumeL( TInt aVolume ); |
|
90 |
|
91 /** |
|
92 * Mutes CS call microphone. |
|
93 */ |
|
94 void MuteMicL( TBool aMute ); |
|
95 |
|
96 /** |
|
97 * Returns current CS call mic mute state. |
|
98 */ |
|
99 TBool IsMicMutedL(); |
|
100 |
|
101 /** |
|
102 * Sets audio routing observer. Can be set to NULL in order to indicate |
|
103 * ending of observing changes in audio routing. |
|
104 */ |
|
105 void SetAudioRoutingObserver( MMusEngAudioRoutingObserver* aObserver ); |
|
106 |
|
107 |
|
108 private: // inherited from CActive |
|
109 |
|
110 /** |
|
111 * |
|
112 */ |
|
113 void RunL(); |
|
114 |
|
115 /** |
|
116 * Cancels outstanding request to phone client |
|
117 */ |
|
118 void DoCancel(); |
|
119 |
|
120 |
|
121 private: // MTelephonyAudioRoutingObserver functions |
|
122 |
|
123 /** |
|
124 * Available outputs have changed |
|
125 */ |
|
126 void AvailableOutputsChanged( |
|
127 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
|
128 |
|
129 /** |
|
130 * Some other application has changed audio output routing |
|
131 */ |
|
132 void OutputChanged( |
|
133 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
|
134 |
|
135 /** |
|
136 * Our request to change audio output routing has completed |
|
137 */ |
|
138 void SetOutputComplete( |
|
139 CTelephonyAudioRouting& aTelephonyAudioRouting, |
|
140 TInt aError ); |
|
141 |
|
142 /** |
|
143 * Set output if setting is currently allowed. Leaves with KErrAccessDenied |
|
144 * if setting is not allowed. |
|
145 */ |
|
146 void DoSetOutputL( CTelephonyAudioRouting::TAudioOutput aAudioOutput ); |
|
147 |
|
148 private: |
|
149 |
|
150 /** |
|
151 * Default C++ constructor |
|
152 */ |
|
153 CMusEngTelephoneUtils(); |
|
154 |
|
155 /** |
|
156 * 2nd phase constructor |
|
157 */ |
|
158 void ConstructL(); |
|
159 |
|
160 |
|
161 private: // HELPER |
|
162 |
|
163 /** |
|
164 * Checks that volume value is between 1 and 10. |
|
165 * |
|
166 * @return validated volume value |
|
167 */ |
|
168 TInt ValidateVolume( const TInt aVolume ) const; |
|
169 |
|
170 |
|
171 private: // DATA |
|
172 |
|
173 /** |
|
174 * Stores the audio routing state at startup. |
|
175 */ |
|
176 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |
|
177 |
|
178 /** |
|
179 * Telephony audio routing instance. Owned. |
|
180 */ |
|
181 CTelephonyAudioRouting* iTelephonyAudioRouting; |
|
182 |
|
183 /** |
|
184 * Central repository. Owned. |
|
185 */ |
|
186 CRepository* iRepository; |
|
187 |
|
188 /** |
|
189 * Command handler for muting the microphone |
|
190 */ |
|
191 CPhCltCommandHandler* iPhoneCommandHandler; |
|
192 |
|
193 /** |
|
194 * Not owned. |
|
195 */ |
|
196 MMusEngAudioRoutingObserver* iAudioRoutingObserver; |
|
197 |
|
198 TBool iShowDialog; |
|
199 |
|
200 }; |
|
201 |
|
202 |
|
203 #endif // MUSENGTELEPHONEUTILS_H |