|
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 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "cmtpusbcontainer.h" |
|
22 #include "mtpusbdatatypeconstants.h" |
|
23 |
|
24 // Dataset constants |
|
25 const TUint CMTPUsbContainer::KFlatChunkSize(12); |
|
26 |
|
27 // Dataset element metadata. |
|
28 const CMTPTypeCompoundBase::TElementInfo CMTPUsbContainer::iElementMetaData[CMTPUsbContainer::ENumElements] = |
|
29 { |
|
30 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT32, 0, KMTPTypeUINT32Size}}, // EContainerLength |
|
31 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT16, 4, KMTPTypeUINT16Size}}, // EContainerType |
|
32 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT16, 6, KMTPTypeUINT16Size}}, // ECode |
|
33 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT32, 8, KMTPTypeUINT32Size}}, // ETransactionID |
|
34 {EIdPayloadChunk, EMTPTypeUndefined, {EMTPTypeUndefined, KMTPNotApplicable, KMTPNotApplicable}} // EPayload |
|
35 }; |
|
36 |
|
37 /** |
|
38 MTP USB device class generic bulk container dataset factory method. This method |
|
39 is used to create an empty MTP USB device class generic bulk container dataset |
|
40 type. |
|
41 @return A pointer to an empty an empty MTP USB device class generic bulk |
|
42 container dataset type. Ownership IS transfered. |
|
43 @leave One of the system wide error codes, if unsuccessful. |
|
44 */ |
|
45 EXPORT_C CMTPUsbContainer* CMTPUsbContainer::NewL() |
|
46 { |
|
47 CMTPUsbContainer* self = new (ELeave) CMTPUsbContainer(); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 /** |
|
55 Destructor. |
|
56 */ |
|
57 EXPORT_C CMTPUsbContainer::~CMTPUsbContainer() |
|
58 { |
|
59 iChunkHeader.Close(); |
|
60 } |
|
61 |
|
62 /** |
|
63 Provides the bulk container payload. |
|
64 @return The bulk container payload. |
|
65 */ |
|
66 EXPORT_C MMTPType* CMTPUsbContainer::Payload() const |
|
67 { |
|
68 return iPayload; |
|
69 } |
|
70 |
|
71 /** |
|
72 Sets the bulk container payload. |
|
73 @param aPayload The new bulk container payload. |
|
74 */ |
|
75 EXPORT_C void CMTPUsbContainer::SetPayloadL(MMTPType* aPayload) |
|
76 { |
|
77 if (iPayload) |
|
78 { |
|
79 // Remove the existing payload from the super class. |
|
80 ChunkRemove(iElementMetaData[EPayload].iChunkId); |
|
81 } |
|
82 |
|
83 if (aPayload) |
|
84 { |
|
85 // Pass the payload to the super class for management. |
|
86 ChunkAppendL(*aPayload); |
|
87 } |
|
88 iPayload = aPayload; |
|
89 } |
|
90 |
|
91 |
|
92 EXPORT_C TUint CMTPUsbContainer::Type() const |
|
93 { |
|
94 return EMTPUsbTypeContainer; |
|
95 } |
|
96 |
|
97 const CMTPTypeCompoundBase::TElementInfo& CMTPUsbContainer::ElementInfo(TInt aElementId) const |
|
98 { |
|
99 __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant()); |
|
100 return iElementInfo[aElementId]; |
|
101 } |
|
102 |
|
103 /** |
|
104 Constructor. |
|
105 */ |
|
106 CMTPUsbContainer::CMTPUsbContainer() : |
|
107 CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), |
|
108 iChunkHeader(KFlatChunkSize, *this), |
|
109 iElementInfo(iElementMetaData, ENumElements) |
|
110 { |
|
111 |
|
112 } |
|
113 |
|
114 /** |
|
115 Second phase constructor. |
|
116 */ |
|
117 void CMTPUsbContainer::ConstructL() |
|
118 { |
|
119 iChunkHeader.OpenL(); |
|
120 ChunkAppendL(iChunkHeader); |
|
121 } |
|
122 |