mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cgetobjectinfo.cpp
changeset 0 a2952bb97e68
child 9 05b0d2323768
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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 operation: GetObjectInfo
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mtp/mmtpdataproviderframework.h>
       
    20 #include <mtp/cmtptypeobjectinfo.h>
       
    21 #include <f32file.h>
       
    22 
       
    23 #include "mmmtpdputility.h"
       
    24 #include "cgetobjectinfo.h"
       
    25 #include "cmmmtpdpmetadataaccesswrapper.h"
       
    26 #include "tmmmtpdppanic.h"
       
    27 #include "mmmtpdplogger.h"
       
    28 #include "mmmtpdpconfig.h"
       
    29 
       
    30 _LIT( KMtpDateTimeFormat, "%F%Y%M%DT%H%T%S" );
       
    31 const TInt KMtpMaxDateTimeStringLength = 15;
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // Verification data for GetObjectInfo request
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 const TMTPRequestElementInfo KMTPGetObjectInfoPolicy[] =
       
    38     {
       
    39         {
       
    40         TMTPTypeRequest::ERequestParameter1,
       
    41         EMTPElementTypeObjectHandle,
       
    42         EMTPElementAttrNone,
       
    43         0,
       
    44         0,
       
    45         0
       
    46         }
       
    47     };
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CGetObjectInfo::NewL
       
    51 // Two-phase construction method
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C MMmRequestProcessor* CGetObjectInfo::NewL( MMTPDataProviderFramework& aFramework,
       
    55     MMTPConnection& aConnection,
       
    56     MMmMtpDpConfig& aDpConfig )
       
    57     {
       
    58     CGetObjectInfo* self = new ( ELeave ) CGetObjectInfo( aFramework, aConnection, aDpConfig );
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62 
       
    63     return self;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CGetObjectInfo::~CGetObjectInfo
       
    68 // Destructor
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C CGetObjectInfo::~CGetObjectInfo()
       
    72     {
       
    73     delete iObjectInfo;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CGetObjectInfo::CGetObjectInfo
       
    78 // Standard c++ constructor
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CGetObjectInfo::CGetObjectInfo( MMTPDataProviderFramework& aFramework,
       
    82     MMTPConnection& aConnection,
       
    83     MMmMtpDpConfig& aDpConfig ) :
       
    84     CRequestProcessor( aFramework,
       
    85         aConnection,
       
    86         sizeof ( KMTPGetObjectInfoPolicy ) / sizeof( TMTPRequestElementInfo ),
       
    87         KMTPGetObjectInfoPolicy ),
       
    88     iDpConfig( aDpConfig )
       
    89     {
       
    90     PRINT( _L( "Operation: GetObjectInfo(0x1008)" ) );
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CGetObjectInfo::ConstructL
       
    95 // Second-phase construction
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 EXPORT_C void CGetObjectInfo::ConstructL()
       
    99     {
       
   100     CActiveScheduler::Add( this );
       
   101 
       
   102     SetPSStatus();
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CGetObjectInfo::ServiceL
       
   107 // GetObjectInfo request handler
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CGetObjectInfo::ServiceL()
       
   111     {
       
   112     PRINT( _L( "MM MTP => CGetObjectInfo::ServiceL" ) );
       
   113 
       
   114     delete iObjectInfo;
       
   115     iObjectInfo = NULL;
       
   116     iObjectInfo = CMTPTypeObjectInfo::NewL();
       
   117 
       
   118     BuildObjectInfoL();
       
   119 
       
   120     SendDataL( *iObjectInfo );
       
   121 
       
   122     PRINT( _L( "MM MTP <= CGetObjectInfo::ServiceL" ) );
       
   123     }
       
   124 
       
   125 void CGetObjectInfo::BuildObjectInfoL()
       
   126     {
       
   127     PRINT( _L( "MM MTP => CGetObjectInfo::BuildObjectInfoL" ) );
       
   128     // Get the request information
       
   129     TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
       
   130     PRINT1( _L( "MM MTP <> CGetObjectInfo::BuildObjectInfoL The object handle being queried is: 0x%x" ), objectHandle );
       
   131 
       
   132     CMTPObjectMetaData* object = iRequestChecker->GetObjectInfo( objectHandle );
       
   133     __ASSERT_DEBUG( object, Panic( EMmMTPDpObjectNull ) );
       
   134 
       
   135     // StorageID
       
   136     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EStorageID,
       
   137         object->Uint( CMTPObjectMetaData::EStorageId ) );
       
   138 
       
   139     // Object Format
       
   140     iObjectInfo->SetUint16L( CMTPTypeObjectInfo::EObjectFormat,
       
   141         object->Uint( CMTPObjectMetaData::EFormatCode ) );
       
   142     PRINT1( _L( "MM MTP <> CGetObjectInfo::BuildObjectInfoL objet formatCode = 0x%x" ),
       
   143         object->Uint( CMTPObjectMetaData::EFormatCode ) );
       
   144 
       
   145     // Protection Status
       
   146     TPtrC suid( object->DesC( CMTPObjectMetaData::ESuid ) );
       
   147     PRINT1( _L( "MM MTP <> CGetObjectInfo::BuildObjectInfo suid = %S" ), &suid );
       
   148     TUint16 status = MmMtpDpUtility::GetProtectionStatusL( iFramework.Fs(), suid );
       
   149     iObjectInfo->SetUint16L( CMTPTypeObjectInfo::EProtectionStatus, status);
       
   150 
       
   151     // Object Compressed Size
       
   152     TInt size = MmMtpDpUtility::GetObjectSizeL( iFramework.Fs(), suid );
       
   153     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EObjectCompressedSize, size );
       
   154 
       
   155     // *Thumb Format
       
   156     iObjectInfo->SetUint16L( CMTPTypeObjectInfo::EThumbFormat, 0 );
       
   157     // *Thumb Compressed Size
       
   158     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EThumbCompressedSize, 0 );
       
   159     // *Thumb Pix Width
       
   160     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EThumbPixWidth, 0 );
       
   161     // *Thumb Pix Height
       
   162     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EThumbPixHeight, 0 );
       
   163 
       
   164     TUint32 width(0);
       
   165     TUint32 height(0);
       
   166     TInt err = KErrNone;
       
   167     TRAP( err, iDpConfig.GetWrapperL().GetImageObjPropL( suid, width, height ) );
       
   168     if( err != KErrNone )
       
   169         PRINT1( _L( "MM MTP <> CGetObjectInfo::BuildObjectInfoL TRAP iWrapper.GetImageObjPropL err = %d" ), err );
       
   170 
       
   171     // Image Pix Width
       
   172     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EImagePixWidth, width );
       
   173     // Image Pix Height
       
   174     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EImagePixHeight, height );
       
   175 
       
   176     // Image Bit Depth
       
   177     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EImageBitDepth, 0 );
       
   178     // Parent Object
       
   179     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EParentObject,
       
   180         object->Uint( CMTPObjectMetaData::EParentHandle ) );
       
   181     // Association Type
       
   182     iObjectInfo->SetUint16L( CMTPTypeObjectInfo::EAssociationType, 0 );
       
   183     // Association Description
       
   184     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::EAssociationDescription, 0 );
       
   185     // *Sequence Number
       
   186     iObjectInfo->SetUint32L( CMTPTypeObjectInfo::ESequenceNumber, 0 );
       
   187     // Filename
       
   188     TParsePtrC parse( suid );
       
   189     iObjectInfo->SetStringL( CMTPTypeObjectInfo::EFilename, parse.NameAndExt() );
       
   190 
       
   191     TTime dataModified;
       
   192     dataModified = MmMtpDpUtility::GetObjectDateModifiedL( iFramework.Fs(), suid );
       
   193 
       
   194     TBuf<KMtpMaxDateTimeStringLength> date;
       
   195     dataModified.FormatL( date, KMtpDateTimeFormat );
       
   196     PRINT1( _L( "MM MTP <> CGetObjectInfo::BuildObjectInfo date is %S" ), &date );
       
   197 
       
   198     // Date Created
       
   199     iObjectInfo->SetStringL( CMTPTypeObjectInfo::EDateCreated, date );
       
   200     // Date Modified
       
   201     iObjectInfo->SetStringL( CMTPTypeObjectInfo::EDateModified, date );
       
   202     // Keywords, not supported
       
   203     iObjectInfo->SetStringL( CMTPTypeObjectInfo::EKeywords, KNullDesC );
       
   204 
       
   205     PRINT( _L( "MM MTP <= CGetObjectInfo::BuildObjectInfoL" ) );
       
   206     }
       
   207 
       
   208 // end of file