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