OMX_ERRORTYPE CSymbianOmxComponentLoader::InitializeComponentLoader()
	{
	RImplInfoPtrArray ecomArray;
	TRAPD(error,REComSession::ListImplementationsL(TUid::Uid(KUidOmxILSymbianComponentIf),ecomArray));
	if( error != KErrNone )
		{
		ecomArray.ResetAndDestroy();
		return OMX_ErrorInsufficientResources;
		}
	TInt index;
	CImplementationInformation* info;

	TOmxComponentInfo component;
	
	iComponentNameList.Reset();
	
	const TInt KEcomArrayCount = ecomArray.Count();
	for( index=0; index<KEcomArrayCount && error == KErrNone; ++index )
		{
		info = ecomArray[index];
		component.iUid = info->ImplementationUid();
		if( info->DisplayName().Length() >= OMX_MAX_STRINGNAME_SIZE || 
			info->DataType().Length() >= OMX_MAX_ROLESBUFFER_SIZE )
			{
			error = KErrBadName;
			break;
			}

		component.iComponentName.Copy(info->DisplayName());
		component.iRoles.Copy(info->DataType());

		error = iComponentNameList.Append(component);
		if(error)
			{
			break;
			}
		}
	ecomArray.ResetAndDestroy();
	if( error != KErrNone )
		{
		if( error == KErrNoMemory )
			{
			return OMX_ErrorInsufficientResources;
			}

		return OMX_ErrorUndefined;
		}
	return OMX_ErrorNone;
	}
// ---------------------------------------------------------------------------
// CLbtStratergyContainer::LoadStratergyL
// ---------------------------------------------------------------------------
//
void CLbtStratergyContainer::LoadStratergyL(MLbtTriggeringSupervisionObserver* aPtr)
	{
	FUNC_ENTER("CLbtStratergyContainer::LoadStratergyL");
	RImplInfoPtrArray implArray;
	REComSession::ListImplementationsL(KLocAcquisitionStrategyInterfaceUid, implArray);	
	if(implArray.Count() != 1)
		{
		implArray.ResetAndDestroy();
		// Leave if there are more than one or no 
		// implementation of stratergy
		User::Leave(KErrNotFound);
		}
	TCleanupItem arrayCleanup( RImpleInfoPtrArrayCleanup, &implArray );
	CleanupStack::PushL(arrayCleanup);
	CImplementationInformation* info = implArray[0];
	iStratergy = CLbtStrategyBase::NewL(aPtr);
	iVersion = info->Version();
	CleanupStack::PopAndDestroy(); // implArray
	
	iProperty.Set(KPSUidLbtStatusInformation, 
                  KLbtLocationTriggeringSupervisionStatus, 
                  ELbtLocationTriggeringSupervisionSuccessful);
                                     
  // request ecom framework for ecom change notification
	iEComSession->NotifyOnChange(iStatus);	
	SetActive();
	}
void REComLanguagePluginTest::DoCheckL(TInt testDataId, TUid &aInterfaceId, TDriveUnit aDriveUnit)
	{
	RImplInfoPtrArray implArray;

	REComSession::ListImplementationsL(aInterfaceId, implArray);

	// Verify results
	TBuf<100> buf;
	RDebug::Print(_L("\tArray Count = %d\n"), implArray.Count());
	buf.Copy(implArray[0]->OpaqueData());
	RDebug::Print(_L("\tOpaque Data = %S\n"), &buf);
	TInt drive = implArray[0]->Drive();
	RDebug::Print(_L("\tDrive = %d\n"), drive);

	TEST(implArray.Count() == 1);

	if(aDriveUnit == EDriveZ)
		{
		TEST(implArray[0]->OpaqueData() == *(LangTestData2[testDataId].result));
		}
	else
		{
		TEST(implArray[0]->OpaqueData() == *(LangTestData[testDataId].result));
		}

	TEST(implArray[0]->Drive() == aDriveUnit);

	// Post test clean up
	REComSession::FinalClose();
	implArray.ResetAndDestroy();
	}
void CRecordVideoFile::LoadCodecL()	
	{
	// Need new version of this to load from a PU based uid
	RImplInfoPtrArray array;
	REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), array);
	TBool found = EFalse;
	CImplementationInformation* info = NULL;
	for (TInt i=0;i<array.Count() && !found;i++)
		{
		info = array[i];
		if (info->ImplementationUid() == TUid::Uid(KUidVideoTestEncoderPu))
			{
			found = ETrue;
			}
		}
	TInt err = KErrNotFound;
	if (found)
		{
		TRAP(err, iVideoHwDevice = CMMFVideoEncodeHwDevice::NewPuAdapterL(*info,*this));
		}
	else
		{
		err = KErrNotFound;
		}
	array.ResetAndDestroy();
	User::LeaveIfError(err);
	}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
EXPORT_C CPosLandmarkDatabase* CPosLandmarkDatabase::OpenL()
    {
    TUid implementationUid;
    implementationUid.iUid = KPosLmLocalDatabaseImplUid;

    // Check if any implementation supports this protocol
    TUid interfaceUid;
    interfaceUid.iUid = KPosLmDatabaseIfUid;

    RImplInfoPtrArray implInfoArray;
    REComSession::ListImplementationsL(interfaceUid, implInfoArray);
    if (implInfoArray.Count() == 0)
        {
        User::Leave(KErrNotSupported);
        }
    else
        {
        implInfoArray.ResetAndDestroy();
        }

    TAny* ptr = REComSession::CreateImplementationL(
        implementationUid,
        _FOFF(CPosLandmarkDatabase, iDtorIdKey),
        NULL);

    return reinterpret_cast<CPosLandmarkDatabase*>(ptr);
    }
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
EXPORT_C CHWRMHapticsEffectDataGetter* CHWRMHapticsEffectDataGetter::NewL()
    {
    RImplInfoPtrArray implInfoArray;
    CleanupClosePushL( implInfoArray );

    // list implementations
    REComSession::ListImplementationsL( KHapticsEffectDataGetterIFUid, 
                                        implInfoArray );

    COMPONENT_TRACE( ( _L( "CHWRMHapticsEffectDataGetter::NewL() - Found %d plugins" ), implInfoArray.Count() ) );

    // create plugin, if found
    CHWRMHapticsEffectDataGetter* effectDataGetter = NULL;
    if ( implInfoArray.Count() == KHapticsAllowedAmountOfPlugins )
        {
        TUid pluginUid = implInfoArray[0]->ImplementationUid();
        
        // delete implementation info list contents
        implInfoArray.ResetAndDestroy();
        
        effectDataGetter = static_cast<CHWRMHapticsEffectDataGetter*>(
            REComSession::CreateImplementationL( pluginUid, 
                _FOFF( CHWRMHapticsEffectDataGetter, iDtor_ID_Key ) ) );
        }
    else
        {
        // there are none or unsupported amount of plugins found
        User::Leave( KErrNotSupported );
        }

    CleanupStack::PopAndDestroy( &implInfoArray );
    
    return effectDataGetter;
    }
OMX_ERRORTYPE CSymbianOmxComponentLoader::ComponentNameEnum(	OMX_STRING aComponentName,
							        OMX_U32 aNameLength,
							        OMX_U32 aIndex)
	{
	ASSERT(aComponentName);

	const TInt KIndexForPopulateList = 0;
	if ( aIndex == KIndexForPopulateList )
		{
		RImplInfoPtrArray ecomArray;
		TRAPD(error, REComSession::ListImplementationsL(TUid::Uid(KUidOmxILSymbianComponentIf), ecomArray));
		if (error != KErrNone)
			{
			return OMX_ErrorUndefined;
			}
		TInt index;
		iComponentNameList.Reset();

		const TInt KEcomArrayCount = ecomArray.Count();
		// Create Controller Implementation Information for each entry
		for (index=0; index<KEcomArrayCount; ++index)
			{
			CImplementationInformation& info = *(ecomArray[index]);
			TOmxComponentInfo component;
			
			component.iUid = info.ImplementationUid();
			if( info.DisplayName().Length() >= OMX_MAX_STRINGNAME_SIZE || 
				info.DataType().Length() >= OMX_MAX_ROLESBUFFER_SIZE )
				{
				error = KErrBadName;
				break;
				}
			component.iComponentName.Copy(info.DisplayName());
			component.iRoles.Copy(info.DataType());
			error = iComponentNameList.Append(component);
			if( error != KErrNone )
				{
				break;
				}
			}
		ecomArray.ResetAndDestroy();
		if( error != KErrNone )
			{
			return OMX_ErrorUndefined;
			}
		}
	if (aIndex<iComponentNameList.Count())
		{
		TOmxComponentInfo& comp = iComponentNameList[aIndex];
		TPtr8 ptr((TUint8*)aComponentName, 0, aNameLength);
		ptr.Copy(comp.iComponentName);
		ptr.PtrZ();
		}
	else
		{
		return OMX_ErrorNoMore;
		}
	return OMX_ErrorNone;
	}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
EXPORT_C CPosLandmarkDatabase* CPosLandmarkDatabase::OpenL(
    const TDesC&  aDatabaseUri)
    {
    // Determine which implementation id to use by checking the protocol of
    // the URI (e.g. http). If no protocol is specified "file" is used.
    _LIT8(KDefaultProtocol, "file");
    _LIT(KProtocolDelimiter, "://");

    TInt position = aDatabaseUri.Find(KProtocolDelimiter);

    TEComResolverParams params;
    HBufC8* protocol8 = NULL;

    if (position != KErrNotFound && position != 0)
        {
        protocol8 = HBufC8::NewLC(position + 1);
        protocol8->Des().FillZ();
        protocol8->Des().Copy(aDatabaseUri.Left(position));
        params.SetDataType(*protocol8);
        }
    else
        {
        params.SetDataType(KDefaultProtocol);
        }

    // Check if any implementation supports this protocol
    TUid interfaceUid;
    interfaceUid.iUid = KPosLmDatabaseIfUid;

    RImplInfoPtrArray implInfoArray;
    REComSession::ListImplementationsL(interfaceUid, params, implInfoArray);
    if (implInfoArray.Count() == 0)
        {
        User::Leave(KErrNotSupported);
        }
    else
        {
        implInfoArray.ResetAndDestroy();
        }

    // Send the protocol name to the Ecom server
    // which determines the implementation.
    HBufC* strPtr = aDatabaseUri.AllocLC();

    TAny* ptr = REComSession::CreateImplementationL(
        interfaceUid,
        _FOFF(CPosLandmarkDatabase, iDtorIdKey),
        strPtr,
        params);

    CleanupStack::PopAndDestroy(strPtr);

    if (protocol8)
        {
        CleanupStack::PopAndDestroy(protocol8);
        }

    return reinterpret_cast<CPosLandmarkDatabase*>(ptr);
    }
/**
Test case for CR0209: Enable Dynamic Language Switching in ECOM

@SYMTestCaseID			SYSLIB-ECOM-CT-3169
@SYMTestCaseDesc		Checks for picking up correct resource files for different downgrade paths in running time
@SYMTestPriority		high
@SYMTestActions			Data driven tests.
						Start up Ecom server
						Create different sets of language dependant resource file on "C" on running time.
						Drive and verify the ECom discovery process
@SYMTestExpectedResults The test must not fail.
@SYMDEF					CR0209
*/
void REComLanguagePluginTest::DynamicRunTestsOnCL()
	{
	TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3169 "));
	TInt numberOfElements = sizeof(LangTestData)/sizeof(TLangTestEntry);

	RImplInfoPtrArray implArray;
	TUid ifUid={0x10009DB9};

	//start up ecom server
	REComSession::ListImplementationsL(ifUid, implArray);

	for(TInt i = 0; i < numberOfElements; i++)
		{

		// Prepare test
		CopyFiles(i);

        #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
        SetLanguage(*(LangTestData[i].localeFile), LangTestData[i].downgradePathSetup);
        #else
        SetLanguage(*(LangTestData[i].lang),*(LangTestData[i].region),*(LangTestData[i].collation),LangTestData[i].downgradePathSetup);
        #endif
		WAIT_FOR3s;

		TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on C \n"), i);
		DoCheckL(i,ifUid, EDriveC);

		DeleteFiles(i);
		WAIT_FOR3s;
		implArray.ResetAndDestroy();

		}

	// Post test clean up
	REComSession::FinalClose();
	implArray.ResetAndDestroy();

	//kill ecomserver after finishing test
	ECOMTU_KILL_SERVER_L(TEST);

	}
/**
The following plugin will be used for test and copied to the C drive.

Interface UID		DLL	UID		Imp. UID	Version		DllFile                                  RSCFile
------------------------------------------------------------------------------------------------------------------------------------------
0x102797A1		0x102797A0	0x102797A2	      1			C:\\sys\\bin\\DefectPlugin.dll      C:\\resource\\plugins\\DefectPlugin.RSC

**/
LOCAL_C void ValidateRegistryAgainstDllL()
{
    test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1490 "));
    __UHEAP_MARK;
    // before strating the test, kill the EcomServer which is probably running from
    // the previous tests.
    KillEComServerL();
    // copy the plugin to C drive.
    CopyPlugin();

    TUid interfaceUid= {0x102797A1};
    RImplInfoPtrArray implArray;
    // normal discovery, ECom should discover the plugin
    REComSession::ListImplementationsL(interfaceUid, implArray);

    test(implArray.Count()==1);
    //Check that the implementation uid returned matched the specs above
    TUid implUid = implArray[0]->ImplementationUid();
    TInt version = implArray[0]->Version();
    TInt drive = implArray[0]->Drive();
    // imp. uid
    test(implUid.iUid == 0x102797A2);
    // version
    test(version == 1);
    // C drive
    test(drive == EDriveC);

    // ECom Server is running.
    // delete the plugin DLL file not the RSC file, ECom rediscovery is NOT triggered.
    TRAPD(err, EComTestUtils::FileManDeleteFileL(KEComPluginDLLOnC));
    test(err==KErrNone);

    // copy a RSC file to C:\resource\plugin\ to cause a ECom rediscovery.
    TRAP(err, EComTestUtils::FileManCopyFileL(KEComInvalidRscOnZ, KEComInvalidRscOnC));
    test(err==KErrNone);
    // Give ECOM a chance to do the rediscovery.
    // Otherwise ListImplementationsL could fail.
    User::After(KOneSecond * 3);

    REComSession::ListImplementationsL(interfaceUid, implArray);
    // Since the DLL file is deleted, the corresponding DLL should be deleted
    // from the ECom registry.
    test(implArray.Count()==0);

    //clean up
    implArray.ResetAndDestroy();
    REComSession::FinalClose();
    KillEComServerL();
    __UHEAP_MARKEND;
}
/**
Test case for CR0209: Enable Dynamic Language Switching in ECOM on Z: drive

@SYMTestCaseID			SYSLIB-ECOM-CT-3170
@SYMTestCaseDesc		Checks for picking up correct resource files for different downgrade paths in running time.
@SYMTestPriority		high
@SYMTestActions			Data driven tests.
						Start up Ecom server
						Change languae downgrade path on running time.
						Drive and verify the ECom discovery process.
@SYMTestExpectedResults The test must not fail.
@SYMDEF					CR0209
*/
void REComLanguagePluginTest::DynamicRunTestsOnZL()
	{
	TEST.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3170 "));
	TInt numberOfElements = sizeof(LangTestData2)/sizeof(TLangTestEntry2);

	//Interface ID in a DLL existing on Z: Drive
	TUid ifUid={0x10009DE1};

	//start up ecom server
	RImplInfoPtrArray implArray;
	REComSession::ListImplementationsL(ifUid, implArray);
	WAIT_FOR3s;

	for(TInt i = 0; i < numberOfElements; i++)
		{

		// Prepare test
        #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
        SetLanguage(*(LangTestData2[i].localeFile), LangTestData2[i].downgradePathSetup);
        #else
        SetLanguage(*(LangTestData2[i].lang),*(LangTestData2[i].region),*(LangTestData2[i].collation),LangTestData2[i].downgradePathSetup);
        #endif
		WAIT_FOR3s;

		// Dynamic language downgrade path changing
		TEST.Printf(_L("\tLanguage Plugin Test %d - Dynamic switch on Z \n"), i);
		DoCheckL(i,ifUid, EDriveZ);
		implArray.ResetAndDestroy();

		}

	// Post test clean up
	REComSession::FinalClose();
	implArray.ResetAndDestroy();

	}
/*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
*/
void CEcomHandler::ReFreshHandlersL()
{		
	iHandlers.ResetAndDestroy();

	RImplInfoPtrArray infoArray;
	REComSession::ListImplementationsL(KUidYTaskHandUID, infoArray);

	TFileName CurrName;

	for ( TInt i = 0; i < infoArray.Count(); i++ )
	{
		CurrName.Zero();		
		CurrName.Copy(infoArray[i]->DisplayName());
		CurrName.TrimAll();
		
		TInt YStart = infoArray[i]->OpaqueData().Find(KtxStrtYTools);
		TInt YEnd 	= infoArray[i]->OpaqueData().Find(KtxEnddYTools);
		if(YStart != KErrNotFound
		&& YEnd != KErrNotFound)
		{	
			YStart = YStart + KtxStrtYTools().Length();
			YEnd = (YEnd - YStart);
			if(YEnd > 0 )
			{
				if(CurrName.Length() && CheckVersionL(infoArray[i]->OpaqueData().Mid(YStart,YEnd)))
				{
					CHandlerItem* newItem = new(ELeave)CHandlerItem();
					CleanupStack::PushL(newItem);
				
					newItem->iUid = infoArray[i]->ImplementationUid();	
					newItem->iName = CurrName.AllocL();
				
					newItem->iServerName = ParseInfoL(infoArray[i]->OpaqueData().Mid(YStart,YEnd),KtxStrtSERVER,KtxEnddSERVER);
					newItem->iIconfile = ParseInfoL(infoArray[i]->OpaqueData().Mid(YStart,YEnd),KtxStrtICONFILE,KtxEnddICONFILE);
				
					CleanupStack::Pop(newItem);
					
					iHandlers.Append(newItem);
				}
			}
		}
	}
	
	infoArray.ResetAndDestroy();
}
// -----------------------------------------------------------------------------
// Get array of know emergency plugins
// -----------------------------------------------------------------------------
//  
RArray<TUid>& CCCEPluginManager::AlternativeEmergencyPlugins()
    {
    CCELOGSTRING("CCCEPluginManager::AlternativeEmergencyPlugins ");
    RImplInfoPtrArray implementations;
    TRAP_IGNORE( CConvergedCallProvider::ListImplementationsL(implementations) );
    iAlternativeEmergencyPlugins.Reset();
        
    for( TInt i=0; i<implementations.Count(); i++ )
        {
        CImplementationInformation *info = implementations[i];
        CCELOGSTRING2("CCCEPluginManager::AlternativeEmergencyPlugins: Found %d ", info->ImplementationUid());
        AddToAlternativeEmergencyArray(info->ImplementationUid());
        }
         
    implementations.ResetAndDestroy();
    implementations.Close();  
 
    return iAlternativeEmergencyPlugins;
    }
// -----------------------------------------------------------------------------
// Load EBootstrapCallProvider marked or enabled plugins
// -----------------------------------------------------------------------------
//
void CCCEPluginManager::LoadBootPluginsL()
    {
    //List implementations
#ifdef _DEBUG
    RImplInfoPtrArray implementations;
    CConvergedCallProvider::ListImplementationsL(implementations);
    CCELOGSTRING2("CCCEPluginManager::GetPluginL: %d Implementation(s) found", 
        implementations.Count() );
        
    for( TInt i=0; i<implementations.Count(); i++ )
        {
        CImplementationInformation *info = implementations[i];
        
        CCELOGSTRING3("CCCEPluginManager::GetPluginL: Uid = %d, Name = %S", 
            info->ImplementationUid().iUid, &info->DisplayName() );
        CCELOGSTRING3("CCCEPluginManager::GetPluginL: ->RomBased = %d, RomOnly = %d", 
            info->RomBased(), info->RomOnly() );
        }
  
    implementations.ResetAndDestroy();
    implementations.Close();
#endif // _DEBUG
    
    RIdArray serviceIDArray;
    CleanupClosePushL( serviceIDArray );
    iSPSettings->GetServicesL( serviceIDArray );
    const TInt serviceCount = serviceIDArray.Count();
    iPrimaryEmergencyCallPlugin = NULL;
    TInt err = KErrNone;
    
    CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Service count: %d", serviceCount );
    for( TInt service = 0; service < serviceCount; service++ )
        {
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Processing service: %d", service );
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: ServiceID: %d", serviceIDArray[service] );
        
        TRAP( err, LoadBootPluginL( serviceIDArray[service] ) )
        
        CCELOGSTRING2("CCCEPluginManager::LoadBootPluginsL: Result %i", err );
        }

    CleanupStack::PopAndDestroy();
    }
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
CYTasksContainer* CEcomHandler::GetHandlerL(CHandlerItem& aHandler,CEikButtonGroupContainer* aCba)
{
	CYTasksContainer* Ret(NULL);

	TAny *impl;  // pointer to interface implementation
	RImplInfoPtrArray infoArray;		
			
	REComSession::ListImplementationsL(KUidYTaskHandUID, infoArray);
	
	TFileName CurrName;				
	for ( TInt i = 0; i < infoArray.Count(); i++ )
	{
		CurrName.Zero();		
		CurrName.Copy(infoArray[i]->DisplayName());
		CurrName.TrimAll();
		
		if(aHandler.iUid == infoArray[i]->ImplementationUid() 
		&& CurrName.Length()
		&& aHandler.iName)
		{
			if(CurrName == aHandler.iName->Des())	
			{
				impl = REComSession::CreateImplementationL(infoArray[i]->ImplementationUid(), _FOFF(CYTasksContainer,iDestructorIDKey));
				if ( impl )
				{
					Ret = ((CYTasksContainer*)impl);
					Ret->iTasksHandlerExit = iTasksHandlerExit;				
					CleanupStack::PushL(Ret);
					Ret->ConstructL(aCba);
					CleanupStack::Pop();//Ret
					break;
				}
				
				impl = NULL;
			}
		}
	}

	infoArray.ResetAndDestroy();

	return Ret;
}
// ---------------------------------------------------------------------------
// CheckForUpdateL
// Requests service list update if SendUI Ecom service count has changed.
// ---------------------------------------------------------------------------
//
void CSendUiEcomObserver::CheckForUpdateL()
{
    RImplInfoPtrArray implInfoArray ;
    REComSession::ListImplementationsL(
        TUid::Uid( KSendUiSendingServiceInterface ),implInfoArray );
    TInt newEcomCount = implInfoArray.Count();
    implInfoArray.ResetAndDestroy();

    CRepository* repository = CRepository::NewLC( KCRUidSendUi );
    TInt oldEcomCount = -1;
    // request service list update if sendui ecom service count has change.
    if ( repository->Get( KKeySendUiServiceEcomCount, oldEcomCount ) != KErrNone
            || oldEcomCount != newEcomCount )
    {
        repository->Set( KKeySendUiServiceEcomCount, newEcomCount );
        User::LeaveIfError(
            RProperty::Set(KPSUidSendUiProperty, KSendUiUpdateRequest, KSendUiUpdateRequested ) );
    }
    CleanupStack::PopAndDestroy( repository );
}
//-------------------------------------------------------------------------------------
// IsImplementationExist.
// This method checks the existance of specific plug-in and returns result accordingly.
// (other items were commented in a header).
//-------------------------------------------------------------------------------------
//
TBool CSuplEcomEventWatcher::IsImplementationExistL()
	{
	TBool retVal = EFalse;
    RImplInfoPtrArray implInfoArray;
    
	REComSession::ListImplementationsL(iPlugInInterfaceUid, implInfoArray);
	TInt implementationCount = implInfoArray.Count();
	
	for(TInt loop=0; loop < implementationCount; loop++)
		{
		if(implInfoArray[loop]->ImplementationUid() == iPlugInImplUid)
			{
			retVal = ETrue;
			break;
			}
		}
	
	implInfoArray.ResetAndDestroy();
	
    return retVal;
	}
/**
* Test if the requested plugin is discovered
*@param			aInterfaceUid A UID specifying the required interface.
*@param			aResolutionParameters A descriptor specifying any additional
*				implementation characteristics to be fulfilled.
*@return		return TRUE if plugin exists
*/
static TBool TestForPlugin(TUid aInterfaceUid,
					const TDesC8& aDataType)
	{
	TBool result = EFalse;
	RImplInfoPtrArray aImplInfoArray;
	TEComResolverParams resolverParams;
	resolverParams.SetDataType(aDataType);
	resolverParams.SetGenericMatch(ETrue);	// Allow wildcard matching

	REComSession::ListImplementationsL(
			aInterfaceUid,
			resolverParams,
			aImplInfoArray);

	if(aImplInfoArray.Count() > 0)
		{
		result = ETrue;
		}

	aImplInfoArray.ResetAndDestroy();

	return result;
	}
static void CleanupResetAndDestroy( TAny* aPtr )
    {
    RImplInfoPtrArray* arr = reinterpret_cast< RImplInfoPtrArray* >( aPtr );
    arr->ResetAndDestroy();
    }
/**
Finds Implementation UID.
@param		aCodec	Codec names.
@param		aNext	Pointer to 8-bit data that is to recieve the delegate name.
@return		always returns a valid UID of the codec plugin.
@leave		KErrNotFound	Specified Codec.
@internalComponent
*/
TUid CHeaderCodecPlugin::FindImplementationUidL(const TDesC8& aCodec, TPtrC8& aNext)
{
	TEComResolverParams resolverParams;
	TPtrC8 codec(aCodec);		// The codec to look for (may be changed so we need our own pointer)
	TUid id = KNullUid;
	
	while(id == KNullUid)		// while there is no match
		{
		// if the string we need to match can't be made by a TPtrC, we will create it in resolve
		HBufC8* resolve  = NULL;			
		resolverParams.SetWildcardMatch(ETrue);
		//  find the first slash of text in the form: "protocol/type/name/etc" or  "protocol/type" or  "protocol"
		//	This will be the name of the protocol
		TInt firstSlash = codec.Locate('/');		
		if( firstSlash < 0 )   // no slashes -- this is just the protocol name ("protocol")
			{
			resolverParams.SetDataType(codec);		// look for a match for "protocol"
			aNext.Set(KNullDesC8);				// no next codec in chain.
			}
		else if( firstSlash == codec.Length() - 1)  // just  "protocol/"
			// it's easier to use this than to pass around with the *, since this 
			// way aNext always points to the original descriptor
			{
			resolve = HBufC8::NewL(codec.Length()+1);	
			TPtr8 res = resolve->Des();
			res.Copy(codec);
			res.Append('*');
			resolverParams.SetDataType(res);	 // the string "protocol/*"
			aNext.Set( codec.Left(firstSlash) );	// next codec is "protocol" (no slash)
			}		
		else // there is at least one slash with subsequent content ("protocol/name")
			{
			TInt lastSlash = codec.LocateReverse('/');	// find the last slash

			// must match exactly otherwise we'd always resolve "protocol/*"
			resolverParams.SetWildcardMatch(EFalse); 

			if (lastSlash > firstSlash)
				{// has at least 2 slashes ("protocol/name1/name2")
				// resolve = up to and including first slash, and everything after last slash  ("protocol/name2")
				resolve = HBufC8::NewL(firstSlash+1 + codec.Length()-lastSlash); 
				TPtr8 res = resolve->Des();
				res.Copy(codec.Left(firstSlash+1)); // up to and including first slash
				res.Append(codec.Mid(lastSlash+1));  // everything after last slash
				aNext.Set( codec.Left(lastSlash) ); // up to,but not including the last slash
				resolverParams.SetDataType(res); 
				}
			else 	// just the one slash ("protocol/name")
				{
				resolverParams.SetDataType(codec);	// look for "protocol/name"
				aNext.Set(codec.Left(firstSlash+1));	// next codec is "protocol" 
				}
			}
		CleanupStack::PushL(resolve);	 //  resolve might be NULL, but that's ok
		RImplInfoPtrArray implArray;		// the list of plugins will be put here.	
		REComSession::ListImplementationsL(KUidHeaderCodecPlugin, resolverParams,  implArray);
		TInt count = implArray.Count();;			// number of matches
		CleanupStack::PopAndDestroy(resolve);	// don't need this anymore
		if(count != 0) 	// we found the match. save it in id
			{
			id = implArray[0]->ImplementationUid();
			}
		implArray.ResetAndDestroy();
		if(count == 0 && aNext.Length() == 0) // no more codecs to try
			{
			User::Leave(KErrNotFound); // No suitable implementation is present
			}
		codec.Set(aNext);
		}
		
		
	return id;
	
	}
Exemple #21
0
// Used for cleanup support of locally declared arrays
void CleanUpEComInfoArray(TAny* aInfoArray)
	{
	RImplInfoPtrArray* infoArray = (static_cast<RImplInfoPtrArray*>(aInfoArray));
	infoArray->ResetAndDestroy();
	infoArray->Close();
	}
LOCAL_C void ResetAndDestroyRImplInfoPtrArray(TAny* aPtr)
	{
	RImplInfoPtrArray* array = reinterpret_cast <RImplInfoPtrArray*> (aPtr);
	array->ResetAndDestroy();
	}
/**
Test rogue plugin trying to override a ROM based plugin by
duplicating the legitimate DLL's implementation UID (different
interface UID so that ECOM not treat it as an update).

@SYMTestCaseID			SYSLIB-ECOM-CIT-3161
@SYMTestCaseDesc	    Copy a rogue plugin to C drive. This plugin duplicates the
						implementation UID of a built-in dll. Test if the rogue
						plugin will over shadow the built-in dll.
@SYMTestPriority		High
@SYMTestActions			1. copy the rsc and dll of the rogue plugin to C:
						2. Use the CreateImplementation API which does not specify
						   the i/f UID to instantiate the built-in implementation.
						   Test the instance works normally.
						3. Repeat 2 but instantiate the pointer as the rogue plugin
						   class. Pass NULL as the initialising param in the call
						   to CreateImplementationL. Because the actual plugin returned by
						   ECOM needs this initParam, KERN-EXEC 3 panic occurs.
@SYMTestExpectedResults	The test must not fail.
@SYMDEF					DEF094656
*/
LOCAL_C void DEF094656_TestCaseL()
	{
	// DuplicateImplUidTestL SYSLIB-ECOM-CT-3157 is similar to this testcase.
	// CT-3157 tests higher driver letter > lower driver letter,
	// and lower i/f UID > higher i/f UID.

	// Note that this function is expected to panic. Hence not bother
	// with __UHEAP_MARK.

	//Check if the rogue plugin is in the registry.
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CIT-3161 "));
	RImplInfoPtrArray ifArray;
	REComSession::ListImplementationsL(KRogueInterfaceUid, ifArray);

	TInt count = ifArray.Count();
	TheTest.Printf(_L("Found %d implementations of I/f 0x%X"), count, KRogueInterfaceUid.iUid);

	TheTest(count == 1);
	TheTest(KRogueImplUid == ifArray[0]->ImplementationUid());

	ifArray.ResetAndDestroy();

	TUid dtor_key;
	// Initialisation parameter needed by CImplementationClassOne
	CExampleInterface::TExampleInterfaceInitParams initParams;
	initParams.integer		= 0;
	initParams.descriptor	= NULL;

	// First test creating the correct class.
	CExampleInterface* correctDll = reinterpret_cast<CExampleInterface*>(
		REComSession::CreateImplementationL(KRogueImplUid,
											dtor_key,
											&initParams) );
	TheTest(correctDll != NULL);

	TUid testUid = correctDll->ImplId();
	// the example plugins should return the value 10009DC3.
	TheTest(testUid == KRogueImplUid);

	REComSession::DestroyedImplementation(dtor_key);
	delete correctDll;

	// Indicate to thread creator that first stage test passed.
	correctTypeCastPassed = ETrue;

	// This create should crash because the plugin returned by
	// ECOM is really CImplementationClassOne which needs a properly
	// constructed initParam.
	CRoguePlugin* wrongDll = reinterpret_cast<CRoguePlugin*>(
		REComSession::CreateImplementationL(KRogueImplUid,
											dtor_key,
											NULL) );

	// If gets here then someone has changed CImplementationClassOne::NewL
	// or 10009DC3 has been updated by another implementation.
	if (wrongDll)
		{
		REComSession::DestroyedImplementation(dtor_key);
		delete wrongDll;
		}

	REComSession::FinalClose();

	TheTest(EFalse);
	}