|
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 EXIFREADERWRITER_H |
|
17 #define EXIFREADERWRITER_H |
|
18 |
|
19 #include <iclexif.h> // For MExifMetadata declaration |
|
20 |
|
21 // Forward declarations |
|
22 class CIfdGeneral; |
|
23 class CIfd0; |
|
24 class CIfd1; |
|
25 class CExifIfd; |
|
26 class CInteropIfd; |
|
27 class CGpsIfd; |
|
28 |
|
29 class CExifReaderWriter : public CBase, public MExifMetadata |
|
30 { |
|
31 public: |
|
32 friend class CExifVerifier; |
|
33 |
|
34 public: |
|
35 ~CExifReaderWriter(); |
|
36 |
|
37 // Functions derived from MExifMetaData |
|
38 TInt GetIntegerParam(TUint aTag, TUint aIfd, TInt& aParam) const; |
|
39 TInt GetShortParam(TUint aTag, TUint aIfd, TUint16& aParam) const; |
|
40 TInt GetRationalParam(TUint aTag, TUint aIfd, TInt& aNumer, TInt& aDenom) const; |
|
41 TInt GetParam8(TUint aTag, TUint aIfd, HBufC8*& aParam) const; |
|
42 TInt GetParam16(TUint aTag, TUint aIfd, HBufC16*& aParam) const; |
|
43 TInt GetIntegerArrayParam(TUint aTag, TUint aIfd, CArrayFix<TInt>& aParam) const; |
|
44 TInt GetShortArrayParam(TUint aTag, TUint aIfd, CArrayFix<TUint16>& aParam) const; |
|
45 TInt GetRationalArrayParam(TUint aTag, TUint aIfd, CArrayFix<TRational>& aParam) const; |
|
46 |
|
47 TInt SetParam8(TUint aTag, TUint aIfd, HBufC8* aParam); |
|
48 TInt SetParam16(TUint aTag, TUint aIfd, HBufC16* aParam); |
|
49 TInt SetIntegerParam(TUint aTag, TUint aIfd, TInt aParam); |
|
50 TInt SetShortParam(TUint aTag, TUint aIfd, TUint16 aParam); |
|
51 TInt SetRationalParam(TUint aTag, TUint aIfd, TInt aNumerator, TInt aDenominator); |
|
52 TInt SetIntegerArrayParam(TUint aTag, TUint aIfd, CArrayFix<TInt>& aParam); |
|
53 TInt SetShortArrayParam(TUint aTag, TUint aIfd, CArrayFix<TUint16>& aParam); |
|
54 TInt SetRationalArrayParam(TUint aTag, TUint aIfd, CArrayFix<TRational>& aParam); |
|
55 |
|
56 |
|
57 virtual HBufC8* GetJpegThumbnailData(); |
|
58 virtual void SetThumbnailData(HBufC8* aJpegData); |
|
59 |
|
60 TBool IsExifDataModified(); |
|
61 void ResetExifDataModified(); |
|
62 |
|
63 // Helper Function |
|
64 static TUint ReadUint32(const TBool aIntelByteAlign, const TUint8* aPtr); |
|
65 // Helper Function |
|
66 static TUint16 ReadUint16(const TBool aIntelByteAlign, const TUint8* aPtr); |
|
67 |
|
68 protected: |
|
69 void SetUpIfdsL(); |
|
70 virtual void SetIfd1L()=0; |
|
71 TInt CheckExifOffset(const TUint aOffset); |
|
72 TBool FindIfdIndex(TInt aRealIfd, TInt& aIfdIndex) const; |
|
73 CIfdGeneral* GetIfd(TInt aIndex); |
|
74 void RemoveThumbnailData(); |
|
75 |
|
76 CExifReaderWriter(); |
|
77 |
|
78 void InitializeIfdsL(TBool aAlwaysCreateIfd1, TBool aCreateGpsIfd); |
|
79 void InitializeIfdsL(TUint8* aData, TUint aApp1Size); |
|
80 |
|
81 void SetThumbnailDataBaseL(CIfdGeneral* ifd1, TBool aKeepIfd1); |
|
82 HBufC8* CreateExifHeaderBaseL(); |
|
83 TInt GetThumbnailLengthOffsetBase(TUint& aThumbnailLengthOffset); |
|
84 |
|
85 private: // functions |
|
86 |
|
87 void ReadHeaderL(); |
|
88 TInt InternalIfd(const TUint aTag, const TInt aExternalIfd) const; |
|
89 TInt CheckTagL(const TUint aTag, const TUint aIfd) const; |
|
90 void FindInternalIfdDataL(const TUint aTag, const TUint aExternalIfdNumber, TInt& aInternalIfdNumber, CIfdGeneral*& aInternalIfd); |
|
91 CIfdGeneral* FindIfd(const TUint aTag, const TUint aExternalIfd) const; |
|
92 TInt ProcessGpsIfdAddParamResult(CIfdGeneral*& aGpsIfd, TInt aAddParamResult); |
|
93 CIfdGeneral* CreateAndAppendSubIfdL(CIfdGeneral& aIfd, TUint aTag); |
|
94 |
|
95 // thumbnail helper functions |
|
96 virtual void WriteExifFileHeaderBaseL(const TUint aApp1Size, TUint8*& aPtr); |
|
97 virtual void SetFirstIfdOffsetBase(); |
|
98 |
|
99 TInt DoSetParam8(TUint aTag, TUint aIfd, HBufC8* aParam); |
|
100 TInt DoSetParam16(TUint aTag, TUint aIfd, HBufC16* aParam); |
|
101 TInt DoSetIntegerParam(TUint aTag, TUint aIfd, TInt aParam); |
|
102 TInt DoSetShortParam(TUint aTag, TUint aIfd, TUint16 aParam); |
|
103 TInt DoSetRationalParam(TUint aTag, TUint aIfd, TInt aNumerator, TInt aDenominator); |
|
104 TInt DoSetIntegerArrayParam(TUint aTag, TUint aIfd, CArrayFix<TInt>& aParam); |
|
105 TInt DoSetShortArrayParam(TUint aTag, TUint aIfd, CArrayFix<TUint16>& aParam); |
|
106 TInt DoSetRationalArrayParam(TUint aTag, TUint aIfd, CArrayFix<TRational>& aParam); |
|
107 |
|
108 protected: |
|
109 RPointerArray<CIfdGeneral> iIfds; //own IFDs |
|
110 TBool iEncodeThumbnail; |
|
111 TUint8* iData; |
|
112 TBool iIntel; |
|
113 const TUint8* iBase; |
|
114 TUint16 iExifDataLength; // used to check that offsets are within a valid range |
|
115 |
|
116 private: // member variables |
|
117 TUint iOffsetToZerothIfd; |
|
118 HBufC8* iJpegThumbnailData; |
|
119 TBool iExifDataModified; |
|
120 }; |
|
121 |
|
122 #endif // EXIFREADERWRITER_H |