|
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 |
|
17 #include <mtp/cmtptypeobjectinfo.h> |
|
18 #include <mtp/mtpdatatypeconstants.h> |
|
19 #include <mtp/mtptypescomplex.h> |
|
20 |
|
21 #include "mtpdatatypespanic.h" |
|
22 |
|
23 // Dataset constants |
|
24 const TUint CMTPTypeObjectInfo::KFlatChunkSize(52); |
|
25 |
|
26 // Dataset element metadata. |
|
27 const CMTPTypeCompoundBase::TElementInfo CMTPTypeObjectInfo::iElementMetaData[CMTPTypeObjectInfo::ENumElements] = |
|
28 { |
|
29 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 0, KMTPTypeUINT32Size}}, // EStorageID |
|
30 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT16, 4, KMTPTypeUINT16Size}}, // EObjectFormat |
|
31 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT16, 6, KMTPTypeUINT16Size}}, // EProtectionStatus |
|
32 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 8, KMTPTypeUINT32Size}}, // EObjectCompressedSize |
|
33 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT16, 12, KMTPTypeUINT16Size}}, // EThumbFormat |
|
34 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 14, KMTPTypeUINT32Size}}, // EThumbCompressedSize |
|
35 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 18, KMTPTypeUINT32Size}}, // EThumbPixWidth |
|
36 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 22, KMTPTypeUINT32Size}}, // EThumbPixHeight |
|
37 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 26, KMTPTypeUINT32Size}}, // EImagePixWidth |
|
38 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 30, KMTPTypeUINT32Size}}, // EImagePixHeight |
|
39 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 34, KMTPTypeUINT32Size}}, // EImageBitDepth |
|
40 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 38, KMTPTypeUINT32Size}}, // EParentObject |
|
41 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT16, 42, KMTPTypeUINT16Size}}, // EAssociationType |
|
42 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 44, KMTPTypeUINT32Size}}, // EAssociationDescription |
|
43 {EIdFlat1Chunk, EMTPTypeFlat, {EMTPTypeUINT32, 48, KMTPTypeUINT32Size}}, // ESequenceNumber |
|
44 {EIdFilenameChunk, EMTPTypeString, {EMTPTypeString, KMTPNotApplicable, KMTPNotApplicable}}, // EFilename |
|
45 {EIdDateCreatedChunk, EMTPTypeString, {EMTPTypeString, KMTPNotApplicable, KMTPNotApplicable}}, // EDateCreated |
|
46 {EIdDateModifiedChunk, EMTPTypeString, {EMTPTypeString, KMTPNotApplicable, KMTPNotApplicable}}, // EDateModified |
|
47 {EIdKeywordsChunk, EMTPTypeString, {EMTPTypeString, KMTPNotApplicable, KMTPNotApplicable}}, // EKeywords |
|
48 }; |
|
49 |
|
50 /** |
|
51 MTP ObjectInfo dataset factory method. This method is used to create an empty |
|
52 MTP ObjectInfo dataset type. A pointer to the data type is placed on the |
|
53 cleanup stack. |
|
54 @return A pointer to an empty MTP ObjectInfo dataset type. Ownership IS |
|
55 transfered. |
|
56 @leave One of the system wide error codes, if unsuccessful. |
|
57 */ |
|
58 EXPORT_C CMTPTypeObjectInfo* CMTPTypeObjectInfo::NewL() |
|
59 { |
|
60 CMTPTypeObjectInfo* self = CMTPTypeObjectInfo::NewLC(); |
|
61 CleanupStack::Pop(self); |
|
62 return self; |
|
63 } |
|
64 |
|
65 /** |
|
66 MTP ObjectInfo dataset factory method. This method is used to create an empty |
|
67 MTP ObjectInfo dataset type. |
|
68 @return A pointer to an empty MTP ObjectInfo dataset type. Ownership IS |
|
69 transfered. |
|
70 @leave One of the system wide error codes, if unsuccessful. |
|
71 */ |
|
72 EXPORT_C CMTPTypeObjectInfo* CMTPTypeObjectInfo::NewLC() |
|
73 { |
|
74 CMTPTypeObjectInfo* self = new (ELeave) CMTPTypeObjectInfo(); |
|
75 CleanupStack::PushL(self); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 /** |
|
81 Destructor. |
|
82 */ |
|
83 EXPORT_C CMTPTypeObjectInfo::~CMTPTypeObjectInfo() |
|
84 { |
|
85 iChunkFlat.Close(); |
|
86 iChunksString.ResetAndDestroy(); |
|
87 } |
|
88 |
|
89 EXPORT_C TUint CMTPTypeObjectInfo::Type() const |
|
90 { |
|
91 return EMTPTypeObjectInfoDataset; |
|
92 } |
|
93 |
|
94 const CMTPTypeCompoundBase::TElementInfo& CMTPTypeObjectInfo::ElementInfo(TInt aElementId) const |
|
95 { |
|
96 return iElementInfo[aElementId]; |
|
97 } |
|
98 |
|
99 CMTPTypeObjectInfo::CMTPTypeObjectInfo() : |
|
100 CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), |
|
101 iElementInfo(iElementMetaData, ENumElements), |
|
102 iChunkFlat(KFlatChunkSize, *this) |
|
103 { |
|
104 |
|
105 } |
|
106 |
|
107 void CMTPTypeObjectInfo::ConstructL() |
|
108 { |
|
109 for (TUint i(0); (i < ENumElements); i++) |
|
110 { |
|
111 const TElementInfo& info(iElementInfo[i]); |
|
112 if (ChunkCount() <= info.iChunkId) |
|
113 { |
|
114 MMTPType* chunk(NULL); |
|
115 |
|
116 switch (info.iType) |
|
117 { |
|
118 case EMTPTypeFlat: |
|
119 chunk = NewFlatChunkL(info); |
|
120 break; |
|
121 |
|
122 case EMTPTypeString: |
|
123 chunk = NewStringChunkL(info); |
|
124 break; |
|
125 |
|
126 default: |
|
127 break; |
|
128 } |
|
129 |
|
130 __ASSERT_DEBUG(chunk, User::Invariant()); |
|
131 ChunkAppendL(*chunk); |
|
132 } |
|
133 } |
|
134 } |
|
135 |
|
136 MMTPType* CMTPTypeObjectInfo::NewFlatChunkL(const TElementInfo& aElementInfo) |
|
137 { |
|
138 MMTPType* chunk(NULL); |
|
139 if (aElementInfo.iChunkId == 0) |
|
140 { |
|
141 iChunkFlat.OpenL(); |
|
142 chunk = &iChunkFlat; |
|
143 } |
|
144 __ASSERT_DEBUG(chunk, User::Invariant()); |
|
145 return chunk; |
|
146 } |
|
147 |
|
148 MMTPType* CMTPTypeObjectInfo::NewStringChunkL(const TElementInfo& /*aElementInfo*/) |
|
149 { |
|
150 CMTPTypeString* chunk(CMTPTypeString::NewLC()); |
|
151 iChunksString.AppendL(chunk); |
|
152 CleanupStack::Pop(chunk); |
|
153 return chunk; |
|
154 } |