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> |
30 |
31 |
31 // FORWARD DECLARATIONS |
32 // FORWARD DECLARATIONS |
32 class CRepository; |
33 class CRepository; |
33 class CTelephonyAudioRouting; |
34 class CTelephonyAudioRouting; |
34 class CPhCltCommandHandler; |
35 class CPhCltCommandHandler; |
35 class MMusEngAudioRoutingObserver; |
36 class MMusEngAudioRoutingObserver; |
|
37 class MMusEngVolumeChangeObserver; |
36 |
38 |
37 /** |
39 /** |
38 * Utility class to handle all phone related requests: |
40 * Utility class to handle all phone related requests: |
39 * Audio routing, volume control and microphone muting. |
41 * Audio routing, volume control and microphone muting. |
40 */ |
42 */ |
41 class CMusEngTelephoneUtils : public CActive, |
43 class CMusEngTelephoneUtils : public CActive, |
42 public MTelephonyAudioRoutingObserver |
44 public MTelephonyAudioRoutingObserver, |
|
45 public MCenRepNotifyHandlerCallback |
43 { |
46 { |
44 MUS_UNITTEST( UT_CMusEngTelephoneUtils ) |
47 MUS_UNITTEST( UT_CMusEngTelephoneUtils ) |
45 MUS_UNITTEST( UT_CMusEngSession ) |
48 MUS_UNITTEST( UT_CMusEngSession ) |
46 |
49 |
47 public: |
50 public: |
48 |
51 |
49 /** |
52 /** |
50 * |
53 * |
51 */ |
54 */ |
52 static CMusEngTelephoneUtils* NewL( |
55 static CMusEngTelephoneUtils* NewL(); |
53 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
|
54 |
56 |
55 /** |
57 /** |
56 * |
58 * |
57 */ |
59 */ |
58 ~CMusEngTelephoneUtils(); |
60 ~CMusEngTelephoneUtils(); |
|
61 |
59 |
62 |
60 public: // API |
63 public: // API |
61 |
64 |
62 /** |
65 /** |
63 * Checks if audio routing can be changed using LoudspeakerL |
66 * Checks if audio routing can be changed using LoudspeakerL |
64 * |
67 * |
65 * @return ETrue if audio routing can be changed using LoudspeakerL |
68 * @return ETrue if audio routing can be changed using LoudspeakerL |
66 */ |
69 */ |
67 TBool AudioRoutingCanBeChanged(); |
70 TBool AudioRoutingCanBeChanged() const; |
68 |
71 |
|
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 |
69 /** |
87 /** |
70 * Changes the audio routing between loudspeaker and handset. |
88 * Changes the audio routing between loudspeaker and handset. |
71 */ |
89 * |
72 void LoudspeakerL( TBool aEnable ); |
90 * @param aShowDialog if ETrue, user is notified about new audio routing |
|
91 */ |
|
92 void LoudspeakerL( TBool aEnable, TBool aShowDialog ); |
73 |
93 |
74 /** |
94 /** |
75 * |
95 * |
76 */ |
96 */ |
77 TBool IsLoudSpeakerEnabled() const; |
97 TBool IsLoudSpeakerEnabled() const; |
78 |
98 |
79 /** |
99 /** |
80 * |
100 * Returns current CS call volume level from central repository |
81 */ |
101 */ |
82 TInt GetVolumeL() const; |
102 TInt GetVolumeL() const; |
83 |
103 |
|
104 /** |
|
105 * Returns locally cached CS call volume level |
|
106 */ |
|
107 TInt GetVolume() const; |
|
108 |
84 /** |
109 /** |
85 * |
110 * |
86 */ |
111 */ |
87 void SetVolumeL( TInt aVolume ); |
112 void SetVolumeL( TInt aVolume ); |
88 |
113 |
92 void MuteMicL( TBool aMute ); |
117 void MuteMicL( TBool aMute ); |
93 |
118 |
94 /** |
119 /** |
95 * Returns current CS call mic mute state. |
120 * Returns current CS call mic mute state. |
96 */ |
121 */ |
97 TBool IsMicMutedL(); |
122 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 ); |
98 |
135 |
99 private: // inherited from CActive |
136 private: // inherited from CActive |
100 |
137 |
101 /** |
138 /** |
102 * |
139 * |
103 */ |
140 */ |
104 void RunL(); |
141 void RunL(); |
|
142 TInt RunError( TInt aError ); |
105 |
143 |
106 /** |
144 /** |
107 * Cancels outstanding request to phone client |
145 * Cancels outstanding request to phone client |
108 */ |
146 */ |
109 void DoCancel(); |
147 void DoCancel(); |
113 |
151 |
114 /** |
152 /** |
115 * Available outputs have changed |
153 * Available outputs have changed |
116 */ |
154 */ |
117 void AvailableOutputsChanged( |
155 void AvailableOutputsChanged( |
118 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
156 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
119 |
157 |
120 /** |
158 /** |
121 * Some other application has changed audio output routing |
159 * Some other application has changed audio output routing |
122 */ |
160 */ |
123 void OutputChanged( |
161 void OutputChanged( |
124 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
162 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
125 |
163 |
126 /** |
164 /** |
127 * Our request to change audio output routing has completed |
165 * Our request to change audio output routing has completed |
128 */ |
166 */ |
129 void SetOutputComplete( |
167 void SetOutputComplete( |
130 CTelephonyAudioRouting& aTelephonyAudioRouting, |
168 CTelephonyAudioRouting& aTelephonyAudioRouting, |
131 TInt aError ); |
169 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 ); |
132 |
180 |
133 private: |
181 private: |
134 |
182 |
135 /** |
183 /** |
136 * Default C++ constructor |
184 * Default C++ constructor |
137 */ |
185 */ |
138 CMusEngTelephoneUtils( |
186 CMusEngTelephoneUtils(); |
139 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
|
140 |
187 |
141 /** |
188 /** |
142 * 2nd phase constructor |
189 * 2nd phase constructor |
143 */ |
190 */ |
144 void ConstructL(); |
191 void ConstructL(); |
151 * |
198 * |
152 * @return validated volume value |
199 * @return validated volume value |
153 */ |
200 */ |
154 TInt ValidateVolume( const TInt aVolume ) const; |
201 TInt ValidateVolume( const TInt aVolume ) const; |
155 |
202 |
156 |
203 /** |
|
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 |
157 private: // DATA |
210 private: // DATA |
158 |
|
159 MMusEngAudioRoutingObserver& iAudioRoutingObserver; |
|
160 |
211 |
161 /** |
212 /** |
162 * Stores the audio routing state at startup. |
213 * Stores the audio routing state at startup. |
163 */ |
214 */ |
164 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |
215 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |