sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "mmfmatchdata.h" sl@0: #include sl@0: #include "MMFFormatImplementationInformationBody.h" sl@0: #include sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: _LIT8(KSupplier, ""); sl@0: _LIT8(KMediaId, ""); sl@0: _LIT8(KUriScheme,""); sl@0: _LIT8(KNonNetwork,""); sl@0: _LIT8(KPlayFormatCollectionUid, "

"); sl@0: _LIT8(KRecordFormatCollectionUid, ""); sl@0: _LIT8(KFormatFileExtension, ""); sl@0: _LIT8(KFormatMimeType, ""); sl@0: _LIT8(KFormatHeaderData, ""); sl@0: _LIT8(KHeapSize, ""); sl@0: _LIT8(KCustomInterfaceSupport, ""); sl@0: _LIT8(KSecureDRMProcessMode, ""); sl@0: _LIT8(KStackSize, ""); sl@0: _LIT8(KTagMatch, "**"); sl@0: _LIT8(KTagYes,"yes"); sl@0: sl@0: const TInt KTagLength = 3; sl@0: sl@0: const TInt KMaxExtLen = 5 ; sl@0: const TInt KDesCArrayGranularity = 1; sl@0: sl@0: const TInt KUriPriorityHigh = 3; sl@0: const TInt KUriPriorityMedium = 2; sl@0: const TInt KUriPriorityLow = 1; sl@0: const TInt KUriPriorityNone = 0; sl@0: sl@0: static const TUid KUidInterfaceFormatDecode = {KMmfUidPluginInterfaceFormatDecode}; sl@0: static const TUid KUidInterfaceFormatEncode = {KMmfUidPluginInterfaceFormatEncode}; sl@0: static const TUid KUidInterfaceMMFController = {KMmfUidPluginInterfaceController}; sl@0: sl@0: sl@0: EXPORT_C CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewL() sl@0: { sl@0: CMMFFormatSelectionParameters* s = CMMFFormatSelectionParameters::NewLC(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewLC() sl@0: { sl@0: CMMFFormatSelectionParameters* s = new(ELeave) CMMFFormatSelectionParameters; sl@0: CleanupStack::PushL(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFFormatSelectionParameters* CMMFFormatSelectionParameters::NewL(const CMMFFormatSelectionParameters& aParams) sl@0: { sl@0: CMMFFormatSelectionParameters* s = CMMFFormatSelectionParameters::NewLC(); sl@0: s->ConstructL(aParams); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: void CMMFFormatSelectionParameters::ConstructL(const CMMFFormatSelectionParameters& aParams) sl@0: { sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(aParams.MatchData()); sl@0: iMatchReqData->SetMatchUriSchemeL(aParams.MatchUriScheme()); sl@0: iMatchDataType = aParams.MatchDataType(); sl@0: } sl@0: sl@0: CMMFFormatSelectionParameters::~CMMFFormatSelectionParameters() sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData= NULL; sl@0: } sl@0: sl@0: CMMFFormatSelectionParameters::CMMFFormatSelectionParameters() sl@0: { sl@0: iMatchDataType = EMatchAny; sl@0: } sl@0: sl@0: EXPORT_C void CMMFFormatSelectionParameters::SetMatchToFileNameL(const TDesC& aFileName) sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData = NULL; sl@0: iMatchDataType = EMatchAny; sl@0: // Extract the extension from the data passed in sl@0: sl@0: // Parse the path and extract the extension sl@0: _LIT( KDot, "." ) ; sl@0: _LIT8( KDot8, "." ); sl@0: sl@0: // If there is no dot "." in aFileName then assume that we have been passed the extension only (if KMaxExtLen or less) sl@0: if ( (aFileName.Length() <= KMaxExtLen) && (aFileName.Find( KDot ) == KErrNotFound) ) sl@0: { sl@0: RBuf8 temp; sl@0: CleanupClosePushL(temp); sl@0: temp.CreateL(aFileName.Length()+1); sl@0: User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName)); sl@0: temp.Insert(0,KDot8); sl@0: sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(temp); sl@0: sl@0: CleanupStack::PopAndDestroy(&temp); sl@0: sl@0: } sl@0: else if ( aFileName.Find( KDot ) == 0 ) // the first character is dot so assume extension only sl@0: { sl@0: RBuf8 temp; sl@0: CleanupClosePushL(temp); sl@0: temp.CreateL(aFileName.Length()); sl@0: User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName)); sl@0: sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(temp); sl@0: sl@0: CleanupStack::PopAndDestroy(&temp); sl@0: sl@0: } sl@0: else // We have been given the whole filename. Use TParse to extract the extension. sl@0: { sl@0: TParse parser ; sl@0: parser.Set( aFileName, NULL, NULL ) ; sl@0: if ( !( parser.NamePresent() ) ) sl@0: User::Leave( KErrBadName ) ; sl@0: if ( !( parser.PathPresent() ) ) sl@0: { sl@0: RFs fsSession ; sl@0: User::LeaveIfError(fsSession.Connect()); sl@0: TInt error = fsSession.Parse(aFileName, parser); sl@0: fsSession.Close(); sl@0: User::LeaveIfError(error); sl@0: } sl@0: // Parser should now have the full filename and path sl@0: TPtrC extension = parser.Ext(); sl@0: sl@0: RBuf8 temp; sl@0: CleanupClosePushL(temp); sl@0: temp.CreateL(extension.Length()); sl@0: User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, extension)); sl@0: sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(temp); sl@0: sl@0: CleanupStack::PopAndDestroy(&temp); sl@0: sl@0: } sl@0: sl@0: // If we're here, we must now have the file extension sl@0: iMatchDataType = EMatchFileExtension; sl@0: } sl@0: sl@0: EXPORT_C void CMMFFormatSelectionParameters::SetMatchToUriL(const TDesC& aUrl) sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData = NULL; sl@0: iMatchDataType = EMatchAny; sl@0: sl@0: CUri8* uri = UriUtils::CreateUriL(aUrl); //Converts the TDesC16 aUrl to TDesC8 type sl@0: CleanupStack::PushL(uri); sl@0: const TDesC8& path = uri->Uri().Extract(EUriPath); sl@0: sl@0: // Now parse the file name sl@0: TInt pos = path.LocateReverse('.'); sl@0: sl@0: if(pos != KErrNotFound) // if not found, then by default match data is NULL sl@0: { sl@0: TPtrC8 extension(path.Right(path.Length()-pos)); sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(extension); sl@0: } sl@0: CleanupStack::PopAndDestroy(uri); sl@0: sl@0: // If we're here, we must now have the file extension sl@0: // Use match file extension, because we are matching to the file extension of the file specified by the URI sl@0: iMatchDataType = EMatchFileExtension; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Sets this object to match to uri scheme and file extension specified by a URI. sl@0: sl@0: The Uri scheme and extension are saved in iMatchReqData. Further,iMatchData contains uri extension, sl@0: iMatchUriScheme contains uri scheme. sl@0: sl@0: @param aUri sl@0: The URI containing the scheme and uri extension to be matched. sl@0: sl@0: */ sl@0: EXPORT_C void CMMFFormatSelectionParameters::SetMatchToUriSupportL(const TDesC& aUrl) sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData = NULL; sl@0: iMatchDataType = EMatchAny; sl@0: sl@0: CUri8* uri = UriUtils::CreateUriL(aUrl); //Converts the TDesC16 aUrl to TDesC8 type sl@0: CleanupStack::PushL(uri); sl@0: sl@0: const TDesC8& scheme = uri->Uri().Extract(EUriScheme); //get the uri scheme sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchUriSchemeL(scheme); sl@0: sl@0: const TDesC8& path = uri->Uri().Extract(EUriPath); sl@0: // Now parse the file name sl@0: TInt pos = path.LocateReverse('.'); sl@0: sl@0: if(pos != KErrNotFound) // if not found, by default match data is NULL sl@0: { sl@0: TPtrC8 extension(path.Right(path.Length()-pos)); sl@0: iMatchReqData->SetMatchDataL(extension); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(uri); sl@0: // If we're here, we must now have the uri saved in iMatchData. Now, set match type sl@0: // to EMatchUri for checking schema and uri extension sl@0: iMatchDataType = EMatchUri; sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C void CMMFFormatSelectionParameters::SetMatchToMimeTypeL(const TDesC8& aMimeType) sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData = NULL; sl@0: iMatchDataType = EMatchAny; sl@0: sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(aMimeType); sl@0: iMatchDataType = EMatchMimeType; sl@0: } sl@0: sl@0: EXPORT_C void CMMFFormatSelectionParameters::SetMatchToHeaderDataL(const TDesC8& aHeaderData) sl@0: { sl@0: delete iMatchReqData; sl@0: iMatchReqData = NULL; sl@0: iMatchDataType = EMatchAny; sl@0: sl@0: iMatchReqData = CMatchData::CreateL(); sl@0: iMatchReqData->SetMatchDataL(aHeaderData); sl@0: iMatchDataType = EMatchHeaderData; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CMMFFormatSelectionParameters::MatchData() const sl@0: { sl@0: if (iMatchReqData) sl@0: { sl@0: return iMatchReqData->MatchData(); sl@0: } sl@0: else sl@0: { sl@0: return KNullDesC8; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Returns the uri scheme used to perform the plugin match. sl@0: sl@0: @return The uri scheme. sl@0: sl@0: */ sl@0: EXPORT_C const TDesC8& CMMFFormatSelectionParameters::MatchUriScheme() const sl@0: { sl@0: if (iMatchReqData) sl@0: { sl@0: return iMatchReqData->MatchUriScheme(); sl@0: } sl@0: else sl@0: { sl@0: return KNullDesC8; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C CMMFFormatSelectionParameters::TMatchDataType CMMFFormatSelectionParameters::MatchDataType() const sl@0: { sl@0: return iMatchDataType; sl@0: } sl@0: sl@0: CMMFPluginSelectionParameters::CMMFPluginSelectionParameters(TUid aPluginInterfaceUid) : sl@0: iPluginInterfaceUid(aPluginInterfaceUid) sl@0: { sl@0: iPreferredSupplierMatchType = ENoPreferredSupplierMatch; sl@0: iMediaIdMatchType = ENoMediaIdMatch; sl@0: } sl@0: sl@0: CMMFPluginSelectionParameters::~CMMFPluginSelectionParameters() sl@0: { sl@0: delete iPreferredSupplier; sl@0: iMediaIds.Reset(); sl@0: iMediaIds.Close(); sl@0: } sl@0: sl@0: EXPORT_C void CMMFPluginSelectionParameters::SetPreferredSupplierL(const TDesC& aPreferredSupplier, TPreferredSupplierMatchType aMatchType) sl@0: { sl@0: delete iPreferredSupplier; sl@0: iPreferredSupplier = NULL; sl@0: iPreferredSupplier = aPreferredSupplier.AllocL(); sl@0: iPreferredSupplierMatchType = aMatchType; sl@0: } sl@0: sl@0: EXPORT_C void CMMFPluginSelectionParameters::SetMediaIdsL(const RArray& aMediaIds, TMediaIdMatchType aMatchType) sl@0: { sl@0: iMediaIds.Reset(); sl@0: for (TInt i=0; i& CMMFPluginSelectionParameters::MediaIds() const sl@0: { sl@0: return iMediaIds; sl@0: } sl@0: sl@0: EXPORT_C CMMFPluginSelectionParameters::TMediaIdMatchType CMMFPluginSelectionParameters::MediaIdMatchType() const sl@0: { sl@0: return iMediaIdMatchType; sl@0: } sl@0: sl@0: EXPORT_C TUid CMMFPluginSelectionParameters::InterfaceUid() const sl@0: { sl@0: return iPluginInterfaceUid; sl@0: } sl@0: sl@0: sl@0: TBool CMMFPluginSelectionParameters::CheckMediaIdSupportL(const CMMFPluginImplementationInformation& aPlugin) const sl@0: { sl@0: TBool ret = EFalse; sl@0: switch (MediaIdMatchType()) sl@0: { sl@0: case CMMFPluginSelectionParameters::ENoMediaIdMatch: sl@0: // No match required so suitable sl@0: ret = ETrue; sl@0: break; sl@0: case CMMFPluginSelectionParameters::EAllowOtherMediaIds: sl@0: // Just check that the requested media id is supported by the plugin sl@0: { sl@0: for (TInt i=0; iGetPlayFormatsL(); sl@0: } sl@0: if (iRequiredRecordFormatSupport) sl@0: { sl@0: c->GetRecordFormatsL(); sl@0: } sl@0: sl@0: // Find out whether this controller matches the client's requirements... sl@0: TBool suitable = EFalse; sl@0: TInt arrayPos; sl@0: suitable = CheckUriSupport(iRequiredPlayFormatSupport, c, c->PlayFormats()); sl@0: if(suitable) sl@0: { sl@0: suitable = CheckUriSupport(iRequiredRecordFormatSupport, c, c->RecordFormats()); sl@0: } sl@0: if(suitable) sl@0: { sl@0: MatchImplementationToSelectParamsL(aImplementations, *c, arrayPos); sl@0: } sl@0: else sl@0: { sl@0: arrayPos = -1; sl@0: } sl@0: sl@0: if (arrayPos >=0) sl@0: { sl@0: // This plugin is suitable - insert it into the array at the suggested position sl@0: User::LeaveIfError(aImplementations.Insert(c, arrayPos)); sl@0: CleanupStack::Pop(c); sl@0: } sl@0: else sl@0: { sl@0: // This plugin isn't suitable so just destroy it sl@0: CleanupStack::PopAndDestroy(c); sl@0: } sl@0: } sl@0: else if (error != KErrCorrupt) sl@0: { sl@0: // Ignore the plugin if it is corrupt. Otherwise, leave. sl@0: // if error !=KErrNone, c hasn't been constructed so it is safe to leave sl@0: User::Leave(error); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy();//ecomArray sl@0: } sl@0: sl@0: void CMMFControllerPluginSelectionParameters::MatchImplementationToSelectParamsL(RMMFControllerImplInfoArray& aImplementations, const CMMFControllerImplementationInformation& aPlugin, TInt& aArrayPos) const sl@0: { sl@0: TBool suitable = EFalse; sl@0: sl@0: // First, check whether the plugin supports the required play formats sl@0: suitable = CheckFormatSupportL(iRequiredPlayFormatSupport, aPlugin.PlayFormats()); sl@0: sl@0: // Next, check the record formats sl@0: if (suitable) sl@0: suitable = CheckFormatSupportL(iRequiredRecordFormatSupport, aPlugin.RecordFormats()); sl@0: sl@0: // Next, check for correct media id support sl@0: if (suitable) sl@0: suitable = CheckMediaIdSupportL(aPlugin); sl@0: sl@0: // Finally, calculate the position the plugin should take in aImplementations depending on the preferred supplier and version number. sl@0: if (suitable) sl@0: aArrayPos = CheckPreferredSupplierL(aImplementations, aPlugin); sl@0: else sl@0: aArrayPos = -1; sl@0: } sl@0: sl@0: /** sl@0: Checks the given Controller for uri support. Uri support may be there sl@0: if either requiredscheme or extension matches with that given controller sl@0: sl@0: @param aSelectParams sl@0: Describes the selection parameter which a controller needs to sl@0: support in order to be selected sl@0: sl@0: @param aPlugin sl@0: The controller plugin which is checked for uri support sl@0: sl@0: @param aFormats sl@0: The play or record formats looked for extension match sl@0: */ sl@0: TBool CMMFControllerPluginSelectionParameters::CheckUriSupport(CMMFFormatSelectionParameters* aSelectParams, CMMFControllerImplementationInformation* aPlugin, const RMMFFormatImplInfoArray& aFormats) const sl@0: { sl@0: // If aSelectParams are NULL (ie none were set) then the plugin must be suitable! sl@0: if (aSelectParams == NULL) sl@0: return ETrue; sl@0: sl@0: //If EMatchUri not set then the plugin might be suitable! sl@0: if(aSelectParams->MatchDataType() != CMMFFormatSelectionParameters::EMatchUri) sl@0: { sl@0: return ETrue; sl@0: } sl@0: sl@0: TBool suitable = EFalse; sl@0: TInt index; sl@0: sl@0: //If yes is there in the aPlugin's opaque data, sl@0: //URI support not assumed. So, don't load the controller sl@0: if(!aPlugin->SupportsNetworkCapability()) sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: //the uri scheme to be matched for sl@0: if (aPlugin->SupportsUriScheme(aSelectParams->MatchUriScheme())) sl@0: { sl@0: aPlugin->SetUriPriority(KUriPriorityMedium); sl@0: suitable = ETrue; sl@0: } sl@0: else sl@0: { sl@0: //if other uri scheme support declared, but not the required one, sl@0: // even then controller not supported sl@0: if(aPlugin->SupportedUriSchemes().Count() > 0) sl@0: { sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: sl@0: //then match Uri extension. . sl@0: sl@0: //if ctrl has no network capability, then lowest priority given on matching file extension sl@0: for (index=0;index SupportsFileExtension(aSelectParams->MatchData())) sl@0: { sl@0: if(!suitable) sl@0: { sl@0: aPlugin->SetUriPriority(KUriPriorityLow); sl@0: } sl@0: else sl@0: { sl@0: aPlugin->SetUriPriority(KUriPriorityHigh); sl@0: } sl@0: sl@0: suitable = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: return suitable; sl@0: } sl@0: sl@0: TInt CMMFControllerPluginSelectionParameters::CheckPreferredSupplierL(RMMFControllerImplInfoArray& aImplementations, const CMMFControllerImplementationInformation& aPlugin) const sl@0: { sl@0: // Set the return value to indicated the plugin is not suitable. sl@0: TBool pluginSuitable = EFalse; sl@0: TBool needToPlaceInVersionOrder = EFalse; sl@0: TBool needToPlaceInUriPriorityOrder = EFalse; sl@0: sl@0: if((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri)) sl@0: || (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() == CMMFFormatSelectionParameters::EMatchUri))) sl@0: { sl@0: needToPlaceInUriPriorityOrder = ETrue; sl@0: } sl@0: sl@0: switch (PreferredSupplierMatchType()) sl@0: { sl@0: case ENoPreferredSupplierMatch: sl@0: // No match, so suitable. sl@0: pluginSuitable = ETrue; sl@0: break; sl@0: case EPreferredSupplierPluginsFirstInList: sl@0: pluginSuitable = ETrue; sl@0: if (aPlugin.SupportsSupplier(PreferredSupplier())) sl@0: needToPlaceInVersionOrder = ETrue; sl@0: break; sl@0: case EOnlyPreferredSupplierPluginsReturned: sl@0: if (aPlugin.SupportsSupplier(PreferredSupplier())) sl@0: { sl@0: pluginSuitable = ETrue; sl@0: needToPlaceInVersionOrder = ETrue; sl@0: } sl@0: break; sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: TInt arrayPos; sl@0: sl@0: if (!pluginSuitable) sl@0: { sl@0: arrayPos = -1; sl@0: } sl@0: sl@0: else sl@0: { sl@0: if(needToPlaceInUriPriorityOrder) sl@0: { sl@0: arrayPos = aImplementations.Count(); sl@0: // Cycle through aImplementations to find the first plugin with a uri priority LOWER than aPlugin's sl@0: for (TInt i=0; iUriPriority() < aPlugin.UriPriority()) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(!needToPlaceInVersionOrder) //case 2 sl@0: { sl@0: /** sl@0: This reflects the case EPreferredSupplierPluginsFirstInList and sl@0: aPlugin supplier not matching. sl@0: Place the plugin based on its Uri Priority after the required suppliers plugin. sl@0: If priority is equal, new plugin will be placed last. sl@0: */ sl@0: if( (c->Supplier() != PreferredSupplier()) && (c->UriPriority() < aPlugin.UriPriority())) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: else //case 3 sl@0: { sl@0: /** sl@0: This reflects the case where sl@0: Supplier matches and EPreferredSupplierPluginsFirstInList is specified. sl@0: OR sl@0: Supplier matches and EOnlyPreferredSupplierPluginsReturned is specified. sl@0: */ sl@0: if(c->Supplier() == PreferredSupplier()) sl@0: { sl@0: if(c->UriPriority() == aPlugin.UriPriority()) sl@0: { sl@0: if(c->Version() <= aPlugin.Version()) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(c->UriPriority() < aPlugin.UriPriority()) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: /** sl@0: This is a case of aImplementations now having unpreferred suppliers sl@0: when EPreferredSupplierPluginsFirstInList is specified and aPlugin is sl@0: of preferred supplier but least priority. sl@0: */ sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: else sl@0: { sl@0: if (!needToPlaceInVersionOrder) sl@0: { sl@0: /** sl@0: place it at the end. sl@0: */ sl@0: arrayPos = aImplementations.Count(); sl@0: } sl@0: else sl@0: { sl@0: // Insert the plugin at the beginning of the array, in version order if possible. sl@0: // Make an assumption: if we've been asked for format support, then only plugins sl@0: // that support the same format will be in the array - so ordering them by version sl@0: // will be meaningful. Otherwise, there's no point. sl@0: if ((iRequiredPlayFormatSupport && (iRequiredPlayFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny)) sl@0: || (iRequiredRecordFormatSupport && (iRequiredRecordFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny))) sl@0: { sl@0: // Put the plugin in version order at the beginning of the list sl@0: sl@0: // Set aArrayPos to the end of the array in case this plugin has the lowest version number sl@0: arrayPos = aImplementations.Count(); sl@0: // Cycle through aImplementations to find the first plugin with a version number LOWER than aPlugin sl@0: for (TInt i=0; iSupplier() == aPlugin.Supplier()) sl@0: { sl@0: if (c->Version() <= aPlugin.Version()) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: arrayPos = i; //c has wrong supplier so this plugin must go before c sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // We can't use the version numbers meaningfully, so just put this plugin sl@0: // at the top of the list. sl@0: arrayPos = 0; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: return arrayPos; sl@0: } sl@0: sl@0: TBool CMMFControllerPluginSelectionParameters::CheckFormatSupportL(CMMFFormatSelectionParameters* aSelectParams, const RMMFFormatImplInfoArray& aFormats) const sl@0: { sl@0: // If aSelectParams are NULL (ie none were set) then the plugin must be suitable! sl@0: if (aSelectParams == NULL) sl@0: return ETrue; sl@0: sl@0: TBool suitable = EFalse; sl@0: sl@0: // Check all the formats in aFormats. If any support the required data type, return ETrue. sl@0: TInt index; sl@0: switch (aSelectParams->MatchDataType()) sl@0: { sl@0: case CMMFFormatSelectionParameters::EMatchAny: sl@0: // All plugins intrinsically match this! sl@0: suitable = ETrue; sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchFileExtension: sl@0: for (index=0;indexSupportsFileExtension(aSelectParams->MatchData())) sl@0: { sl@0: suitable = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchMimeType: sl@0: for (index=0;indexSupportsMimeType(aSelectParams->MatchData())) sl@0: { sl@0: suitable = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchHeaderData: sl@0: for (index=0;indexSupportsHeaderDataL(aSelectParams->MatchData())) sl@0: { sl@0: suitable = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case CMMFFormatSelectionParameters::EMatchUri: sl@0: { sl@0: suitable = ETrue; //if uri match specifically looked , then that has been already matched in a CheckUriSupport() sl@0: break; sl@0: } sl@0: sl@0: sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: }; sl@0: sl@0: return suitable; sl@0: } sl@0: sl@0: sl@0: sl@0: EXPORT_C CMMFControllerSecureDrmPluginSelectionParameters* CMMFControllerSecureDrmPluginSelectionParameters::NewL() sl@0: { sl@0: CMMFControllerSecureDrmPluginSelectionParameters* s = CMMFControllerSecureDrmPluginSelectionParameters::NewLC(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFControllerSecureDrmPluginSelectionParameters* CMMFControllerSecureDrmPluginSelectionParameters::NewLC() sl@0: { sl@0: CMMFControllerSecureDrmPluginSelectionParameters* s = new(ELeave) CMMFControllerSecureDrmPluginSelectionParameters; sl@0: CleanupStack::PushL(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFControllerSecureDrmPluginSelectionParameters::CMMFControllerSecureDrmPluginSelectionParameters() : sl@0: CMMFControllerPluginSelectionParameters() sl@0: { sl@0: } sl@0: sl@0: EXPORT_C void CMMFControllerSecureDrmPluginSelectionParameters::ListImplementationsL(RMMFControllerImplInfoArray& aImplementations) const sl@0: { sl@0: CMMFControllerPluginSelectionParameters::ListImplementationsL(aImplementations); sl@0: TInt pluginsCount = aImplementations.Count(); sl@0: for (TInt i = pluginsCount - 1; i >= 0; i--) sl@0: { sl@0: CMMFControllerImplementationInformation* c = aImplementations[i]; sl@0: if (!c->SupportsSecureDRMProcessMode()) sl@0: { sl@0: aImplementations.Remove(i); sl@0: delete c; sl@0: } sl@0: } sl@0: aImplementations.Compress(); sl@0: } sl@0: sl@0: sl@0: sl@0: CMMFFormatPluginSelectionParameters::CMMFFormatPluginSelectionParameters(TUid aInterfaceUid) : sl@0: CMMFPluginSelectionParameters(aInterfaceUid) sl@0: { sl@0: } sl@0: sl@0: CMMFFormatPluginSelectionParameters::~CMMFFormatPluginSelectionParameters() sl@0: { sl@0: delete iRequiredFormatSupport; sl@0: } sl@0: sl@0: EXPORT_C void CMMFFormatPluginSelectionParameters::SetRequiredFormatSupportL(const CMMFFormatSelectionParameters& aRequiredSupport) sl@0: { sl@0: delete iRequiredFormatSupport; sl@0: iRequiredFormatSupport = NULL; sl@0: iRequiredFormatSupport = CMMFFormatSelectionParameters::NewL(aRequiredSupport); sl@0: } sl@0: sl@0: EXPORT_C void CMMFFormatPluginSelectionParameters::ListImplementationsL(RMMFFormatImplInfoArray& aImplementations) const sl@0: { sl@0: aImplementations.ResetAndDestroy(); sl@0: sl@0: RImplInfoPtrArray ecomArray; sl@0: CleanupResetAndDestroyPushL(ecomArray); sl@0: sl@0: MmPluginUtils::FindImplementationsL(InterfaceUid(), ecomArray); sl@0: sl@0: sl@0: TInt index; sl@0: // Create Format Implementation Information for each entry sl@0: for (index=0; index=0) sl@0: { sl@0: // This plugin is suitable - insert it into the array at the suggested position sl@0: User::LeaveIfError(aImplementations.Insert(c, arrayPos)); sl@0: CleanupStack::Pop(c); sl@0: } sl@0: else sl@0: { sl@0: // This plugin isn't suitable so just destroy it sl@0: CleanupStack::PopAndDestroy(c); sl@0: } sl@0: } sl@0: else if (error != KErrCorrupt) sl@0: { sl@0: // Ignore the plugin if it is corrupt. Otherwise, leave. sl@0: // if error !=KErrNone, c hasn't been constructed so it is safe to leave sl@0: User::Leave(error); sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy();//ecomArray sl@0: } sl@0: sl@0: void CMMFFormatPluginSelectionParameters::MatchImplementationToSelectParamsL(RMMFFormatImplInfoArray& aImplementations, const CMMFFormatImplementationInformation& aPlugin, TInt& aArrayPos) const sl@0: { sl@0: TBool suitable = EFalse; sl@0: sl@0: // First, check whether the plugin supports the required play formats sl@0: suitable = CheckFormatSupportL(aPlugin); sl@0: sl@0: // Next, check for correct media id support sl@0: if (suitable) sl@0: suitable = CheckMediaIdSupportL(aPlugin); sl@0: sl@0: // Finally, calculate the position the plugin should take in aImplementations depending on the preferred supplier and version number. sl@0: if (suitable) sl@0: aArrayPos = CheckPreferredSupplierL(aImplementations, aPlugin); sl@0: else sl@0: aArrayPos = -1; sl@0: } sl@0: sl@0: TInt CMMFFormatPluginSelectionParameters::CheckPreferredSupplierL(RMMFFormatImplInfoArray& aImplementations, const CMMFFormatImplementationInformation& aPlugin) const sl@0: { sl@0: // Set the return value to indicated the plugin is not suitable. sl@0: TBool pluginSuitable = EFalse; sl@0: TBool needToPlaceInVersionOrder = EFalse; sl@0: sl@0: switch (PreferredSupplierMatchType()) sl@0: { sl@0: case ENoPreferredSupplierMatch: sl@0: // No match, so suitable. sl@0: pluginSuitable = ETrue; sl@0: break; sl@0: case EPreferredSupplierPluginsFirstInList: sl@0: pluginSuitable = ETrue; sl@0: if (aPlugin.SupportsSupplier(PreferredSupplier())) sl@0: needToPlaceInVersionOrder = ETrue; sl@0: break; sl@0: case EOnlyPreferredSupplierPluginsReturned: sl@0: if (aPlugin.SupportsSupplier(PreferredSupplier())) sl@0: { sl@0: pluginSuitable = ETrue; sl@0: needToPlaceInVersionOrder = ETrue; sl@0: } sl@0: break; sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: sl@0: TInt arrayPos; sl@0: sl@0: if (!pluginSuitable) sl@0: { sl@0: arrayPos = -1; sl@0: } sl@0: else sl@0: { sl@0: if (!needToPlaceInVersionOrder) sl@0: { sl@0: arrayPos = aImplementations.Count(); sl@0: } sl@0: else sl@0: { sl@0: // Insert the plugin at the beginning of the array, in version order if possible. sl@0: // Make an assumption: if we've been asked for format support, then only plugins sl@0: // that support the same format will be in the array - so ordering them by version sl@0: // will be meaningful. Otherwise, there's no point. sl@0: if (iRequiredFormatSupport && (iRequiredFormatSupport->MatchDataType() != CMMFFormatSelectionParameters::EMatchAny)) sl@0: { sl@0: // Put the plugin in version order at the beginning of the list sl@0: sl@0: // Set aArrayPos to the end of the array in case this plugin has the lowest version number sl@0: arrayPos = aImplementations.Count(); sl@0: // Cycle through aImplementations to find the first plugin with a version number LOWER than aPlugin sl@0: for (TInt i=0; iSupplier() == aPlugin.Supplier()) sl@0: && (c->Version() <= aPlugin.Version())) sl@0: { sl@0: arrayPos = i;//plugin will be inserted before c in the array sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // We can't use the version numbers meaningfully, so just put this plugin sl@0: // at the top of the list. sl@0: arrayPos = 0; sl@0: } sl@0: } sl@0: } sl@0: return arrayPos; sl@0: } sl@0: sl@0: TBool CMMFFormatPluginSelectionParameters::CheckFormatSupportL(const CMMFFormatImplementationInformation& aPlugin) const sl@0: { sl@0: // If iRequiredFormatSupport is NULL (ie no requirements set) then the plugin must be suitable! sl@0: if (iRequiredFormatSupport == NULL) sl@0: return ETrue; sl@0: sl@0: TBool suitable = EFalse; sl@0: sl@0: switch (iRequiredFormatSupport->MatchDataType()) sl@0: { sl@0: case CMMFFormatSelectionParameters::EMatchAny: sl@0: suitable = ETrue; sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchFileExtension: sl@0: if (aPlugin.SupportsFileExtension(iRequiredFormatSupport->MatchData())) sl@0: suitable = ETrue; sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchMimeType: sl@0: if (aPlugin.SupportsMimeType(iRequiredFormatSupport->MatchData())) sl@0: suitable = ETrue; sl@0: break; sl@0: case CMMFFormatSelectionParameters::EMatchHeaderData: sl@0: if (aPlugin.SupportsHeaderDataL(iRequiredFormatSupport->MatchData())) sl@0: suitable = ETrue; sl@0: break; sl@0: default: sl@0: User::Leave(KErrNotSupported); sl@0: }; sl@0: sl@0: return suitable; sl@0: } sl@0: sl@0: sl@0: EXPORT_C CMMFFormatEncodePluginSelectionParameters* CMMFFormatEncodePluginSelectionParameters::NewL() sl@0: { sl@0: CMMFFormatEncodePluginSelectionParameters* s = CMMFFormatEncodePluginSelectionParameters::NewLC(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFFormatEncodePluginSelectionParameters* CMMFFormatEncodePluginSelectionParameters::NewLC() sl@0: { sl@0: CMMFFormatEncodePluginSelectionParameters* s = new(ELeave) CMMFFormatEncodePluginSelectionParameters; sl@0: CleanupStack::PushL(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFFormatEncodePluginSelectionParameters::CMMFFormatEncodePluginSelectionParameters() : sl@0: CMMFFormatPluginSelectionParameters(KUidInterfaceFormatEncode) sl@0: { sl@0: } sl@0: sl@0: sl@0: EXPORT_C CMMFFormatDecodePluginSelectionParameters* CMMFFormatDecodePluginSelectionParameters::NewL() sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* s = CMMFFormatDecodePluginSelectionParameters::NewLC(); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFFormatDecodePluginSelectionParameters* CMMFFormatDecodePluginSelectionParameters::NewLC() sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* s = new(ELeave) CMMFFormatDecodePluginSelectionParameters; sl@0: CleanupStack::PushL(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFFormatDecodePluginSelectionParameters::CMMFFormatDecodePluginSelectionParameters() : sl@0: CMMFFormatPluginSelectionParameters(KUidInterfaceFormatDecode) sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: void TaggedDataParser::ParseTaggedDataL(const TDesC8& aData, MTaggedDataParserClient& aClient) sl@0: { sl@0: TPtrC8 data(aData); sl@0: TInt readPosition = 0; sl@0: TBool moreData = data.Length() ? ETrue : EFalse; sl@0: while (moreData) sl@0: { sl@0: // Assumes that this segment will begin with a tag sl@0: TPtrC8 restOfData = data.Mid(readPosition); sl@0: sl@0: TInt endPos = restOfData.MatchF(KTagMatch); sl@0: if (endPos == KErrNotFound) sl@0: User::Leave(KErrCorrupt); sl@0: sl@0: // extract the tag sl@0: TPtrC8 tag = restOfData.Left(KTagLength); sl@0: sl@0: sl@0: readPosition += KTagLength; sl@0: sl@0: // Find the next tag sl@0: restOfData.Set(data.Mid(readPosition)); sl@0: endPos = restOfData.MatchF(KTagMatch); sl@0: sl@0: TPtrC8 tagData; sl@0: if (endPos == KErrNotFound) sl@0: { sl@0: // If we didn't find a tag, we must be at the end of the data sl@0: tagData.Set(restOfData); sl@0: readPosition = restOfData.Length(); sl@0: moreData = EFalse; sl@0: } sl@0: else sl@0: { sl@0: tagData.Set(restOfData.Left(endPos)); sl@0: readPosition += endPos; sl@0: } sl@0: sl@0: aClient.ProcessTaggedDataL(tag, tagData); sl@0: } sl@0: } sl@0: sl@0: void TaggedDataParser::ConvertTextToUidL(const TDesC8& aData, TUid& aUid) sl@0: { sl@0: // Make sure aData is in the correct format - "0x12345678" sl@0: _LIT8(K0x, "0x"); sl@0: _LIT8(K0X, "0X"); sl@0: if ((aData.Length() == 10) && ((aData.FindF(K0x) == 0) || (aData.FindF(K0X) == 0))) sl@0: { sl@0: // only take the right 8 characters (ie discard the "0x") sl@0: TLex8 lex(aData.Right(8)); sl@0: TUint32 value = 0; sl@0: User::LeaveIfError(lex.Val(value, EHex)); sl@0: aUid.iUid = value; sl@0: } sl@0: else sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: sl@0: sl@0: void TaggedDataParser::ConvertTextToTUintL(const TDesC8& aData, TUint& aUint) sl@0: { sl@0: // Determine whether hex or decimal then parse as such sl@0: _LIT8(K0x, "0x"); sl@0: _LIT8(K0X, "0X"); sl@0: if (((aData.FindF(K0x) == 0) || (aData.FindF(K0X) == 0)) && (aData.Length() >= 3)) sl@0: { sl@0: // only take the characters after "0x" sl@0: TLex8 lex(aData.Right(aData.Length()-2)); sl@0: TUint32 value = 0; sl@0: User::LeaveIfError(lex.Val(value, EHex)); sl@0: aUint = value; sl@0: } sl@0: else if (aData.Length() > 0) sl@0: { sl@0: TLex8 lex(aData.Right(aData.Length())); sl@0: TUint32 value = 0; sl@0: User::LeaveIfError(lex.Val(value, EDecimal)); sl@0: aUint = value; sl@0: } sl@0: else sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TBool CMMFPluginImplementationInformation::SupportsSupplier(const TDesC& aSupplier) const sl@0: { sl@0: if (iSupplier) sl@0: { sl@0: if (aSupplier.CompareF(*iSupplier) == KErrNone) sl@0: return ETrue; sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFPluginImplementationInformation::SupportsMediaId(TUid aMediaId) const sl@0: { sl@0: TInt location = iMediaIds.Find(aMediaId); sl@0: return (location != KErrNotFound); sl@0: } sl@0: sl@0: EXPORT_C TUid CMMFPluginImplementationInformation::Uid() const sl@0: { sl@0: return iUid; sl@0: } sl@0: sl@0: EXPORT_C const TDesC& CMMFPluginImplementationInformation::DisplayName() const sl@0: { sl@0: if (iDisplayName) sl@0: return *iDisplayName; sl@0: else sl@0: return KNullDesC; sl@0: } sl@0: sl@0: EXPORT_C const TDesC& CMMFPluginImplementationInformation::Supplier() const sl@0: { sl@0: if (iSupplier) sl@0: return *iSupplier; sl@0: else sl@0: return KNullDesC; sl@0: } sl@0: sl@0: EXPORT_C TInt CMMFPluginImplementationInformation::Version() const sl@0: { sl@0: return iVersion; sl@0: } sl@0: sl@0: EXPORT_C const RArray& CMMFPluginImplementationInformation::SupportedMediaIds() const sl@0: { sl@0: return iMediaIds; sl@0: } sl@0: sl@0: CMMFPluginImplementationInformation::~CMMFPluginImplementationInformation() sl@0: { sl@0: delete iDisplayName; sl@0: delete iSupplier; sl@0: iMediaIds.Close(); sl@0: } sl@0: sl@0: sl@0: CMMFPluginImplementationInformation::CMMFPluginImplementationInformation() sl@0: { sl@0: } sl@0: sl@0: void CMMFPluginImplementationInformation::SetSupplierL(const TDesC8& aData) sl@0: { sl@0: delete iSupplier; sl@0: iSupplier = NULL; sl@0: // Convert aData to unicode... sl@0: iSupplier = HBufC::NewL(aData.Length()); sl@0: TPtr ptr = iSupplier->Des(); sl@0: User::LeaveIfError(CnvUtfConverter::ConvertToUnicodeFromUtf8(ptr, aData)); sl@0: } sl@0: sl@0: void CMMFPluginImplementationInformation::AddMediaIdL(const TDesC8& aData) sl@0: { sl@0: TUid mediaId; sl@0: TaggedDataParser::ConvertTextToUidL(aData, mediaId); sl@0: User::LeaveIfError(iMediaIds.Append(mediaId)); sl@0: } sl@0: sl@0: CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewL(const CImplementationInformation& aImplInfo) sl@0: { sl@0: CMMFControllerImplementationInformation* s = CMMFControllerImplementationInformation::NewLC(aImplInfo); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewLC(const CImplementationInformation& aImplInfo) sl@0: { sl@0: CMMFControllerImplementationInformation* s = new(ELeave) CMMFControllerImplementationInformation; sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(aImplInfo); sl@0: return s; sl@0: } sl@0: sl@0: EXPORT_C CMMFControllerImplementationInformation* CMMFControllerImplementationInformation::NewL(TUid aUid) sl@0: { sl@0: RImplInfoPtrArray ecomArray; sl@0: CleanupResetAndDestroyPushL(ecomArray); sl@0: sl@0: MmPluginUtils::FindImplementationsL(KUidInterfaceMMFController, ecomArray); sl@0: sl@0: TInt index; sl@0: CMMFControllerImplementationInformation* controller = NULL; sl@0: // Create Controller Implementation Information for the entry with the requested UID sl@0: for (index=0; indexImplementationUid()==aUid) sl@0: { sl@0: // Create the impl info object, and get the play and record formats supported by the plugin sl@0: controller = CMMFControllerImplementationInformation::NewL(*(ecomArray[index])); sl@0: sl@0: CleanupStack::PushL(controller); // INC023207 - Placed controller on CleanupStack sl@0: controller->GetPlayFormatsL(); sl@0: controller->GetRecordFormatsL(); // INC023207 sl@0: CleanupStack::Pop(); sl@0: } sl@0: } sl@0: sl@0: if (controller == NULL) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); // ecomArray sl@0: return controller; sl@0: } sl@0: sl@0: EXPORT_C const RMMFFormatImplInfoArray& CMMFControllerImplementationInformation::PlayFormats() const sl@0: { sl@0: return iPlayFormats; sl@0: } sl@0: sl@0: EXPORT_C const RMMFFormatImplInfoArray& CMMFControllerImplementationInformation::RecordFormats() const sl@0: { sl@0: return iRecordFormats; sl@0: } sl@0: sl@0: sl@0: EXPORT_C TUint CMMFControllerImplementationInformation::HeapSpaceRequired() const sl@0: { sl@0: return iHeapSpaceRequired; sl@0: } sl@0: sl@0: EXPORT_C TUint CMMFControllerImplementationInformation::StackSize() const sl@0: { sl@0: return iStackSize; sl@0: } sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Returns the uri schemes of this plugin. sl@0: sl@0: @return The array of uri schemes. sl@0: */ sl@0: EXPORT_C const CDesC8Array& CMMFControllerImplementationInformation::SupportedUriSchemes() const sl@0: { sl@0: return *iUriSchemes; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Tests whether the plugin supports aUriScheme. sl@0: sl@0: @param aUriScheme sl@0: The required Uri Scheme. sl@0: sl@0: @return A boolean indicating if the plugin supports aUriScheme. ETrue if this plugin supports aUriScheme, EFalse if not. sl@0: */ sl@0: EXPORT_C TBool CMMFControllerImplementationInformation::SupportsUriScheme(const TDesC8& aUriScheme) const sl@0: { sl@0: TInt position; sl@0: TInt error = iUriSchemes->FindIsq(aUriScheme, position, ECmpFolded); sl@0: return (error==KErrNone); sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Sets the uri priority of this controller sl@0: sl@0: @param aUriPriority sl@0: The Uri priority to be assigned. sl@0: */ sl@0: EXPORT_C void CMMFControllerImplementationInformation::SetUriPriority(TInt aUriPriority) sl@0: { sl@0: iUriPriority = aUriPriority; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Retrieves the uri priority of this controller sl@0: sl@0: @return The assigned Uri priority. sl@0: */ sl@0: EXPORT_C TInt CMMFControllerImplementationInformation::UriPriority() const sl@0: { sl@0: return iUriPriority; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Tests whether the controller plugin supports url sl@0: sl@0: @return A boolean indicating if the plugin supports url. ETrue for uri supporting controller, EFalse if not. sl@0: */ sl@0: EXPORT_C TBool CMMFControllerImplementationInformation::SupportsNetworkCapability() const sl@0: { sl@0: return iIsNetworkCtrl; sl@0: } sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @prototype sl@0: sl@0: Check whether the controller plugin supports secure DRM process mode sl@0: sl@0: @return A boolean indicating if the plugin supports secure DRM process mode. sl@0: */ sl@0: EXPORT_C TBool CMMFControllerImplementationInformation::SupportsSecureDRMProcessMode() const sl@0: { sl@0: return iSupportsSecureDRMProcessMode; sl@0: } sl@0: sl@0: CMMFControllerImplementationInformation::CMMFControllerImplementationInformation() sl@0: { sl@0: iUriPriority = KUriPriorityNone; sl@0: iIsNetworkCtrl = ETrue; sl@0: iPlayFormatCollectionUid = KNullUid; sl@0: iRecordFormatCollectionUid = KNullUid; sl@0: iHeapSpaceRequired = KMMFDefaultControllerThreadHeapSize; sl@0: iSupportsSecureDRMProcessMode = EFalse; sl@0: iStackSize = KDefaultStackSize; sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::ConstructL(const CImplementationInformation& aImplInfo) sl@0: { sl@0: iUriSchemes = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); sl@0: iUid = aImplInfo.ImplementationUid(); sl@0: iDisplayName = aImplInfo.DisplayName().AllocL(); sl@0: iVersion = aImplInfo.Version(); sl@0: sl@0: // Parse the opaque data... sl@0: TaggedDataParser::ParseTaggedDataL(aImplInfo.OpaqueData(), *this); sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aData) sl@0: { sl@0: if (aTag==KSupplier) sl@0: { sl@0: SetSupplierL(aData); sl@0: } sl@0: else if (aTag==KMediaId) sl@0: { sl@0: AddMediaIdL(aData); sl@0: } sl@0: else if (aTag==KUriScheme) sl@0: { sl@0: SetUriSchemeL(aData); sl@0: } sl@0: else if (aTag==KNonNetwork) sl@0: { sl@0: SetNetworkCapabilityL(aData); sl@0: } sl@0: else if (aTag==KPlayFormatCollectionUid) sl@0: { sl@0: SetPlayFormatCollectionUidL(aData); sl@0: } sl@0: else if (aTag==KRecordFormatCollectionUid) sl@0: { sl@0: SetRecordFormatCollectionUidL(aData); sl@0: } sl@0: else if(aTag==KHeapSize) sl@0: { sl@0: SetHeapSizeL(aData); sl@0: } sl@0: else if (aTag==KSecureDRMProcessMode) sl@0: { sl@0: iSupportsSecureDRMProcessMode = ETrue; sl@0: } sl@0: else if (aTag==KStackSize) sl@0: { sl@0: SetStackSizeL(aData); sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: } sl@0: sl@0: sl@0: CMMFControllerImplementationInformation::~CMMFControllerImplementationInformation() sl@0: { sl@0: iPlayFormats.ResetAndDestroy(); sl@0: iRecordFormats.ResetAndDestroy(); sl@0: delete iUriSchemes; sl@0: } sl@0: sl@0: sl@0: void CMMFControllerImplementationInformation::SetPlayFormatCollectionUidL(const TDesC8& aData) sl@0: { sl@0: TaggedDataParser::ConvertTextToUidL(aData, iPlayFormatCollectionUid); sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::SetRecordFormatCollectionUidL(const TDesC8& aData) sl@0: { sl@0: TaggedDataParser::ConvertTextToUidL(aData, iRecordFormatCollectionUid); sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::SetHeapSizeL(const TDesC8& aData) sl@0: { sl@0: TaggedDataParser::ConvertTextToTUintL(aData, iHeapSpaceRequired); sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::SetStackSizeL(const TDesC8& aData) sl@0: { sl@0: TaggedDataParser::ConvertTextToTUintL(aData, iStackSize); sl@0: } sl@0: sl@0: sl@0: void CMMFControllerImplementationInformation::AddFormatsSwallowCorruptL(RImplInfoPtrArray& aEcomArray, RMMFFormatImplInfoArray& aFormatArray) sl@0: { sl@0: for (TInt index=0; index controllerUid; sl@0: _LIT8(K0x, "0x"); sl@0: controllerUid.Append(K0x); sl@0: controllerUid.AppendNumFixedWidth(iUid.iUid, EHex, 8); sl@0: sl@0: MmPluginUtils::FindImplementationsL(aFormatPluginCollectionUid, ecomArray, controllerUid); sl@0: // Create format implementation information for each entry sl@0: AddFormatsSwallowCorruptL(ecomArray, aFormatArray); sl@0: sl@0: CleanupStack::PopAndDestroy();//ecomArray sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::GetPlayFormatsL() sl@0: { sl@0: GetFormatsL(iPlayFormatCollectionUid, KUidInterfaceFormatDecode, iPlayFormats); sl@0: } sl@0: sl@0: void CMMFControllerImplementationInformation::GetRecordFormatsL() sl@0: { sl@0: GetFormatsL(iRecordFormatCollectionUid, KUidInterfaceFormatEncode, iRecordFormats); sl@0: } sl@0: sl@0: /** sl@0: Sets the Uri Scheme found in opaque data sl@0: sl@0: @param aUriScheme sl@0: Gives the uri scheme supported by the controller sl@0: */ sl@0: void CMMFControllerImplementationInformation::SetUriSchemeL(const TDesC8& aUriScheme) sl@0: { sl@0: //If No uri support already declared in the resource file, sl@0: //then mentioning a particular schema support is illegal sl@0: if(!iIsNetworkCtrl) sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: // Insert the new uri scheme into the array sl@0: iUriSchemes->InsertIsqL(aUriScheme, ECmpFolded);//ensures there are no repeated entries sl@0: } sl@0: sl@0: /** sl@0: Sets the Network capability found in opaque data sl@0: sl@0: @param aNetworkCapable sl@0: Declares the incapability to support uri if matches to 'yes'. sl@0: If this is the case, iIsNetworkCtrl is set to EFalse sl@0: */ sl@0: void CMMFControllerImplementationInformation::SetNetworkCapabilityL(const TDesC8& aNetworkCapable) sl@0: { sl@0: //If a uri scheme is already declared in the resource file, sl@0: //then mentioning no url support is illegal sl@0: if(iUriSchemes->Count() > 0) sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: if (aNetworkCapable.CompareF(KTagYes) == KErrNone) sl@0: { sl@0: iIsNetworkCtrl = EFalse; sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrBadName); // will leave if aNetworkCapable is anything other than 'yes'. sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CMMFFormatImplementationInformation* CMMFFormatImplementationInformation::NewL(const CImplementationInformation& aImplInfo) sl@0: { sl@0: CMMFFormatImplementationInformation* s = CMMFFormatImplementationInformation::NewLC(aImplInfo); sl@0: CleanupStack::Pop(s); sl@0: return s; sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation* CMMFFormatImplementationInformation::NewLC(const CImplementationInformation& aImplInfo) sl@0: { sl@0: CMMFFormatImplementationInformation* s = new(ELeave) CMMFFormatImplementationInformation(); sl@0: CleanupStack::PushL(s); sl@0: s->ConstructL(aImplInfo); sl@0: return s; sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation::CMMFFormatImplementationInformation() sl@0: { sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::ConstructL(const CImplementationInformation& aImplInfo) sl@0: { sl@0: iUid = aImplInfo.ImplementationUid(); sl@0: iDisplayName = aImplInfo.DisplayName().AllocL(); sl@0: sl@0: iBody = CMMFFormatImplementationInformation::CBody::NewL(); sl@0: sl@0: // Extract the rest of the data from the opaque data field of aImplInfo... sl@0: // Parse the opaque data... sl@0: TaggedDataParser::ParseTaggedDataL(aImplInfo.OpaqueData(), *this); sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aTagData) sl@0: { sl@0: if (aTag == KSupplier) sl@0: SetSupplierL(aTagData); sl@0: else if (aTag == KMediaId) sl@0: AddMediaIdL(aTagData); sl@0: else if (aTag == KFormatFileExtension) sl@0: AddFileExtensionL(aTagData); sl@0: else if (aTag == KFormatMimeType) sl@0: AddMimeTypeL(aTagData); sl@0: else if (aTag == KFormatHeaderData) sl@0: AddHeaderDataL(aTagData); sl@0: else if ((aTag == KCustomInterfaceSupport) && (aTagData.CompareF(KTagYes) == 0)) sl@0: iBody->SetSupportsCustomInterfaces(ETrue); sl@0: else sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::AddFileExtensionL(const TDesC8& aData) sl@0: { sl@0: iBody->AddFileExtensionL(aData); sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::AddMimeTypeL(const TDesC8& aData) sl@0: { sl@0: iBody->AddMimeTypeL(aData); sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::AddHeaderDataL(const TDesC8& aData) sl@0: { sl@0: iBody->AddHeaderDataL(aData); sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation::~CMMFFormatImplementationInformation() sl@0: { sl@0: delete iBody; sl@0: } sl@0: sl@0: EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedFileExtensions() const sl@0: { sl@0: return iBody->SupportedFileExtensions(); sl@0: } sl@0: sl@0: EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedMimeTypes() const sl@0: { sl@0: return iBody->SupportedMimeTypes(); sl@0: } sl@0: sl@0: EXPORT_C const CDesC8Array& CMMFFormatImplementationInformation::SupportedHeaderData() const sl@0: { sl@0: return iBody->SupportedHeaderData(); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TBool CMMFFormatImplementationInformation::SupportsFileExtension(const TDesC8& aFileExtension) const sl@0: { sl@0: return iBody->SupportsFileExtension(aFileExtension); sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFFormatImplementationInformation::SupportsMimeType(const TDesC8& aMimeType) const sl@0: { sl@0: return iBody->SupportsMimeType(aMimeType); sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFFormatImplementationInformation::SupportsHeaderDataL(const TDesC8& aHeaderData) const sl@0: { sl@0: return iBody->SupportsHeaderDataL(aHeaderData); sl@0: } sl@0: sl@0: EXPORT_C TBool CMMFFormatImplementationInformation::SupportsCustomInterfaces() const sl@0: { sl@0: return iBody->SupportsCustomInterfaces(); sl@0: } sl@0: sl@0: CMatchData* CMatchData::CreateL() sl@0: { sl@0: return new (ELeave) CMatchData(); sl@0: } sl@0: sl@0: void CMatchData::SetMatchDataL(const TDesC8& aMatchData) sl@0: { sl@0: delete iMatchData; sl@0: iMatchData = NULL; sl@0: sl@0: iMatchData = aMatchData.AllocL(); sl@0: } sl@0: sl@0: void CMatchData::SetMatchUriSchemeL(const TDesC8& aMatchUriScheme) sl@0: { sl@0: delete iMatchUriScheme; sl@0: iMatchUriScheme = NULL; sl@0: sl@0: iMatchUriScheme = aMatchUriScheme.AllocL(); sl@0: } sl@0: sl@0: const TDesC8& CMatchData::MatchData() const sl@0: { sl@0: if (iMatchData ) sl@0: { sl@0: return *iMatchData; sl@0: } sl@0: else sl@0: { sl@0: return KNullDesC8; sl@0: } sl@0: } sl@0: sl@0: const TDesC8& CMatchData::MatchUriScheme() const sl@0: { sl@0: if (iMatchUriScheme ) sl@0: { sl@0: return *iMatchUriScheme; sl@0: } sl@0: else sl@0: { sl@0: return KNullDesC8; sl@0: } sl@0: } sl@0: sl@0: CMatchData::~CMatchData() sl@0: { sl@0: delete iMatchData; sl@0: delete iMatchUriScheme; sl@0: } sl@0: