videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/xqpluginloader.cpp
changeset 36 8aed59de29f9
child 44 518105d52e45
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
       
     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:   XQPluginLoader stub
       
    15 *
       
    16 */
       
    17 
       
    18 #include "stub/inc/xqpluginloader.h"
       
    19 #include "stub/inc/xqplugininfo.h"
       
    20 #include "testviewplugin.h"
       
    21 #include "mpxvideo_debug.h"
       
    22 
       
    23 QHash<int, MpxViewPlugin*> XQPluginLoader::mPluginList;
       
    24 int XQPluginLoader::mFailToLoadPluginUid = -1;
       
    25 
       
    26 XQPluginLoader::XQPluginLoader( int uid, QObject* parent )
       
    27 {
       
    28     MPX_DEBUG(_L("XQPluginLoader::XQPluginLoader()"));  
       
    29     
       
    30     Q_UNUSED( parent );    
       
    31     mUid = uid;
       
    32 }
       
    33 
       
    34 XQPluginLoader::~XQPluginLoader()
       
    35 {
       
    36     MPX_DEBUG(_L("XQPluginLoader::~XQPluginLoader()"));      
       
    37 }
       
    38 
       
    39 bool XQPluginLoader::listImplementations( const QString &interfaceName, 
       
    40                                           QList<XQPluginInfo > &impls )
       
    41 {
       
    42     MPX_DEBUG(_L("XQPluginLoader::listImplementations()"));  
       
    43     return true;
       
    44 }
       
    45 
       
    46 QObject* XQPluginLoader::instance()
       
    47 {
       
    48     MPX_ENTER_EXIT(_L("XQPluginLoader::instance()"));
       
    49     
       
    50     if ( mUid == mFailToLoadPluginUid )
       
    51     {
       
    52         return 0;
       
    53     }
       
    54     
       
    55     if ( ! mPluginList.contains( mUid ) )
       
    56     {
       
    57         mPluginList[mUid] = new TestViewPlugin();
       
    58     }
       
    59 
       
    60     return mPluginList[mUid];
       
    61 }
       
    62 
       
    63 void XQPluginLoader::cleanup()
       
    64 {
       
    65     MPX_ENTER_EXIT(_L("XQPluginLoader::cleanup()"));
       
    66     
       
    67     QHash<int, MpxViewPlugin*>::const_iterator i = mPluginList.constBegin();
       
    68     while(i != mPluginList.constEnd()) 
       
    69     {
       
    70         TestViewPlugin *view = dynamic_cast<TestViewPlugin*>(i.value());
       
    71         if(view)
       
    72             view->destroyView(); 
       
    73         delete i.value();
       
    74          ++i;
       
    75     }
       
    76 }
       
    77 
       
    78 /**
       
    79  * Sets plugin load to fail.
       
    80  */
       
    81 void XQPluginLoader::setPluginLoadFailure( int uid )
       
    82 {
       
    83     MPX_DEBUG(_L("XQPluginLoader::setPluginLoadFailure()"));
       
    84     mFailToLoadPluginUid = uid;
       
    85 }