musichomescreen_multiview/musiccontentpublisher/src/pluginmanager.cpp
branchRCL_3
changeset 17 c8156a91d13c
parent 0 ff3acec5bc43
equal deleted inserted replaced
15:171e07ac910f 17:c8156a91d13c
   101     REComSession::FinalClose();
   101     REComSession::FinalClose();
   102     MPX_DEBUG1("CPluginManager::~CPluginManager --->");
   102     MPX_DEBUG1("CPluginManager::~CPluginManager --->");
   103     }
   103     }
   104 
   104 
   105 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
   106 // Retuns a plugin by UID
   106 // Retuns a plugin by Implementation UID
   107 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   108 //
   108 //
   109 TAny* CPluginManager::GetImplementation( TUid aUid )
   109 TAny* CPluginManager::GetImplementation( TUid aUid )
   110     {
   110     {
   111     TInt32 key = aUid.iUid;
       
   112     TAny* ret= NULL;
   111     TAny* ret= NULL;
   113     TAny** imp= NULL;
   112     THashMapIter<TInt32, TAny*> iter( iPluginMap );
   114     imp = iPluginMap.Find( key );
   113     const TInt32* pluginInstanceKey( NULL );
   115     if ( imp )
   114     TAny*const* ptr = iter.NextValue();
   116         {
   115     while ( ptr )
   117         ret = *imp;
   116         {
       
   117         pluginInstanceKey = iter.CurrentKey();
       
   118         if (REComSession::GetImplementationUidL( TUid::Uid( *pluginInstanceKey ) ) == aUid) 
       
   119             {
       
   120             ret = *ptr;
       
   121             break;
       
   122             }
       
   123         ptr = iter.NextValue();
   118         }
   124         }
   119     return ret;
   125     return ret;
   120     }
   126     }
   121 
   127 
   122 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   163     REComSession::ListImplementationsL( iUid, infoArray );
   169     REComSession::ListImplementationsL( iUid, infoArray );
   164     for ( TInt i = 0; i < infoArray.Count(); i++ )
   170     for ( TInt i = 0; i < infoArray.Count(); i++ )
   165         {
   171         {
   166         TUid current_plugin = infoArray[i]->ImplementationUid();
   172         TUid current_plugin = infoArray[i]->ImplementationUid();
   167         TAny* plug( NULL );
   173         TAny* plug( NULL );
   168         TUid temp;
   174         TUid instanceKey;
   169         TInt err( KErrNone );
   175         TInt err( KErrNone );
   170         TRAP( err, plug = REComSession::CreateImplementationL(
   176         TRAP( err, plug = REComSession::CreateImplementationL(
   171                         current_plugin,
   177                         current_plugin,
   172                         temp,
   178                         instanceKey,
   173                         iParameter ) );
   179                         iParameter ) );
   174         if ( err == KErrNone && plug )
   180         if ( err == KErrNone && plug )
   175             {
   181             {
   176             CleanupStack::PushL( plug );
   182             CleanupStack::PushL( plug );
   177             TInt32 key = current_plugin.iUid;
   183             TInt32 key = instanceKey.iUid;
   178             iPluginMap.InsertL( key, plug );
   184             iPluginMap.InsertL( key, plug );
   179             CleanupStack::Pop( plug );
   185             CleanupStack::Pop( plug );
   180             }
   186             }
   181         }
   187         }
   182 
   188 
   192     {
   198     {
   193     MPX_DEBUG1("CPluginManager::CleanPluginsTable <---");
   199     MPX_DEBUG1("CPluginManager::CleanPluginsTable <---");
   194     THashMapIter<TInt32, TAny*> iter( iPluginMap );
   200     THashMapIter<TInt32, TAny*> iter( iPluginMap );
   195     TAny*const* ptr = iter.NextValue();
   201     TAny*const* ptr = iter.NextValue();
   196     CBase* plug( NULL );
   202     CBase* plug( NULL );
   197     const TInt32* pluginUid( NULL );
   203     const TInt32* pluginInstanceKey( NULL );
   198     while ( ptr )
   204     while ( ptr )
   199         {
   205         {
   200         plug = static_cast<CBase*>( *ptr );
   206         plug = static_cast<CBase*>( *ptr );
   201         delete plug;
   207         delete plug;
   202         plug = NULL;
   208         plug = NULL;
   203         pluginUid = iter.CurrentKey();
   209         pluginInstanceKey = iter.CurrentKey();
   204         REComSession::DestroyedImplementation( TUid::Uid( *pluginUid ) );
   210         REComSession::DestroyedImplementation( TUid::Uid( *pluginInstanceKey ) );
   205         ptr = iter.NextValue();
   211         ptr = iter.NextValue();
   206         pluginUid = NULL;
   212         pluginInstanceKey = NULL;
   207         }
   213         }
   208     MPX_DEBUG1("CPluginManager::CleanPluginsTable --->");
   214     MPX_DEBUG1("CPluginManager::CleanPluginsTable --->");
   209     }
   215     }
   210 
   216 
   211 // ---------------------------------------------------------------------------
   217 // ---------------------------------------------------------------------------