|
1 /* |
|
2 * Copyright (c) 2007 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: MusIndicatorApi provides means to show notes and indicate |
|
15 * availability of videosharing to user. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "musindicatorapi.h" |
|
22 #include "musresourcefinderutil.h" |
|
23 #include "muslogger.h" |
|
24 #include "musindicatordsa.h" |
|
25 #include "mussettings.h" |
|
26 #include "mussettingskeys.h" |
|
27 #include "mussoundplayer.h" |
|
28 #include "musresourceutil.h" |
|
29 #include <musindicator.rsg> |
|
30 #include <coreapplicationuisdomainpskeys.h> |
|
31 |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL( MMusIndicatorObserver& aObserver ) |
|
40 { |
|
41 CMusIndicatorApi* self = CMusIndicatorApi::NewLC( aObserver ); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewLC( MMusIndicatorObserver& aObserver ) |
|
52 { |
|
53 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( &aObserver ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL() |
|
65 { |
|
66 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( NULL ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMusIndicatorApi::~CMusIndicatorApi() |
|
79 { |
|
80 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::~CMusIndicatorApi" ); |
|
81 |
|
82 Cancel(); |
|
83 delete iIndicatorWindow; |
|
84 delete iSoundPlayer; |
|
85 if ( !IsSubscriber() ) |
|
86 { |
|
87 Indicator( EFalse ); |
|
88 } |
|
89 |
|
90 iProperty.Close(); |
|
91 |
|
92 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::~CMusIndicatorApi" ); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 TBool CMusIndicatorApi::IsSubscriber() const |
|
101 { |
|
102 return !iObserver; |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // Indicates VS availability to user. |
|
108 // In operator specific variant this can include DSA note and an audio tone |
|
109 // played with CMdaAudioPlayerUtility. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C void CMusIndicatorApi::IndicateAvailabilityL() |
|
113 { |
|
114 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::IndicateAvailabilityL" ) |
|
115 __ASSERT_ALWAYS( !IsSubscriber(), User::Leave( KErrArgument ) ); |
|
116 |
|
117 Indicator( ETrue ); |
|
118 |
|
119 if( MultimediaSharingSettings::AuditoryNotificationSettingL() == |
|
120 MusSettingsKeys::EAuditoryNotificationOn ) |
|
121 { |
|
122 MUS_LOG( "mus: [MUSIND] Play tone" ) |
|
123 PlayToneL(); |
|
124 } |
|
125 |
|
126 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::IndicateAvailabilityL" ) |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // From CActive. |
|
132 // Handles completion of an outstanding asynchronous request. |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CMusIndicatorApi::RunL() |
|
136 { |
|
137 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::RunL" ) |
|
138 |
|
139 if ( !IsSubscriber() ) |
|
140 { |
|
141 MUS_LOG( "mus: [MUSIND ] : publisher" ) |
|
142 StartLiveSharingL(); |
|
143 } |
|
144 else |
|
145 { |
|
146 MUS_LOG( "mus: [MUSIND ] : subscriber" ) |
|
147 ToggleIndicatorL(); |
|
148 } |
|
149 |
|
150 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::RunL" ) |
|
151 } |
|
152 |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CMusIndicatorApi::StartLiveSharingL() |
|
159 { |
|
160 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::StartLiveSharingL" ) |
|
161 |
|
162 if( iStatus.Int() != KErrNotFound ) // eq. Cancel -button |
|
163 { |
|
164 if ( iObserver ) |
|
165 { |
|
166 iObserver->StartLiveSharingL(); |
|
167 } |
|
168 } |
|
169 |
|
170 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::StartLiveSharingL" ) |
|
171 } |
|
172 |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CMusIndicatorApi::ToggleIndicatorL() |
|
179 { |
|
180 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::ToggleIndicatorL" ) |
|
181 TInt val; |
|
182 |
|
183 |
|
184 |
|
185 User::LeaveIfError( RProperty::Get( KPSUidCoreApplicationUIs, |
|
186 KCoreAppUIsVideoSharingIndicator, |
|
187 val ) ); |
|
188 iProperty.Subscribe( iStatus ); |
|
189 SetActive(); |
|
190 |
|
191 TBool on = ( val == ECoreAppUIsVideoSharingIndicatorOn ); |
|
192 |
|
193 if ( on && !iIndicatorWindow |
|
194 && MultimediaSharingSettings::OperatorVariantSettingL() == |
|
195 MusSettingsKeys::EOperatorSpecific ) |
|
196 { |
|
197 iIndicatorWindow = CMusIndicatorDsa::NewL(); |
|
198 } |
|
199 else if ( !on ) |
|
200 { |
|
201 delete iIndicatorWindow; |
|
202 iIndicatorWindow = NULL; |
|
203 } |
|
204 else |
|
205 { |
|
206 //NOP |
|
207 } |
|
208 |
|
209 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::ToggleIndicatorL" ) |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // From CActive. |
|
215 // Cancels an outstanding asynchronous request. |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 void CMusIndicatorApi::DoCancel() |
|
219 { |
|
220 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::DoCancel" ) |
|
221 |
|
222 if ( IsSubscriber() ) |
|
223 { |
|
224 iProperty.Cancel(); |
|
225 } |
|
226 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::DoCancel" ) |
|
227 } |
|
228 |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // From CActive. |
|
232 // Handles a leave occurring in the request completion event handler RunL. |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 #ifdef _DEBUG |
|
236 TInt CMusIndicatorApi::RunError( TInt aError ) |
|
237 #else |
|
238 TInt CMusIndicatorApi::RunError( TInt ) |
|
239 #endif |
|
240 { |
|
241 MUS_LOG1( "mus: [MUSIND] -> CMusIndicatorApi::RunError(%d)", aError ) |
|
242 |
|
243 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::RunError(%d)" ) |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // From MMusSoundPlayerObserver. |
|
250 // Indicates completion of sound playback. |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 #ifdef _DEBUG |
|
254 void CMusIndicatorApi::PlaySoundComplete( TInt aError ) |
|
255 #else |
|
256 void CMusIndicatorApi::PlaySoundComplete( TInt /* aError */ ) |
|
257 #endif |
|
258 { |
|
259 MUS_LOG1( "mus: [MUSIND ] -> MusIndicatorApi::PlaySoundComplete(%d)", aError ) |
|
260 delete iSoundPlayer; |
|
261 iSoundPlayer = NULL; |
|
262 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::PlaySoundComplete" ) |
|
263 } |
|
264 |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 CMusIndicatorApi::CMusIndicatorApi( MMusIndicatorObserver* aObserver ) |
|
271 : CActive( EPriorityStandard ), |
|
272 iObserver( aObserver ) |
|
273 { |
|
274 } |
|
275 |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CMusIndicatorApi::ConstructL() |
|
282 { |
|
283 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::ConstructL" ) |
|
284 |
|
285 if ( IsSubscriber() ) |
|
286 { |
|
287 MUS_LOG( "mus: [MUSIND ] : subscriber (called by aiwprovider)" ) |
|
288 |
|
289 User::LeaveIfError( iProperty.Attach( KPSUidCoreApplicationUIs, |
|
290 KCoreAppUIsVideoSharingIndicator ) ); |
|
291 CActiveScheduler::Add( this ); |
|
292 iProperty.Subscribe( iStatus ); |
|
293 SetActive(); |
|
294 } |
|
295 else |
|
296 { |
|
297 MUS_LOG( "mus: [MUSIND ] : publisher (called by manager)" ) |
|
298 CActiveScheduler::Add( this ); |
|
299 } |
|
300 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::ConstructL" ) |
|
301 } |
|
302 |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // Indicating availability of VS. |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 void CMusIndicatorApi::Indicator( TBool aShown ) |
|
309 { |
|
310 MUS_LOG1( "mus: [MUSIND ] <- MusIndicatorApi::Indicator( %d)" , aShown ) |
|
311 |
|
312 RProperty property; |
|
313 TInt error( KErrNone ); |
|
314 |
|
315 error = property.Attach( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator ); |
|
316 if ( error == KErrNone ) |
|
317 { |
|
318 if ( aShown ) |
|
319 { |
|
320 MUS_LOG( "mus: [MUSIND ] : indicator ON" ) |
|
321 |
|
322 property.Set( ECoreAppUIsVideoSharingIndicatorOn ); |
|
323 } |
|
324 else |
|
325 { |
|
326 MUS_LOG( "mus: [MUSIND ] : indicator OFF" ) |
|
327 property.Set( ECoreAppUIsVideoSharingIndicatorOff ); |
|
328 } |
|
329 } |
|
330 property.Close(); |
|
331 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::Indicator" ) |
|
332 |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // Plays tone indicating availability of VS. |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void CMusIndicatorApi::PlayToneL() |
|
340 { |
|
341 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::PlayToneL" ) |
|
342 delete iSoundPlayer; |
|
343 iSoundPlayer = NULL; |
|
344 iSoundPlayer = CMusSoundPlayer::NewL( *this ); |
|
345 MUS_LOG( "mus: [MUSIND ] MusIndicatorApi::PlayToneL - Play sound" ) |
|
346 iSoundPlayer->PlayL( CMusSoundPlayer::EVsAvailableSound ); |
|
347 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::PlayToneL" ) |
|
348 } |
|
349 |
|
350 |