javauis/amms_akn/mmacontrol/src/cammsvolumecontrol.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 15:32:50 +0300
branchRCL_3
changeset 46 4376525cdefb
parent 19 04becd199f91
permissions -rw-r--r--
Revision: v2.1.30 Kit: 2010125

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Controls the volume of a CMMAVolumeControl.
*
*/


// INCLUDE FILES
#include <cmmavolumecontrol.h>
#include <jdebug.h>

#include "cammsvolumecontrol.h"

#ifdef _DEBUG
// CONSTANTS
const TInt KAMMSMaxVolume = 100;
const TInt KAMMSMinVolume = 0;
#endif // _DEBUG

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CAMMSVolumeControl::NewLC
// Two-phased constructor.
// -----------------------------------------------------------------------------
CAMMSVolumeControl* CAMMSVolumeControl::NewLC(const TDesC& aControlName,
        CMMAVolumeControl* aVolumeControl, CMMAPlayer* aPlayer)
{
    CAMMSVolumeControl* self = new(ELeave) CAMMSVolumeControl(
        aControlName, aVolumeControl, aPlayer);

    CleanupStack::PushL(self);
    self->ConstructL();

    return self;
}

// Destructor
CAMMSVolumeControl::~CAMMSVolumeControl()
{
    DEBUG("AMMS::CAMMSVolumeControl::~CAMMSVolumeControl");
}


// -----------------------------------------------------------------------------
// CAMMSVolumeControl::SetVolumeL
// Sets the volume level.
// -----------------------------------------------------------------------------
//
void CAMMSVolumeControl::SetVolumeL(TInt aVolume)
{
    // Check in debug build that aVolume is within valid range.
    __ASSERT_DEBUG(
        (aVolume <= KAMMSMaxVolume) &&
        (aVolume >= KAMMSMinVolume),
        User::Invariant());

    DEBUG_INT("AMMS::CAMMSVolumeControl::SetVolumeL: Volume = %d", aVolume);
    iVolumeControl->SetVolumeLevelL(iControlLevelIndex, aVolume);
}

const TDesC& CAMMSVolumeControl::ClassName() const
{
    return iClassName;
}

// -----------------------------------------------------------------------------
// CAMMSVolumeControl::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
void CAMMSVolumeControl::ConstructL()
{
    iControlLevelIndex = iVolumeControl->AddLevelL();
    DEBUG_INT("AMMS::CAMMSVolumeControl::ConstructL level index = %d",
              iControlLevelIndex);
}

// -----------------------------------------------------------------------------
// CAMMSVolumeControl::CAMMSVolumeControl
// C++ default constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
CAMMSVolumeControl::CAMMSVolumeControl(
    const TDesC& aControlName,
    CMMAVolumeControl* aVolumeControl,
    CMMAPlayer* aPlayer) :
        CAMMSControl(aPlayer),
        iClassName(aControlName)
{
    iVolumeControl = aVolumeControl;
}

//  End of File