|
1 // Copyright (c) 2004-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 #ifndef IFDGENERAL_H |
|
17 #define IFDGENERAL_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "ExifTagDescriptions.h" |
|
21 |
|
22 class CIfdGeneralEntry; |
|
23 class CIfdGeneral : public CBase |
|
24 { |
|
25 public: |
|
26 friend class CExifVerifier; |
|
27 |
|
28 public: |
|
29 ~CIfdGeneral(); |
|
30 |
|
31 TInt GetIntegerParam(const TUint aTag, TInt& aParam) const; |
|
32 TInt GetShortParam(const TUint aTag, TUint16& aParam) const; |
|
33 TInt GetRationalParam(const TUint aTag, TInt& aNumer, TInt& aDenom) const; |
|
34 TInt GetParam8(const TUint aTag, HBufC8*& aParam) const; |
|
35 TInt GetParam16(const TUint aTag, HBufC16*& aParam) const; |
|
36 |
|
37 void GetIntegerArrayParamL(const TUint aTag, CArrayFix<TInt>& aParam) const; |
|
38 void GetShortArrayParamL(const TUint aTag, CArrayFix<TUint16>& aParam) const; |
|
39 void GetRationalArrayParamL(const TUint aTag, CArrayFix<TRational>& aParam) const; |
|
40 |
|
41 // Returns the number of bytes stored by an Ifd. |
|
42 TInt Size() const; |
|
43 |
|
44 // Can only be called by the 0th Ifd (otherwise returns KErrNotSupported). |
|
45 TInt GetOffsetToFirstIfd(TUint& aOffset) const; |
|
46 |
|
47 TInt Ifd() const; // returns the identifying Ifd. |
|
48 |
|
49 virtual TUint8* CreateIfdBlockL(TUint aOffset); |
|
50 |
|
51 TUint EntryCount() const; |
|
52 |
|
53 // Set the data of existing tag entries. |
|
54 TInt SetParam8(const TUint aTag, HBufC8* aParam); |
|
55 TInt SetParam16(const TUint aTag, HBufC16* aParam); |
|
56 TInt SetIntegerParam(const TUint aTag, const TInt aParam); |
|
57 TInt SetShortParam(const TUint aTag, const TUint16 aParam); |
|
58 TInt SetRationalParam(const TUint aTag, const TInt aNumerator, const TInt aDenominator); |
|
59 void SetIntegerArrayParamL(const TUint aTag, const CArrayFix<TInt>& aParam); |
|
60 void SetRationalArrayParamL(const TUint aTag, const CArrayFix<TRational>& aParam); |
|
61 void SetShortArrayParamL(const TUint aTag, const CArrayFix<TUint16>& aParam); |
|
62 |
|
63 // Add a new entry. |
|
64 void AddParam8L(const TUint aTag, const TUint aFormat, const TUint aComponentCount, HBufC8* aParam); |
|
65 void AddParam16L(const TUint aTag, const TUint aFormat, const TUint aComponentCount, HBufC16* aParam); |
|
66 void AddIntegerParamL(const TUint aTag, const TUint aFormat, const TUint aComponentCount, TInt aParam); |
|
67 void AddShortParamL(const TUint aTag, const TUint aFormat, const TUint aComponentCount, TUint16 aParam); |
|
68 void AddRationalParamL(const TUint aTag, const TUint aFormat, const TUint aComponentCount, const TInt aNumerator, const TInt aDenominator); |
|
69 void AddIntegerArrayParamL(const TUint aTag, const TUint aFormat, const CArrayFix<TInt>& aParam); |
|
70 void AddRationalArrayParamL(const TUint aTag, const TUint aFormat, const CArrayFix<TRational>& aParam); |
|
71 void AddShortArrayParamL(const TUint aTag, const TUint aFormat, const CArrayFix<TUint16>& aParam); |
|
72 |
|
73 // Does the given tag exist in this Ifd? |
|
74 TBool EntryExists(const TUint aTag) const; |
|
75 |
|
76 TInt GetFormat(TUint aTag, TUint& aFormat); |
|
77 TInt GetComponentCount(TUint aTag, TUint& aComponentCount); |
|
78 |
|
79 TBool FindTag(const TUint aTag); |
|
80 |
|
81 // Remove an entry |
|
82 void RemoveEntryL(const TUint aTag); |
|
83 |
|
84 virtual void CheckMandatoryEntriesL(); |
|
85 protected: |
|
86 CIfdGeneral(const TInt aIfdNumber, const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
87 void ConstructL(); |
|
88 |
|
89 virtual TInt GetTagIndex(const TUint aTag); |
|
90 virtual TInt GetNumberOfValidTags()=0; |
|
91 virtual const TUint* GetTagInformation(TInt aIndex)=0; |
|
92 |
|
93 virtual TBool AllowNullTags(); |
|
94 //check if the ifd entry count is valid with respect to minimum and maximum value. |
|
95 virtual TBool IsValidIfdEntryCount(TUint16 aIfdEntryCount) const; |
|
96 private: // Functions |
|
97 void SetupDirectoryEntriesL(); |
|
98 void AddAllIfdEntriesL(); |
|
99 CIfdGeneralEntry* CreateIfdEntryLC(const TUint& aTag, const TUint& aFormat, const TUint& aComponentCount, const TUint8* aValuePtr, TUint aValueOffset, TUint aTotalSize, TBool& aUnknownTag); |
|
100 TInt LocateEntry(const TUint16 aTag) const; |
|
101 |
|
102 void WriteIfdDirEntriesL(TUint8* aBlock, TUint aOffset); |
|
103 void WriteIfdData(TUint8* aBlock); |
|
104 |
|
105 |
|
106 protected: // Member variables. |
|
107 const TUint iIfdNumber; |
|
108 const TBool iIntel; |
|
109 const TUint iOffsetToIfd; |
|
110 const TUint8* iBase; // base pointer to ifd entry memory. Not owned |
|
111 const TUint iExifDataLength;// size of EXIF data (i.e. from iBase to the end of |
|
112 // the EXIF data) used for offset checking. |
|
113 |
|
114 TUint16 iIfdEntryCount; // The number of tags a decoded IFD header thinks it has. |
|
115 RPointerArray<CIfdGeneralEntry> iIfdEntries; // iIfdEntries.Count() is the number of valid tags. |
|
116 }; |
|
117 |
|
118 |
|
119 class CIfd0 : public CIfdGeneral |
|
120 { |
|
121 public: |
|
122 static CIfd0* NewLC(const TUint aOffsetToIfd=0, const TUint8* aBase=NULL, const TBool aIntel=EFalse, const TUint aExifDataLength=0); |
|
123 virtual TInt GetNumberOfValidTags(); |
|
124 virtual const TUint* GetTagInformation(TInt aIndex); |
|
125 ~CIfd0(); |
|
126 protected: |
|
127 void ConstructL(); |
|
128 virtual TBool IsValidIfdEntryCount(TUint16 aIfdEntryCount) const; |
|
129 //Gets information about manufacturer name, model name and UI platform - depending on the tagvalue |
|
130 HBufC8* GetDeviceInfo(TUint aTagValue); |
|
131 private: |
|
132 CIfd0(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
133 protected: |
|
134 //buffer for storing manufaturer, model and UI platform |
|
135 HBufC8* iManufacturerName; |
|
136 HBufC8* iModelName; |
|
137 HBufC8* iUIPlatform; |
|
138 TUint iTag010F[6]; |
|
139 TUint iTag0110[6]; |
|
140 TUint iTag0131[6]; |
|
141 }; |
|
142 |
|
143 class CExifIfd : public CIfdGeneral |
|
144 { |
|
145 public: |
|
146 static CExifIfd* NewLC(const TUint aOffsetToIfd=0, const TUint8* aBase=NULL, const TBool aIntel=EFalse, const TUint aExifDataLength=0); |
|
147 static CExifIfd* NewL(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
148 virtual TInt GetNumberOfValidTags(); |
|
149 virtual const TUint* GetTagInformation(TInt aIndex); |
|
150 virtual void CheckMandatoryEntriesL(); |
|
151 TBool CheckImageSizeTags(); |
|
152 void UpdateImageSizeTagsL(const TSize& aSize); |
|
153 private: |
|
154 CExifIfd(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
155 }; |
|
156 |
|
157 class CInteropIfd : public CIfdGeneral |
|
158 { |
|
159 public: |
|
160 static CInteropIfd* NewLC(const TUint aOffsetToIfd=0, const TUint8* aBase=NULL, const TBool aIntel=EFalse, const TUint aExifDataLength=0); |
|
161 static CInteropIfd* NewL(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
162 virtual TInt GetNumberOfValidTags(); |
|
163 virtual const TUint* GetTagInformation(TInt aIndex); |
|
164 |
|
165 protected: |
|
166 virtual TBool IsValidIfdEntryCount(TUint16 aIfdEntryCount) const; |
|
167 |
|
168 private: |
|
169 CInteropIfd(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
170 }; |
|
171 |
|
172 class CIfd1 : public CIfdGeneral |
|
173 { |
|
174 public: |
|
175 static CIfd1* NewLC(const TUint aOffsetToIfd=0, const TUint8* aBase=NULL, const TBool aIntel=EFalse, const TUint aExifDataLength=0); |
|
176 virtual TInt GetNumberOfValidTags(); |
|
177 virtual const TUint* GetTagInformation(TInt aIndex); |
|
178 |
|
179 private: |
|
180 CIfd1(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
181 }; |
|
182 |
|
183 class CGpsIfd : public CIfdGeneral |
|
184 { |
|
185 public: |
|
186 static CGpsIfd* NewLC(const TUint aOffsetToIfd=0, const TUint8* aBase=NULL, const TBool aIntel=EFalse, const TUint aExifDataLength=0); |
|
187 static CGpsIfd* NewL(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
188 virtual TInt GetNumberOfValidTags(); |
|
189 virtual const TUint* GetTagInformation(TInt aIndex); |
|
190 |
|
191 protected: |
|
192 virtual TBool IsValidIfdEntryCount(TUint16 aIfdEntryCount) const; |
|
193 |
|
194 TBool AllowNullTags(); |
|
195 |
|
196 private: |
|
197 CGpsIfd(const TUint aOffsetToIfd, const TUint8* aBase, const TBool aIntel, const TUint aExifDataLength); |
|
198 }; |
|
199 |
|
200 |
|
201 #endif // IFDGENERAL_H |