javauis/amms_qt/mmacontrol/src/cammsvolumecontrol.cpp
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Controls the volume of a CMMAVolumeControl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <cmmavolumecontrol.h>
       
    21 #include <logger.h>
       
    22 
       
    23 #include "cammsvolumecontrol.h"
       
    24 
       
    25 #ifdef _DEBUG
       
    26 // CONSTANTS
       
    27 const TInt KAMMSMaxVolume = 100;
       
    28 const TInt KAMMSMinVolume = 0;
       
    29 #endif // _DEBUG
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CAMMSVolumeControl::NewLC
       
    35 // Two-phased constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 CAMMSVolumeControl* CAMMSVolumeControl::NewLC(const TDesC& aControlName,
       
    38         CMMAVolumeControl* aVolumeControl, CMMAPlayer* aPlayer)
       
    39 {
       
    40     CAMMSVolumeControl* self = new(ELeave) CAMMSVolumeControl(
       
    41         aControlName, aVolumeControl, aPlayer);
       
    42 
       
    43     CleanupStack::PushL(self);
       
    44     self->ConstructL();
       
    45 
       
    46     return self;
       
    47 }
       
    48 
       
    49 // Destructor
       
    50 CAMMSVolumeControl::~CAMMSVolumeControl()
       
    51 {
       
    52     LOG( EJavaAMMS, EInfo, "AMMS::CAMMSVolumeControl::~CAMMSVolumeControl");
       
    53 }
       
    54 
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CAMMSVolumeControl::SetVolumeL
       
    58 // Sets the volume level.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CAMMSVolumeControl::SetVolumeL(TInt aVolume)
       
    62 {
       
    63     // Check in debug build that aVolume is within valid range.
       
    64     __ASSERT_DEBUG(
       
    65         (aVolume <= KAMMSMaxVolume) &&
       
    66         (aVolume >= KAMMSMinVolume),
       
    67         User::Invariant());
       
    68 
       
    69     LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSVolumeControl::SetVolumeL: Volume = %d", aVolume);
       
    70     iVolumeControl->SetVolumeLevelL(iControlLevelIndex, aVolume);
       
    71 }
       
    72 
       
    73 const TDesC& CAMMSVolumeControl::ClassName() const
       
    74 {
       
    75     return iClassName;
       
    76 }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CAMMSVolumeControl::ConstructL
       
    80 // Symbian 2nd phase constructor can leave.
       
    81 // -----------------------------------------------------------------------------
       
    82 void CAMMSVolumeControl::ConstructL()
       
    83 {
       
    84     iControlLevelIndex = iVolumeControl->AddLevelL();
       
    85     LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSVolumeControl::ConstructL level index = %d",
       
    86               iControlLevelIndex);
       
    87 }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CAMMSVolumeControl::CAMMSVolumeControl
       
    91 // C++ default constructor can NOT contain any code, that
       
    92 // might leave.
       
    93 // -----------------------------------------------------------------------------
       
    94 CAMMSVolumeControl::CAMMSVolumeControl(
       
    95     const TDesC& aControlName,
       
    96     CMMAVolumeControl* aVolumeControl,
       
    97     CMMAPlayer* aPlayer) :
       
    98         CAMMSControl(aPlayer),
       
    99         iClassName(aControlName)
       
   100 {
       
   101     iVolumeControl = aVolumeControl;
       
   102 }
       
   103 
       
   104 //  End of File
       
   105