EXPORT_C void CMMFControllerSecureDrmPluginSelectionParameters::ListImplementationsL(RMMFControllerImplInfoArray& aImplementations) const
	{
	CMMFControllerPluginSelectionParameters::ListImplementationsL(aImplementations);
	TInt pluginsCount = aImplementations.Count();
	for (TInt i = pluginsCount - 1; i >= 0; i--)
		{
		CMMFControllerImplementationInformation* c = aImplementations[i];
		if (!c->SupportsSecureDRMProcessMode())
			{
			aImplementations.Remove(i);
			delete c;
			}
		}
	aImplementations.Compress();
	}
QStringList S60FormatSupported::supportedPlayMimeTypesL()
{
    RArray<TUid> mediaIds; //search for both audio and video
    RMMFControllerImplInfoArray iControllers;
    m_controllerparam = CMMFControllerPluginSelectionParameters::NewL();
    m_playformatparam = CMMFFormatSelectionParameters::NewL();
    mediaIds.Append(KUidMediaTypeAudio);
    mediaIds.Append(KUidMediaTypeVideo);
    m_controllerparam->SetMediaIdsL(mediaIds, CMMFPluginSelectionParameters::EAllowOtherMediaIds);
    m_controllerparam->SetRequiredPlayFormatSupportL(*m_playformatparam);
    m_controllerparam->ListImplementationsL(iControllers);
    CDesC8ArrayFlat* controllerArray = new (ELeave) CDesC8ArrayFlat(1);
    for (TInt i = 0; i < iControllers.Count(); i++) {
        for (TInt j = 0; j < (iControllers[i]->PlayFormats()).Count(); j++) {
            const CDesC8Array& iarr = (iControllers[i]->PlayFormats()[j]->SupportedMimeTypes());
            TInt count = iarr.Count();
            for (TInt k = 0; k < count; k++) {
                TPtrC8 ptr = iarr.MdcaPoint(k);
                HBufC8* n = HBufC8::NewL(ptr.Length());
                TPtr8 ptr1 = n->Des();
                ptr1.Copy((TUint8*) ptr.Ptr(), ptr.Length());
                controllerArray->AppendL(ptr1);
            }
        }
    }

    // converting CDesC8Array to QStringList
    for (TInt x = 0; x < controllerArray->Count(); x++) {
        m_supportedplaymime.append(QString::fromUtf8(
                (const char*) (controllerArray->MdcaPoint(x).Ptr()),
                controllerArray->MdcaPoint(x).Length()));
    }

    // populating the list with only audio and controller mime types
    QStringList tempaudio = m_supportedplaymime.filter(QString("audio"));
    QStringList tempvideo = m_supportedplaymime.filter(QString("video"));

    m_supportedplaymime.clear();
    m_supportedplaymime = tempaudio + tempvideo;
    mediaIds.Close();
    delete controllerArray;
    iControllers.ResetAndDestroy();
    return m_supportedplaymime;
}
TInt CMMFControllerPluginSelectionParameters::CheckPreferredSupplierL(RMMFControllerImplInfoArray& aImplementations, const CMMFControllerImplementationInformation& aPlugin) const
	{
	// Set the return value to indicated the plugin is not suitable.
	TBool pluginSuitable = EFalse;
	TBool needToPlaceInVersionOrder = EFalse;
	TBool needToPlaceInUriPriorityOrder = EFalse;

	if((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri))
	 || (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri)))
		{
		needToPlaceInUriPriorityOrder = ETrue;
		}
	
	switch (PreferredSupplierMatchType())
		{
	case ENoPreferredSupplierMatch:
		// No match, so suitable.
		pluginSuitable = ETrue;
	    break;
	case EPreferredSupplierPluginsFirstInList:
		pluginSuitable = ETrue;
		if (aPlugin.SupportsSupplier(PreferredSupplier()))
			needToPlaceInVersionOrder = ETrue;
		break;
	case EOnlyPreferredSupplierPluginsReturned:
		if (aPlugin.SupportsSupplier(PreferredSupplier()))
			{
			pluginSuitable = ETrue;
			needToPlaceInVersionOrder = ETrue;
			}
		break;
	default:
		User::Leave(KErrNotSupported);
		}

	TInt arrayPos;
			
	if (!pluginSuitable)
		{
		arrayPos = -1;
		}
		
	else
		{
		if(needToPlaceInUriPriorityOrder)
			{
			arrayPos = aImplementations.Count();
			// Cycle through aImplementations to find the first plugin with a uri priority LOWER than aPlugin's
			for (TInt i=0; i<aImplementations.Count(); i++)
				{
				CMMFControllerImplementationInformation* c = aImplementations[i];
				
				if(PreferredSupplierMatchType() == ENoPreferredSupplierMatch) //case 1
					{
					/**
					Place the plugin based on its Uri priority.
					Arrange the plugins in Decreasing order of their priority. In case if two or more plugins 
					have similar priority, append the next one at the end. 
					*/
					if (c->UriPriority() < aPlugin.UriPriority())
						{
						arrayPos = i;//plugin will be inserted before c in the array
						break;
						}
					}
				else
					{
					if(!needToPlaceInVersionOrder)  //case 2
						{
						/**
						This reflects the case EPreferredSupplierPluginsFirstInList and 
						aPlugin supplier not matching.
						Place the plugin based on its Uri Priority after the required suppliers plugin.
						If priority is equal, new plugin will be placed last.
						*/
						if( (c->Supplier() != PreferredSupplier()) && (c->UriPriority() < aPlugin.UriPriority()))
							{
							arrayPos = i;//plugin will be inserted before c in the array
							break;
							}
						}
					else  //case 3
						{
						/** 
						This reflects the case where 
						Supplier matches and EPreferredSupplierPluginsFirstInList is specified.
						OR
						Supplier matches and EOnlyPreferredSupplierPluginsReturned is specified.
						*/
						if(c->Supplier() == PreferredSupplier()) 
							{
							if(c->UriPriority() == aPlugin.UriPriority())
								{
								if(c->Version() <= aPlugin.Version())
									{
									arrayPos = i;//plugin will be inserted before c in the array
									break;
									}
								}
							else 
								{
								if(c->UriPriority() < aPlugin.UriPriority())
									{
									arrayPos = i;//plugin will be inserted before c in the array
									break;
									}
								}
							}
						else
							{
							/**
							This is a case of aImplementations now having unpreferred suppliers 
							when EPreferredSupplierPluginsFirstInList is specified and aPlugin is
							of preferred supplier but least priority.
							*/
							arrayPos = i;//plugin will be inserted before c in the array
							break;
							}
						}
					}
				}
			}
			
		else
			{
			if (!needToPlaceInVersionOrder)  
				{
				/**
				place it at the end.
				*/
				arrayPos = aImplementations.Count();
				}
			else
				{
				// Insert the plugin at the beginning of the array, in version order if possible.
				// Make an assumption: if we've been asked for format support, then only plugins 
				// that support the same format will be in the array - so ordering them by version
				// will be meaningful.  Otherwise, there's no point.
				if ((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny))
					|| (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny)))
					{
					// Put the plugin in version order at the beginning of the list

					// Set aArrayPos to the end of the array in case this plugin has the lowest version number
					arrayPos = aImplementations.Count();
					// Cycle through aImplementations to find the first plugin with a version number LOWER than aPlugin
					for (TInt i=0; i<aImplementations.Count(); i++)
						{
						CMMFControllerImplementationInformation* c = aImplementations[i];
						if (c->Supplier() == aPlugin.Supplier())
							{
							if (c->Version() <= aPlugin.Version())
								{
								arrayPos = i;//plugin will be inserted before c in the array
								break;
								}
							}
						else
							{
							arrayPos = i; //c has wrong supplier so this plugin must go before c
							break;
							}
						}
					}
				else
					{
					// We can't use the version numbers meaningfully, so just put this plugin
					// at the top of the list.
					arrayPos = 0;
					}
				}
			}
		}
	
	return arrayPos;
	}
EXPORT_C void CMMFControllerPluginSelectionParameters::ListImplementationsL(RMMFControllerImplInfoArray& aImplementations) const
	{
	aImplementations.ResetAndDestroy();

	RImplInfoPtrArray ecomArray;
	CleanupResetAndDestroyPushL(ecomArray);

	MmPluginUtils::FindImplementationsL(InterfaceUid(), ecomArray);

	TInt index;
	// Create Controller Implementation Information for each entry
	for (index=0; index<ecomArray.Count(); index++)
		{
		CMMFControllerImplementationInformation* c = NULL;
		if (ecomArray[index] == NULL)
			{
			User::Leave(KErrNoMemory);
			}
		TRAPD(error, c = CMMFControllerImplementationInformation::NewL(*(ecomArray[index])));

		if (error == KErrNone)
			{
			CleanupStack::PushL(c);
			
		// If required, get the play and record formats for the controller.
			if (iRequiredPlayFormatSupport)
				{
				c->GetPlayFormatsL();
				}
			if (iRequiredRecordFormatSupport)
				{
				c->GetRecordFormatsL();
				}
			
			// Find out whether this controller matches the client's requirements...
			TBool suitable = EFalse;
			TInt arrayPos; 
			suitable = CheckUriSupport(iRequiredPlayFormatSupport, c, c->PlayFormats());
			if(suitable)
				{
				suitable = CheckUriSupport(iRequiredRecordFormatSupport, c, c->RecordFormats());
				}
			if(suitable)
				{
				MatchImplementationToSelectParamsL(aImplementations, *c, arrayPos);
				}
			else
				{
				arrayPos = -1;	
				}
			
			if (arrayPos >=0)
				{
				// This plugin is suitable - insert it into the array at the suggested position
				User::LeaveIfError(aImplementations.Insert(c, arrayPos));
				CleanupStack::Pop(c);
				}
			else
				{
				// This plugin isn't suitable so just destroy it
				CleanupStack::PopAndDestroy(c);
				}
			}
		else if (error != KErrCorrupt)
			{
			// Ignore the plugin if it is corrupt.  Otherwise, leave.
			// if error !=KErrNone, c hasn't been constructed so it is safe to leave
			User::Leave(error);
			}
		}

	CleanupStack::PopAndDestroy();//ecomArray
	}