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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <ecom/ecom.h>
22 #include <ecom/implementationproxy.h>
23 #include "constants.h"
26 // This class is used to store the results of a match.
27 // iConfidence - the confidence of the match
28 // iMime - the matched mime-type.
34 : iConfidence(CApaDataRecognizerType::ENotRecognized),
39 TMatch(TInt aConfidence, const TText8* aMime)
40 : iConfidence(aConfidence),
47 iConfidence = KConfNotRecognised;
57 // Function prototype for custom format recogniser functions.
58 // Forward declaration of CReader required.
61 typedef void (*TCustomProc)(const TDesC& aFileExt, CReader& aReader, TMatch& aMatch);
65 // These macros are used when creating the KSigs table.
66 // CUSTOM_SIG - this is to be used when a format cannot be identified
67 // from a known header pattern. It takes the MIME-type it
68 // tries to identify and a pointer to a function that
69 // does the identification.
70 // HEADER_SIG - this is to be used when a format can be identified
71 // from a known header pattern.
73 #define CUSTOM_SIG(mime, funcPtr) {NULL, (mime), (TAny*)(funcPtr), 0}
74 #define HEADER_SIG(mime, ext, header) {(ext), (mime), (TAny*)_S8(header), sizeof(header) - 1}
78 // This structure tells the recogniser how to match a format.
79 // iExt - the standard file extension for the format.
80 // iMime - the defined MIME-type for the format.
81 // iHeaderOrProc - a pointer to either a header signature pattern
82 // (if iHeaderLen = 0) or a function that carries
83 // out in-depth parsing of the file (if iHeaderLen > 0)
84 // iHeaderLen - the length of the header signature in characters, or zero
85 // if iHeaderOrProc is a pointer to a function.
97 // UIDs taken from Multimedia Allocation Table.
98 static const TInt KRecogniserUID = 0x1027381A;
99 static const TUid KMMRUFDLLUid = {0x102825F6};
101 // The amount of file data wanted from the AppArc framework.
102 static const TInt KPreferredBufSize = 256;
104 // The recogniser priority.
105 static const TInt KRecogniserPriority = CApaDataRecognizerType::ENormal;
109 // This class does the recognising.
111 class CMMRUF : public CApaDataRecognizerType
114 static CMMRUF* NewL();
116 TDataType SupportedDataTypeL(TInt aIndex) const;
117 TDataType SupportedDataTypeL(const TText8* aMime) const;
118 TUint PreferredBufSize();
121 void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
122 void SetDataTypeL(TInt aConfidence, const TText8* aMime);
123 TUint8 MatchExtension(const TDesC& aFileName, const TText* aExt) const;
124 TUint8 MatchHeader(const TDesC8& aBuffer, const TDesC8& aHeader) const;