radioapp/radiouiengine/src/radiocontrolservice.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:12:57 +0300
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 33 11b6825f0862
permissions -rw-r--r--
Revision: 201023 Kit: 2010125

/*
* 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:
*
*/

// System includes
#include <xqserviceutil.h>

// User includes
#include "radiocontrolservice.h"
#include "radiouiengine.h"
#include "radioservicedef.h"

// Constants
const int SERVICE_POWEROFF_DELAY = 5000;

/*!
 *
 */
RadioControlService::RadioControlService( RadioUiEngine& engine ) :
    XQServiceProvider( RADIO_SERVICE +"."+ RADIO_CONTROL_SERVICE, &engine ),
    mUiEngine( engine )
{
    publishAll();
    if ( XQServiceUtil::isService() ) {
        XQServiceUtil::toBackground( true );
    }
}

/*!
 *
 */
RadioControlService::~RadioControlService()
{
}

/*!
 * Public slot
 */
void RadioControlService::command( int commandId )
{
    //TODO: Uncomment when vendor id can be read from the client
//    if ( requestInfo().clientVendorId() != NOKIA_VENDORID ) {
//        return;
//    }

    switch ( commandId )
    {
        case RadioServiceCommand::PowerOn:
            mUiEngine.setPowerOn();
            break;

        case RadioServiceCommand::PowerOff:
            mUiEngine.setPowerOff( SERVICE_POWEROFF_DELAY );
            break;

        case RadioServiceCommand::Previous:
            mUiEngine.skipStation( StationSkip::PreviousFavorite );
            break;

        case RadioServiceCommand::Next:
            mUiEngine.skipStation( StationSkip::NextFavorite );
            break;

        case RadioServiceCommand::SeekUp:
            mUiEngine.seekStation( Seek::Up );
            break;

        case RadioServiceCommand::SeekDown:
            mUiEngine.seekStation( Seek::Down );
            break;

        case RadioServiceCommand::Foreground:
            XQServiceUtil::toBackground( false );
            break;

        case RadioServiceCommand::Background:
            XQServiceUtil::toBackground( true );
            break;

        case RadioServiceCommand::Mute:
            mUiEngine.setMute( true );
            break;

        case RadioServiceCommand::UnMute:
            mUiEngine.setMute( false );
            break;

        default:
            break;
    }
}