|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implement the operation: GetObjectPropList |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 #include <e32std.h> |
|
21 #include <mtp/mmtpdataproviderframework.h> |
|
22 #include <mtp/mmtpobjectmgr.h> |
|
23 #include <mtp/cmtptypeobjectproplist.h> |
|
24 #include <mtp/cmtptypestring.h> |
|
25 #include <mtp/cmtptypearray.h> |
|
26 #include <mtp/cmtpobjectmetadata.h> |
|
27 |
|
28 #include "tobjectdescription.h" |
|
29 #include "cgetobjectproplist.h" |
|
30 #include "tmmmtpdppanic.h" |
|
31 #include "mmmtpdplogger.h" |
|
32 #include "mmmtpdpconfig.h" |
|
33 #include "mmmtpdputility.h" |
|
34 #include "cmmmtpdpmetadataaccesswrapper.h" |
|
35 |
|
36 static const TUint32 KMTPAll = 0xffffffff; |
|
37 _LIT( KMtpDateTimeFormat, "%F%Y%M%DT%H%T%S" ); |
|
38 const TInt KMtpMaxDateTimeStringLength = 15; |
|
39 |
|
40 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG) |
|
41 _LIT( KSubFormatParse, "SubFormatParse" ); |
|
42 #endif |
|
43 |
|
44 // Verification data for the getObjectPropList request |
|
45 const TMTPRequestElementInfo KMTPGetObjectPropListPolicy[] = |
|
46 { |
|
47 { |
|
48 TMTPTypeRequest::ERequestParameter1, |
|
49 EMTPElementTypeObjectHandle, |
|
50 EMTPElementAttrNone, |
|
51 2, |
|
52 KMTPHandleAll, |
|
53 KMTPHandleNone |
|
54 } |
|
55 }; |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CGetObjectPropList::~CGetObjectPropList |
|
59 // Destructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C CGetObjectPropList::~CGetObjectPropList() |
|
63 { |
|
64 Cancel(); |
|
65 |
|
66 delete iObject; |
|
67 delete iPropertyList; |
|
68 delete iPropertyElement; |
|
69 iHandles.Close(); |
|
70 iPropertyArray.Close(); |
|
71 |
|
72 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG) |
|
73 delete iPerfLog; |
|
74 #endif |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CGetObjectPropList::CGetObjectPropList |
|
79 // Standard C++ Constructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CGetObjectPropList::CGetObjectPropList( MMTPDataProviderFramework& aFramework, |
|
83 MMTPConnection& aConnection, |
|
84 MMmMtpDpConfig& aDpConfig ) : |
|
85 CRequestProcessor( aFramework, |
|
86 aConnection, |
|
87 sizeof ( KMTPGetObjectPropListPolicy ) / sizeof( TMTPRequestElementInfo ), |
|
88 KMTPGetObjectPropListPolicy ), |
|
89 iHandles ( KMmMtpRArrayGranularity ), |
|
90 iDpConfig( aDpConfig ), |
|
91 iPropertyArray( KMmMtpRArrayGranularity ) |
|
92 { |
|
93 PRINT( _L( "Operation: GetObjectPropList(0x9805)" ) ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CGetObjectPropList::ConstructL |
|
98 // 2nd Phase Constructor |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void CGetObjectPropList::ConstructL() |
|
102 { |
|
103 CActiveScheduler::Add( this ); |
|
104 |
|
105 iPropertyList = CMTPTypeObjectPropList::NewL(); |
|
106 |
|
107 SetPSStatus(); |
|
108 |
|
109 #if defined(_DEBUG) || defined(MMMTPDP_PERFLOG) |
|
110 iPerfLog = CMmMtpDpPerfLog::NewL( _L( "MediaMtpDataProviderEnumerator" ) ); |
|
111 #endif |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CGetObjectPropList::CheckRequestL |
|
116 // Verify the reqeust and returns it |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C TMTPResponseCode CGetObjectPropList::CheckRequestL() |
|
120 { |
|
121 PRINT( _L( "MM MTP => CGetObjectPropList::CheckRequestL" ) ); |
|
122 |
|
123 TMTPResponseCode result = CRequestProcessor::CheckRequestL(); |
|
124 |
|
125 if ( result == EMTPRespCodeOK ) |
|
126 { |
|
127 result = CheckFormatL(); |
|
128 } |
|
129 |
|
130 if ( result == EMTPRespCodeOK ) |
|
131 { |
|
132 result = CheckDepth(); |
|
133 } |
|
134 |
|
135 if ( result == EMTPRespCodeOK ) |
|
136 { |
|
137 result = CheckPropCodeL(); |
|
138 } |
|
139 |
|
140 PRINT1( _L("MM MTP <= CGetObjectPropList::CheckRequestL, response 0x%x"), result ); |
|
141 |
|
142 return result; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CGetObjectPropList::ServiceL |
|
147 // service a request at request phase |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C void CGetObjectPropList::ServiceL() |
|
151 { |
|
152 GetObjectHandlesL(); |
|
153 TInt numOfObjects = iHandles.Count(); |
|
154 PRINT2( _L( "MM MTP <> CGetObjectPropList::ServiceL, numOfObjects = %d, iPropCode = 0x%x" ), |
|
155 numOfObjects, |
|
156 iPropCode ); |
|
157 if ( numOfObjects > 0 |
|
158 && ( iPropCode == KMTPAll || iPropCode == EMTPObjectPropCodeUndefined ) ) |
|
159 { |
|
160 // iFirstUnprocessed = 0; |
|
161 TRequestStatus* status = &iStatus; |
|
162 User::RequestComplete( status, iStatus.Int() ); |
|
163 SetActive(); |
|
164 } |
|
165 else |
|
166 { |
|
167 TInt err = KErrNone; |
|
168 for ( TInt i = 0; i < numOfObjects; i++ ) |
|
169 { |
|
170 TUint32 handle = iHandles[i ]; |
|
171 |
|
172 if ( iFramework.ObjectMgr().ObjectOwnerId( handle ) |
|
173 == iFramework.DataProviderId() ) |
|
174 { |
|
175 delete iObject; |
|
176 iObject = NULL; |
|
177 iObject = CMTPObjectMetaData::NewL(); |
|
178 |
|
179 if ( iFramework.ObjectMgr().ObjectL( handle, *iObject ) ) // Populate the object meta data |
|
180 { |
|
181 SetSubFormatCodeL(); |
|
182 |
|
183 err = ServiceOneObjectPropertyL( handle, iPropCode ); |
|
184 if ( err != KErrNone && err != KErrNotSupported ) |
|
185 break; |
|
186 } |
|
187 } |
|
188 } |
|
189 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceL, one property was queried, Send data to PC! err = %d" ), err ); |
|
190 if ( err == KErrNone || err == KErrNotSupported ) |
|
191 SendDataL( *iPropertyList ); |
|
192 else if ( err == KErrNotFound ) |
|
193 SendResponseL( EMTPRespCodeAccessDenied ); |
|
194 else |
|
195 SendResponseL( EMTPRespCodeGeneralError ); |
|
196 } |
|
197 |
|
198 PRINT( _L( "MM MTP <= CGetObjectPropList::ServiceL" ) ); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CGetObjectPropList::CheckFormatL |
|
203 // Ensures the object format operation parameter is valid |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 TMTPResponseCode CGetObjectPropList::CheckFormatL() const |
|
207 { |
|
208 TMTPResponseCode response = EMTPRespCodeOK; |
|
209 |
|
210 PRINT( _L( "MM MTP => CGetObjectPropList::CheckFormatL" ) ); |
|
211 |
|
212 TUint32 formatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter2 ); |
|
213 iFormatCode = formatCode; |
|
214 |
|
215 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckFormatL formatCode = 0x%x" ), formatCode ); |
|
216 |
|
217 if ( formatCode != 0 ) |
|
218 { |
|
219 response = EMTPRespCodeInvalidObjectFormatCode; |
|
220 |
|
221 const RArray<TUint>* format = iDpConfig.GetSupportedFormat(); |
|
222 TInt count = format->Count(); |
|
223 |
|
224 for ( TInt i = 0; i < count; i++ ) |
|
225 { |
|
226 if ( formatCode == (*format)[i ] ) |
|
227 { |
|
228 response = EMTPRespCodeOK; |
|
229 break; |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 PRINT1( _L( "MM MTP <= CGetObjectPropList::CheckFormatL, response 0x%x" ), response ); |
|
235 |
|
236 return response; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CGetObjectPropList::CheckPropCodeL |
|
241 // Ensures the object prop code operation parameter is valid |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TMTPResponseCode CGetObjectPropList::CheckPropCodeL() const |
|
245 { |
|
246 PRINT( _L( "MM MTP => CGetObjectPropList::CheckPropCode" ) ); |
|
247 |
|
248 TMTPResponseCode response = EMTPRespCodeOK; |
|
249 |
|
250 TUint32 formatCode = Request().Uint32( TMTPTypeRequest::ERequestParameter2 ); |
|
251 iPropCode = Request().Uint32( TMTPTypeRequest::ERequestParameter3 ); |
|
252 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckPropCode, iPropCode = 0x%x" ), iPropCode ); |
|
253 |
|
254 iPropertyArray.Reset(); |
|
255 if ( iPropCode == EMTPObjectPropCodeUndefined ) |
|
256 { |
|
257 // Get group code |
|
258 TUint32 groupCode = Request().Uint32( TMTPTypeRequest::ERequestParameter4 ); |
|
259 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckPropCode, Group Code = 0x%x" ), groupCode ); |
|
260 |
|
261 // check if groupCode is supported |
|
262 TInt count = sizeof ( KSupportedGroupCode ) |
|
263 / sizeof ( KSupportedGroupCode[0] ); |
|
264 TInt i = 0; |
|
265 for ( ; i < count; i++ ) |
|
266 { |
|
267 if ( groupCode == KSupportedGroupCode[i ] ) |
|
268 break; |
|
269 } |
|
270 if ( i == count ) |
|
271 response = EMTPRespCodeSpecificationByGroupUnsupported; |
|
272 |
|
273 } |
|
274 else if ( iPropCode != KMTPAll ) |
|
275 { |
|
276 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckPropCode, Property(0x%x) was queried." ), iPropCode ); |
|
277 |
|
278 TInt err = KErrNone; |
|
279 const RArray<TUint>* properties = NULL; |
|
280 if ( formatCode == KMTPFormatsAll ) |
|
281 properties = iDpConfig.GetAllSupportedProperties(); |
|
282 else |
|
283 properties = iDpConfig.GetSupportedPropertiesL( formatCode ); |
|
284 |
|
285 User::LeaveIfError( err ); |
|
286 |
|
287 const TInt count = properties->Count(); |
|
288 TInt i = 0; |
|
289 for ( i = 0; i < count; i++ ) |
|
290 { |
|
291 if ( (*properties)[i] == iPropCode ) |
|
292 { |
|
293 iPropertyArray.Append( iPropCode ); |
|
294 break; |
|
295 } |
|
296 } |
|
297 |
|
298 if ( iPropertyArray.Count() == 0 ) |
|
299 { |
|
300 response = EMTPRespCodeInvalidObjectPropCode; |
|
301 } |
|
302 } |
|
303 else |
|
304 { |
|
305 PRINT( _L( "MM MTP <> CGetObjectPropList::CheckPropCode, All properties were queried." ) ); |
|
306 } |
|
307 |
|
308 PRINT1( _L( "MM MTP <= CGetObjectPropList::CheckPropCode, response 0x%x" ), response ); |
|
309 |
|
310 return response; |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CGetObjectPropList::CheckDepth |
|
315 // Ensures the depth operation parameter is valid |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 TMTPResponseCode CGetObjectPropList::CheckDepth() const |
|
319 { |
|
320 TMTPResponseCode response = EMTPRespCodeSpecificationByDepthUnsupported; |
|
321 |
|
322 PRINT( _L( "MM MTP => CGetObjectPropList::CheckDepth" ) ); |
|
323 |
|
324 // We either support no depth at all, or 1 depth or (0xFFFFFFFF) with objecthandle as 0x00000000 |
|
325 iHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
|
326 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckDepth iHandle = 0x%x" ), iHandle ); |
|
327 iDepth = Request().Uint32( TMTPTypeRequest::ERequestParameter5 ); |
|
328 PRINT1( _L( "MM MTP <> CGetObjectPropList::CheckDepth iDepth = 0x%x" ), iDepth ); |
|
329 |
|
330 if ( ( iDepth == 0 ) |
|
331 || ( iDepth == 1 ) |
|
332 || ( iDepth == KMTPAll && iHandle == KMTPHandleNone ) ) |
|
333 { |
|
334 response = EMTPRespCodeOK; |
|
335 } |
|
336 |
|
337 PRINT1( _L( "MM MTP <= CGetObjectPropList::CheckDepth, response 0x%x" ), response ); |
|
338 |
|
339 return response; |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CGetObjectPropList::GetObjectHandlesL |
|
344 // Gets the handles for the objects that we want the properties for |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CGetObjectPropList::GetObjectHandlesL() |
|
348 { |
|
349 PRINT( _L( "MM MTP => CGetObjectPropList::GetObjectHandlesL" ) ); |
|
350 |
|
351 iHandles.Reset(); |
|
352 |
|
353 if ( iHandle == KMTPHandleAll ) |
|
354 { |
|
355 GetObjectHandlesL( KMTPStorageAll, KMTPHandleNone ); |
|
356 } |
|
357 else if ( iHandle == KMTPHandleNone ) |
|
358 { |
|
359 GetRootObjectHandlesL( iDepth, iFormatCode ); |
|
360 } |
|
361 else |
|
362 { |
|
363 CMTPObjectMetaData* meta( iRequestChecker->GetObjectInfo( iHandle ) ); |
|
364 TPtrC suid( meta->DesC( CMTPObjectMetaData::ESuid ) ); |
|
365 TParsePtrC parse( suid ); |
|
366 iDpConfig.GetWrapperL().SetStorageRootL( parse.Drive() ); |
|
367 |
|
368 __ASSERT_DEBUG( meta, Panic( EMmMTPDpObjectNull ) ); |
|
369 |
|
370 if ( ( meta->Uint( CMTPObjectMetaData::EFormatCode ) == EMTPFormatCodeAssociation ) |
|
371 && ( meta->Uint( CMTPObjectMetaData::EFormatSubCode ) == EMTPAssociationTypeGenericFolder ) ) |
|
372 { |
|
373 GetFolderObjectHandlesL( iDepth, iHandle ); |
|
374 } |
|
375 else |
|
376 { |
|
377 iHandles.Append( iHandle ); |
|
378 } |
|
379 } |
|
380 |
|
381 PRINT( _L( "MM MTP <= CGetObjectPropList::GetObjectHandlesL" ) ); |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CGetObjectPropList::GetObjectHandlesL |
|
386 // Gets all object handles (for GetObjectHandlesL) |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 void CGetObjectPropList::GetObjectHandlesL( TUint32 aStorageId, |
|
390 TUint32 aParentHandle, |
|
391 TUint16 aFormat /*= 0x0000*/) |
|
392 { |
|
393 PRINT2( _L( "MM MTP => CGetObjectPropList::GetObjectHandlesL, aStorageId = 0x%x, aParentHandle = 0x%x" ), |
|
394 aStorageId, |
|
395 aParentHandle ); |
|
396 |
|
397 RMTPObjectMgrQueryContext context; |
|
398 CleanupClosePushL( context ); // + context |
|
399 |
|
400 iHandles.Reset(); |
|
401 |
|
402 if ( aFormat ) |
|
403 { |
|
404 TMTPObjectMgrQueryParams params( aStorageId, aFormat, aParentHandle ); |
|
405 |
|
406 do |
|
407 { |
|
408 iFramework.ObjectMgr().GetObjectHandlesL( params, context, iHandles ); |
|
409 } |
|
410 while ( !context.QueryComplete() ); |
|
411 } |
|
412 else |
|
413 { |
|
414 TMTPObjectMgrQueryParams params( aStorageId, |
|
415 KMTPFormatsAll, |
|
416 aParentHandle ); |
|
417 |
|
418 do |
|
419 { |
|
420 RArray<TUint> handles; |
|
421 CleanupClosePushL( handles ); // + handles |
|
422 iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles ); |
|
423 |
|
424 for ( TInt i = 0; i < handles.Count(); i++ ) |
|
425 { |
|
426 if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i ] ) |
|
427 == iFramework.DataProviderId() ) |
|
428 iHandles.Append( handles[i ] ); |
|
429 } |
|
430 CleanupStack::PopAndDestroy( &handles ); // - handles |
|
431 } |
|
432 while ( !context.QueryComplete() ); |
|
433 } |
|
434 |
|
435 CleanupStack::PopAndDestroy( &context ); // - context |
|
436 |
|
437 PRINT( _L( "MM MTP <= CGetObjectPropList::GetObjectHandlesL" ) ); |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // CGetObjectPropList::GetFolderObjectHandlesL |
|
442 // Gets a folder object handle |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CGetObjectPropList::GetFolderObjectHandlesL( TUint32 aDepth, |
|
446 TUint32 aParentHandle ) |
|
447 { |
|
448 PRINT2( _L( "MM MTP => CGetObjectPropList::GetFolderObjectHandlesL aDepth = 0x%x, aParentHandle = 0x%x" ), |
|
449 aDepth, |
|
450 aParentHandle ); |
|
451 |
|
452 if ( aDepth == 0 ) |
|
453 { |
|
454 // Do Nothing!!! |
|
455 } |
|
456 else //if(aDepth ==1) |
|
457 { |
|
458 GetObjectHandlesL( KMTPStorageAll, aParentHandle, iFormatCode ); |
|
459 } |
|
460 |
|
461 PRINT( _L( "MM MTP <= CGetObjectPropList::GetFolderObjectHandlesL" ) ); |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // CGetObjectPropList::GetRootObjectHandlesL |
|
466 // Gets the handles of all objects on the root |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CGetObjectPropList::GetRootObjectHandlesL( TUint32 aDepth, TUint16 aFormat ) |
|
470 { |
|
471 PRINT2( _L( "MM MTP => CGetObjectPropList::GetRootObjectHandlesL aDepth = 0x%x, aFormat = 0x%x" ), aDepth , aFormat); |
|
472 |
|
473 if ( aDepth == KMaxTUint ) |
|
474 { |
|
475 GetObjectHandlesL( KMTPStorageAll, KMTPHandleNone, aFormat ); |
|
476 } |
|
477 else if ( aDepth == 0 ) |
|
478 { |
|
479 // Return empty set to PC according to spec 0.96, folder is handled by device dp |
|
480 iHandles.Reset(); |
|
481 } |
|
482 else |
|
483 { |
|
484 GetObjectHandlesL( KMTPStorageAll, KMTPHandleNoParent, aFormat ); |
|
485 } |
|
486 |
|
487 PRINT( _L( "MM MTP <= CGetObjectPropList::GetRootObjectHandlesL" ) ); |
|
488 } |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CGetObjectPropList::ServiceAllPropertiesL |
|
491 // Gets a list of all the properties supported |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 TInt CGetObjectPropList::ServiceAllPropertiesL( TUint32 aHandle ) |
|
495 { |
|
496 PRINT1( _L( "MM MTP => CGetObjectPropList::ServiceAllPropertiesL aHandle = 0x%x" ), aHandle ); |
|
497 |
|
498 // Append the current object info onto our list |
|
499 TFileName fileName( iObject->DesC( CMTPObjectMetaData::ESuid ) ); |
|
500 TUint32 formatCode = iObject->Uint( CMTPObjectMetaData::EFormatCode ); |
|
501 |
|
502 PRINT2( _L( "MM MTP <> CGetObjectPropList::ServiceAllPropertiesL, fileName = %S, formatCode = 0x%x" ), |
|
503 &fileName, |
|
504 formatCode ); |
|
505 |
|
506 const RArray<TUint>* properties = NULL; |
|
507 if ( formatCode == KMTPFormatsAll ) |
|
508 properties = iDpConfig.GetAllSupportedProperties(); |
|
509 else |
|
510 properties = iDpConfig.GetSupportedPropertiesL( formatCode ); |
|
511 |
|
512 const TInt count = properties->Count(); |
|
513 |
|
514 TInt err = KErrNone; |
|
515 for ( TInt i = 0; i < count; i++ ) |
|
516 { |
|
517 // no need to do the trap anymore, this is being handle internally in Media DP's ServiceSpecificObjectPropertyL, also, this base class should not know too much of different handling between different formats |
|
518 err = ServiceOneObjectPropertyL( aHandle, (*properties)[i] ); |
|
519 if ( err == KErrNotSupported ) // Skip |
|
520 err = KErrNone; |
|
521 if ( err != KErrNone ) |
|
522 break; |
|
523 } |
|
524 |
|
525 PRINT1( _L( "MM MTP <= CGetObjectPropList::ServiceAllPropertiesL err = %d" ), err ); |
|
526 return err; |
|
527 } |
|
528 |
|
529 TInt CGetObjectPropList::ServiceGroupPropertiesL( TUint32 aHandle ) |
|
530 { |
|
531 PRINT1( _L( "MM MTP => CGetObjectPropList::ServiceGroupPropertiesL aHandle = 0x%x" ), aHandle ); |
|
532 |
|
533 TFileName fileName( iObject->DesC( CMTPObjectMetaData::ESuid ) ); |
|
534 TUint32 formatCode = iObject->Uint( CMTPObjectMetaData::EFormatCode ); |
|
535 |
|
536 PRINT2( _L( "MM MTP <> CGetObjectPropList::ServiceGroupPropertiesL, fileName = %S, formatCode = 0x%x" ), |
|
537 &fileName, |
|
538 formatCode ); |
|
539 |
|
540 // Get property codes according to group code, put those into array |
|
541 TUint32 groupCode = Request().Uint32( TMTPTypeRequest::ERequestParameter4 ); |
|
542 iPropertyArray.Reset(); |
|
543 GetPropertiesL( iPropertyArray, groupCode, formatCode ); |
|
544 |
|
545 const TInt count = iPropertyArray.Count(); |
|
546 |
|
547 TInt err = KErrNone; |
|
548 for ( TInt i = 0; i < count; i++ ) |
|
549 { |
|
550 err = ServiceOneObjectPropertyL( aHandle, iPropertyArray[i] ); |
|
551 if ( err == KErrNotSupported ) // Skip |
|
552 err = KErrNone; |
|
553 if ( err != KErrNone ) |
|
554 break; |
|
555 } |
|
556 |
|
557 PRINT1( _L( "MM MTP <= CGetObjectPropList::ServiceGroupPropertiesL err = %d" ), err ); |
|
558 |
|
559 return err; |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CGetObjectPropList::ServiceOneObjectPropertyL |
|
564 // Gets the object property information for the required object |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 TInt CGetObjectPropList::ServiceOneObjectPropertyL( TUint32 aHandle, |
|
568 TUint16 aPropCode ) |
|
569 { |
|
570 PRINT2( _L( "MM MTP => CGetObjectPropList::ServiceOneObjectPropertyL aHandle = 0x%x, aPropCode = 0x%x" ), |
|
571 aHandle, |
|
572 aPropCode ); |
|
573 CMTPTypeString* textData = NULL; |
|
574 TInt err = KErrNone; |
|
575 |
|
576 if ( iPropertyElement != NULL ) |
|
577 { |
|
578 delete iPropertyElement; |
|
579 iPropertyElement = NULL; |
|
580 } |
|
581 |
|
582 switch ( aPropCode ) |
|
583 { |
|
584 // Storage ID |
|
585 case EMTPObjectPropCodeStorageID: |
|
586 { |
|
587 TMTPTypeUint32 storageId( iObject->Uint( CMTPObjectMetaData::EStorageId ) ); |
|
588 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
589 iPropertyElement->SetUint32L(CMTPTypeObjectPropListElement::EValue, storageId.Value()); |
|
590 } |
|
591 break; |
|
592 |
|
593 // Format Code |
|
594 case EMTPObjectPropCodeObjectFormat: |
|
595 { |
|
596 TMTPTypeUint16 objectFormat( iObject->Uint( CMTPObjectMetaData::EFormatCode ) ); |
|
597 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
598 iPropertyElement->SetUint16L(CMTPTypeObjectPropListElement::EValue, objectFormat.Value()); |
|
599 } |
|
600 break; |
|
601 |
|
602 // Protection Status |
|
603 case EMTPObjectPropCodeProtectionStatus: |
|
604 { |
|
605 TMTPTypeUint16 protectionStatus( MmMtpDpUtility::GetProtectionStatusL( iFramework.Fs(), |
|
606 iObject->DesC( CMTPObjectMetaData::ESuid ) ) ); |
|
607 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
608 iPropertyElement->SetUint16L(CMTPTypeObjectPropListElement::EValue, protectionStatus.Value()); |
|
609 } |
|
610 break; |
|
611 |
|
612 // Object Size |
|
613 case EMTPObjectPropCodeObjectSize: |
|
614 { |
|
615 TMTPTypeUint64 objectSize( MmMtpDpUtility::GetObjectSizeL( iFramework.Fs(), |
|
616 iObject->DesC( CMTPObjectMetaData::ESuid ) ) ); |
|
617 iPropertyElement = &( iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
|
618 iPropertyElement->SetUint64L( CMTPTypeObjectPropListElement::EValue, objectSize.Value() ); |
|
619 } |
|
620 break; |
|
621 |
|
622 // Filename |
|
623 case EMTPObjectPropCodeObjectFileName: |
|
624 { |
|
625 #ifdef _DEBUG |
|
626 HBufC* log = iObject->DesC( CMTPObjectMetaData::ESuid ).Alloc(); |
|
627 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL FileName = %S" ), log ); |
|
628 delete log; |
|
629 log = NULL; |
|
630 #endif // _DEBUG |
|
631 TParsePtrC parse( iObject->DesC( CMTPObjectMetaData::ESuid ) ); |
|
632 textData = CMTPTypeString::NewLC( parse.NameAndExt() ); // + textData |
|
633 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
634 iPropertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
|
635 CleanupStack::PopAndDestroy( textData ); // - textData |
|
636 } |
|
637 break; |
|
638 |
|
639 // Parent Object |
|
640 case EMTPObjectPropCodeParentObject: |
|
641 { |
|
642 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
643 iPropertyElement->SetUint32L(CMTPTypeObjectPropListElement::EValue, iObject->Uint( CMTPObjectMetaData::EParentHandle )); |
|
644 } |
|
645 break; |
|
646 |
|
647 // PUID |
|
648 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
|
649 { |
|
650 TMTPTypeUint128 puid = iFramework.ObjectMgr().PuidL( aHandle ); |
|
651 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
652 iPropertyElement->SetUint128L(CMTPTypeObjectPropListElement::EValue,puid.UpperValue(), puid.LowerValue() ); |
|
653 } |
|
654 break; |
|
655 |
|
656 case EMTPObjectPropCodeName: |
|
657 case EMTPObjectPropCodeDateAdded: |
|
658 { |
|
659 if ( ( aPropCode == EMTPObjectPropCodeName ) |
|
660 || ( ( !MmMtpDpUtility::IsVideoL( iObject->DesC( CMTPObjectMetaData::ESuid ), iFramework ) ) |
|
661 && ( aPropCode == EMTPObjectPropCodeDateAdded ) ) ) |
|
662 { |
|
663 textData = CMTPTypeString::NewLC(); // + textData |
|
664 |
|
665 TRAP( err, iDpConfig.GetWrapperL().GetObjectMetadataValueL( aPropCode, |
|
666 *textData, |
|
667 *iObject ) ); |
|
668 |
|
669 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL err = %d" ), err ); |
|
670 |
|
671 if ( err == KErrNone ) |
|
672 { |
|
673 iPropertyElement = &(iPropertyList->ReservePropElemL( aHandle, aPropCode ) ); |
|
674 iPropertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, textData->StringChars()); |
|
675 } |
|
676 |
|
677 CleanupStack::PopAndDestroy( textData ); // - textData |
|
678 } |
|
679 } |
|
680 break; |
|
681 |
|
682 case EMTPObjectPropCodeDateCreated: |
|
683 case EMTPObjectPropCodeDateModified: |
|
684 { |
|
685 TTime dataModified; |
|
686 dataModified = MmMtpDpUtility::GetObjectDateModifiedL( iFramework.Fs(), |
|
687 iObject->DesC( CMTPObjectMetaData::ESuid ) ); |
|
688 |
|
689 TBuf<KMtpMaxDateTimeStringLength> timeStr; |
|
690 dataModified.FormatL( timeStr, KMtpDateTimeFormat ); |
|
691 PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr ); |
|
692 CMTPTypeString* datastring = CMTPTypeString::NewLC( timeStr ); // + datastring |
|
693 |
|
694 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
695 iPropertyElement->SetStringL(CMTPTypeObjectPropListElement::EValue, datastring->StringChars()); |
|
696 CleanupStack::PopAndDestroy( datastring ); // - datastring |
|
697 } |
|
698 break; |
|
699 |
|
700 // Consumable Value |
|
701 case EMTPObjectPropCodeNonConsumable: |
|
702 { |
|
703 iPropertyElement = &(iPropertyList->ReservePropElemL(aHandle, aPropCode)); |
|
704 iPropertyElement->SetUint8L(CMTPTypeObjectPropListElement::EValue,0); |
|
705 } |
|
706 break; |
|
707 |
|
708 default: |
|
709 { |
|
710 err = ServiceSpecificObjectPropertyL( aPropCode, aHandle ); |
|
711 } |
|
712 break; |
|
713 } |
|
714 |
|
715 if ( iPropertyElement != NULL ) |
|
716 { |
|
717 iPropertyList->CommitPropElemL( *iPropertyElement ); |
|
718 iPropertyElement = NULL; |
|
719 } |
|
720 |
|
721 PRINT( _L( "MM MTP <= CGetObjectPropList::ServiceOneObjectPropertyL" ) ); |
|
722 |
|
723 return err; |
|
724 } |
|
725 |
|
726 // ----------------------------------------------------------------------------- |
|
727 // CGetObjectPropList::RunL |
|
728 // |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 EXPORT_C void CGetObjectPropList::RunL() |
|
732 { |
|
733 if ( iHandles.Count() > 0 ) |
|
734 { |
|
735 TInt err = KErrNone; |
|
736 TUint32 handle = iHandles[0]; |
|
737 PRINT1( _L( "MM MTP <> CGetObjectPropList::RunL, handle = 0x%x" ), handle ); |
|
738 if ( iFramework.ObjectMgr().ObjectOwnerId( handle ) |
|
739 == iFramework.DataProviderId() ) |
|
740 { |
|
741 delete iObject; |
|
742 iObject = NULL; |
|
743 iObject = CMTPObjectMetaData::NewL(); |
|
744 |
|
745 if ( iFramework.ObjectMgr().ObjectL( handle, *iObject ) ) // Populate the object meta data |
|
746 { |
|
747 SetSubFormatCodeL(); |
|
748 |
|
749 if ( iPropCode == KMTPAll ) |
|
750 err = ServiceAllPropertiesL( handle ); |
|
751 else if ( iPropCode == EMTPObjectPropCodeUndefined ) |
|
752 { |
|
753 err = ServiceGroupPropertiesL( handle ); |
|
754 } |
|
755 if ( err == KErrNotFound ) |
|
756 SendResponseL( EMTPRespCodeAccessDenied ); |
|
757 else if ( err != KErrNone ) |
|
758 SendResponseL( EMTPRespCodeGeneralError ); |
|
759 } |
|
760 } |
|
761 |
|
762 // Complete ourselves with current TRequestStatus |
|
763 // Increase index to process next handle on next round |
|
764 // iFirstUnprocessed++; |
|
765 iHandles.Remove( 0 ); |
|
766 |
|
767 if ( err == KErrNone ) |
|
768 { |
|
769 TRequestStatus* status = &iStatus; |
|
770 User::RequestComplete( status, iStatus.Int() ); |
|
771 SetActive(); |
|
772 } |
|
773 } |
|
774 else // all handles processed, can send data |
|
775 { |
|
776 PRINT( _L( "MM MTP <> CGetObjectPropList::RunL, Finished, Send data to PC!" ) ); |
|
777 SendDataL( *iPropertyList ); |
|
778 } |
|
779 } |
|
780 |
|
781 // ----------------------------------------------------------------------------- |
|
782 // CGetObjectPropList::RunError |
|
783 // |
|
784 // ----------------------------------------------------------------------------- |
|
785 // |
|
786 EXPORT_C TInt CGetObjectPropList::RunError( TInt aError ) |
|
787 { |
|
788 PRINT1( _L( "MM MTP <> CGetObjectPropList::RunError aError = %d" ), aError ); |
|
789 TRAP_IGNORE( SendResponseL( EMTPRespCodeGeneralError ) ); |
|
790 |
|
791 return KErrNone; |
|
792 } |
|
793 |
|
794 // ----------------------------------------------------------------------------- |
|
795 // CGetObjectPropList::DoCancel() |
|
796 // Cancel the process |
|
797 // ----------------------------------------------------------------------------- |
|
798 // |
|
799 EXPORT_C void CGetObjectPropList::DoCancel() |
|
800 { |
|
801 // TODO: need to send the data here? |
|
802 // SendDataL( *iPropertyList ); |
|
803 } |
|
804 |
|
805 void CGetObjectPropList::GetPropertiesL( RArray<TUint>& aPropArray, |
|
806 TUint32 aGroupCode, |
|
807 TUint16 aFormatCode ) const |
|
808 { |
|
809 aPropArray.Reset(); |
|
810 |
|
811 const RArray<TUint>* properties = NULL; |
|
812 if ( aFormatCode == KMTPFormatsAll ) |
|
813 properties = iDpConfig.GetAllSupportedProperties(); |
|
814 else |
|
815 properties = iDpConfig.GetSupportedPropertiesL( aFormatCode ); |
|
816 |
|
817 TInt count = sizeof ( KPropGroupMapTable ) / sizeof ( KPropGroupMapTable[0] ); |
|
818 for ( TInt i = 0; i < properties->Count(); i++ ) |
|
819 { |
|
820 for ( TInt j = 0; j < count; j++ ) |
|
821 { |
|
822 if( KPropGroupMapTable[j].iPropCode == (*properties)[i] |
|
823 && KPropGroupMapTable[j].iGroupCode == aGroupCode ) |
|
824 { |
|
825 aPropArray.Append( (*properties)[i] ); |
|
826 break; |
|
827 } |
|
828 } |
|
829 } |
|
830 } |
|
831 |
|
832 void CGetObjectPropList::SetSubFormatCodeL() |
|
833 { |
|
834 __ASSERT_DEBUG( iObject, Panic( EMmMTPDpObjectNull ) ); |
|
835 |
|
836 // Note: Parsing out subformat code in external enumeration phase. |
|
837 // This process was delayed in internal phase to avoid time-out. |
|
838 TUint16 formatCode = iObject->Uint( CMTPObjectMetaData::EFormatCode ); |
|
839 TUint subFormatCode = iObject->Uint( CMTPObjectMetaData::EFormatSubCode ); |
|
840 PRINT2( _L( "MM MTP <> CGetObjectPropList::SetSubFormatCode, formatCode = 0x%x, subFormatCode = 0x%x" ), |
|
841 formatCode, |
|
842 subFormatCode ); |
|
843 |
|
844 TBool ifNeedParse = ( ( formatCode == EMTPFormatCodeMP4Container ) |
|
845 || ( formatCode == EMTPFormatCode3GPContainer ) |
|
846 || ( formatCode== EMTPFormatCodeASF ) ) |
|
847 && ( subFormatCode == EMTPSubFormatCodeUnknown ); |
|
848 if ( ifNeedParse ) |
|
849 { |
|
850 PERFLOGSTART( KSubFormatParse ); |
|
851 |
|
852 if ( MmMtpDpUtility::IsVideoL( iObject->DesC( CMTPObjectMetaData::ESuid ) ) ) |
|
853 subFormatCode = EMTPSubFormatCodeVideo; |
|
854 else |
|
855 subFormatCode = EMTPSubFormatCodeAudio; |
|
856 |
|
857 PERFLOGSTOP( KSubFormatParse ); |
|
858 |
|
859 iObject->SetUint( CMTPObjectMetaData::EFormatSubCode, subFormatCode ); |
|
860 } |
|
861 } |
|
862 |
|
863 // end of file |