1 /* |
|
2 * Copyright (c) 2010 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 // includes |
|
19 #include <QTimer> |
|
20 #include <QCoreApplication> |
|
21 #include <QtDebug> |
|
22 #include <hbmessagebox.h>//playtone note |
|
23 |
|
24 #include "SatAppToneProvider.h" |
|
25 #include "satappconstant.h" |
|
26 #include "satappaction.h" |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // SatAppToneProvider::SatAppToneProvider |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 SatAppToneProvider::SatAppToneProvider(QObject *parent) : |
|
33 QObject(parent) |
|
34 { |
|
35 qDebug("SATAPP: SatAppToneProvider::SatAppToneProvider <>"); |
|
36 mState = Idle; |
|
37 mWarningAndPlayTones = false; |
|
38 mVolume = 0; |
|
39 mPlayer = 0; |
|
40 mPlayToneError = ESatSuccess; |
|
41 mTimer = 0; |
|
42 mPermanentNote = 0; |
|
43 mAudioPlayer = 0; |
|
44 mCurrentAction = 0; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // SatAppToneProvider::~SatAppToneProvider |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 SatAppToneProvider::~SatAppToneProvider() |
|
52 { |
|
53 qDebug("SATAPP: SatAppToneProvider::~SatAppToneProvider >"); |
|
54 |
|
55 if (mCurrentAction) { |
|
56 stopPlayTone(); |
|
57 } |
|
58 |
|
59 if (mPermanentNote) { |
|
60 qDebug("SatAppToneProvider::resetState delete mPermanentNote"); |
|
61 delete mPermanentNote; |
|
62 mPermanentNote = 0; |
|
63 } |
|
64 |
|
65 if (mTimer) { |
|
66 qDebug("SatAppToneProvider::resetState delete timer"); |
|
67 delete mTimer; |
|
68 mTimer = 0; |
|
69 } |
|
70 |
|
71 qDebug("SATAPP: SatAppToneProvider::~SatAppToneProvider <"); |
|
72 } |
|
73 |
|
74 //----------------------------------------------------------------------------- |
|
75 // SatAppToneProvider::playTone |
|
76 //----------------------------------------------------------------------------- |
|
77 void SatAppToneProvider::playTone(SatAppAction& action) |
|
78 { |
|
79 qDebug("SATAPP: SatAppToneProvider::playTone >"); |
|
80 resetState(); |
|
81 |
|
82 mCurrentAction = &action; |
|
83 int tone = action.value(KeyToneId).toInt(); |
|
84 int duration = action.value(KeyDuration).toInt(); |
|
85 QString text = action.value(KeyText).toString(); |
|
86 QByteArray sequence; |
|
87 mState = recognizeTone(tone,sequence,duration); |
|
88 if (mState == PlayStandardTone) |
|
89 { |
|
90 playStandardTone(text,sequence,duration); |
|
91 } |
|
92 else if (mState == PlayUserSelectedTone) |
|
93 { |
|
94 playUserSelectedTone(text,tone,duration); |
|
95 } |
|
96 else |
|
97 { |
|
98 mCurrentAction->complete(ESatCmdDataNotUnderstood); |
|
99 mCurrentAction = 0; |
|
100 } |
|
101 qDebug("SATAPP: SatAppToneProvider::playTone <"); |
|
102 } |
|
103 |
|
104 //----------------------------------------------------------------------------- |
|
105 // SatAppToneProvider::recognizeTone |
|
106 // @param tone the tone code from server (see TSatTone in MSatUiObserver) |
|
107 // @param sequence (out) standard tone play sequence |
|
108 // @param duration (out) stanrard tone play duration (manipulated in some cases) |
|
109 // @return suggested state for the tone provider (or Idle if tone is not recognised) |
|
110 //----------------------------------------------------------------------------- |
|
111 SatAppToneProvider::State SatAppToneProvider::recognizeTone( |
|
112 int tone, |
|
113 QByteArray& sequence, |
|
114 int& duration) |
|
115 { |
|
116 qDebug("SATAPP: SatAppToneProvider::recognizeTone >"); |
|
117 State ret = Idle; |
|
118 qDebug("SATAPP: SatAppToneProvider::recognizeTone tone: %d", tone); |
|
119 switch (tone) |
|
120 { |
|
121 case ESatGeneralBeep: |
|
122 case ESatPositiveTone: |
|
123 case ESatToneNotSet: |
|
124 { |
|
125 if (duration == 0) duration = KSatDur170ms; // 170ms |
|
126 sequence = charArrayToByteArray(KGeneralBeep, |
|
127 sizeof(KGeneralBeep)); |
|
128 ret = PlayStandardTone; |
|
129 break; |
|
130 } |
|
131 case ESatNegativeTone: |
|
132 { |
|
133 if (duration == 0) duration = KSatDur250ms; // 250ms |
|
134 sequence = charArrayToByteArray(KErrorTone, |
|
135 sizeof(KErrorTone)); |
|
136 ret = PlayStandardTone; |
|
137 break; |
|
138 } |
|
139 case ESatRadioPathNotAvailableCallDropped: |
|
140 { |
|
141 if (duration == 0) duration = KSatDur1200ms; // 1200ms |
|
142 sequence = charArrayToByteArray(KRadioPathNotAvailable, |
|
143 sizeof(KRadioPathNotAvailable)); |
|
144 ret = PlayStandardTone; |
|
145 break; |
|
146 } |
|
147 case ESatRadioPathAcknowledge: |
|
148 { |
|
149 if (duration == 0) duration = KSatDur200ms; // 200ms |
|
150 sequence = charArrayToByteArray(KRadioPathAck, |
|
151 sizeof(KRadioPathAck)); |
|
152 ret = PlayStandardTone; |
|
153 break; |
|
154 } |
|
155 case ESatDialTone: |
|
156 { |
|
157 if (duration == 0) break; |
|
158 sequence = charArrayToByteArray(KNetToneSeqDial, |
|
159 sizeof(KNetToneSeqDial)); |
|
160 ret = PlayStandardTone; |
|
161 break; |
|
162 } |
|
163 case ESatCalledSubscriberBusy: |
|
164 { |
|
165 if (duration == 0) break; |
|
166 sequence = charArrayToByteArray(KNetToneSeqNetBusy, |
|
167 sizeof(KNetToneSeqNetBusy)); |
|
168 ret = PlayStandardTone; |
|
169 break; |
|
170 } |
|
171 case ESatCongestion: |
|
172 { |
|
173 if (duration == 0) break; |
|
174 sequence = charArrayToByteArray(KNetToneSeqNetCongestion, |
|
175 sizeof(KNetToneSeqNetCongestion)); |
|
176 ret = PlayStandardTone; |
|
177 break; |
|
178 } |
|
179 case ESatErrorSpecialInfo: |
|
180 { |
|
181 if (duration == 0) break; |
|
182 sequence = charArrayToByteArray(KNetToneSeqNetSpecialInformation, |
|
183 sizeof(KNetToneSeqNetSpecialInformation)); |
|
184 ret = PlayStandardTone; |
|
185 break; |
|
186 } |
|
187 case ESatCallWaitingTone: |
|
188 { |
|
189 if (duration == 0) break; |
|
190 sequence = charArrayToByteArray(KNetToneSeqNetCallWaiting, |
|
191 sizeof(KNetToneSeqNetCallWaiting)); |
|
192 ret = PlayStandardTone; |
|
193 break; |
|
194 } |
|
195 case ESatRingingTone: |
|
196 { |
|
197 if (duration == 0) break; |
|
198 sequence = charArrayToByteArray(KNetToneSeqRingGoing, |
|
199 sizeof(KNetToneSeqRingGoing)); |
|
200 ret = PlayStandardTone; |
|
201 break; |
|
202 } |
|
203 case ESatUserSelectedToneIncomingSpeech: |
|
204 case ESatUserSelectedToneIncomingSms: |
|
205 { |
|
206 ret = PlayUserSelectedTone; |
|
207 break; |
|
208 } |
|
209 default: |
|
210 break; |
|
211 } |
|
212 |
|
213 qDebug("SATAPP: SatAppToneProvider::recognizeTone state=%d <", ret); |
|
214 return ret; |
|
215 } |
|
216 |
|
217 //----------------------------------------------------------------------------- |
|
218 // SatAppToneProvider::charArrayToByteArray |
|
219 //----------------------------------------------------------------------------- |
|
220 QByteArray SatAppToneProvider::charArrayToByteArray( |
|
221 const char tone[], |
|
222 int size) |
|
223 { |
|
224 qDebug("SATAPP: SatAppToneProvider::charArrayToByteArray >"); |
|
225 QByteArray seq; |
|
226 seq = QByteArray::fromRawData(tone, size); |
|
227 qDebug("SATAPP: SatAppToneProvider::charArrayToByteArray <"); |
|
228 return seq; |
|
229 } |
|
230 |
|
231 //----------------------------------------------------------------------------- |
|
232 // SatAppToneProvider::playStandardTone |
|
233 //----------------------------------------------------------------------------- |
|
234 void SatAppToneProvider::playStandardTone( |
|
235 const QString& text, |
|
236 const QByteArray& sequence, |
|
237 int duration) |
|
238 { |
|
239 qDebug("SATAPP: SatAppToneProvider::playStandardTone >"); |
|
240 |
|
241 if (text.length() > 0) { |
|
242 mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
243 SAT_ASSERT(connect(mPermanentNote, SIGNAL(aboutToClose()), |
|
244 this, SLOT(stopPlayTone()))); |
|
245 mPermanentNote->setText(text); |
|
246 mPermanentNote->setStandardButtons(HbMessageBox::Cancel); |
|
247 if (duration > 0 ) { |
|
248 mPermanentNote->setTimeout(duration); |
|
249 } |
|
250 mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere); |
|
251 qDebug("SatAppToneProvider::playStandardTone show before"); |
|
252 mPermanentNote->show(); |
|
253 qDebug("SatAppToneProvider::playStandardTone show after"); |
|
254 } |
|
255 |
|
256 TPtrC8 seq((unsigned char*)sequence.constData(), sequence.length()); |
|
257 qDebug("SATAPP: SatAppToneProvider::playStandardTone TPtrC8 seq: %S", &seq); |
|
258 QT_TRAP_THROWING(SymbianPrepareAudioToneUtilityL(seq)); |
|
259 |
|
260 if (duration > 0) { |
|
261 mTimer = new QTimer(this); |
|
262 SAT_ASSERT(connect(mTimer, SIGNAL(timeout()), |
|
263 this, SLOT(stopPlayTone()))); |
|
264 mTimer->start(duration); |
|
265 } |
|
266 |
|
267 qDebug("SATAPP: SatAppToneProvider::playStandardTone <"); |
|
268 } |
|
269 |
|
270 //----------------------------------------------------------------------------- |
|
271 // SatAppToneProvider::playUserSelectedTone |
|
272 //----------------------------------------------------------------------------- |
|
273 void SatAppToneProvider::playUserSelectedTone( |
|
274 const QString& text, |
|
275 int tone, |
|
276 int duration) |
|
277 { |
|
278 qDebug("SatAppToneProvider::playUserSelectedTone >"); |
|
279 |
|
280 // If several messages/calls arrive during a small amount of time and if the |
|
281 // message received or incoming call tone is already being played we do not |
|
282 // restart it. |
|
283 if (mAudioPlayer) { |
|
284 qDebug( "SatAppToneProvider::\ |
|
285 PlayUserSelectedToneL Error - already played" ); |
|
286 mCurrentAction->complete(ESatFailure); |
|
287 mCurrentAction = 0; |
|
288 mState = Idle; |
|
289 return; |
|
290 } |
|
291 |
|
292 if (text.length() > 0) { |
|
293 mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
|
294 mPermanentNote->setText(text); |
|
295 mPermanentNote->setStandardButtons(HbMessageBox::Cancel); |
|
296 if (duration) { |
|
297 mPermanentNote->setTimeout(duration); |
|
298 } |
|
299 mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere); |
|
300 qDebug("SatAppToneProvider::PlayUserSelectedToneL show before"); |
|
301 mPermanentNote->show(); |
|
302 qDebug("SatAppToneProvider::PlayUserSelectedToneL show after"); |
|
303 } |
|
304 |
|
305 QT_TRAP_THROWING(SymbianPrepareAudioPlayerL(tone,duration)); |
|
306 |
|
307 if (duration > 0) { |
|
308 qDebug( "SATAPP: SatAppToneProvider::PlayUserSelectedToneL\ |
|
309 duration not 0" ); |
|
310 mTimer = new QTimer(this); |
|
311 mTimer->start(duration); |
|
312 SAT_ASSERT(connect(mTimer, SIGNAL(timeout()), this, SLOT(stopPlayTone()))); |
|
313 |
|
314 if (mPermanentNote) { |
|
315 SAT_ASSERT(connect(mPermanentNote, SIGNAL(aboutToClose()), |
|
316 this, SLOT(stopPlayTone()))); |
|
317 } |
|
318 } |
|
319 |
|
320 qDebug( "SatAppToneProvider::PlayUserSelectedToneL <" ); |
|
321 } |
|
322 |
|
323 |
|
324 // ---------------------------------------------------------------------------- |
|
325 // SatAppToneProvider::clearScreen |
|
326 // terminates all ongoing UI actions |
|
327 // ---------------------------------------------------------------------------- |
|
328 // |
|
329 void SatAppToneProvider::clearScreen() |
|
330 { |
|
331 qDebug( "SatAppToneProvider::clearScreen >" ); |
|
332 if (mCurrentAction) { |
|
333 stopPlayTone(); |
|
334 } |
|
335 qDebug( "SatAppToneProvider::clearScreen <" ); |
|
336 } |
|
337 |
|
338 // ---------------------------------------------------------------------------- |
|
339 // SatAppToneProvider::stopPlayTone |
|
340 // Stops the music, frees blocked functions |
|
341 // ---------------------------------------------------------------------------- |
|
342 // |
|
343 void SatAppToneProvider::stopPlayTone() |
|
344 { |
|
345 qDebug("SATAPP: SatAppToneProvider::stopPlayTone >"); |
|
346 |
|
347 if (mPermanentNote) { |
|
348 qDebug("SatAppToneProvider::stopPlayTone close mPermanentNote"); |
|
349 disconnect(mPermanentNote,SIGNAL(aboutToClose()), |
|
350 this, SLOT(stopPlayTone())); |
|
351 mPermanentNote->close(); |
|
352 } |
|
353 |
|
354 if (mTimer) { |
|
355 qDebug("SatAppToneProvider::stopPlayTone stop timer"); |
|
356 disconnect(mTimer,SIGNAL(timeout()), this, SLOT(stopPlayTone())); |
|
357 if (mTimer->isActive()) { |
|
358 mTimer->stop(); |
|
359 } |
|
360 } |
|
361 |
|
362 switch(mState) { |
|
363 case PlayStandardTone: { |
|
364 qDebug("SATAPP: SatAppToneProvider::stopPlayTone before play cancel"); |
|
365 SymbianStopAudioToneUtility(); |
|
366 |
|
367 //get warning and game tones setting from active profile |
|
368 QT_TRAP_THROWING(GetProfileParamsL()); |
|
369 if( EFalse == mWarningAndPlayTones |
|
370 && ESatSuccess == mPlayToneError ) { |
|
371 mPlayToneError = ESatSuccessToneNotPlayed; |
|
372 } |
|
373 break; |
|
374 } |
|
375 case PlayUserSelectedTone: { |
|
376 // Sample is played in forever loop for the duration. |
|
377 // After duration call back timers are destroyed |
|
378 // If player exists, stop playing and delete player. MapcPlayComplete |
|
379 // is not called because CallBackTimer stops the playing. |
|
380 SymbianStopAudioPlayer(); |
|
381 if( EFalse == mWarningAndPlayTones ) { |
|
382 mPlayToneError = ESatSuccessToneNotPlayed; |
|
383 } |
|
384 break; |
|
385 } |
|
386 default: |
|
387 break; |
|
388 } |
|
389 |
|
390 mState = Idle; |
|
391 if (mCurrentAction) { |
|
392 mCurrentAction->complete(mPlayToneError); |
|
393 mCurrentAction = 0; |
|
394 } |
|
395 |
|
396 qDebug("SATAPP: SatAppToneProvider::stopPlayTone <"); |
|
397 } |
|
398 |
|
399 void SatAppToneProvider::resetState() |
|
400 { |
|
401 qDebug("SATAPP: SatAppToneProvider::resetState >"); |
|
402 if (mCurrentAction) { |
|
403 mCurrentAction->completeWithNoResponse(); |
|
404 mCurrentAction = 0; |
|
405 } |
|
406 |
|
407 if (mPermanentNote) { |
|
408 qDebug("SatAppToneProvider::resetState delete mPermanentNote"); |
|
409 delete mPermanentNote; |
|
410 mPermanentNote = 0; |
|
411 } |
|
412 |
|
413 if (mTimer) { |
|
414 qDebug("SatAppToneProvider::resetState delete timer"); |
|
415 delete mTimer; |
|
416 mTimer = 0; |
|
417 } |
|
418 qDebug("SATAPP: SatAppToneProvider::resetState <"); |
|
419 } |
|
420 |
|
421 |
|
422 |
|
423 // **************************************************************************** |
|
424 // * ************************************************************************ * |
|
425 // * * SYMBIAN PART * * |
|
426 // * ************************************************************************ * |
|
427 // **************************************************************************** |
|
428 |
|
429 |
|
430 // includes |
|
431 #include <e32std.h> //TTimeIntervalMicroSeconds |
|
432 #include <MProfile.h> |
|
433 #include <MProfileEngine.h> |
|
434 #include <MProfileTones.h> |
|
435 #include <TProfileToneSettings.h> |
|
436 #include <AudioPreference.h> //KAudioPriorityLowLevel |
|
437 #include <mdaaudiotoneplayer.h> // for CMdaAudioToneUtility&CMdaAudioPlayerUtility |
|
438 #include <mda/common/resource.h> //KMdaRepeatForever |
|
439 |
|
440 //constants |
|
441 |
|
442 // Maximum length for sound file. |
|
443 const TInt KMaxSoundFileLength = 256; |
|
444 // Used when dividing some values. Used only for preventing the use of magic |
|
445 // numbers |
|
446 // Audio sample is repeated indefinitely. |
|
447 const TInt KSoundPlayerRepeatForever = KMdaRepeatForever; |
|
448 |
|
449 // The max volume value from settings. |
|
450 // From TProfileToneSettings.h |
|
451 const TInt KMaxVolumeFromProfile( 10 ); |
|
452 |
|
453 // ---------------------------------------------------------------------------- |
|
454 // SatAppToneProvider::SymbianPrepareAudioToneUtilityL |
|
455 // creates and prepares CMdaAudioToneUtility |
|
456 // ---------------------------------------------------------------------------- |
|
457 // |
|
458 void SatAppToneProvider::SymbianPrepareAudioToneUtilityL(const TDesC8& sequence) |
|
459 { |
|
460 qDebug( "SatAppToneProvider::SymbianPrepareAudioToneUtilityL >" ); |
|
461 if (mPlayer) { |
|
462 delete mPlayer; |
|
463 mPlayer = 0; |
|
464 } |
|
465 mPlayer = CMdaAudioToneUtility::NewL(*this); |
|
466 TInt volume(mPlayer->MaxVolume()); |
|
467 mPlayer->SetVolume(volume); |
|
468 mPlayer->PrepareToPlayDesSequence(sequence); |
|
469 qDebug( "SatAppToneProvider::SymbianPrepareAudioToneUtilityL <" ); |
|
470 } |
|
471 |
|
472 // ---------------------------------------------------------------------------- |
|
473 // SatAppToneProvider::SymbianStopAudioToneUtility |
|
474 // cancels and deletes CMdaAudioToneUtility |
|
475 // ---------------------------------------------------------------------------- |
|
476 void SatAppToneProvider::SymbianStopAudioToneUtility() |
|
477 { |
|
478 qDebug( "SatAppToneProvider::SymbianStopAudioToneUtility >" ); |
|
479 if (mPlayer) { |
|
480 mPlayer->CancelPlay(); |
|
481 } |
|
482 delete mPlayer; |
|
483 mPlayer = NULL; |
|
484 qDebug( "SatAppToneProvider::SymbianStopAudioToneUtility <" ); |
|
485 } |
|
486 |
|
487 // ---------------------------------------------------------------------------- |
|
488 // SatAppToneProvider::SymbianPrepareAudioPlayerL |
|
489 // cancels and deletes CMdaAudioToneUtility |
|
490 // ---------------------------------------------------------------------------- |
|
491 void SatAppToneProvider::SymbianPrepareAudioPlayerL( |
|
492 int tone, int duration) |
|
493 { |
|
494 qDebug( "SatAppToneProvider::SymbianPrepareAudioPlayerL >" ); |
|
495 // This defines name for the current message alert or incoming call tone. |
|
496 TBuf<KMaxSoundFileLength> soundFileName; |
|
497 GetProfileParamsL(tone, &soundFileName); |
|
498 |
|
499 // This defines the behaviour to be adopted by an |
|
500 // audio client if a higher priority client takes over the device. |
|
501 TInt mdaPriority( KAudioPrefIncomingCall ); |
|
502 // This is used to resolve conflicts when more than one client tries to |
|
503 // access the same sound output device simultaneously. |
|
504 TInt audioPriority( KAudioPriorityPhoneCall ); |
|
505 |
|
506 qDebug( "SATAPP: SatAppToneProvider::PlayUserSelectedToneL\ |
|
507 Volume is %d ", mVolume ); |
|
508 |
|
509 // Creates the audio player. |
|
510 mAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( |
|
511 soundFileName, |
|
512 *this, |
|
513 audioPriority, |
|
514 ( TMdaPriorityPreference ) mdaPriority ); |
|
515 |
|
516 TTimeIntervalMicroSeconds no_silence(0); |
|
517 if (duration > 0) |
|
518 { |
|
519 // repeat forever in a loop |
|
520 mAudioPlayer->SetRepeats(KSoundPlayerRepeatForever, no_silence); |
|
521 } |
|
522 else |
|
523 { |
|
524 // play only once |
|
525 mAudioPlayer->SetRepeats(0, no_silence); |
|
526 } |
|
527 qDebug( "SatAppToneProvider::SymbianPrepareAudioPlayerL <" ); |
|
528 |
|
529 } |
|
530 |
|
531 // ---------------------------------------------------------------------------- |
|
532 // SatAppToneProvider::SymbianStopAudioPlayer |
|
533 // cancels and deletes CMdaAudioToneUtility |
|
534 // ---------------------------------------------------------------------------- |
|
535 void SatAppToneProvider::SymbianStopAudioPlayer() |
|
536 { |
|
537 qDebug( "SatAppToneProvider::SymbianStopAudioPlayer >" ); |
|
538 if (mAudioPlayer) { |
|
539 qDebug( "SatAppToneProvider::SymbianStopAudioPlayer AudioPlayer stop" ); |
|
540 mAudioPlayer->Stop(); |
|
541 } |
|
542 delete mAudioPlayer; |
|
543 mAudioPlayer = 0; |
|
544 qDebug( "SatAppToneProvider::SymbianStopAudioPlayer <" ); |
|
545 } |
|
546 |
|
547 // --------------------------------------------------------- |
|
548 // SatAppCommandHandler::GetProfileParamsL |
|
549 // Get and store settings from current profile |
|
550 // (other items were commented in a header). |
|
551 // --------------------------------------------------------- |
|
552 // |
|
553 void SatAppToneProvider::GetProfileParamsL( |
|
554 int aTone /*= ESatToneNotSet*/, |
|
555 TDes* aToneName /*= NULL*/ ) |
|
556 { |
|
557 qDebug( "SatAppCommandHandler::GetProfileParamsL >" ); |
|
558 MProfile* profile = NULL; |
|
559 MProfileEngine* engine = NULL; |
|
560 engine = CreateProfileEngineL(); |
|
561 CleanupReleasePushL( *engine ); |
|
562 |
|
563 profile = engine->ActiveProfileLC(); |
|
564 |
|
565 const MProfileTones& tones = profile->ProfileTones(); |
|
566 |
|
567 // Takes a current warning and gametones setting. |
|
568 const TProfileToneSettings& ts = tones.ToneSettings(); |
|
569 mWarningAndPlayTones = ts.iWarningAndGameTones; |
|
570 mVolume = ts.iRingingVolume; |
|
571 |
|
572 qDebug( "SatAppCommandHandler::GetProfileParamsL \ |
|
573 mVolume before mapping %d", mVolume ); |
|
574 |
|
575 // Max volume from profile is KMaxVolumeFromProfile, Max volume from |
|
576 // CMdaAudioToneUtility is different, maybe 10,000. So, |
|
577 // rate = maxVolumeFromPlayer / KMaxVolumeFromProfile |
|
578 // User may never hear the TONE, because volume is too small. |
|
579 // iVolume times the rate make it can be heard. |
|
580 |
|
581 CMdaAudioToneUtility* toneUtl = CMdaAudioToneUtility::NewL( *this ); |
|
582 TInt maxVolumeFromPlayer( toneUtl->MaxVolume() ); |
|
583 mVolume *= maxVolumeFromPlayer / KMaxVolumeFromProfile; |
|
584 delete toneUtl; |
|
585 toneUtl = NULL; |
|
586 qDebug( "CSatUiViewAppUi::GetProfileParamsL \ |
|
587 mVolume after mapping %d", mVolume ); |
|
588 |
|
589 if ( ( ESatUserSelectedToneIncomingSms == aTone ) && ( aToneName ) ) |
|
590 { |
|
591 qDebug("SatAppCommandHandler::GetProfileParamsL message tone"); |
|
592 aToneName->Copy( tones.MessageAlertTone() ); |
|
593 } else if( aToneName ) { |
|
594 qDebug("SatAppCommandHandler::GetProfileParamsL ring tone"); |
|
595 aToneName->Copy( tones.RingingTone1() ); |
|
596 } |
|
597 |
|
598 CleanupStack::PopAndDestroy(2); // engine, profile |
|
599 qDebug("SatAppCommandHandler::GetProfileParamsL <"); |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------- |
|
603 // SatAppToneProvider::MatoPrepareComplete |
|
604 // Preparation is complete -> Starts playing tone |
|
605 // --------------------------------------------------------- |
|
606 // |
|
607 void SatAppToneProvider::MatoPrepareComplete(TInt aError) |
|
608 { |
|
609 qDebug("SatAppToneProvider::MatoPrepareComplete \ |
|
610 aError = %d >", aError); |
|
611 if (KErrNone == aError && mPlayer) { |
|
612 mPlayToneError = ESatSuccess; |
|
613 TTimeIntervalMicroSeconds zero(static_cast<TInt64>( 0 )); |
|
614 mPlayer->SetPriority(KAudioPriorityLowLevel, |
|
615 STATIC_CAST(TMdaPriorityPreference, KAudioPrefConfirmation)); |
|
616 mPlayer->SetRepeats( KMdaAudioToneRepeatForever, zero ); |
|
617 mPlayer->Play(); |
|
618 } else { |
|
619 mPlayToneError = ESatFailure; |
|
620 stopPlayTone(); |
|
621 } |
|
622 qDebug( "SatAppToneProvider::MatoPrepareComplete <" ); |
|
623 } |
|
624 |
|
625 //----------------------------------------------------------------------------- |
|
626 // SatAppToneProvider::MatoPlayComplete |
|
627 // Play complete -> Frees blocking function |
|
628 // (other items were commented in a header). |
|
629 // ---------------------------------------------------------------------------- |
|
630 // |
|
631 void SatAppToneProvider::MatoPlayComplete( TInt aError ) |
|
632 { |
|
633 qDebug("SatAppToneProvider::MatoPlayComplete >"); |
|
634 if (KErrNone == aError && mPlayer) { |
|
635 qDebug("SatAppToneProvider::MatoPlayComplete play"); |
|
636 mPlayer->Play(); |
|
637 } else { |
|
638 qDebug( "SatAppToneProvider::MatoPlayComplete stop playing"); |
|
639 // Stops playing if error. |
|
640 stopPlayTone(); |
|
641 } |
|
642 qDebug("SatAppToneProvider::MatoPlayComplete error %d <", aError); |
|
643 } |
|
644 |
|
645 //----------------------------------------------------------------------------- |
|
646 // SatAppToneProvider::MapcInitComplete |
|
647 // Initialisation complete -> starts playing the tone. |
|
648 // ---------------------------------------------------------------------------- |
|
649 void SatAppToneProvider::MapcInitComplete( TInt aError, |
|
650 const TTimeIntervalMicroSeconds& /*aDuration*/ ) |
|
651 { |
|
652 qDebug( "SatAppToneProvider::MapcInitComplete >" ); |
|
653 // Audio player is initialised, so if there is no error, we can start |
|
654 // playing the tone. |
|
655 if (KErrNone == aError && mAudioPlayer) { |
|
656 const TInt volume( Max(0, Min(mVolume, |
|
657 mAudioPlayer->MaxVolume()))); |
|
658 qDebug("CSatUiViewAppUi::\ |
|
659 MapcInitComplete SetVolume %d", volume ); |
|
660 // Set volume according Settings. |
|
661 mAudioPlayer->SetVolume( volume ); |
|
662 mAudioPlayer->Play(); |
|
663 qDebug( "SatAppToneProvider::MapcInitComplete Play" ); |
|
664 } else { |
|
665 // Otherwise, we delete the initialised audio player. |
|
666 if ( mAudioPlayer ) { |
|
667 qDebug( "SatAppToneProvider::MapcInitComplete mAudioPlayer \ |
|
668 true" ); |
|
669 delete mAudioPlayer; |
|
670 mAudioPlayer = 0; |
|
671 } |
|
672 |
|
673 // Remove also the note for play tone |
|
674 // If there was a duration for play tone, stop waiting |
|
675 stopPlayTone(); |
|
676 |
|
677 qDebug( "SatAppToneProvider::MapcInitComplete Error %d", aError ); |
|
678 } |
|
679 qDebug( "SatAppToneProvider::MapcInitComplete <" ); |
|
680 } |
|
681 |
|
682 //----------------------------------------------------------------------------- |
|
683 // SatAppToneProvider::MapcPlayComplete |
|
684 // Deletes audio player after playing is completed. |
|
685 // ---------------------------------------------------------------------------- |
|
686 void SatAppToneProvider::MapcPlayComplete( TInt /*aError*/ ) |
|
687 { |
|
688 qDebug( "SatAppToneProvider::MapcPlayComplete >" ); |
|
689 |
|
690 // When playing is completed, deleting the audio player. |
|
691 if ( mAudioPlayer ) { |
|
692 qDebug("SatAppToneProvider::MapcPlayComplete delete mAudioPlayer"); |
|
693 delete mAudioPlayer; |
|
694 mAudioPlayer = 0; |
|
695 } |
|
696 // Remove note after play has completed. |
|
697 stopPlayTone(); |
|
698 qDebug( "SatAppToneProvider::MapcPlayComplete <" ); |
|
699 } |
|
700 |
|
701 |
|
702 //End of file |
|