25 // SYSTEM |
25 // SYSTEM |
26 #include <e32base.h> |
26 #include <e32base.h> |
27 #include <MTelephonyAudioRoutingObserver.h> |
27 #include <MTelephonyAudioRoutingObserver.h> |
28 #include <TelephonyAudioRouting.h> |
28 #include <TelephonyAudioRouting.h> |
29 #include <RPhCltServer.h> |
29 #include <RPhCltServer.h> |
30 #include <cenrepnotifyhandler.h> |
|
31 |
30 |
32 // FORWARD DECLARATIONS |
31 // FORWARD DECLARATIONS |
33 class CRepository; |
32 class CRepository; |
34 class CTelephonyAudioRouting; |
33 class CTelephonyAudioRouting; |
35 class CPhCltCommandHandler; |
34 class CPhCltCommandHandler; |
36 class MMusEngAudioRoutingObserver; |
35 class MMusEngAudioRoutingObserver; |
37 class MMusEngVolumeChangeObserver; |
|
38 |
36 |
39 /** |
37 /** |
40 * Utility class to handle all phone related requests: |
38 * Utility class to handle all phone related requests: |
41 * Audio routing, volume control and microphone muting. |
39 * Audio routing, volume control and microphone muting. |
42 */ |
40 */ |
43 class CMusEngTelephoneUtils : public CActive, |
41 class CMusEngTelephoneUtils : public CActive, |
44 public MTelephonyAudioRoutingObserver, |
42 public MTelephonyAudioRoutingObserver |
45 public MCenRepNotifyHandlerCallback |
|
46 { |
43 { |
47 MUS_UNITTEST( UT_CMusEngTelephoneUtils ) |
44 MUS_UNITTEST( UT_CMusEngTelephoneUtils ) |
48 MUS_UNITTEST( UT_CMusEngSession ) |
45 MUS_UNITTEST( UT_CMusEngSession ) |
49 |
46 |
50 public: |
47 public: |
51 |
48 |
52 /** |
49 /** |
53 * |
50 * |
54 */ |
51 */ |
55 static CMusEngTelephoneUtils* NewL(); |
52 static CMusEngTelephoneUtils* NewL( |
|
53 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
56 |
54 |
57 /** |
55 /** |
58 * |
56 * |
59 */ |
57 */ |
60 ~CMusEngTelephoneUtils(); |
58 ~CMusEngTelephoneUtils(); |
61 |
|
62 |
59 |
63 public: // API |
60 public: // API |
64 |
61 |
65 /** |
62 /** |
66 * Checks if audio routing can be changed using LoudspeakerL |
63 * Checks if audio routing can be changed using LoudspeakerL |
67 * |
64 * |
68 * @return ETrue if audio routing can be changed using LoudspeakerL |
65 * @return ETrue if audio routing can be changed using LoudspeakerL |
69 */ |
66 */ |
70 TBool AudioRoutingCanBeChanged() const; |
67 TBool AudioRoutingCanBeChanged(); |
71 |
68 |
72 /** |
|
73 * Checks if audio routing is headset |
|
74 * |
|
75 * @return ETrue if audio routing is headset |
|
76 */ |
|
77 TBool IsAudioRoutingHeadset() const; |
|
78 |
|
79 /** |
|
80 * Checks if audio routing is LoudSpeaker |
|
81 * |
|
82 * @return ETrue if audio routing is LoudSpeaker and |
|
83 * currentMode != iAudioOutputAtStartup |
|
84 */ |
|
85 TBool IsAudioRoutingLoudSpeaker() const; |
|
86 |
|
87 /** |
69 /** |
88 * Changes the audio routing between loudspeaker and handset. |
70 * Changes the audio routing between loudspeaker and handset. |
89 * |
|
90 * @param aShowDialog if ETrue, user is notified about new audio routing |
|
91 */ |
71 */ |
92 void LoudspeakerL( TBool aEnable, TBool aShowDialog ); |
72 void LoudspeakerL( TBool aEnable ); |
93 |
73 |
94 /** |
74 /** |
95 * |
75 * |
96 */ |
76 */ |
97 TBool IsLoudSpeakerEnabled() const; |
77 TBool IsLoudSpeakerEnabled() const; |
98 |
78 |
99 /** |
79 /** |
100 * Returns current CS call volume level from central repository |
80 * |
101 */ |
81 */ |
102 TInt GetVolumeL() const; |
82 TInt GetVolumeL() const; |
103 |
83 |
104 /** |
|
105 * Returns locally cached CS call volume level |
|
106 */ |
|
107 TInt GetVolume() const; |
|
108 |
|
109 /** |
84 /** |
110 * |
85 * |
111 */ |
86 */ |
112 void SetVolumeL( TInt aVolume ); |
87 void SetVolumeL( TInt aVolume ); |
113 |
88 |
117 void MuteMicL( TBool aMute ); |
92 void MuteMicL( TBool aMute ); |
118 |
93 |
119 /** |
94 /** |
120 * Returns current CS call mic mute state. |
95 * Returns current CS call mic mute state. |
121 */ |
96 */ |
122 TBool IsMicMutedL(); |
97 TBool IsMicMutedL(); |
123 |
|
124 /** |
|
125 * Sets audio routing observer. Can be set to NULL in order to indicate |
|
126 * ending of observing changes in audio routing. |
|
127 */ |
|
128 void SetAudioRoutingObserver( MMusEngAudioRoutingObserver* aObserver ); |
|
129 |
|
130 /** |
|
131 * Sets volume level observer. Can be set to NULL in order to indicate |
|
132 * ending of observing changes in volume level. |
|
133 */ |
|
134 void SetVolumeChangeObserver( MMusEngVolumeChangeObserver* aObserver ); |
|
135 |
98 |
136 private: // inherited from CActive |
99 private: // inherited from CActive |
137 |
100 |
138 /** |
101 /** |
139 * |
102 * |
140 */ |
103 */ |
141 void RunL(); |
104 void RunL(); |
142 TInt RunError( TInt aError ); |
|
143 |
105 |
144 /** |
106 /** |
145 * Cancels outstanding request to phone client |
107 * Cancels outstanding request to phone client |
146 */ |
108 */ |
147 void DoCancel(); |
109 void DoCancel(); |
151 |
113 |
152 /** |
114 /** |
153 * Available outputs have changed |
115 * Available outputs have changed |
154 */ |
116 */ |
155 void AvailableOutputsChanged( |
117 void AvailableOutputsChanged( |
156 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
118 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
157 |
119 |
158 /** |
120 /** |
159 * Some other application has changed audio output routing |
121 * Some other application has changed audio output routing |
160 */ |
122 */ |
161 void OutputChanged( |
123 void OutputChanged( |
162 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
124 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
163 |
125 |
164 /** |
126 /** |
165 * Our request to change audio output routing has completed |
127 * Our request to change audio output routing has completed |
166 */ |
128 */ |
167 void SetOutputComplete( |
129 void SetOutputComplete( |
168 CTelephonyAudioRouting& aTelephonyAudioRouting, |
130 CTelephonyAudioRouting& aTelephonyAudioRouting, |
169 TInt aError ); |
131 TInt aError ); |
170 |
|
171 /** |
|
172 * Set output if setting is currently allowed. Leaves with KErrAccessDenied |
|
173 * if setting is not allowed. |
|
174 */ |
|
175 void DoSetOutputL( CTelephonyAudioRouting::TAudioOutput aAudioOutput ); |
|
176 |
|
177 private:// From MCenRepNotifyHandlerCallback |
|
178 |
|
179 void HandleNotifyGeneric( TUint32 aId ); |
|
180 |
132 |
181 private: |
133 private: |
182 |
134 |
183 /** |
135 /** |
184 * Default C++ constructor |
136 * Default C++ constructor |
185 */ |
137 */ |
186 CMusEngTelephoneUtils(); |
138 CMusEngTelephoneUtils( |
|
139 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
187 |
140 |
188 /** |
141 /** |
189 * 2nd phase constructor |
142 * 2nd phase constructor |
190 */ |
143 */ |
191 void ConstructL(); |
144 void ConstructL(); |
198 * |
151 * |
199 * @return validated volume value |
152 * @return validated volume value |
200 */ |
153 */ |
201 TInt ValidateVolume( const TInt aVolume ) const; |
154 TInt ValidateVolume( const TInt aVolume ) const; |
202 |
155 |
203 /** |
156 |
204 * Checks current volume level and notifies observer, if volume changed |
|
205 * @param aAudioRouteChanged, ETrue if volume check should be done |
|
206 * because of audio route change |
|
207 */ |
|
208 void UpdateCurrentVolume( TBool aAudioRouteChanged ); |
|
209 |
|
210 private: // DATA |
157 private: // DATA |
|
158 |
|
159 MMusEngAudioRoutingObserver& iAudioRoutingObserver; |
211 |
160 |
212 /** |
161 /** |
213 * Stores the audio routing state at startup. |
162 * Stores the audio routing state at startup. |
214 */ |
163 */ |
215 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |
164 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |