os/mm/mmlibs/mmfw/src/ControllerFramework/MMFFormatImplementationInformationBody.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <badesca.h>
    17 #include "MMFFormatImplementationInformationBody.h"
    18 
    19 const TInt KDesCArrayGranularity = 1;
    20 
    21 CMMFFormatImplementationInformation::CBody* CMMFFormatImplementationInformation::CBody::NewL()
    22 	{
    23 	CMMFFormatImplementationInformation::CBody* self = CMMFFormatImplementationInformation::CBody::NewLC();
    24 	CleanupStack::Pop(self);
    25 	return self;
    26 	}
    27 
    28 CMMFFormatImplementationInformation::CBody* CMMFFormatImplementationInformation::CBody::NewLC()
    29 	{
    30 	CMMFFormatImplementationInformation::CBody* self = new(ELeave) CMMFFormatImplementationInformation::CBody();
    31 	CleanupStack::PushL(self);
    32 	self->ConstructL();
    33 	return self;
    34 	}
    35 
    36 CMMFFormatImplementationInformation::CBody::CBody()
    37 	{
    38 	}
    39 
    40 CMMFFormatImplementationInformation::CBody::~CBody()
    41 	{
    42 	delete iFileExtensions;
    43 	delete iMimeTypes;
    44 	delete iHeaderData;
    45 	}
    46 	
    47 void CMMFFormatImplementationInformation::CBody::ConstructL()
    48 	{
    49 	// Create the descriptor arrays
    50 	iFileExtensions = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity);
    51 	iMimeTypes = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity);
    52 	iHeaderData = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity);	
    53 	}
    54 
    55 void CMMFFormatImplementationInformation::CBody::AddFileExtensionL(const TDesC8& aData)
    56 	{
    57 	// Insert the new file extension into the array
    58 	iFileExtensions->InsertIsqL(aData, ECmpFolded);//ensures there are no repeated entries
    59 	}
    60 
    61 void CMMFFormatImplementationInformation::CBody::AddMimeTypeL(const TDesC8& aData)
    62 	{
    63 	// Insert the new file extension into the array
    64 	TInt position;
    65 	if (iMimeTypes->Find(aData, position) != 0)
    66 		iMimeTypes->AppendL(aData);//ensures there are no repeated entries
    67 	}
    68 
    69 void CMMFFormatImplementationInformation::CBody::AddHeaderDataL(const TDesC8& aData)
    70 	{
    71 	// Insert the new file extension into the array, only if its not empty
    72 	if (aData.Length() > 0)
    73 		{
    74 		iHeaderData->InsertIsqL(aData, ECmpFolded);//ensures there are no repeated entries
    75 		}
    76 	}
    77 
    78 void CMMFFormatImplementationInformation::CBody::SetSupportsCustomInterfaces(const TBool aSupportsCustomInterfaces)
    79 	{
    80 	iSupportsCustomInterfaces = aSupportsCustomInterfaces;
    81 	}
    82 
    83 const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedFileExtensions() const
    84 	{
    85 	return *iFileExtensions;
    86 	}
    87 
    88 const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedMimeTypes() const
    89 	{
    90 	return *iMimeTypes;
    91 	}
    92 
    93 const CDesC8Array& CMMFFormatImplementationInformation::CBody::SupportedHeaderData() const
    94 	{
    95 	return *iHeaderData;
    96 	}
    97 
    98 
    99 TBool CMMFFormatImplementationInformation::CBody::SupportsFileExtension(const TDesC8& aFileExtension) const
   100 	{
   101 	TInt position;
   102 	TInt error = iFileExtensions->FindIsq(aFileExtension, position, ECmpFolded);
   103 	return (error==KErrNone);
   104 	}
   105 
   106 TBool CMMFFormatImplementationInformation::CBody::SupportsMimeType(const TDesC8& aMimeType) const
   107 	{
   108 	TInt position;
   109 	TInt error = iMimeTypes->Find(aMimeType, position, ECmpFolded);
   110 	return (error==KErrNone);
   111 	}
   112 
   113 TBool CMMFFormatImplementationInformation::CBody::SupportsHeaderDataL(const TDesC8& aHeaderData) const
   114 	{
   115 	TBool matchFound = EFalse;
   116 	// Search aHeaderData for each chunk of header data in iHeaderData
   117 	for (TInt i=0; i<iHeaderData->Count(); i++)
   118 		{
   119 		TPtrC8 headerData = (*iHeaderData)[i];
   120 		// search for match section in the main buffer.
   121 		// ...by putting it in wildcards!
   122 		HBufC8* wildMatch = HBufC8::NewLC( headerData.Length() + 1) ;
   123 		TPtr8 wildMatchPtr = wildMatch->Des() ;
   124 		wildMatchPtr.Copy( headerData ) ;
   125 		_LIT8(KStar, "*");
   126 		wildMatchPtr.Append( KStar ) ;
   127 		if (aHeaderData.MatchF(*wildMatch) != KErrNotFound)
   128 			{
   129 			matchFound = ETrue;
   130 			}
   131 		CleanupStack::PopAndDestroy(wildMatch);//wildMatch
   132 		if (matchFound)
   133 			break;
   134 		}
   135 	return matchFound;
   136 	}
   137 
   138 TBool CMMFFormatImplementationInformation::CBody::SupportsCustomInterfaces() const
   139 	{
   140 	return iSupportsCustomInterfaces;
   141 	}
   142