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 // USER INCLUDES |
|
20 #include "musengsession.h" |
|
21 #include "musengsessionobserver.h" |
|
22 #include "musengtelephoneutils.h" |
|
23 #include "muslogger.h" |
|
24 |
|
25 // SYSTEM INCLUDES |
|
26 |
|
27 #include <e32cmn.h> |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMusEngSession::~CMusEngSession() // destruct - virtual, so no export |
|
34 { |
|
35 MUS_LOG( "mus: [ENGINE] -> CMusEngSession::~CMusEngSession()" ) |
|
36 delete iTelephoneUtils; |
|
37 MUS_LOG( "mus: [ENGINE] <- CMusEngSession::~CMusEngSession()" ) |
|
38 } |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C TRect CMusEngSession::Rect() const |
|
46 { |
|
47 MUS_LOG( "mus: [ENGINE] CMusEngSession::Rect()" ) |
|
48 return iRect; |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C void CMusEngSession::SetRectL( const TRect& aRect ) |
|
57 { |
|
58 MUS_LOG( "mus: [ENGINE] CMusEngSession::SetRect()" ) |
|
59 iRect = aRect; |
|
60 RectChangedL(); |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C TBool CMusEngSession::AudioRoutingCanBeChanged() const |
|
69 { |
|
70 return iTelephoneUtils->AudioRoutingCanBeChanged(); |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C TBool CMusEngSession::IsAudioRoutingHeadset() const |
|
79 { |
|
80 return iTelephoneUtils->IsAudioRoutingHeadset(); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C TBool CMusEngSession::IsAudioRoutingLoudSpeaker() const |
|
88 { |
|
89 return iTelephoneUtils->IsAudioRoutingLoudSpeaker(); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C void CMusEngSession::EnableLoudspeakerL( TBool aEnable, |
|
97 TBool aShowDialog ) |
|
98 { |
|
99 TRAPD( error, iTelephoneUtils->LoudspeakerL( aEnable, aShowDialog ) ) |
|
100 |
|
101 if ( error != KErrNone ) |
|
102 { |
|
103 // This is writed for emulator use |
|
104 if ( error != KErrNotSupported ) |
|
105 { |
|
106 MUS_LOG1( "mus: [ENGINE] CMusEngSession::EnableLoudspeakerL() Leave: #%d", |
|
107 error) |
|
108 User::Leave( error ); |
|
109 } |
|
110 // Not leave in emulator if KErrNotSupported |
|
111 #if (!defined (__WINS__) && !defined(__WINSCW__)) |
|
112 User::Leave( error ); |
|
113 #endif |
|
114 } |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C TBool CMusEngSession::IsLoudSpeakerEnabled() const |
|
123 { |
|
124 return iTelephoneUtils->IsLoudSpeakerEnabled(); |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TInt CMusEngSession::VolumeL() const |
|
133 { |
|
134 return iTelephoneUtils->GetVolume(); |
|
135 } |
|
136 |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C void CMusEngSession::MuteMicL( TBool aMute ) |
|
143 { |
|
144 iTelephoneUtils->MuteMicL( aMute ); |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TBool CMusEngSession::IsMicMutedL() |
|
153 { |
|
154 return iTelephoneUtils->IsMicMutedL(); |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void CMusEngSession::SetAudioRoutingObserver( |
|
163 MMusEngAudioRoutingObserver* aObserver ) |
|
164 { |
|
165 iTelephoneUtils->SetAudioRoutingObserver( aObserver ); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C void CMusEngSession::SetVolumeChangeObserver( |
|
173 MMusEngVolumeChangeObserver* aObserver ) |
|
174 { |
|
175 iVolumeObserver = aObserver; |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // Increases CS call volume level by one. |
|
181 // Leaves if error occurs when accessing central repository. |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C void CMusEngSession::VolumeUpL( ) |
|
185 { |
|
186 TInt currentVolume = iTelephoneUtils->GetVolume(); |
|
187 iTelephoneUtils->SetVolumeL( currentVolume + 1 ); |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // Decreases CS call volume level by one. |
|
193 // Leaves if error occurs when accessing central repository. |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C void CMusEngSession::VolumeDownL( ) |
|
197 { |
|
198 TInt currentVolume = iTelephoneUtils->GetVolume(); |
|
199 iTelephoneUtils->SetVolumeL( currentVolume - 1 ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // Set CS call volume value |
|
204 // Leaves if error occurs when accessing central repository. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 EXPORT_C void CMusEngSession::SetVolumeL( TInt aVal ) |
|
208 { |
|
209 iTelephoneUtils->SetVolumeL( aVal ); |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 CMusEngSession::CMusEngSession( const TRect& aRect ) |
|
218 :iRect( aRect ) |
|
219 { |
|
220 } |
|
221 |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void CMusEngSession::ConstructL() // second-phase constructor |
|
228 { |
|
229 MUS_LOG( "mus: [ENGINE] -> CMusEngSession::ConstructL()" ) |
|
230 iTelephoneUtils = CMusEngTelephoneUtils::NewL(); |
|
231 iTelephoneUtils->SetVolumeChangeObserver( this ); |
|
232 MUS_LOG( "mus: [ENGINE] <- CMusEngSession::ConstructL()" ) |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CMusEngSession::VolumeChanged( TInt aVolume, TBool aAudioRouteChanged ) |
|
240 { |
|
241 if ( iVolumeObserver ) |
|
242 { |
|
243 iVolumeObserver->VolumeChanged( aVolume, aAudioRouteChanged ); |
|
244 } |
|
245 } |
|