qtinternetradio/ui/src/irfileviewservice.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:07:46 +0300
changeset 17 38bbf2dcd608
parent 11 f683e24efca3
permissions -rw-r--r--
Revision: 201037 Kit: 201039

/*
* 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:
*
*/
#include <xqserviceutil.h>
#include <xqsharablefile.h>

#include "irfileviewservice.h"
#include "irplaylist.h"
#include "irapplication.h"
#include "irqsettings.h"
#include "irqlogger.h"

#define INTERNETRADIO_SERVICE_NAME "internet_radio_10_1.com.nokia.symbian.IFileView"

IRFileViewService::IRFileViewService(IRApplication *aApplication) : XQServiceProvider(INTERNETRADIO_SERVICE_NAME),
iApplication(aApplication), iPlayList(NULL)
{
    LOG_METHOD;
    if (XQServiceUtil::isService())
    {
        //Publishes all public slots on this object
        publishAll();
    }
}

IRFileViewService::~IRFileViewService()
{
    delete iPlayList;
}

IRPlayList* IRFileViewService::getPlayList() const
{
    return iPlayList;
}

void IRFileViewService::view(const QString &aFileName)
{
    LOG_METHOD;
    if (NULL == iPlayList)
    {
        iPlayList = new IRPlayList;
    }
    
    iPlayList->parseFile(aFileName);
    
    if (1 == iPlayList->getNumberOfEntries())
    {
        iApplication->launchStartingView(EIRView_PlayingView);
    }
    else if (iPlayList->getNumberOfEntries() > 1)
    {
        iApplication->launchStartingView(EIRView_PlsView);
    }
    else
    {
        //normal launch, launch starting view
        TIRViewId viewId = EIRView_CategoryView;
        iApplication->getSettings()->getStartingViewId(viewId);        
        iApplication->launchStartingView(viewId);
    }
}

void IRFileViewService::view(const XQSharableFile &aSharableFile)
{
    LOG_METHOD;
    QString name = aSharableFile.fileName();
    LOG(STRING2CHAR(name));
    view(name);
}