|
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 @publishedPartner |
|
19 */ |
|
20 |
|
21 #include <mtp/tmtptypeflatbase.h> |
|
22 #include <mtp/cmtptypestring.h> |
|
23 #include <mtp/cmtptypeserviceevent.h> |
|
24 |
|
25 #include "mtpdatatypespanic.h" |
|
26 |
|
27 // Dataset constants |
|
28 const TUint KMTPChunk0Size = 18; |
|
29 |
|
30 |
|
31 const CMTPTypeCompoundBase::TElementInfo CMTPTypeServiceEventElement::iElementMetaData[CMTPTypeServiceEventElement::ENumElements] = |
|
32 { |
|
33 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT16, 0, KMTPTypeUINT16Size}}, // EMTPServiceEventCode |
|
34 {EIdFlatChunk, EMTPTypeFlat, {EMTPTypeUINT128, 2, KMTPTypeUINT128Size}}, // EMTPServiceEventGUID |
|
35 {EIdServiceEventNameChunk, EMTPTypeString, {EMTPTypeString, KMTPNotApplicable, KMTPNotApplicable}}, // EMTPServiceEventName |
|
36 }; |
|
37 |
|
38 EXPORT_C CMTPTypeServiceEventList* CMTPTypeServiceEventList::NewL() |
|
39 { |
|
40 CMTPTypeServiceEventList* self = CMTPTypeServiceEventList::NewLC(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 EXPORT_C CMTPTypeServiceEventList* CMTPTypeServiceEventList::NewLC() |
|
46 { |
|
47 CMTPTypeServiceEventList* self = new(ELeave) CMTPTypeServiceEventList(); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 EXPORT_C CMTPTypeServiceEventList::~CMTPTypeServiceEventList() |
|
54 { |
|
55 } |
|
56 |
|
57 EXPORT_C void CMTPTypeServiceEventList::AppendL(CMTPTypeServiceEventElement* aElement) |
|
58 { |
|
59 CMTPTypeList::AppendL(aElement); |
|
60 } |
|
61 EXPORT_C CMTPTypeServiceEventElement& CMTPTypeServiceEventList::ElementL(TUint aIndex) const |
|
62 { |
|
63 return static_cast<CMTPTypeServiceEventElement&>( CMTPTypeList::ElementL(aIndex) ); |
|
64 } |
|
65 |
|
66 CMTPTypeServiceEventList::CMTPTypeServiceEventList() : |
|
67 CMTPTypeList(EMTPTypeServiceEventListDataset,EMTPTypeServiceEventElementDataset) |
|
68 { |
|
69 } |
|
70 |
|
71 void CMTPTypeServiceEventList::ConstructL() |
|
72 { |
|
73 InitListL(); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewL() |
|
79 { |
|
80 CMTPTypeServiceEventElement* self = NewLC( ); |
|
81 CleanupStack::Pop(self); |
|
82 return self; |
|
83 } |
|
84 |
|
85 EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewLC() |
|
86 { |
|
87 CMTPTypeServiceEventElement* self = new(ELeave) CMTPTypeServiceEventElement(); |
|
88 CleanupStack::PushL(self); |
|
89 self->ConstructL(); |
|
90 return self; |
|
91 } |
|
92 |
|
93 EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName) |
|
94 { |
|
95 CMTPTypeServiceEventElement* self = NewLC( aEventCode, aEventGUID, aEventName); |
|
96 CleanupStack::Pop(self); |
|
97 return self; |
|
98 } |
|
99 |
|
100 EXPORT_C CMTPTypeServiceEventElement* CMTPTypeServiceEventElement::NewLC(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName) |
|
101 { |
|
102 CMTPTypeServiceEventElement* self = new (ELeave) CMTPTypeServiceEventElement(); |
|
103 CleanupStack::PushL(self); |
|
104 self->ConstructL(aEventCode, aEventGUID, aEventName); |
|
105 return self; |
|
106 } |
|
107 |
|
108 /** |
|
109 Destructor. |
|
110 */ |
|
111 EXPORT_C CMTPTypeServiceEventElement::~CMTPTypeServiceEventElement() |
|
112 { |
|
113 iChunkFlat.Close(); |
|
114 delete iChunkString; |
|
115 } |
|
116 |
|
117 |
|
118 EXPORT_C TUint CMTPTypeServiceEventElement::Type() const |
|
119 { |
|
120 return EMTPTypeServiceEventElementDataset; |
|
121 } |
|
122 |
|
123 |
|
124 const CMTPTypeCompoundBase::TElementInfo& CMTPTypeServiceEventElement::ElementInfo(TInt aElementId) const |
|
125 { |
|
126 return iElementInfo[aElementId]; |
|
127 } |
|
128 |
|
129 CMTPTypeServiceEventElement::CMTPTypeServiceEventElement() : |
|
130 CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), |
|
131 iElementInfo(iElementMetaData, ENumElements), |
|
132 iChunkFlat(KMTPChunk0Size, *this) |
|
133 { |
|
134 |
|
135 } |
|
136 |
|
137 void CMTPTypeServiceEventElement::ConstructL() |
|
138 { |
|
139 for (TUint i(0); (i < ENumElements); i++) |
|
140 { |
|
141 const TElementInfo& info(iElementInfo[i]); |
|
142 if (ChunkCount() <= info.iChunkId) |
|
143 { |
|
144 MMTPType* chunk(NULL); |
|
145 |
|
146 switch (info.iType) |
|
147 { |
|
148 case EMTPTypeFlat: |
|
149 chunk = NewFlatChunkL(); |
|
150 break; |
|
151 case EMTPTypeString: |
|
152 iChunkString = CMTPTypeString::NewL(); |
|
153 chunk = iChunkString ; |
|
154 break; |
|
155 default: |
|
156 break; |
|
157 } |
|
158 |
|
159 __ASSERT_DEBUG(chunk, User::Invariant()); |
|
160 ChunkAppendL(*chunk); |
|
161 } |
|
162 } |
|
163 } |
|
164 |
|
165 |
|
166 MMTPType* CMTPTypeServiceEventElement::NewFlatChunkL() |
|
167 { |
|
168 MMTPType* chunk(NULL); |
|
169 |
|
170 iChunkFlat.OpenL(); |
|
171 chunk = &iChunkFlat; |
|
172 |
|
173 __ASSERT_DEBUG(chunk, User::Invariant()); |
|
174 return chunk; |
|
175 } |
|
176 |
|
177 void CMTPTypeServiceEventElement::ConstructL(const TUint16 aEventCode,const TMTPTypeGuid& aEventGUID,const TDesC& aEventName) |
|
178 { |
|
179 |
|
180 ConstructL(); |
|
181 |
|
182 // Set mandatory construction values. |
|
183 SetUint16L(EEventCode, aEventCode); |
|
184 SetL(EEventGUID, aEventGUID); |
|
185 SetStringL(EEventName,aEventName); |
|
186 } |