musicservices/src/musicservices.cpp
branchRCL_3
changeset 25 14979e23cb5e
equal deleted inserted replaced
24:26a1709b9fec 25:14979e23cb5e
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <hbapplication.h>
       
    19 #include <QStringList>
       
    20 
       
    21 #include "musicservices.h"
       
    22 #include "getmusicservice.h"
       
    23 #include "playmusicservice.h"
       
    24 #include "mptrace.h"
       
    25 
       
    26 /*!
       
    27     \class MusicServices
       
    28     \brief Music services available.
       
    29 
       
    30     MusicServices implements fetching of music URIs via service provider API and embedded playback.
       
    31 */
       
    32 
       
    33 /*!
       
    34     \fn void playReady( const QString& aFileName )
       
    35 
       
    36     This signal is emitted when the play service has been loaded and playback of aFilenName should start
       
    37 
       
    38  */
       
    39 
       
    40 /*!
       
    41     \fn void playReady( const XQSharableFile& file )
       
    42 
       
    43     This signal is emitted when the play service has been loaded and playback of file handle should start
       
    44 
       
    45  */
       
    46 
       
    47 /*!
       
    48     \fn void serviceActive()
       
    49 
       
    50     This signal is emitted when the requested service has been detected and view initialization should continue
       
    51 
       
    52  */
       
    53 
       
    54 /*!
       
    55  Constructs music services
       
    56  */
       
    57 MusicServices::MusicServices() : 
       
    58         mCurrentService( MusicServices::ENoService )
       
    59 {
       
    60     TX_ENTRY
       
    61     mFetchService = new GetMusicService( this );
       
    62     mPlayService = new PlayMusicService( this );
       
    63     TX_EXIT
       
    64 }
       
    65 
       
    66 /*!
       
    67  Destruct music services
       
    68  */
       
    69 MusicServices::~MusicServices()
       
    70 {
       
    71     TX_ENTRY
       
    72     delete mFetchService;
       
    73     delete mPlayService;
       
    74     TX_EXIT
       
    75 }
       
    76 
       
    77 /*!
       
    78  Gets current active service
       
    79  */
       
    80 MusicServices::MusicService MusicServices::currentService()
       
    81 {
       
    82     return mCurrentService;
       
    83 }
       
    84 
       
    85 /*!
       
    86  Sets current active service
       
    87  */
       
    88 void MusicServices::setCurrentService( MusicServices::MusicService service )
       
    89 {
       
    90     mCurrentService = service;
       
    91 }
       
    92 
       
    93 /*!
       
    94  Returns service context title
       
    95  */
       
    96 QString MusicServices::contextTitle() const
       
    97 {
       
    98 
       
    99     if( mCurrentService == MusicServices::EUriFetcher ) {
       
   100         return mFetchService->contextTitle();
       
   101     }
       
   102     else if ( mCurrentService == MusicServices::EPlayback ) {
       
   103         return mPlayService->contextTitle();
       
   104     }
       
   105     else {
       
   106         Q_ASSERT_X(false, "MusicServices::contexTitle", "undefined service");
       
   107         return QString();
       
   108     }
       
   109     
       
   110     
       
   111 }
       
   112 
       
   113 /*!
       
   114  Slot to be called when service is to be completed with selected item \songName
       
   115  */
       
   116 void MusicServices::itemSelected( QString songName )
       
   117 {
       
   118     TX_ENTRY_ARGS("songName: " << songName);
       
   119     QStringList list;
       
   120     list.append( songName );
       
   121     if ( mCurrentService == MusicServices::EUriFetcher ) {
       
   122         mFetchService->complete( list );
       
   123     }
       
   124     else if ( mCurrentService == MusicServices::EPlayback ) {
       
   125         mPlayService->complete( list );
       
   126     }
       
   127     
       
   128 }
       
   129