|
1 // Copyright (c) 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 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <f32file.h> |
|
22 #include <mtp/tmtptyperequest.h> |
|
23 #include <mtp/tmtptypeuint8.h> |
|
24 #include <mtp/tmtptypeuint32.h> |
|
25 #include <mtp/tmtptypeuint64.h> |
|
26 #include <mtp/tmtptypeuint128.h> |
|
27 #include <mtp/cmtptypestring.h> |
|
28 #include <mtp/mmtpdataproviderframework.h> |
|
29 #include <mtp/mtpprotocolconstants.h> |
|
30 #include <mtp/mmtpobjectmgr.h> |
|
31 #include <mtp/cmtpobjectmetadata.h> |
|
32 |
|
33 #include "cmtpimagedpgetobjectpropvalue.h" |
|
34 #include "mtpimagedpconst.h" |
|
35 #include "cmtpimagedpobjectpropertymgr.h" |
|
36 #include "mtpimagedppanic.h" |
|
37 #include "cmtpimagedp.h" |
|
38 #include "mtpimagedputilits.h" |
|
39 |
|
40 |
|
41 __FLOG_STMT(_LIT8(KComponent,"GetObjectPropValue");) |
|
42 |
|
43 /** |
|
44 Two-phase construction method |
|
45 @param aPlugin The data provider plugin |
|
46 @param aFramework The data provider framework |
|
47 @param aConnection The connection from which the request comes |
|
48 @return a pointer to the created request processor object |
|
49 */ |
|
50 MMTPRequestProcessor* CMTPImageDpGetObjectPropValue::NewL( |
|
51 MMTPDataProviderFramework& aFramework, |
|
52 MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) |
|
53 { |
|
54 CMTPImageDpGetObjectPropValue* self = new (ELeave) CMTPImageDpGetObjectPropValue(aFramework, aConnection,aDataProvider); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 /** |
|
62 Destructor |
|
63 */ |
|
64 CMTPImageDpGetObjectPropValue::~CMTPImageDpGetObjectPropValue() |
|
65 { |
|
66 delete iMTPTypeString; |
|
67 delete iObjectMeta; |
|
68 __FLOG_CLOSE; |
|
69 } |
|
70 |
|
71 /** |
|
72 Standard c++ constructor |
|
73 */ |
|
74 CMTPImageDpGetObjectPropValue::CMTPImageDpGetObjectPropValue( |
|
75 MMTPDataProviderFramework& aFramework, |
|
76 MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) |
|
77 :CMTPRequestProcessor(aFramework, aConnection,0, NULL), |
|
78 iObjectPropertyMgr(aDataProvider.PropertyMgr()) |
|
79 { |
|
80 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
81 } |
|
82 |
|
83 /** |
|
84 Second-phase construction |
|
85 */ |
|
86 void CMTPImageDpGetObjectPropValue::ConstructL() |
|
87 { |
|
88 iMTPTypeString = CMTPTypeString::NewL(); |
|
89 iObjectMeta = CMTPObjectMetaData::NewL(); |
|
90 } |
|
91 |
|
92 /** |
|
93 * Check format code, prop code and objectg Handle |
|
94 */ |
|
95 TMTPResponseCode CMTPImageDpGetObjectPropValue::CheckRequestL() |
|
96 { |
|
97 TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); |
|
98 TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
|
99 |
|
100 if(responseCode == EMTPRespCodeOK) |
|
101 { |
|
102 const TInt count = sizeof(KMTPImageDpSupportedProperties) / sizeof(TUint16); |
|
103 TInt i = 0; |
|
104 for(i = 0; i < count; i++) |
|
105 |
|
106 if(KMTPImageDpSupportedProperties[i] == propCode) |
|
107 { |
|
108 break; |
|
109 } |
|
110 if(i == count) |
|
111 { |
|
112 responseCode = EMTPRespCodeInvalidObjectPropCode; |
|
113 } |
|
114 } |
|
115 |
|
116 if(responseCode == EMTPRespCodeOK) |
|
117 { |
|
118 responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta); |
|
119 iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse); |
|
120 } |
|
121 |
|
122 return responseCode; |
|
123 } |
|
124 |
|
125 /** |
|
126 GetObjectPropValue request handler |
|
127 */ |
|
128 void CMTPImageDpGetObjectPropValue::ServiceL() |
|
129 { |
|
130 TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
|
131 switch(propCode) |
|
132 { |
|
133 case EMTPObjectPropCodeStorageID: |
|
134 ServiceStorageIdL(); |
|
135 break; |
|
136 case EMTPObjectPropCodeObjectFormat: |
|
137 ServiceObjectFormatL(); |
|
138 break; |
|
139 case EMTPObjectPropCodeProtectionStatus: |
|
140 ServiceProtectionStatusL(); |
|
141 break; |
|
142 case EMTPObjectPropCodeObjectSize: |
|
143 ServiceObjectSizeL(); |
|
144 break; |
|
145 case EMTPObjectPropCodeObjectFileName: |
|
146 ServiceFileNameL(); |
|
147 break; |
|
148 case EMTPObjectPropCodeDateCreated: |
|
149 ServiceDateCreatedL(); |
|
150 break; |
|
151 case EMTPObjectPropCodeDateModified: |
|
152 ServiceDateModifiedL(); |
|
153 break; |
|
154 case EMTPObjectPropCodeParentObject: |
|
155 ServiceParentObjectL(); |
|
156 break; |
|
157 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
|
158 ServicePuidL(); |
|
159 break; |
|
160 case EMTPObjectPropCodeName: |
|
161 ServiceNameL(); |
|
162 break; |
|
163 case EMTPObjectPropCodeWidth: |
|
164 ServiceWidthL(); |
|
165 break; |
|
166 case EMTPObjectPropCodeHeight: |
|
167 ServiceHeightL(); |
|
168 break; |
|
169 case EMTPObjectPropCodeImageBitDepth: |
|
170 ServiceImageBitDepthL(); |
|
171 break; |
|
172 case EMTPObjectPropCodeRepresentativeSampleFormat: |
|
173 ServiceRepresentativeSampleFormatL(); |
|
174 break; |
|
175 case EMTPObjectPropCodeRepresentativeSampleSize: |
|
176 ServiceRepresentativeSampleSizeL(); |
|
177 break; |
|
178 case EMTPObjectPropCodeRepresentativeSampleHeight: |
|
179 ServiceRepresentativeSampleHeightL(); |
|
180 break; |
|
181 case EMTPObjectPropCodeRepresentativeSampleWidth: |
|
182 ServiceRepresentativeSampleWidthL(); |
|
183 break; |
|
184 case EMTPObjectPropCodeNonConsumable: |
|
185 ServiceNonConsumableL(); |
|
186 break; |
|
187 default: |
|
188 User::Leave(KErrGeneral); |
|
189 } |
|
190 } |
|
191 |
|
192 void CMTPImageDpGetObjectPropValue::ServiceStorageIdL() |
|
193 { |
|
194 TUint32 storageId; |
|
195 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeStorageID, storageId); |
|
196 iMTPTypeUint32.Set(storageId); |
|
197 |
|
198 SendDataL(iMTPTypeUint32); |
|
199 } |
|
200 |
|
201 void CMTPImageDpGetObjectPropValue::ServiceObjectFormatL() |
|
202 { |
|
203 TUint16 format(EMTPFormatCodeUndefined); |
|
204 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFormat, format); |
|
205 iMTPTypeUint16.Set(format); |
|
206 |
|
207 SendDataL(iMTPTypeUint16); |
|
208 } |
|
209 |
|
210 void CMTPImageDpGetObjectPropValue::ServiceProtectionStatusL() |
|
211 { |
|
212 TUint16 protection; |
|
213 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection); |
|
214 iMTPTypeUint16.Set(protection); |
|
215 |
|
216 SendDataL(iMTPTypeUint16); |
|
217 } |
|
218 |
|
219 void CMTPImageDpGetObjectPropValue::ServiceObjectSizeL() |
|
220 { |
|
221 TUint64 size; |
|
222 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectSize, size); |
|
223 iMTPTypeUint64.Set(size); |
|
224 |
|
225 SendDataL(iMTPTypeUint64); |
|
226 } |
|
227 |
|
228 |
|
229 void CMTPImageDpGetObjectPropValue::ServiceFileNameL() |
|
230 { |
|
231 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFileName, *iMTPTypeString); |
|
232 SendDataL(*iMTPTypeString); |
|
233 } |
|
234 |
|
235 void CMTPImageDpGetObjectPropValue::ServiceDateCreatedL() |
|
236 { |
|
237 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateCreated, *iMTPTypeString); |
|
238 SendDataL(*iMTPTypeString); |
|
239 } |
|
240 |
|
241 void CMTPImageDpGetObjectPropValue::ServiceDateModifiedL() |
|
242 { |
|
243 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateModified, *iMTPTypeString); |
|
244 SendDataL(*iMTPTypeString); |
|
245 } |
|
246 |
|
247 void CMTPImageDpGetObjectPropValue::ServiceParentObjectL() |
|
248 { |
|
249 TUint32 parent; |
|
250 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeParentObject, parent); |
|
251 if (parent == KMTPHandleNoParent) |
|
252 { |
|
253 parent = 0; |
|
254 } |
|
255 iMTPTypeUint32.Set(parent); |
|
256 |
|
257 SendDataL(iMTPTypeUint32); |
|
258 } |
|
259 |
|
260 void CMTPImageDpGetObjectPropValue::ServicePuidL() |
|
261 { |
|
262 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodePersistentUniqueObjectIdentifier, iMTPTypeUint128); |
|
263 SendDataL(iMTPTypeUint128); |
|
264 } |
|
265 |
|
266 void CMTPImageDpGetObjectPropValue::ServiceNameL() |
|
267 { |
|
268 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeName, *iMTPTypeString); |
|
269 SendDataL(*iMTPTypeString); |
|
270 } |
|
271 |
|
272 void CMTPImageDpGetObjectPropValue::ServiceWidthL() |
|
273 { |
|
274 TUint32 width; |
|
275 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeWidth, width); |
|
276 iMTPTypeUint32.Set(width); |
|
277 |
|
278 SendDataL(iMTPTypeUint32); |
|
279 } |
|
280 |
|
281 void CMTPImageDpGetObjectPropValue::ServiceHeightL() |
|
282 { |
|
283 TUint32 height; |
|
284 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeHeight, height); |
|
285 iMTPTypeUint32.Set(height); |
|
286 |
|
287 SendDataL(iMTPTypeUint32); |
|
288 } |
|
289 |
|
290 void CMTPImageDpGetObjectPropValue::ServiceImageBitDepthL() |
|
291 { |
|
292 TUint32 imageBitDepth; |
|
293 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeImageBitDepth, imageBitDepth); |
|
294 iMTPTypeUint32.Set(imageBitDepth); |
|
295 |
|
296 SendDataL(iMTPTypeUint32); |
|
297 } |
|
298 |
|
299 |
|
300 void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleFormatL() |
|
301 { |
|
302 TUint16 representativeSampleFormat; |
|
303 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleFormat, representativeSampleFormat); |
|
304 iMTPTypeUint16.Set(representativeSampleFormat); |
|
305 |
|
306 SendDataL(iMTPTypeUint16); |
|
307 } |
|
308 |
|
309 void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleSizeL() |
|
310 { |
|
311 TUint32 representativeSampleSize; |
|
312 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, representativeSampleSize); |
|
313 iMTPTypeUint32.Set(representativeSampleSize); |
|
314 |
|
315 SendDataL(iMTPTypeUint32); |
|
316 } |
|
317 |
|
318 void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleHeightL() |
|
319 { |
|
320 TUint32 representativeSampleHeight; |
|
321 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleHeight, representativeSampleHeight); |
|
322 iMTPTypeUint32.Set(representativeSampleHeight); |
|
323 |
|
324 SendDataL(iMTPTypeUint32); |
|
325 } |
|
326 |
|
327 void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleWidthL() |
|
328 { |
|
329 TUint32 representativeSampleWidth; |
|
330 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleWidth, representativeSampleWidth); |
|
331 iMTPTypeUint32.Set(representativeSampleWidth); |
|
332 |
|
333 SendDataL(iMTPTypeUint32); |
|
334 } |
|
335 |
|
336 void CMTPImageDpGetObjectPropValue::ServiceNonConsumableL() |
|
337 { |
|
338 TUint8 nonConsumable; |
|
339 iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeNonConsumable, nonConsumable); |
|
340 iMTPTypeUint8.Set(nonConsumable); |
|
341 SendDataL(iMTPTypeUint8); |
|
342 } |