mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectinfo.cpp
changeset 0 d0791faffa3f
child 4 60a94a45d437
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     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 #include <mtp/tmtptyperequest.h>
       
    17 #include <mtp/mmtpdataproviderframework.h>
       
    18 #include <mtp/mtpprotocolconstants.h>
       
    19 #include <mtp/mmtpobjectmgr.h>
       
    20 #include <mtp/cmtptypeobjectinfo.h>
       
    21 #include <mtp/cmtpobjectmetadata.h>
       
    22 #include <mtp/cmtptypestring.h>
       
    23 
       
    24 #include "cmtpgetobjectinfo.h"
       
    25 #include "mtpdppanic.h"
       
    26 
       
    27 /**
       
    28 Verification data for GetObjectInfo request
       
    29 */
       
    30 const TMTPRequestElementInfo KMTPGetObjectInfoPolicy[] = 
       
    31     {
       
    32         {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 0, 0, 0}
       
    33     };
       
    34 
       
    35 /**
       
    36 Two-phase construction method
       
    37 @param aFramework	The data provider framework
       
    38 @param aConnection	The connection from which the request comes
       
    39 @return a pointer to the created request processor object
       
    40 */    
       
    41 EXPORT_C MMTPRequestProcessor* CMTPGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework,											
       
    42 											MMTPConnection& aConnection)
       
    43 	{
       
    44 	CMTPGetObjectInfo* self = new (ELeave) CMTPGetObjectInfo(aFramework, aConnection);
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop(self);
       
    48 	return self;
       
    49 	}
       
    50 
       
    51 /**
       
    52 Destructor
       
    53 */	
       
    54 EXPORT_C CMTPGetObjectInfo::~CMTPGetObjectInfo()
       
    55 	{	
       
    56 	delete iObjectInfoToBuild;
       
    57 	iDpSingletons.Close();
       
    58 	}
       
    59 
       
    60 /**
       
    61 Standard c++ constructor
       
    62 */	
       
    63 CMTPGetObjectInfo::CMTPGetObjectInfo(MMTPDataProviderFramework& aFramework,
       
    64 									MMTPConnection& aConnection)
       
    65 	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectInfoPolicy),
       
    66 	iRfs(aFramework.Fs())
       
    67 	{
       
    68 	}
       
    69 
       
    70 /**
       
    71 GetObjectInfo request handler
       
    72 */		
       
    73 void CMTPGetObjectInfo::ServiceL()
       
    74 	{
       
    75 	BuildObjectInfoL();
       
    76 	SendDataL(*iObjectInfoToBuild);	
       
    77 	}
       
    78 
       
    79 /**
       
    80 Second-phase construction
       
    81 */		
       
    82 void CMTPGetObjectInfo::ConstructL()
       
    83 	{
       
    84 	iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
       
    85 	iDpSingletons.OpenL(iFramework);
       
    86 	}
       
    87 
       
    88 /**
       
    89 Populate the object info dataset
       
    90 */		
       
    91 void CMTPGetObjectInfo::BuildObjectInfoL()	
       
    92 	{
       
    93 	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
       
    94 	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    95 	//does not take owernship
       
    96 	CMTPObjectMetaData* objectInfoFromStore = iRequestChecker->GetObjectInfo(objectHandle);
       
    97 	__ASSERT_DEBUG(objectInfoFromStore, Panic(EMTPDpObjectNull));
       
    98 	
       
    99 	TEntry fileEntry;
       
   100 	User::LeaveIfError(iRfs.Entry(objectInfoFromStore->DesC(CMTPObjectMetaData::ESuid), fileEntry));
       
   101 			
       
   102 	//1. storage id
       
   103 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, objectInfoFromStore->Uint(CMTPObjectMetaData::EStorageId));	
       
   104 	
       
   105 	//2. object format
       
   106 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatCode));
       
   107 	
       
   108 	//3. protection status,
       
   109 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, fileEntry.IsReadOnly());
       
   110 	
       
   111 	//4. object compressed size
       
   112 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, fileEntry.FileSize());
       
   113 	
       
   114 	//5. thumb format	
       
   115 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, 0);
       
   116 	
       
   117 	//6. thumb compressed size
       
   118 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, 0);
       
   119 	
       
   120 	//7. thumb pix width
       
   121 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, 0);
       
   122 	
       
   123 	//8, thumb pix height
       
   124 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, 0);
       
   125 	
       
   126 	//9. image pix width
       
   127 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, 0);
       
   128 	
       
   129 	//10. image pix height
       
   130 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, 0);
       
   131 	
       
   132 	//11. image bit depth
       
   133 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, 0);
       
   134 	
       
   135 	//12. Parent object
       
   136 	TUint32 parentHandle = objectInfoFromStore->Uint(CMTPObjectMetaData::EParentHandle);
       
   137 	// refer to 5.3.1.9 of MTP Spec 1.0 
       
   138 	if (parentHandle == KMTPHandleNoParent)
       
   139 	    {
       
   140 	    parentHandle = 0;
       
   141 	    }
       
   142 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EParentObject, parentHandle);
       
   143 		
       
   144 	//13 and 14. Association type and description
       
   145 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EAssociationType, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatSubCode));	
       
   146 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
       
   147 		
       
   148 	//15. sequence number
       
   149 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
       
   150 	
       
   151 	//16. file name
       
   152 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EFilename, fileEntry.iName);
       
   153 	
       
   154 	//17. Date created
       
   155 	TBuf<64> dateString;	
       
   156 	iDpSingletons.MTPUtility().TTime2MTPTimeStr(fileEntry.iModified, dateString);
       
   157 	//file modified time
       
   158 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateModified, dateString);
       
   159 	
       
   160 	//18. Date modified
       
   161 	//file creation time, set it as the same as modified time, as Symbian does not support this field
       
   162 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, dateString);	
       
   163 		
       
   164 	//19. keyword
       
   165 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
       
   166 	}
       
   167