mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp
changeset 17 aabe5387f5ce
parent 0 d0791faffa3f
child 47 63cf70d3ecd8
equal deleted inserted replaced
0:d0791faffa3f 17:aabe5387f5ce
    54     
    54     
    55     switch ( aHandle )
    55     switch ( aHandle )
    56         {
    56         {
    57         case KMTPHandleAll:
    57         case KMTPHandleAll:
    58             GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
    58             GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
       
    59            
    59             break;
    60             break;
    60         case KMTPHandleNone:
    61         case KMTPHandleNone:
    61             GetRootObjectHandlesL( 0, aFormatCode, aDepth, aBrowseCallback );
    62             GetRootObjectHandlesL( 0, aFormatCode, aDepth, aBrowseCallback );
    62             break;
    63             break;
    63         default:
    64         default:
    86     {
    87     {
    87     __FLOG_VA( ( _L8("+GetObjectHandlesL( %d, 0x%08X, 0x%08X, %d, 0x%08X )"), aCurDepth, aStorageId, aFormatCode, aDepth, aParentHandle ) );
    88     __FLOG_VA( ( _L8("+GetObjectHandlesL( %d, 0x%08X, 0x%08X, %d, 0x%08X )"), aCurDepth, aStorageId, aFormatCode, aDepth, aParentHandle ) );
    88     
    89     
    89     RMTPObjectMgrQueryContext   context;
    90     RMTPObjectMgrQueryContext   context;
    90     RArray< TUint >             handles;
    91     RArray< TUint >             handles;
    91     TMTPObjectMgrQueryParams    params( aStorageId, aFormatCode, aParentHandle );
    92     TMTPObjectMgrQueryParams    params( aStorageId, KMTPFormatsAll, aParentHandle );
       
    93     // if parenthandle = 0, depth >0 and != ffffffff, for service dp, 
       
    94     // 1. there is no tree structure
       
    95     // 2. KMTPFormatsAll may make the low lever api filter the handls of service dp.
       
    96     if( (aFormatCode >= EMTPFormatCodeVendorExtStart)&&(aFormatCode <= EMTPFormatCodeVendorExtEnd) )
       
    97         {
       
    98         params.iFormatCode = aFormatCode ;
       
    99         }
       
   100      
       
   101       
    92     CleanupClosePushL( context );
   102     CleanupClosePushL( context );
    93     CleanupClosePushL( handles );
   103     CleanupClosePushL( handles );
    94     
   104     
    95     do
   105     do
    96         {
   106         {
   105             }
   115             }
   106         else
   116         else
   107             {
   117             {
   108             for ( TUint i = 0; i < handleCount; i++ )
   118             for ( TUint i = 0; i < handleCount; i++ )
   109                 {
   119                 {
   110                 aBrowseCallback.iCallback( aBrowseCallback.iContext, handles[i], aCurDepth );
   120                 //before insert the handle to th result list , check it's format.
       
   121                 iDpFw.ObjectMgr().ObjectL( handles[i], *iObjMetaCache );
       
   122                 if ( (KMTPFormatsAll == aFormatCode) || ( aFormatCode == iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode )) )
       
   123                    {
       
   124                    aBrowseCallback.iCallback( aBrowseCallback.iContext, handles[i], aCurDepth );
       
   125                    }
       
   126            
   111                 }
   127                 }
   112             }
   128             }
   113         }
   129         }
   114     while ( !context.QueryComplete() );
   130     while ( !context.QueryComplete() );
   115     
   131     
   121 
   137 
   122 void CMTPObjectBrowser::GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   138 void CMTPObjectBrowser::GetFolderObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   123     {
   139     {
   124     __FLOG_VA( ( _L8("+GetFolderObjectHandlesL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
   140     __FLOG_VA( ( _L8("+GetFolderObjectHandlesL( %d, 0x%08X, %d, 0x%08X )"), aCurDepth, aFormatCode, aDepth, aParentHandle ) );
   125     
   141     
   126     if ( 0 == aDepth )
   142     if (  aDepth > 0)
   127         {
       
   128         aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
       
   129         }
       
   130     else
       
   131         {
   143         {
   132         GetObjectHandlesL( aCurDepth + 1, KMTPStorageAll, aFormatCode, aDepth - 1, aParentHandle, aBrowseCallback );
   144         GetObjectHandlesL( aCurDepth + 1, KMTPStorageAll, aFormatCode, aDepth - 1, aParentHandle, aBrowseCallback );
   133         aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
   145         }
   134         }
   146     
   135     
   147     //before insert the handle to th result list , check it's format.
       
   148     iDpFw.ObjectMgr().ObjectL( aParentHandle, *iObjMetaCache );
       
   149     if ( (KMTPFormatsAll == aFormatCode) || ( aFormatCode == iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode )) )
       
   150        {
       
   151        aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
       
   152        }
       
   153             
   136     __FLOG( _L8("-GetFolderObjectHandlesL") );
   154     __FLOG( _L8("-GetFolderObjectHandlesL") );
   137     }
   155     }
   138 
   156 
   139 void CMTPObjectBrowser::GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
   157 void CMTPObjectBrowser::GetRootObjectHandlesL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, const TBrowseCallback& aBrowseCallback ) const
   140     {
   158     {
   141     __FLOG_VA( ( _L8("+GetRootObjectHandlesL( %d, 0x%08X, %d )"), aCurDepth, aFormatCode, aDepth ) );
   159     __FLOG_VA( ( _L8("+GetRootObjectHandlesL( %d, 0x%08X, %d )"), aCurDepth, aFormatCode, aDepth ) );
   142     
   160     
   143     switch ( aDepth )
   161     if( aDepth > 0)
   144         {
   162         {        
   145         case KMaxTUint:
   163                 // attention: aDepth should be reduced by 1 here
   146             GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth, KMTPHandleNoParent, aBrowseCallback );
   164                 GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth-1, KMTPHandleNoParent, aBrowseCallback );
   147             break;
   165         }
   148         case 0:
   166     
   149             // do nothing
   167     // if aDepth == 0, no handles should be returned.
   150             break;
       
   151         default:
       
   152             GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth, KMTPHandleNoParent, aBrowseCallback );
       
   153             break;
       
   154         }
       
   155     
   168     
   156     __FLOG( _L8("-GetRootObjectHandlesL") );
   169     __FLOG( _L8("-GetRootObjectHandlesL") );
   157     }
   170     }
   158 
   171 
   159 void CMTPObjectBrowser::GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   172 void CMTPObjectBrowser::GetObjectHandlesTreeL( TUint32 aCurDepth, TUint32 aFormatCode, TUint32 aDepth, TUint32 aParentHandle, const TBrowseCallback& aBrowseCallback ) const
   167 #endif
   180 #endif
   168     if ( IsFolderFormat( iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode ), iObjMetaCache->Uint( CMTPObjectMetaData::EFormatSubCode ) ) )
   181     if ( IsFolderFormat( iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode ), iObjMetaCache->Uint( CMTPObjectMetaData::EFormatSubCode ) ) )
   169         {
   182         {
   170         GetFolderObjectHandlesL( aCurDepth, aFormatCode, aDepth, aParentHandle, aBrowseCallback );
   183         GetFolderObjectHandlesL( aCurDepth, aFormatCode, aDepth, aParentHandle, aBrowseCallback );
   171         }
   184         }
       
   185     else if ( (KMTPFormatsAll == aFormatCode) || ( aFormatCode == iObjMetaCache->Uint( CMTPObjectMetaData::EFormatCode )) )
       
   186         {
       
   187         aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
       
   188         }
   172     else
   189     else
   173         {
   190         {
   174         aBrowseCallback.iCallback( aBrowseCallback.iContext, aParentHandle, aCurDepth );
   191           // format doesn't match, do nothing
   175         }
   192         }
   176 #ifdef __FLOG_ACTIVE
   193 #ifdef __FLOG_ACTIVE
   177     __FLOG_1( _L8("recursion_depth: %d"), aCurDepth );
   194     __FLOG_1( _L8("recursion_depth: %d"), aCurDepth );
   178     __FLOG_1( _L("recursion_suid: %S"), &suid );
   195     __FLOG_1( _L("recursion_suid: %S"), &suid );
   179     suid.Close();
   196     suid.Close();
   180 #endif
   197 #endif
   181     __FLOG( _L8("-GetObjectHandlesTreeL") );
   198     __FLOG( _L8("-GetObjectHandlesTreeL") );
   182     }
   199     }
   183 
   200 
   184 
   201 /**
       
   202  * This function retrives all the object handles with the format code of aFormatCode.
       
   203  * 
       
   204  * If aFormatCode == KMTPFormatsAll, only Legacy dp's object handles are returned. Object
       
   205  * Handles of service dp's will not be returned.
       
   206  * 
       
   207  */
       
   208 
       
   209 void CMTPObjectBrowser::GetAllObjectHandlesL(TUint32 aFormatCode,const TBrowseCallback& aBrowseCallback ) const
       
   210     {
       
   211     __FLOG( _L8("CMTPObjectBrowser::GetAllObjectHandles-----entry") );
       
   212 
       
   213     RMTPObjectMgrQueryContext   context;
       
   214     RArray< TUint >             handles;
       
   215     TMTPObjectMgrQueryParams    params( KMTPStorageAll, aFormatCode, KMTPHandleNone );
       
   216     
       
   217    
       
   218     CleanupClosePushL( context );
       
   219     CleanupClosePushL( handles );
       
   220       
       
   221     do
       
   222         {
       
   223         iDpFw.ObjectMgr().GetObjectHandlesL( params, context, handles );
       
   224         TUint handleCount = handles.Count();
       
   225         
       
   226         for ( TUint i = 0; i < handleCount; i++ )
       
   227           {
       
   228             /* the argument aCurDepth of the callback is set to 0, since the call back never use this argument. 
       
   229              * If aCurDepth is used later, this arugment shoud be changed to the valid value.
       
   230              */
       
   231             aBrowseCallback.iCallback( aBrowseCallback.iContext, handles[i], 0 );
       
   232           }
       
   233         
       
   234         }
       
   235     while ( !context.QueryComplete() );
       
   236       
       
   237     CleanupStack::PopAndDestroy( &handles );
       
   238     CleanupStack::PopAndDestroy( &context );
       
   239     
       
   240     __FLOG( _L8("CMTPObjectBrowser::GetAllObjectHandles------exit") );
       
   241     }
       
   242