|
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 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
|
54 |
|
55 /** |
|
56 * |
|
57 */ |
|
58 ~CMusEngTelephoneUtils(); |
|
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 void LoudspeakerL( TBool aEnable ); |
|
73 |
|
74 /** |
|
75 * |
|
76 */ |
|
77 TBool IsLoudSpeakerEnabled() const; |
|
78 |
|
79 /** |
|
80 * |
|
81 */ |
|
82 TInt GetVolumeL() const; |
|
83 |
|
84 /** |
|
85 * |
|
86 */ |
|
87 void SetVolumeL( TInt aVolume ); |
|
88 |
|
89 /** |
|
90 * Mutes CS call microphone. |
|
91 */ |
|
92 void MuteMicL( TBool aMute ); |
|
93 |
|
94 /** |
|
95 * Returns current CS call mic mute state. |
|
96 */ |
|
97 TBool IsMicMutedL(); |
|
98 |
|
99 private: // inherited from CActive |
|
100 |
|
101 /** |
|
102 * |
|
103 */ |
|
104 void RunL(); |
|
105 |
|
106 /** |
|
107 * Cancels outstanding request to phone client |
|
108 */ |
|
109 void DoCancel(); |
|
110 |
|
111 |
|
112 private: // MTelephonyAudioRoutingObserver functions |
|
113 |
|
114 /** |
|
115 * Available outputs have changed |
|
116 */ |
|
117 void AvailableOutputsChanged( |
|
118 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
|
119 |
|
120 /** |
|
121 * Some other application has changed audio output routing |
|
122 */ |
|
123 void OutputChanged( |
|
124 CTelephonyAudioRouting& aTelephonyAudioRouting ); |
|
125 |
|
126 /** |
|
127 * Our request to change audio output routing has completed |
|
128 */ |
|
129 void SetOutputComplete( |
|
130 CTelephonyAudioRouting& aTelephonyAudioRouting, |
|
131 TInt aError ); |
|
132 |
|
133 private: |
|
134 |
|
135 /** |
|
136 * Default C++ constructor |
|
137 */ |
|
138 CMusEngTelephoneUtils( |
|
139 MMusEngAudioRoutingObserver& aAudioRoutingObserver ); |
|
140 |
|
141 /** |
|
142 * 2nd phase constructor |
|
143 */ |
|
144 void ConstructL(); |
|
145 |
|
146 |
|
147 private: // HELPER |
|
148 |
|
149 /** |
|
150 * Checks that volume value is between 1 and 10. |
|
151 * |
|
152 * @return validated volume value |
|
153 */ |
|
154 TInt ValidateVolume( const TInt aVolume ) const; |
|
155 |
|
156 |
|
157 private: // DATA |
|
158 |
|
159 MMusEngAudioRoutingObserver& iAudioRoutingObserver; |
|
160 |
|
161 /** |
|
162 * Stores the audio routing state at startup. |
|
163 */ |
|
164 CTelephonyAudioRouting::TAudioOutput iAudioOutputAtStartup; |
|
165 |
|
166 /** |
|
167 * Telephony audio routing instance. Owned. |
|
168 */ |
|
169 CTelephonyAudioRouting* iTelephonyAudioRouting; |
|
170 |
|
171 /** |
|
172 * Central repository. Owned. |
|
173 */ |
|
174 CRepository* iRepository; |
|
175 |
|
176 /** |
|
177 * Command handler for muting the microphone |
|
178 */ |
|
179 CPhCltCommandHandler* iPhoneCommandHandler; |
|
180 }; |
|
181 |
|
182 #endif // MUSENGTELEPHONEUTILS_H |