fmradio/fmradioengine/src/fmradiordsreceiver.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:30:32 +0100
branchRCL_3
changeset 20 93c594350b9a
parent 0 f3d95d9c00ab
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201031 Kit: 201035

/*
* Copyright (c) 2009 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:  The RDS receiver implementation for FM Radio
*
*/


#include "fmradiordsreceiver.h"

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

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::CFMRadioRdsReceiver
// ---------------------------------------------------------------------------
//
CFMRadioRdsReceiver::CFMRadioRdsReceiver( TRadioSettings& aSettings ) : CFMRadioRdsReceiverBase(aSettings)
    {
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::ConstructL
// ---------------------------------------------------------------------------
//
void CFMRadioRdsReceiver::ConstructL()
    {
    BaseConstructL();
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::NewL
// ---------------------------------------------------------------------------
//
CFMRadioRdsReceiver* CFMRadioRdsReceiver::NewL( TRadioSettings& aSettings )
    {
    CFMRadioRdsReceiver* self = new ( ELeave ) CFMRadioRdsReceiver( aSettings );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::~CFMRadioRdsReceiver
// ---------------------------------------------------------------------------
//
CFMRadioRdsReceiver::~CFMRadioRdsReceiver()
    {
    if( iRdsUtility )
        {
        iRdsUtility->Close();
        }
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::InitL
// ---------------------------------------------------------------------------
//
void CFMRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub )
    {    
    iPubSub = aPubSub;
    
    iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this );

    SetAutomaticSwitchingL( iSettings.IsRdsAfSearchEnabled() );
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::SetAutomaticSwitchingL
// ---------------------------------------------------------------------------
//
void CFMRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable )
    {
    if( iRdsUtility )
        {
        User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) );
        }
    
    CFMRadioRdsReceiverBase::SetAutomaticSwitchingL( aEnable );
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::StartReceiver
// ---------------------------------------------------------------------------
//
void CFMRadioRdsReceiver::StartReceiver()
    {    
    TRdsData rdsData;
    rdsData.iRdsFunctions = ERdsProgrammeService | ERdsAlternateFrequency | ERdsRadioText | ERdsRadioTextPlus;
    rdsData.iAdditionalFunctions1 = 0;
    rdsData.iAdditionalFunctions2 = 0;
    
    if( iRdsUtility && !iStarted)
        {
        if( iRdsUtility->NotifyRdsDataChange( rdsData ) == KErrNone )
            {
            // Avoid further calls
            iStarted = ETrue;
            }
        }
    }

// ---------------------------------------------------------------------------
// CFMRadioRdsReceiver::StopReceiver
// ---------------------------------------------------------------------------
//
void CFMRadioRdsReceiver::StopReceiver()
    {
    if( iRdsUtility )
        {
        iRdsUtility->CancelNotifyRdsDataChange();
        }
    iStarted = EFalse;
    }