app/tsrc/unittest_mpglobalpopuphandler/stub/src/mpenginefactory.cpp
changeset 48 af3740e3753f
child 55 f3930dda3342
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
       
     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: MpEngineFactory stub for testing MpNowPlayingWidget
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "mpenginefactory.h"
       
    20 
       
    21 
       
    22 /*!
       
    23  *  Stub function
       
    24  */
       
    25 MpEngineFactory::MpEngineFactory()
       
    26     : mSharedEngine( 0 )
       
    27 {
       
    28 }
       
    29 
       
    30 /*!
       
    31  *  Stub function
       
    32  */
       
    33 MpEngineFactory::~MpEngineFactory()
       
    34 {
       
    35 }
       
    36 
       
    37 /*!
       
    38  *  Stub function
       
    39  */
       
    40 MpEngineFactory * MpEngineFactory::instance()
       
    41 {
       
    42     static MpEngineFactory instance;
       
    43     return &instance;
       
    44 }
       
    45 
       
    46 /*!
       
    47  *  Stub function
       
    48  */
       
    49 MpEngine *MpEngineFactory::sharedEngine()
       
    50 {
       
    51     if ( !instance()->mSharedEngine ) {
       
    52         instance()->mSharedEngine = new MpEngine();
       
    53     }
       
    54     return instance()->mSharedEngine;
       
    55 }
       
    56 
       
    57 /*!
       
    58  Returns an instance to an isolated engine with \a mode.
       
    59  */
       
    60 MpEngine *MpEngineFactory::createIsolatedEngine( MpEngine::EngineMode mode )
       
    61 {
       
    62     instance()->mEngines.append( new MpEngine() );
       
    63     instance()->mEngines.last()->initialize( TUid::Uid( MpCommon::KMusicPlayerUid + instance()->mEngines.count() ), mode );
       
    64     return instance()->mEngines.last();
       
    65 }
       
    66 
       
    67 /*!
       
    68  Closes all engines created on this process.
       
    69  */
       
    70 void MpEngineFactory::close()
       
    71 {
       
    72     if ( instance()->mSharedEngine ) {
       
    73         delete instance()->mSharedEngine;
       
    74         instance()->mSharedEngine = 0;
       
    75         
       
    76     }
       
    77     MpEngine *ptr;
       
    78     foreach ( ptr, instance()->mEngines ) {
       
    79         delete ptr;
       
    80         ptr = 0;
       
    81     }
       
    82 }
       
    83 
       
    84 /*!
       
    85  Returns an instance to an engine with \a hostUid, and \a mode, if the shared engine is 
       
    86  already created parameters are ignored.
       
    87  */
       
    88 MpEngine *MpEngineFactory::createSharedEngine( TUid hostUid , MpEngine::EngineMode mode )
       
    89 {
       
    90     if ( !instance()->mSharedEngine ) {
       
    91         instance()->mSharedEngine = new MpEngine();
       
    92         instance()->mSharedEngine->initialize( hostUid, mode );
       
    93     }
       
    94     return instance()->mSharedEngine;
       
    95 }
       
    96