mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cgetobjectreferences.cpp
changeset 0 a2952bb97e68
child 17 780c925249c1
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 the operation: GetObjectReferences
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mtp/cmtptypearray.h>
       
    20 #include <mtp/mmtpdataproviderframework.h>
       
    21 #include <mtp/mmtpreferencemgr.h>
       
    22 #ifdef _DEBUG
       
    23 #include <mtp/cmtpobjectmetadata.h>
       
    24 #include <mtp/mmtpobjectmgr.h>
       
    25 #include <mtp/tmtptypeuint128.h>
       
    26 #endif
       
    27 
       
    28 #include "cgetobjectreferences.h"
       
    29 #include "mmmtpdplogger.h"
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // Verification data for the GetReferences request
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 const TMTPRequestElementInfo KMTPGetObjectReferencesPolicy[] =
       
    36     {
       
    37         {
       
    38         TMTPTypeRequest::ERequestParameter1,
       
    39         EMTPElementTypeObjectHandle,
       
    40         EMTPElementAttrNone,
       
    41         0,
       
    42         0,
       
    43         0
       
    44         }
       
    45     };
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CGetObjectReferences::NewL
       
    49 // Two-phase construction method
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C MMmRequestProcessor* CGetObjectReferences::NewL( MMTPDataProviderFramework& aFramework,
       
    53     MMTPConnection& aConnection,
       
    54     MMmMtpDpConfig& /*aDpConfig*/ )
       
    55     {
       
    56     CGetObjectReferences* self = new ( ELeave ) CGetObjectReferences( aFramework,
       
    57         aConnection );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61 
       
    62     return self;
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CGetObjectReferences::ConstructL
       
    67 // Two-phase construction method
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CGetObjectReferences::ConstructL()
       
    71     {
       
    72     SetPSStatus();
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CGetObjectReferences::~CGetObjectReferences
       
    77 // Destructor
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C CGetObjectReferences::~CGetObjectReferences()
       
    81     {
       
    82     delete iReferences;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CGetObjectReferences::CGetObjectReferences
       
    87 // Standard c++ constructor
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CGetObjectReferences::CGetObjectReferences( MMTPDataProviderFramework& aFramework,
       
    91     MMTPConnection& aConnection ) :
       
    92     CRequestProcessor( aFramework,
       
    93         aConnection,
       
    94         sizeof ( KMTPGetObjectReferencesPolicy ) / sizeof( TMTPRequestElementInfo ),
       
    95         KMTPGetObjectReferencesPolicy )
       
    96     {
       
    97     PRINT( _L( "Operation: GetObjectReferences(0x9810)" ) );
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CGetObjectReferences::ServiceL
       
   102 // GetObjectInfo request handler
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CGetObjectReferences::ServiceL()
       
   106     {
       
   107     PRINT( _L( "MM MTP => CGetObjectReferences::ServiceL" ) );
       
   108 
       
   109     TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
       
   110     PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL objectHandle = 0x%x" ),
       
   111             objectHandle );
       
   112     MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr();
       
   113     delete iReferences;
       
   114     iReferences = NULL;
       
   115     iReferences = referenceMgr.ReferencesLC( TMTPTypeUint32( objectHandle ) );
       
   116     CleanupStack::Pop( iReferences );
       
   117     SendDataL( *iReferences );
       
   118 
       
   119 #if _DEBUG
       
   120     TUint32 handle = 0;
       
   121     TUint count = iReferences->NumElements();
       
   122     PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL count = %d" ), count );
       
   123     CMTPObjectMetaData* object = NULL;
       
   124     for( TUint i = 0; i < count; i++ )
       
   125         {
       
   126         object = CMTPObjectMetaData::NewLC(); // + object
       
   127         handle = iReferences->ElementUint( i );
       
   128         PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL handle = 0x%x" ), handle );
       
   129         iFramework.ObjectMgr().ObjectL( handle, *object);
       
   130         PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL object file name is %S" ), &object->DesC( CMTPObjectMetaData::ESuid ) );
       
   131         CleanupStack::PopAndDestroy( object ); // - object
       
   132         TMTPTypeUint128 puoid;
       
   133         puoid.Set( 0, 0 );
       
   134         puoid = iFramework.ObjectMgr().PuidL( handle );
       
   135         PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL higher value of puoid = 0x%04Lx" ), puoid.UpperValue() );
       
   136         PRINT1( _L( "MM MTP <> CGetObjectReferences::ServiceL lower value of puoid = 0x%04Lx" ), puoid.LowerValue() );
       
   137         }
       
   138 #endif
       
   139 
       
   140     PRINT( _L( "MM MTP <= CGetObjectReferences::ServiceL" ) );
       
   141     }
       
   142 
       
   143 // end of file