mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp
changeset 0 d0791faffa3f
child 12 523717cdb0ad
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     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 <mtp/tmtptyperequest.h>
       
    22 #include <mtp/mmtpdataproviderframework.h>
       
    23 #include <mtp/mtpprotocolconstants.h>
       
    24 #include <mtp/mmtpobjectmgr.h>
       
    25 #include <mtp/cmtptypeobjectinfo.h>
       
    26 #include <mtp/cmtpobjectmetadata.h>
       
    27 #include <mtp/cmtptypestring.h>
       
    28 
       
    29 #include "cmtpimagedpgetobjectinfo.h"
       
    30 #include "cmtpimagedpobjectpropertymgr.h"
       
    31 #include "mtpimagedpconst.h"
       
    32 #include "mtpimagedppanic.h"
       
    33 #include "cmtpimagedp.h"
       
    34 #include "mtpimagedputilits.h"
       
    35 
       
    36 __FLOG_STMT(_LIT8(KComponent,"CMTPImageDpGetObjectInfo");)
       
    37 
       
    38 /**
       
    39 Two-phase construction method
       
    40 @param aFramework	The data provider framework
       
    41 @param aConnection	The connection from which the request comes
       
    42 @return a pointer to the created request processor object
       
    43 */    
       
    44 MMTPRequestProcessor* CMTPImageDpGetObjectInfo::NewL(MMTPDataProviderFramework& aFramework,											
       
    45                                             MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider)
       
    46     {
       
    47     CMTPImageDpGetObjectInfo* self = new (ELeave) CMTPImageDpGetObjectInfo(aFramework, aConnection,aDataProvider);
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop(self);
       
    51     return self;
       
    52     }
       
    53     
       
    54 /**
       
    55 Destructor
       
    56 */	
       
    57 CMTPImageDpGetObjectInfo::~CMTPImageDpGetObjectInfo()
       
    58     {
       
    59     __FLOG(_L8(">> ~CMTPImageDpGetObjectInfo"));
       
    60     delete iObjectInfoToBuild;
       
    61     delete iObjectMeta;
       
    62     __FLOG(_L8("<< ~CMTPImageDpGetObjectInfo"));
       
    63     __FLOG_CLOSE;
       
    64     }
       
    65 
       
    66 /**
       
    67 Standard c++ constructor
       
    68 */	
       
    69 CMTPImageDpGetObjectInfo::CMTPImageDpGetObjectInfo(MMTPDataProviderFramework& aFramework,
       
    70                                     MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) : 
       
    71     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
       
    72     iObjectPropertyMgr(aDataProvider.PropertyMgr())
       
    73     {
       
    74     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
    75     __FLOG(_L8("CMTPImageDpGetObjectInfo::CMTPImageDpGetObjectInfo"));
       
    76     }
       
    77 
       
    78 TMTPResponseCode CMTPImageDpGetObjectInfo::CheckRequestL()
       
    79     {
       
    80     __FLOG(_L8(">> CMTPImageDpGetObject::CheckRequestL"));
       
    81     TMTPResponseCode result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
       
    82     __FLOG(_L8("<< CMTPImageDpGetObject::CheckRequestL"));
       
    83     return result;
       
    84     }
       
    85     
       
    86 /**
       
    87 GetObjectInfo request handler
       
    88 */		
       
    89 void CMTPImageDpGetObjectInfo::ServiceL()
       
    90     {
       
    91     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::ServiceL"));
       
    92     BuildObjectInfoL();
       
    93     SendDataL(*iObjectInfoToBuild);	
       
    94     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::ServiceL"));
       
    95     }
       
    96     
       
    97 /**
       
    98 Second-phase construction
       
    99 */		
       
   100 void CMTPImageDpGetObjectInfo::ConstructL()
       
   101     {
       
   102     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::ConstructL"));
       
   103     iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
       
   104     iObjectMeta = CMTPObjectMetaData::NewL();
       
   105     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::ConstructL"));
       
   106     }
       
   107     
       
   108 /**
       
   109 Populate the object info dataset
       
   110 */		
       
   111 void CMTPImageDpGetObjectInfo::BuildObjectInfoL()	
       
   112     {
       
   113     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::BuildObjectInfoL"));
       
   114     iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse);
       
   115     
       
   116     //1. storage id
       
   117     TUint32 storageId;
       
   118     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeStorageID, storageId);
       
   119     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId);	
       
   120     
       
   121     //2. object format
       
   122     TUint16 format;
       
   123     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFormat, format);
       
   124     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format);
       
   125     
       
   126     //3. protection status,
       
   127     TUint16 protection;
       
   128     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
       
   129     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection);
       
   130     
       
   131     //4. object compressed size
       
   132     // see SetFileSizeDateL
       
   133     
       
   134     //5. thumb format	
       
   135     //6. thumb compressed size
       
   136     //7. thumb pix width
       
   137     //8, thumb pix height
       
   138     //9. image pix width
       
   139     //10. image pix height
       
   140     //11. image bit depth
       
   141     TUint16 thumbFormat;
       
   142     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleFormat, thumbFormat);
       
   143     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, thumbFormat);
       
   144     TUint32 value;
       
   145     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, value);
       
   146     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, value);
       
   147     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleWidth, value);
       
   148     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixWidth, value);
       
   149     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleHeight, value);
       
   150     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbPixHeight, value);
       
   151     
       
   152     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeWidth, value);
       
   153     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixWidth, value);
       
   154     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeHeight, value);
       
   155     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImagePixHeight, value);
       
   156     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeImageBitDepth, value);
       
   157     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, value);
       
   158     
       
   159     //12. Parent object
       
   160     TUint32 parent;
       
   161     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeParentObject, parent);
       
   162     if(KMTPHandleNoParent == parent)
       
   163         {
       
   164         parent = KMTPHandleNone;
       
   165         }
       
   166     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EParentObject, parent);
       
   167         
       
   168     //13 and 14. Association type and description
       
   169     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EAssociationType, 0);
       
   170     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EAssociationDescription, 0);
       
   171         
       
   172     //15. sequence number
       
   173     //TUint32 sequenceNum;
       
   174     //iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeAssociationDesc, sequenceNum);
       
   175     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0);
       
   176     
       
   177     //16. file name
       
   178     SetFileNameL();
       
   179     
       
   180     //4, compressed size, 17 Date created, and 18 Date modified
       
   181     SetFileSizeDateL();
       
   182     
       
   183     //18. keyword
       
   184     SetKeywordL();
       
   185     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::BuildObjectInfoL"));
       
   186     }
       
   187 /**
       
   188 Set the file name of the current object in the data set
       
   189 @param aObjectInfo The object info of the current object
       
   190 */	
       
   191 void CMTPImageDpGetObjectInfo::SetFileNameL()
       
   192     {
       
   193     //use the name without full path specification
       
   194     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetFileNameL"));
       
   195     CMTPTypeString* fileName = CMTPTypeString::NewLC();
       
   196     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFileName, *fileName);
       
   197     iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EFilename, fileName->StringChars());
       
   198     CleanupStack::PopAndDestroy(fileName);
       
   199     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetFileNameL"));
       
   200     }
       
   201     
       
   202 /**
       
   203 Set the file size and modified/created date in the data set
       
   204 @param aObjectInfo The object info of the current object
       
   205 */	
       
   206 void CMTPImageDpGetObjectInfo::SetFileSizeDateL()
       
   207     {
       
   208     //file size
       
   209     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetFileSizeDateL"));
       
   210     TUint64 fileSize;
       
   211     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectSize, fileSize);
       
   212     TUint32 shortFileSize = (fileSize > KMaxTUint32) ? KMaxTUint32 : static_cast<TUint32>(fileSize);
       
   213     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, shortFileSize);
       
   214     
       
   215     //file modified time
       
   216     CMTPTypeString* dateString = CMTPTypeString::NewLC();
       
   217     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateModified, *dateString);
       
   218     iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateModified, dateString->StringChars());
       
   219     
       
   220     CMTPTypeString* createdString = CMTPTypeString::NewLC();
       
   221     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeDateCreated, *createdString);
       
   222     iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, createdString->StringChars());	
       
   223     
       
   224     CleanupStack::PopAndDestroy(2); // createdString, dateString
       
   225     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetFileSizeDateL"));
       
   226     }
       
   227     
       
   228 /**
       
   229 Set the keyword of the current object in the data set
       
   230 @param aObjectInfo The object info of the current object
       
   231 */	
       
   232 void CMTPImageDpGetObjectInfo::SetKeywordL()
       
   233     {
       
   234     //empty keyword
       
   235     __FLOG(_L8(">> CMTPImageDpGetObjectInfo::SetKeywordL"));
       
   236     iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
       
   237     __FLOG(_L8("<< CMTPImageDpGetObjectInfo::SetKeywordL"));
       
   238     }