mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp
changeset 47 63cf70d3ecd8
parent 17 aabe5387f5ce
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    21 #include <mtp/mmtpobjectmgr.h>
    21 #include <mtp/mmtpobjectmgr.h>
    22 #include <mtp/cmtpobjectmetadata.h>
    22 #include <mtp/cmtpobjectmetadata.h>
    23 
    23 
    24 #include "cmtprequestchecker.h"
    24 #include "cmtprequestchecker.h"
    25 #include "mtpdppanic.h"
    25 #include "mtpdppanic.h"
    26 
    26 #include "OstTraceDefinitions.h"
    27 __FLOG_STMT(_LIT8(KComponent,"ObjectBrowser");)
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "cmtpobjectbrowserTraces.h"
       
    29 #endif
       
    30 
    28 
    31 
    29 
    32 
    30 CMTPObjectBrowser* CMTPObjectBrowser::NewL( MMTPDataProviderFramework& aDpFw )
    33 CMTPObjectBrowser* CMTPObjectBrowser::NewL( MMTPDataProviderFramework& aDpFw )
    31     {
    34     {
    32     CMTPObjectBrowser* self = new( ELeave ) CMTPObjectBrowser( aDpFw );
    35     CMTPObjectBrowser* self = new( ELeave ) CMTPObjectBrowser( aDpFw );
    41     return ( ( EMTPFormatCodeAssociation == aFmtCode ) && ( EMTPAssociationTypeGenericFolder == aFmtSubCode ) );
    44     return ( ( EMTPFormatCodeAssociation == aFmtCode ) && ( EMTPAssociationTypeGenericFolder == aFmtSubCode ) );
    42     }
    45     }
    43 
    46 
    44 CMTPObjectBrowser::~CMTPObjectBrowser()
    47 CMTPObjectBrowser::~CMTPObjectBrowser()
    45     {
    48     {
       
    49     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_CMTPOBJECTBROWSER_ENTRY );
    46     delete iObjMetaCache;
    50     delete iObjMetaCache;
    47     __FLOG( _L8("+/-Dtor") );
    51     OstTraceFunctionExit0( CMTPOBJECTBROWSER_CMTPOBJECTBROWSER_EXIT );
    48     __FLOG_CLOSE;
       
    49     }
    52     }
    50 
    53 
    51 void CMTPObjectBrowser::GoL( TUint32 aFormatCode, TUint32 aHandle, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
    54 void CMTPObjectBrowser::GoL( TUint32 aFormatCode, TUint32 aHandle, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
    52     {
    55     {
    53     __FLOG_VA( ( _L8("+GoL( 0x%08X, 0x%08X, %d )"), aFormatCode, aHandle, aDepth ) );
    56     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GOL_ENTRY );
       
    57     OstTraceExt3(TRACE_NORMAL, CMTPOBJECTBROWSER_GOL, "0x%08X, 0x%08X, %d",
       
    58             aFormatCode, aHandle, aDepth);
    54     
    59     
    55     switch ( aHandle )
    60     switch ( aHandle )
    56         {
    61         {
    57         case KMTPHandleAll:
    62         case KMTPHandleAll:
    58             GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
    63             GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
    64         default:
    69         default:
    65             GetObjectHandlesTreeL( 0, aFormatCode, aDepth, aHandle, aBrowseCallback );
    70             GetObjectHandlesTreeL( 0, aFormatCode, aDepth, aHandle, aBrowseCallback );
    66             break;
    71             break;
    67         }
    72         }
    68     
    73     
    69     __FLOG( _L8("-GoL") );
    74     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GOL_EXIT );
    70     }
    75     }
    71 
    76 
    72 CMTPObjectBrowser::CMTPObjectBrowser( MMTPDataProviderFramework& aDpFw ):
    77 CMTPObjectBrowser::CMTPObjectBrowser( MMTPDataProviderFramework& aDpFw ):
    73     iDpFw( aDpFw )
    78     iDpFw( aDpFw )
    74     {
    79     {
    75     __FLOG_OPEN( KMTPSubsystem, KComponent );
    80     OstTraceFunctionEntry0( DUP1_CMTPOBJECTBROWSER_CMTPOBJECTBROWSER_ENTRY );
    76     __FLOG( _L8("+/-Ctor") );
    81     OstTraceFunctionExit0( DUP1_CMTPOBJECTBROWSER_CMTPOBJECTBROWSER_EXIT );
    77     }
    82     }
    78 
    83 
    79 void CMTPObjectBrowser::ConstructL()
    84 void CMTPObjectBrowser::ConstructL()
    80     {
    85     {
    81     __FLOG( _L8("+ConstructL") );
    86     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_CONSTRUCTL_ENTRY );
    82     iObjMetaCache = CMTPObjectMetaData::NewL();
    87     iObjMetaCache = CMTPObjectMetaData::NewL();
    83     __FLOG( _L8("-ConstructL") );
    88     OstTraceFunctionExit0( CMTPOBJECTBROWSER_CONSTRUCTL_EXIT );
    84     }
    89     }
    85 
    90 
    86 void CMTPObjectBrowser::GetObjectHandlesL( TUint32 aCurDepth, TUint32 aStorageId, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
    91 void CMTPObjectBrowser::GetObjectHandlesL( TUint32 aCurDepth, TUint32 aStorageId, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
    87     {
    92     {
    88     __FLOG_VA( ( _L8("+GetObjectHandlesL( %d, 0x%08X, 0x%08X, %d, 0x%08X )"), aCurDepth, aStorageId, aFormatCode, aDepth, aParentHandle ) );
    93     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GETOBJECTHANDLESL_ENTRY );
       
    94     OstTraceExt5(TRACE_NORMAL, CMTPOBJECTBROWSER_GETOBJECTHANDLESL, "%d, 0x%08X, 0x%08X, %d, 0x%08X",
       
    95             aCurDepth, aStorageId, aFormatCode, aDepth, aParentHandle);
    89     
    96     
    90     RMTPObjectMgrQueryContext   context;
    97     RMTPObjectMgrQueryContext   context;
    91     RArray< TUint >             handles;
    98     RArray< TUint >             handles;
    92     TMTPObjectMgrQueryParams    params( aStorageId, KMTPFormatsAll, aParentHandle );
    99     TMTPObjectMgrQueryParams    params( aStorageId, KMTPFormatsAll, aParentHandle );
    93     // if parenthandle = 0, depth >0 and != ffffffff, for service dp, 
   100     // if parenthandle = 0, depth >0 and != ffffffff, for service dp, 
   129         }
   136         }
   130     while ( !context.QueryComplete() );
   137     while ( !context.QueryComplete() );
   131     
   138     
   132     CleanupStack::PopAndDestroy( &handles );
   139     CleanupStack::PopAndDestroy( &handles );
   133     CleanupStack::PopAndDestroy( &context );
   140     CleanupStack::PopAndDestroy( &context );
   134     
   141 
   135     __FLOG( _L8("-GetObjectHandlesL") );
   142     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GETOBJECTHANDLESL_EXIT );
   136     }
   143     }
   137 
   144 
   138 void CMTPObjectBrowser::GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   145 void CMTPObjectBrowser::GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   139     {
   146     {
   140     __FLOG_VA( ( _L8("+GetFolderObjectHandlesL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
   147     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GETFOLDEROBJECTHANDLESL_ENTRY );
       
   148     OstTraceExt4(TRACE_NORMAL, CMTPOBJECTBROWSER_GETFOLDEROBJECTHANDLESL, 
       
   149             "%d, 0x%08X, %d, 0x%08X", aCurDepth, aFormatCode, aDepth, aParentHandle);
   141     
   150     
   142     if (  aDepth > 0)
   151     if (  aDepth > 0)
   143         {
   152         {
   144         GetObjectHandlesL( aCurDepth + 1, KMTPStorageAll, aFormatCode, aDepth - 1, aParentHandle, aBrowseCallback );
   153         GetObjectHandlesL( aCurDepth + 1, KMTPStorageAll, aFormatCode, aDepth - 1, aParentHandle, aBrowseCallback );
   145         }
   154         }
   148     iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
   157     iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
   149     if ( (KMTPFormatsAll == aFormatCode) || ( aFormatCode == iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode )) )
   158     if ( (KMTPFormatsAll == aFormatCode) || ( aFormatCode == iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode )) )
   150        {
   159        {
   151        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
   160        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
   152        }
   161        }
   153             
   162 
   154     __FLOG( _L8("-GetFolderObjectHandlesL") );
   163     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GETFOLDEROBJECTHANDLESL_EXIT );
   155     }
   164     }
   156 
   165 
   157 void CMTPObjectBrowser::GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
   166 void CMTPObjectBrowser::GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
   158     {
   167     {
   159     __FLOG_VA( ( _L8("+GetRootObjectHandlesL( %d, 0x%08X, %d )"), aCurDepth, aFormatCode, aDepth ) );
   168     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GETROOTOBJECTHANDLESL_ENTRY );
       
   169     OstTraceExt3(TRACE_NORMAL, CMTPOBJECTBROWSER_GETROOTOBJECTHANDLESL, 
       
   170             "%d, 0x%08X, %d", aCurDepth, aFormatCode, aDepth);
   160     
   171     
   161     if( aDepth > 0)
   172     if( aDepth > 0)
   162         {        
   173         {        
   163                 // attention: aDepth should be reduced by 1 here
   174                 // attention: aDepth should be reduced by 1 here
   164                 GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth-1, KMTPHandleNoParent, aBrowseCallback );
   175                 GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth-1, KMTPHandleNoParent, aBrowseCallback );
   165         }
   176         }
   166     
   177     
   167     // if aDepth == 0, no handles should be returned.
   178     // if aDepth == 0, no handles should be returned.
   168     
   179 
   169     __FLOG( _L8("-GetRootObjectHandlesL") );
   180     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GETROOTOBJECTHANDLESL_EXIT );
   170     }
   181     }
   171 
   182 
   172 void CMTPObjectBrowser::GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   183 void CMTPObjectBrowser::GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   173     {
   184     {
   174     __FLOG_VA( ( _L8("+GetObjectHandlesTreeL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
   185     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GETOBJECTHANDLESTREEL_ENTRY );
   175     
   186     OstTraceExt4(TRACE_NORMAL, CMTPOBJECTBROWSER_GETOBJECTHANDLESTREEL, 
       
   187             "%d, 0x%08X, %d, 0x%08X", aCurDepth, aFormatCode, aDepth, aParentHandle);
       
   188 
   176     iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
   189     iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
   177 #ifdef __FLOG_ACTIVE
   190 #ifdef OST_TRACE_COMPILER_IN_USE
   178     RBuf suid;
   191     RBuf suid;
   179     suid.Create( iObjMetaCache->DesC( CMTPObjectMetaData::ESuid ) );
   192     suid.CreateL( iObjMetaCache->DesC( CMTPObjectMetaData::ESuid ) );
   180 #endif
   193 #endif
   181     if ( IsFolderFormat( iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode ), iObjMetaCache->Uint( CMTPObjectMetaData::EFormatSubCode ) ) )
   194     if ( IsFolderFormat( iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode ), iObjMetaCache->Uint( CMTPObjectMetaData::EFormatSubCode ) ) )
   182         {
   195         {
   183         GetFolderObjectHandlesL( aCurDepth, aFormatCode, aDepth, aParentHandle, aBrowseCallback );
   196         GetFolderObjectHandlesL( aCurDepth, aFormatCode, aDepth, aParentHandle, aBrowseCallback );
   184         }
   197         }
   188         }
   201         }
   189     else
   202     else
   190         {
   203         {
   191           // format doesn't match, do nothing
   204           // format doesn't match, do nothing
   192         }
   205         }
   193 #ifdef __FLOG_ACTIVE
   206 #ifdef OST_TRACE_COMPILER_IN_USE
   194     __FLOG_1( _L8("recursion_depth: %d"), aCurDepth );
   207     OstTrace1( TRACE_NORMAL, DUP1_CMTPOBJECTBROWSER_GETOBJECTHANDLESTREEL, "recursion_depth: %d", aCurDepth );
   195     __FLOG_1( _L("recursion_suid: %S"), &suid );
   208     OstTraceExt1( TRACE_NORMAL, DUP2_CMTPOBJECTBROWSER_GETOBJECTHANDLESTREEL, "recursion_suid: %S", suid );
   196     suid.Close();
   209     suid.Close();
   197 #endif
   210 #endif
   198     __FLOG( _L8("-GetObjectHandlesTreeL") );
   211     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GETOBJECTHANDLESTREEL_EXIT );
   199     }
   212     }
   200 
   213 
   201 /**
   214 /**
   202  * This function retrives all the object handles with the format code of aFormatCode.
   215  * This function retrives all the object handles with the format code of aFormatCode.
   203  * 
   216  * 
   206  * 
   219  * 
   207  */
   220  */
   208 
   221 
   209 void CMTPObjectBrowser::GetAllObjectHandlesL(TUint32 aFormatCode,const TBrowseCallback& aBrowseCallback ) const
   222 void CMTPObjectBrowser::GetAllObjectHandlesL(TUint32 aFormatCode,const TBrowseCallback& aBrowseCallback ) const
   210     {
   223     {
   211     __FLOG( _L8("CMTPObjectBrowser::GetAllObjectHandles-----entry") );
   224     OstTraceFunctionEntry0( CMTPOBJECTBROWSER_GETALLOBJECTHANDLESL_ENTRY );
   212 
   225 
   213     RMTPObjectMgrQueryContext   context;
   226     RMTPObjectMgrQueryContext   context;
   214     RArray< TUint >             handles;
   227     RArray< TUint >             handles;
   215     TMTPObjectMgrQueryParams    params( KMTPStorageAll, aFormatCode, KMTPHandleNone );
   228     TMTPObjectMgrQueryParams    params( KMTPStorageAll, aFormatCode, KMTPHandleNone );
   216     
   229     
   235     while ( !context.QueryComplete() );
   248     while ( !context.QueryComplete() );
   236       
   249       
   237     CleanupStack::PopAndDestroy( &handles );
   250     CleanupStack::PopAndDestroy( &handles );
   238     CleanupStack::PopAndDestroy( &context );
   251     CleanupStack::PopAndDestroy( &context );
   239     
   252     
   240     __FLOG( _L8("CMTPObjectBrowser::GetAllObjectHandles------exit") );
   253     OstTraceFunctionExit0( CMTPOBJECTBROWSER_GETALLOBJECTHANDLESL_EXIT );
   241     }
   254     }
   242 
   255