sl@0: // Copyright (c) 2006-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 "MMFFormatImplementationInformationBody.h" sl@0: sl@0: const TInt KDesCArrayGranularity = 1; sl@0: sl@0: CMMFFormatImplementationInformation::CBody* CMMFFormatImplementationInformation::CBody::NewL() sl@0: { sl@0: CMMFFormatImplementationInformation::CBody* self = CMMFFormatImplementationInformation::CBody::NewLC(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation::CBody* CMMFFormatImplementationInformation::CBody::NewLC() sl@0: { sl@0: CMMFFormatImplementationInformation::CBody* self = new(ELeave) CMMFFormatImplementationInformation::CBody(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation::CBody::CBody() sl@0: { sl@0: } sl@0: sl@0: CMMFFormatImplementationInformation::CBody::~CBody() sl@0: { sl@0: delete iFileExtensions; sl@0: delete iMimeTypes; sl@0: delete iHeaderData; sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::CBody::ConstructL() sl@0: { sl@0: // Create the descriptor arrays sl@0: iFileExtensions = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); sl@0: iMimeTypes = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); sl@0: iHeaderData = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::CBody::AddFileExtensionL(const TDesC8& aData) sl@0: { sl@0: // Insert the new file extension into the array sl@0: iFileExtensions->InsertIsqL(aData, ECmpFolded);//ensures there are no repeated entries sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::CBody::AddMimeTypeL(const TDesC8& aData) sl@0: { sl@0: // Insert the new file extension into the array sl@0: TInt position; sl@0: if (iMimeTypes->Find(aData, position) != 0) sl@0: iMimeTypes->AppendL(aData);//ensures there are no repeated entries sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::CBody::AddHeaderDataL(const TDesC8& aData) sl@0: { sl@0: // Insert the new file extension into the array, only if its not empty sl@0: if (aData.Length() > 0) sl@0: { sl@0: iHeaderData->InsertIsqL(aData, ECmpFolded);//ensures there are no repeated entries sl@0: } sl@0: } sl@0: sl@0: void CMMFFormatImplementationInformation::CBody::SetSupportsCustomInterfaces(const TBool aSupportsCustomInterfaces) sl@0: { sl@0: iSupportsCustomInterfaces = aSupportsCustomInterfaces; sl@0: } sl@0: sl@0: const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedFileExtensions() const sl@0: { sl@0: return *iFileExtensions; sl@0: } sl@0: sl@0: const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedMimeTypes() const sl@0: { sl@0: return *iMimeTypes; sl@0: } sl@0: sl@0: const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedHeaderData() const sl@0: { sl@0: return *iHeaderData; sl@0: } sl@0: sl@0: sl@0: TBool CMMFFormatImplementationInformation::CBody::SupportsFileExtension(const TDesC8& aFileExtension) const sl@0: { sl@0: TInt position; sl@0: TInt error = iFileExtensions->FindIsq(aFileExtension, position, ECmpFolded); sl@0: return (error==KErrNone); sl@0: } sl@0: sl@0: TBool CMMFFormatImplementationInformation::CBody::SupportsMimeType(const TDesC8& aMimeType) const sl@0: { sl@0: TInt position; sl@0: TInt error = iMimeTypes->Find(aMimeType, position, ECmpFolded); sl@0: return (error==KErrNone); sl@0: } sl@0: sl@0: TBool CMMFFormatImplementationInformation::CBody::SupportsHeaderDataL(const TDesC8& aHeaderData) const sl@0: { sl@0: TBool matchFound = EFalse; sl@0: // Search aHeaderData for each chunk of header data in iHeaderData sl@0: for (TInt i=0; iCount(); i++) sl@0: { sl@0: TPtrC8 headerData = (*iHeaderData)[i]; sl@0: // search for match section in the main buffer. sl@0: // ...by putting it in wildcards! sl@0: HBufC8* wildMatch = HBufC8::NewLC( headerData.Length() + 1) ; sl@0: TPtr8 wildMatchPtr = wildMatch->Des() ; sl@0: wildMatchPtr.Copy( headerData ) ; sl@0: _LIT8(KStar, "*"); sl@0: wildMatchPtr.Append( KStar ) ; sl@0: if (aHeaderData.MatchF(*wildMatch) != KErrNotFound) sl@0: { sl@0: matchFound = ETrue; sl@0: } sl@0: CleanupStack::PopAndDestroy(wildMatch);//wildMatch sl@0: if (matchFound) sl@0: break; sl@0: } sl@0: return matchFound; sl@0: } sl@0: sl@0: TBool CMMFFormatImplementationInformation::CBody::SupportsCustomInterfaces() const sl@0: { sl@0: return iSupportsCustomInterfaces; sl@0: } sl@0: