satui/satapp/src/satappplaytoneprovider.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:49:32 +0300
changeset 31 a2467631ae02
parent 27 7eb70891911c
permissions -rw-r--r--
Revision: 201023 Kit: 2010125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
// PlayStandardTone
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include    <MProfile.h>
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include    <MProfileEngine.h>
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include    <MProfileTones.h>
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include    <TProfileToneSettings.h>
27
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    24
#include    <AudioPreference.h> //KAudioPriorityLowLevel
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    25
#include    <mda/common/resource.h>//KMdaRepeatForever
15
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include    <QTimer> // timeout callback
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include    <hbmessagebox.h>//playtone note
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include    <mdaaudiotoneplayer.h>// for CMdaAudioToneUtility&CMdaAudioPlayerUtility
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include    <e32std.h>//TTimeIntervalMicroSeconds
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "satappplaytoneprovider.h"
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "satappcommonconstant.h"
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "tflogger.h"
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
//const
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
// Maximum length for sound file. 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
const TInt KMaxSoundFileLength = 256;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
// Used when dividing some values. Used only for preventing the use of magic 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
// numbers
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
// Audio sample is repeated indefinitely.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
const TInt KSoundPlayerRepeatForever = KMdaRepeatForever;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
27
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    43
// The max volume value from settings.
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    44
// From TProfileToneSettings.h
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    45
const TInt KMaxVolumeFromProfile( 10 );
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    46
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    47
15
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
// SatAppPlayToneProvider::SatAppPlayToneProvider
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
SatAppPlayToneProvider::SatAppPlayToneProvider(QObject *parent) :
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
    QObject(parent), mWarningAndPlayTones(false),mVolume(0),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
    mPlayer(0),mPlayToneError(ESatSuccess), mTimer(0),mLoop(0),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    mPermanentNote(0), mAudioPlayer(0)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::SatAppPlayToneProvider call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::SatAppPlayToneProvider exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
// SatAppPlayToneProvider::~SatAppPlayToneProvider
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// Sets a pointer to CSatUiViewAppUi object.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
SatAppPlayToneProvider::~SatAppPlayToneProvider()
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::~SatAppPlayToneProvider call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    stopPlayTone();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    if (mPermanentNote) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::~SatAppPlayToneProvider note 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
        delete mPermanentNote;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
        mPermanentNote = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::~SatAppPlayToneProvider timer 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
        delete mTimer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
        mTimer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    if (mLoop) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
        TFLOGSTRING("SatAppPlayToneProvider::~SatAppPlayToneProvider loop 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
        delete mLoop;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
        mLoop = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::~SatAppPlayToneProvider exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
//-----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
// SatAppPlayToneProvider::PlayStandardToneL
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
TSatUiResponse SatAppPlayToneProvider::PlayStandardToneL( const TDesC& aText,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    const TDesC8& aSequence,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    TTimeIntervalMicroSeconds aDuration,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    const CFbsBitmap* /*aIconBitmap*/,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    const TBool aSelfExplanatory )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
        if (mTimer->isActive()) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
            mTimer->stop();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
        delete mTimer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
        mTimer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
        TFLOGSTRING("SatAppPlayToneProvider::PlayStandardToneL delete timer")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    if (mLoop) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
        TFLOGSTRING("SatAppPlayToneProvider::PlayStandardToneL delete loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
        if (mLoop->isRunning()) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
            mLoop->exit();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
        delete mLoop;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
        mLoop = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    TSatUiResponse response(ESatSuccess);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    unsigned int duration(0);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    if (aDuration > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
        duration = aDuration.Int64() / 1000;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayStandardToneL \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
     duration microseconds %d", duration)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
    QString text;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    mLoop = new QEventLoop(this);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    if (aText.Length() > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
        text = QString::fromUtf16(aText.Ptr(), aText.Length());
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
        TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayStandardToneL \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
            text=%S", &aText)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
        mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
        bool ret = connect(mPermanentNote, SIGNAL(aboutToClose()),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
                this, SLOT(stopPlayTone()));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
        TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayStandardToneL connect \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
           note close to timer stop: %d", ret)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
        bool selfExplanatory = aSelfExplanatory;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
        if (!selfExplanatory) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
            mPermanentNote->setText(text);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
            if (duration > 0 ) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
                mPermanentNote->setTimeout(duration);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
            }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
            mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
            TFLOGSTRING("SatAppPlayToneProvider::PlayStandardToneL show before")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
            mPermanentNote->show();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
            TFLOGSTRING("SatAppPlayToneProvider::PlayStandardToneL show after")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    if (mPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
        delete mPlayer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
        mPlayer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    mPlayer = CMdaAudioToneUtility::NewL(*this);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    TInt volume(mPlayer->MaxVolume());
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    mPlayer->SetVolume(volume);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    mPlayer->PrepareToPlayDesSequence(aSequence);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    if (duration > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
        mTimer = new QTimer(this);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
        bool ret = connect(mTimer, SIGNAL(timeout()),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
                this, SLOT(stopPlayTone()));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayStandardToneL \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
                connect mTimer stop: %d", ret)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
        mTimer->start(duration);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    if (mLoop) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        mLoop->exec(QEventLoop::AllEvents);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL quit loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
        delete mLoop;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
        mLoop = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    if (mPermanentNote) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL note 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
        delete mPermanentNote;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
        mPermanentNote = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL timer 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
        delete mTimer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
        mTimer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL before play cancel")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    mPlayer->CancelPlay();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
    delete mPlayer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
    mPlayer = NULL;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
    //get warning and game tones setting from active profile
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
    GetProfileParamsL();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    if((EFalse == mWarningAndPlayTones) && 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
          (ESatSuccess == mPlayToneError)) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
        mPlayToneError = ESatSuccessToneNotPlayed;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    response = mPlayToneError;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayStandardToneL exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    return response;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
// ---------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
// SatAppCommandHandler::GetProfileParamsL
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
// Get and store settings from current profile 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
// ---------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
void SatAppPlayToneProvider::GetProfileParamsL( TSatTone aTone /*= ESatToneNotSet*/,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
                                         TDes* aToneName /*= NULL*/ )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    TFLOGSTRING( "SatAppCommandHandler::GetProfileParamsL calling" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    MProfile* profile = NULL;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    MProfileEngine* engine = NULL;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
    engine = CreateProfileEngineL();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    CleanupReleasePushL( *engine );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    profile = engine->ActiveProfileLC();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    const MProfileTones& tones = profile->ProfileTones();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    // Takes a current warning and gametones setting.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    const TProfileToneSettings& ts = tones.ToneSettings();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    mWarningAndPlayTones = ts.iWarningAndGameTones;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
    mVolume = ts.iRingingVolume;
27
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   228
    
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   229
    TFLOGSTRING2( "SatAppCommandHandler::GetProfileParamsL \
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   230
        mVolume before mapping %d", mVolume )
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   231
    
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   232
    // Max volume from profile is KMaxVolumeFromProfile, Max volume from 
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   233
    // CMdaAudioToneUtility is different, maybe 10,000. So, 
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   234
    // rate = maxVolumeFromPlayer / KMaxVolumeFromProfile
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   235
    // User may never hear the TONE, because volume is too small.
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   236
    // iVolume times the rate make it can be heard.
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   237
    
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   238
    CMdaAudioToneUtility* toneUtl = CMdaAudioToneUtility::NewL( *this );
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   239
    TInt maxVolumeFromPlayer( toneUtl->MaxVolume() );
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   240
    mVolume *= maxVolumeFromPlayer / KMaxVolumeFromProfile;
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   241
    delete toneUtl;
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   242
    toneUtl = NULL;
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   243
    TFLOGSTRING2( "CSatUiViewAppUi::GetProfileParamsL \
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   244
        mVolume after mapping %d", mVolume )
7eb70891911c Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   245
    
15
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    if ( ( ESatUserSelectedToneIncomingSms == aTone ) && ( aToneName ) )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
        {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
        TFLOGSTRING("SatAppCommandHandler::GetProfileParamsL message tone")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
        aToneName->Copy( tones.MessageAlertTone() );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
    } else if( aToneName ) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        TFLOGSTRING("SatAppCommandHandler::GetProfileParamsL ring tone")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
        aToneName->Copy( tones.RingingTone1() );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    CleanupStack::PopAndDestroy(2); // engine, profile
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    TFLOGSTRING("SatAppCommandHandler::GetProfileParamsL exits")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
// ---------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
// SatAppPlayToneProvider::MatoPrepareComplete
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
// Indicates success or failure.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
// ---------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
void SatAppPlayToneProvider::MatoPrepareComplete(TInt aError)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    TFLOGSTRING2("SatAppPlayToneProvider::MatoPrepareComplete called\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
        aError = %d", aError)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    if (KErrNone == aError && mPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
        mPlayToneError = ESatSuccess;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
        TTimeIntervalMicroSeconds zero(static_cast<TInt64>( 0 ));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
        mPlayer->SetPriority(KAudioPriorityLowLevel,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
               STATIC_CAST(TMdaPriorityPreference, KAudioPrefConfirmation));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
        mPlayer->SetRepeats( KMdaAudioToneRepeatForever, zero );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
        mPlayer->Play();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    } else {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
        mPlayToneError = ESatFailure;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
    TFLOGSTRING( "SatAppPlayToneProvider::MatoPrepareComplete exit" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
//-----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
// SatAppPlayToneProvider::MatoPlayComplete
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
// Indicates success or failure.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
void SatAppPlayToneProvider::MatoPlayComplete( TInt aError )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    TFLOGSTRING("SatAppPlayToneProvider::MatoPlayComplete calling")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    if (KErrNone == aError && mPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
        TFLOGSTRING("SatAppPlayToneProvider::MatoPlayComplete play")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
        mPlayer->Play();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    } else {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
        TFLOGSTRING( "SatAppPlayToneProvider::MatoPlayComplete stop playing")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
        // Stops playing if error.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
        stopPlayTone();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    TFLOGSTRING2("SatAppPlayToneProvider::MatoPlayComplete exit error %d", aError)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
//-----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
// SatAppPlayToneProvider::PlayUserSelectedToneL
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
TSatUiResponse SatAppPlayToneProvider::PlayUserSelectedToneL(
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
        const TDesC &aText,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
        TTimeIntervalMicroSeconds aDuration,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
        TSatTone aTone,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
        const CFbsBitmap* /*aIconBitmap*/,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
        const TBool aSelfExplanatory )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    TFLOGSTRING("SatAppPlayToneProvider::PlayUserSelectedToneL calling")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
        delete mTimer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
        mTimer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
        TFLOGSTRING("SatAppPlayToneProvider::PlayUserSelectedToneL delete timer")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    if (mLoop) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
        delete mLoop;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
        mLoop = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
        TFLOGSTRING("SatAppPlayToneProvider::PlayUserSelectedToneL delete loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    unsigned int duration(0);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    if (aDuration > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
        duration = aDuration.Int64() / KPlayToneSymbianConvertQtTime;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        TFLOGSTRING2("SatAppPlayToneProvider::PlayUserSelectedToneL duration %d",
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
                duration)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    QString text;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    if (aText.Length() > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
        text = QString::fromUtf16(aText.Ptr(), aText.Length());
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
            text=%S", &aText)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
        mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
        bool selfExplanatory = aSelfExplanatory;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
        if (!selfExplanatory) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
            mPermanentNote->setText(text);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
            if (duration) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
                mPermanentNote->setTimeout(duration);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
            }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
            mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
            TFLOGSTRING("SatAppPlayToneProvider::PlayUserSelectedToneL show before")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
            mPermanentNote->show();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
            TFLOGSTRING("SatAppPlayToneProvider::PlayUserSelectedToneL show after")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    // If several messages/calls arrive during a small amount of time and if the
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
    // message received or incoming call tone is already being played we do not 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
    // restart it.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    if (mAudioPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
        TFLOGSTRING( "SatAppPlayToneProvider::\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
            PlayUserSelectedToneL Error - already played" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
        return ESatFailure;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    TSatUiResponse response(ESatSuccess);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    // This defines name for the current message alert or incoming call tone. 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    TBuf<KMaxSoundFileLength> soundFileName;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    GetProfileParamsL( aTone, &soundFileName );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    // This defines the behaviour to be adopted by an
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    // audio client if a higher priority client takes over the device.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    TInt mdaPriority( KAudioPrefIncomingCall );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    // This is used to resolve conflicts when more than one client tries to 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    // access the same sound output device simultaneously.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    TInt audioPriority( KAudioPriorityPhoneCall );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    TFLOGSTRING2( "SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
        Volume is %d ", mVolume )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    // Creates the audio player.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
    mAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
        soundFileName,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
        *this,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
        audioPriority,
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
        ( TMdaPriorityPreference ) mdaPriority );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    if (aDuration > 0) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
        TFLOGSTRING( "SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
         duration not 0" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
        mAudioPlayer->SetRepeats( KSoundPlayerRepeatForever, 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
                                  TTimeIntervalMicroSeconds( 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
                                  static_cast<TInt64>( 0 ) ) );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
        mTimer = new QTimer(this);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
        mTimer->start(duration);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
        mLoop = new QEventLoop(this);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
        bool ret = connect(mTimer, SIGNAL(timeout()), this, SLOT(stopPlayTone()));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
                connect mTimer stop: %d", ret)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
        if (mPermanentNote) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
            ret = connect(mPermanentNote, SIGNAL(aboutToClose()),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
                    this, SLOT(stopPlayTone()));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
            TFLOGSTRING2("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
               connect note close to timer stop: %d", ret)
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
        if (mLoop) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
            mLoop->exec(QEventLoop::AllEvents);
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
            TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL quit loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
            delete mLoop;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
            mLoop = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
        if (mPermanentNote) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
            TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL note 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
            delete mPermanentNote;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
            mPermanentNote = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
        if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
            TFLOGSTRING("SATAPP: SatAppPlayToneProvider::PlayUserSelectedToneL timer 0")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
            delete mTimer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
            mTimer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
        // Sample is played in forever loop for the duration.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
        // After duration call back timers are destroyed       
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
        // If player exists, stop playing and delete player. MapcPlayComplete
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
        // is not called because CallBackTimer stops the playing.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
        if (mAudioPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
            mAudioPlayer->Stop();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
            delete mAudioPlayer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
            mAudioPlayer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
            TFLOGSTRING( "SatAppPlayToneProvider::PlayUserSelectedToneL\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
                mAudioPlayer deleted" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    } else {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
        // If duration is zero then tone is played only once.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
        // Playing duration is same as duration of the sample.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
        mAudioPlayer->SetRepeats(
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
            0, TTimeIntervalMicroSeconds( static_cast<TInt64>( 0 ) ) );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
        TFLOGSTRING( "SatAppPlayToneProvider::PlayUserSelectedToneL SetRepeats 0" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    TFLOGSTRING( "SatAppPlayToneProvider::PlayUserSelectedToneL exit" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    if( EFalse == mWarningAndPlayTones ) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
        response = ESatSuccessToneNotPlayed;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    TFLOGSTRING( "SatAppPlayToneProvider::PlayUserSelectedToneL exit" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    return response;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
//-----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
// SatAppPlayToneProvider::MapcInitComplete
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
// Plays the tone.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
void SatAppPlayToneProvider::MapcInitComplete( TInt aError, 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    const TTimeIntervalMicroSeconds& /*aDuration*/ )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    TFLOGSTRING( "SatAppPlayToneProvider::MapcInitComplete called" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    // Audio player is initialised, so if there is no error, we can start 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    // playing the tone.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    if (KErrNone == aError && mAudioPlayer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
        const TInt volume( Max(0, Min(mVolume, 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
                           mAudioPlayer->MaxVolume())));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
        TFLOGSTRING2("CSatUiViewAppUi::\
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
            MapcInitComplete SetVolume %d", volume )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
        // Set volume according Settings. 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
        mAudioPlayer->SetVolume( volume );
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
        mAudioPlayer->Play();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
        TFLOGSTRING( "SatAppPlayToneProvider::MapcInitComplete Play" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
    } else {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
        // Otherwise, we delete the initialised audio player.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
        if ( mAudioPlayer ) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
            TFLOGSTRING( "SatAppPlayToneProvider::MapcInitComplete mAudioPlayer \
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
                          true" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
            delete mAudioPlayer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
            mAudioPlayer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
     }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
        // Remove also the note for play tone
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
        // If there was a duration for play tone, stop waiting
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
        stopPlayTone();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
        TFLOGSTRING2( "SatAppPlayToneProvider::MapcInitComplete Error %d", aError )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    TFLOGSTRING( "SatAppPlayToneProvider::MapcInitComplete exit" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
//-----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
// SatAppPlayToneProvider::MapcPlayComplete
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
// Deletes audio player after playing is completed.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
void SatAppPlayToneProvider::MapcPlayComplete( TInt /*aError*/ )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    TFLOGSTRING( "SatAppPlayToneProvider::MapcPlayComplete called" )
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
    // When playing is completed, deleting the audio player.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
    if ( mAudioPlayer ) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
        TFLOGSTRING("SatAppPlayToneProvider::MapcPlayComplete delete mAudioPlayer")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
        delete mAudioPlayer;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
        mAudioPlayer = 0;
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    // Remove note after play has completed.
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
    stopPlayTone();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    TFLOGSTRING("SatAppPlayToneProvider::MapcPlayComplete exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
// SatAppPlayToneProvider::clearScreen
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
void SatAppPlayToneProvider::clearScreen()
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    TFLOGSTRING("SATAPP: SatAppEventProvider::ClearScreen call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    stopPlayTone();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    TFLOGSTRING("SATAPP: SatAppEventProvider::ClearScreen exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
// SatAppPlayToneProvider::clearScreen
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
void SatAppPlayToneProvider::closeSatUI()
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    TFLOGSTRING("SATAPP: SatAppEventProvider::closeSatUI call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    clearScreen();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    TFLOGSTRING("SATAPP: SatAppEventProvider::closeSatUI exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
// SatAppPlayToneProvider::stopPlayTone
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
// (other items were commented in a header).
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
// ----------------------------------------------------------------------------
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
//
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
void SatAppPlayToneProvider::stopPlayTone()
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
{
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    TFLOGSTRING("SATAPP: SatAppEventProvider::stopPlayTone call")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
     if (mPermanentNote) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
        TFLOGSTRING("SatAppPlayToneProvider::stopPlayTone delete mPermanentNote")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
        disconnect(mPermanentNote,SIGNAL(aboutToClose()),
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
                this, SLOT(stopPlayTone())); 
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
        mPermanentNote->close();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
    if (mTimer) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
        TFLOGSTRING("SatAppPlayToneProvider::stopPlayTone delete timer")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
        disconnect(mTimer,SIGNAL(timeout()), this, SLOT(stopPlayTone()));
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
        if (mTimer->isActive()) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
            mTimer->stop();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
        }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
    if (mLoop && mLoop->isRunning()) {
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
        TFLOGSTRING("SatAppPlayToneProvider::stopPlayTone exit loop")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
        mLoop->exit();
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
    }
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    TFLOGSTRING("SATAPP: SatAppEventProvider::stopPlayTone exit")
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
}
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
d7fc66ccd6fb Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
 //End of file