19 |
19 |
20 |
20 |
21 #include "musindicatorapi.h" |
21 #include "musindicatorapi.h" |
22 #include "musresourcefinderutil.h" |
22 #include "musresourcefinderutil.h" |
23 #include "muslogger.h" |
23 #include "muslogger.h" |
24 #include "musindicatordsa.h" |
|
25 #include "mussettings.h" |
24 #include "mussettings.h" |
26 #include "mussettingskeys.h" |
25 #include "mussettingskeys.h" |
27 #include "mussoundplayer.h" |
26 #include "mussoundplayer.h" |
28 #include "musresourceutil.h" |
27 #include "musresourceutil.h" |
29 #include <musindicator.rsg> |
28 #include <musindicator.rsg> |
30 #include <AknGlobalConfirmationQuery.h> |
|
31 #include <AknGlobalMsgQuery.h> |
|
32 #include <coreapplicationuisdomainpskeys.h> |
29 #include <coreapplicationuisdomainpskeys.h> |
33 |
30 |
34 |
31 |
35 const TInt KMusLiveSharingQueryTimeout = 5000000; |
|
36 |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
32 // ======== MEMBER FUNCTIONS ======== |
39 |
33 |
40 using namespace MusSettingsKeys; |
34 // ----------------------------------------------------------------------------- |
41 |
35 // |
42 |
36 // ----------------------------------------------------------------------------- |
|
37 // |
43 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL( MMusIndicatorObserver& aObserver ) |
38 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL( MMusIndicatorObserver& aObserver ) |
44 { |
39 { |
45 CMusIndicatorApi* self = CMusIndicatorApi::NewLC( aObserver ); |
40 CMusIndicatorApi* self = CMusIndicatorApi::NewLC( aObserver ); |
46 CleanupStack::Pop( self ); |
41 CleanupStack::Pop( self ); |
47 return self; |
42 return self; |
48 } |
43 } |
49 |
44 |
50 |
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
51 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewLC( MMusIndicatorObserver& aObserver ) |
50 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewLC( MMusIndicatorObserver& aObserver ) |
52 { |
51 { |
53 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( &aObserver ); |
52 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( &aObserver ); |
54 CleanupStack::PushL( self ); |
53 CleanupStack::PushL( self ); |
55 self->ConstructL(); |
54 self->ConstructL(); |
56 return self; |
55 return self; |
57 } |
56 } |
58 |
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
59 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL() |
63 EXPORT_C CMusIndicatorApi* CMusIndicatorApi::NewL() |
60 { |
64 { |
61 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( NULL ); |
65 CMusIndicatorApi* self = new (ELeave) CMusIndicatorApi( NULL ); |
62 CleanupStack::PushL( self ); |
66 CleanupStack::PushL( self ); |
63 self->ConstructL(); |
67 self->ConstructL(); |
64 CleanupStack::Pop( self ); |
68 CleanupStack::Pop( self ); |
65 return self; |
69 return self; |
66 } |
70 } |
67 |
71 |
68 |
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
69 CMusIndicatorApi::~CMusIndicatorApi() |
77 CMusIndicatorApi::~CMusIndicatorApi() |
70 { |
78 { |
71 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::~CMusIndicatorApi" ); |
79 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::~CMusIndicatorApi" ); |
72 |
80 |
73 Cancel(); |
81 Cancel(); |
74 delete iQuery; |
|
75 delete iIndicatorWindow; |
|
76 delete iSoundPlayer; |
82 delete iSoundPlayer; |
77 delete iLiveSharingQueryTimeout; |
83 |
78 if ( !IsSubscriber() ) |
84 Indicator( EFalse ); |
|
85 |
|
86 |
|
87 iProperty.Close(); |
|
88 |
|
89 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::~CMusIndicatorApi" ); |
|
90 } |
|
91 |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // Indicates VS availability to user. |
|
95 // In operator specific variant this can include DSA note and an audio tone |
|
96 // played with CMdaAudioPlayerUtility. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CMusIndicatorApi::IndicateAvailabilityL() |
|
100 { |
|
101 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::IndicateAvailabilityL" ) |
|
102 Indicator( ETrue ); |
|
103 |
|
104 if( MultimediaSharingSettings::AuditoryNotificationSettingL() == |
|
105 MusSettingsKeys::EAuditoryNotificationOn ) |
79 { |
106 { |
80 Indicator( EFalse ); |
107 MUS_LOG( "mus: [MUSIND] Play tone" ) |
81 } |
|
82 |
|
83 iProperty.Close(); |
|
84 |
|
85 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::~CMusIndicatorApi" ); |
|
86 } |
|
87 |
|
88 |
|
89 TBool CMusIndicatorApi::IsSubscriber() const |
|
90 { |
|
91 return !iObserver; |
|
92 } |
|
93 |
|
94 |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Provides a confirmation query to user and returns true if user selected |
|
98 // "yes". |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C TBool CMusIndicatorApi::ConfirmationQueryL( TVsPopupQuery aQuery ) |
|
102 { |
|
103 MUS_LOG( "mus: [MUSIND ] -> MusIndicatorApi::ConfirmationQueryL" ); |
|
104 |
|
105 CAknGlobalConfirmationQuery* dlg = CAknGlobalConfirmationQuery::NewLC(); |
|
106 TRequestStatus status( KRequestPending ); |
|
107 HBufC* prompt = NoteTextLC( aQuery ); |
|
108 dlg->ShowConfirmationQueryL( status, *prompt, R_AVKON_SOFTKEYS_YES_NO ); |
|
109 User::WaitForRequest( status ); |
|
110 CleanupStack::PopAndDestroy( prompt ); |
|
111 CleanupStack::PopAndDestroy( dlg ); |
|
112 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::ConfirmationQueryL" ); |
|
113 return status == EAknSoftkeyYes; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Indicates VS availability to user. |
|
118 // In operator specific variant this can include a popup-note, DSA note and |
|
119 // an audio tone played with CMdaAudioPlayerUtility. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C void CMusIndicatorApi::IndicateAvailabilityL() |
|
123 { |
|
124 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::IndicateAvailabilityL" ) |
|
125 __ASSERT_ALWAYS( !IsSubscriber(), User::Leave( KErrArgument ) ); |
|
126 |
|
127 Indicator( ETrue ); |
|
128 |
|
129 if( MultimediaSharingSettings::PopupNotificationSettingL() == |
|
130 EPopupNotificationOn ) |
|
131 { |
|
132 // Show dialog |
|
133 MUS_LOG( "mus: [MUSIND] CMusIndicatorApi::IndicateAvailabilityL - Show popup" ) |
|
134 ShowLiveSharingQueryL( EFalse ); |
|
135 } |
|
136 |
|
137 if( MultimediaSharingSettings::AuditoryNotificationSettingL() == |
|
138 EAuditoryNotificationOn ) |
|
139 { |
|
140 MUS_LOG( "mus: [MUSIND] CMusIndicatorApi::IndicateAvailabilityL - Play tone" ) |
|
141 PlayToneL(); |
108 PlayToneL(); |
142 } |
109 } |
143 |
110 |
144 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::IndicateAvailabilityL" ) |
111 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::IndicateAvailabilityL" ) |
145 } |
112 } |
146 |
113 |
147 |
114 |
148 // --------------------------------------------------------------------------- |
115 // ----------------------------------------------------------------------------- |
149 // From CActive. |
116 // From CActive. |
150 // Handles completion of an outstanding asynchronous request. |
117 // Handles completion of an outstanding asynchronous request. |
151 // --------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
152 // |
119 // |
153 void CMusIndicatorApi::RunL() |
120 void CMusIndicatorApi::RunL() |
154 { |
121 { |
155 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::RunL" ) |
122 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::RunL" ) |
156 |
123 |
157 if ( !IsSubscriber() ) |
124 |
158 { |
125 MUS_LOG( "mus: [MUSIND ] : publisher" ) |
159 MUS_LOG( "mus: [MUSIND ] : publisher" ) |
126 StartLiveSharingL(); |
160 StartLiveSharingL(); |
127 |
161 } |
|
162 else |
|
163 { |
|
164 MUS_LOG( "mus: [MUSIND ] : subscriber" ) |
|
165 ToggleIndicatorL(); |
|
166 } |
|
167 |
128 |
168 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::RunL" ) |
129 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::RunL" ) |
169 } |
130 } |
170 |
131 |
171 |
132 |
172 // --------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
173 // |
134 // |
174 // --------------------------------------------------------------------------- |
135 // ----------------------------------------------------------------------------- |
175 // |
136 // |
176 void CMusIndicatorApi::StartLiveSharingL() |
137 void CMusIndicatorApi::StartLiveSharingL() |
177 { |
138 { |
178 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::StartLiveSharingL" ) |
139 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::StartLiveSharingL" ) |
179 delete iQuery; |
|
180 iQuery = NULL; |
|
181 |
|
182 if( iLiveSharingQueryTimeout ) |
|
183 { |
|
184 iLiveSharingQueryTimeout->Cancel(); |
|
185 } |
|
186 delete iLiveSharingQueryTimeout; |
|
187 iLiveSharingQueryTimeout = NULL; |
|
188 |
140 |
189 if( iStatus.Int() != KErrNotFound ) // eq. Cancel -button |
141 if( iStatus.Int() != KErrNotFound ) // eq. Cancel -button |
190 { |
142 { |
191 if ( iObserver ) |
143 if ( iObserver ) |
192 { |
144 { |
196 |
148 |
197 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::StartLiveSharingL" ) |
149 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::StartLiveSharingL" ) |
198 } |
150 } |
199 |
151 |
200 |
152 |
201 // --------------------------------------------------------------------------- |
153 // ----------------------------------------------------------------------------- |
202 // |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CMusIndicatorApi::ToggleIndicatorL() |
|
206 { |
|
207 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::ToggleIndicatorL" ) |
|
208 TInt val; |
|
209 |
|
210 |
|
211 |
|
212 User::LeaveIfError( RProperty::Get( KPSUidCoreApplicationUIs, |
|
213 KCoreAppUIsVideoSharingIndicator, |
|
214 val ) ); |
|
215 iProperty.Subscribe( iStatus ); |
|
216 SetActive(); |
|
217 |
|
218 TBool on = ( val == ECoreAppUIsVideoSharingIndicatorOn ); |
|
219 |
|
220 if ( on && !iIndicatorWindow |
|
221 && MultimediaSharingSettings::OperatorVariantSettingL() == |
|
222 EOperatorSpecific ) |
|
223 { |
|
224 iIndicatorWindow = CMusIndicatorDsa::NewL(); |
|
225 } |
|
226 else if ( !on ) |
|
227 { |
|
228 delete iIndicatorWindow; |
|
229 iIndicatorWindow = NULL; |
|
230 } |
|
231 else |
|
232 { |
|
233 //NOP |
|
234 } |
|
235 |
|
236 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::ToggleIndicatorL" ) |
|
237 } |
|
238 |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // From CActive. |
154 // From CActive. |
242 // Cancels an outstanding asynchronous request. |
155 // Cancels an outstanding asynchronous request. |
243 // --------------------------------------------------------------------------- |
156 // ----------------------------------------------------------------------------- |
244 // |
157 // |
245 void CMusIndicatorApi::DoCancel() |
158 void CMusIndicatorApi::DoCancel() |
246 { |
159 { |
247 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::DoCancel" ) |
160 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::DoCancel" ) |
248 |
161 |
249 if( iLiveSharingQueryTimeout ) |
162 |
250 { |
|
251 iLiveSharingQueryTimeout->Cancel(); |
|
252 } |
|
253 delete iLiveSharingQueryTimeout; |
|
254 iLiveSharingQueryTimeout = NULL; |
|
255 |
|
256 if ( iQuery ) |
|
257 { |
|
258 iQuery->CancelMsgQuery(); |
|
259 } |
|
260 delete iQuery; |
|
261 iQuery = NULL; |
|
262 |
|
263 if ( IsSubscriber() ) |
|
264 { |
|
265 iProperty.Cancel(); |
|
266 } |
|
267 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::DoCancel" ) |
163 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::DoCancel" ) |
268 } |
164 } |
269 |
165 |
270 |
166 |
271 // --------------------------------------------------------------------------- |
167 // ----------------------------------------------------------------------------- |
272 // From CActive. |
168 // From CActive. |
273 // Handles a leave occurring in the request completion event handler RunL. |
169 // Handles a leave occurring in the request completion event handler RunL. |
274 // --------------------------------------------------------------------------- |
170 // ----------------------------------------------------------------------------- |
275 // |
171 // |
276 #ifdef _DEBUG |
172 #ifdef _DEBUG |
277 TInt CMusIndicatorApi::RunError( TInt aError ) |
173 TInt CMusIndicatorApi::RunError( TInt aError ) |
278 #else |
174 #else |
279 TInt CMusIndicatorApi::RunError( TInt ) |
175 TInt CMusIndicatorApi::RunError( TInt ) |
387 iSoundPlayer->PlayL( CMusSoundPlayer::EVsAvailableSound ); |
272 iSoundPlayer->PlayL( CMusSoundPlayer::EVsAvailableSound ); |
388 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::PlayToneL" ) |
273 MUS_LOG( "mus: [MUSIND ] <- MusIndicatorApi::PlayToneL" ) |
389 } |
274 } |
390 |
275 |
391 |
276 |
392 // --------------------------------------------------------------------------- |
|
393 // Returns text associated with specified dialog. |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 HBufC* CMusIndicatorApi::NoteTextLC( TVsPopupQuery aQuery ) |
|
397 { |
|
398 MUS_LOG1( "mus: [MUSIND] -> MusIndicatorApi::NoteTextLC( %d )", aQuery ) |
|
399 |
|
400 HBufC* dlgPrompt( NULL ); |
|
401 |
|
402 switch ( aQuery ) |
|
403 { |
|
404 case EVsRoamingActivationQuery: |
|
405 { |
|
406 dlgPrompt = MusResourceUtil::ReadResourceString16LC( |
|
407 R_MUSINDICATOR_MANUAL_ACTIVATION_TXT, |
|
408 KMusIndicatorResource ); |
|
409 break; |
|
410 } |
|
411 |
|
412 default: |
|
413 { |
|
414 MUS_LOG( "mus: [MUSIND] MusIndicatorApi::NoteTextLC, UNKNOWN" ) |
|
415 User::Leave( KErrNotFound ); |
|
416 } |
|
417 } |
|
418 // now pop and destroy the resource reader |
|
419 |
|
420 MUS_LOG( "mus: [MUSIND] <- MusIndicatorApi::NoteTextLC" ) |
|
421 |
|
422 return dlgPrompt; |
|
423 } |
|
424 |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // Reads resource string |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CMusIndicatorApi::ShowLiveSharingQueryL( TBool aPlayTone ) |
|
431 { |
|
432 MUS_LOG( "mus: [MUSIND] -> CMusIndicatorApi::ShowLiveSharingQuery" ) |
|
433 Cancel(); |
|
434 |
|
435 delete iQuery; |
|
436 iQuery = NULL; |
|
437 |
|
438 HBufC* dlgPrompt = MusResourceUtil::ReadResourceString16LC( |
|
439 R_MUSINDICATOR_NOTE_CAPABILITY_TXT, |
|
440 KMusIndicatorResource ); |
|
441 |
|
442 HBufC* dlgHeader = MusResourceUtil::ReadResourceString16LC( |
|
443 R_MUSINDICATOR_NOTE_VSREADY_TXT, |
|
444 KMusIndicatorResource ); |
|
445 |
|
446 iQuery = CAknGlobalMsgQuery::NewL(); |
|
447 TRAPD( error, |
|
448 iQuery->ShowMsgQueryL( |
|
449 iStatus, |
|
450 *dlgPrompt, |
|
451 R_AVKON_SOFTKEYS_OK_CANCEL, |
|
452 *dlgHeader, |
|
453 KNullDesC, |
|
454 0, // default image id |
|
455 -1, // default image mask id |
|
456 ( aPlayTone ? |
|
457 CAknQueryDialog::EConfirmationTone : |
|
458 CAknQueryDialog::ENoTone ) ) ); |
|
459 |
|
460 CleanupStack::PopAndDestroy( dlgHeader ); |
|
461 CleanupStack::PopAndDestroy( dlgPrompt ); |
|
462 |
|
463 if ( !error ) |
|
464 { |
|
465 SetActive(); |
|
466 |
|
467 delete iLiveSharingQueryTimeout; |
|
468 iLiveSharingQueryTimeout = NULL; |
|
469 iLiveSharingQueryTimeout = |
|
470 CPeriodic::NewL( CActive::EPriorityStandard ); |
|
471 |
|
472 iLiveSharingQueryTimeout->Start( |
|
473 KMusLiveSharingQueryTimeout, |
|
474 KMusLiveSharingQueryTimeout, |
|
475 TCallBack( LiveSharingQueryTimeout, this ) ); |
|
476 |
|
477 } |
|
478 else |
|
479 { |
|
480 delete iQuery; |
|
481 iQuery = NULL; |
|
482 } |
|
483 |
|
484 MUS_LOG( "mus: [MUSIND] <- CMusIndicatorApi::ShowLiveSharingQuery" ) |
|
485 } |
|
486 |
|
487 |
|
488 |
|
489 TInt CMusIndicatorApi::LiveSharingQueryTimeout( TAny* aThis ) |
|
490 { |
|
491 static_cast< CMusIndicatorApi* >( aThis )->Cancel(); |
|
492 return KErrNone; |
|
493 } |
|
494 |
|
495 |
|