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