mmappcomponents/mmmtpdataprovider/tsrc/mtpdataprovidertestmodule/inc/ctestobjectmanager.h
changeset 0 a2952bb97e68
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:  Dummy object manager for test module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CTESTOBJECTMANAGER_H
       
    20 #define CTESTOBJECTMANAGER_H
       
    21 
       
    22 #include <stiflogger.h>
       
    23 #include <mtp/mmtpobjectmgr.h> 
       
    24 #include <mtp/cmtpobjectmetadata.h>
       
    25 #include <mtp/tmtptypeuint32.h>
       
    26 
       
    27 class CTestObjectManager : public MMTPObjectMgr, public CBase
       
    28     {
       
    29 public:
       
    30     // destructor
       
    31     virtual ~CTestObjectManager();
       
    32     static CTestObjectManager* NewL();
       
    33     
       
    34     // from MMTPObjectMgr
       
    35     /**
       
    36     Provides a count of the number of object meta data records present 
       
    37     in the MTP data object enumeration store. This query can be targeted 
       
    38     at specific storage media and/or object data formats, or can be used 
       
    39     to query all MTP data objects on the device.
       
    40     @param aParams The query parameters.
       
    41     @return A count of the number of object meta data records.
       
    42     @leave One of the system wide error codes, if a processing failure occurs.
       
    43     */
       
    44     TUint CountL( const TMTPObjectMgrQueryParams& aParams ) const;
       
    45     
       
    46     /**
       
    47     Commits into MTP data object enumeration store the object handle and 
       
    48     storage space previously reserved for the specified object. This is 
       
    49     typically used when either an MTP SendObjectInfo/SendObject, or 
       
    50     SendObjectPropList/SendObject operation sequence has completed 
       
    51     successfully.
       
    52     @param aObject The MTP data object information record to be commited.
       
    53     @leave One of the system wide error codes, if a processing failure occurs.
       
    54     @see ReserveObjectHandleL
       
    55     */
       
    56     void CommitReservedObjectHandleL( CMTPObjectMetaData& aObject );
       
    57     
       
    58     /**
       
    59     Provides an array of object handles present in the MTP data object 
       
    60     enumeration store. This query can be targeted at specific storage media 
       
    61     and/or object data formats, or can be used to query all MTP data objects 
       
    62     on the device. 
       
    63     
       
    64     Depending on the query parameter specified, this query may incur significant 
       
    65     RAM consumption, and so is intended to be called repeatedly in order to 
       
    66     retrieve all matching SUID data. On completion, @see aContext can be used
       
    67     to determine if there is more data to be retrieved.
       
    68     
       
    69     If there are no object handles which match the specified parameters then a 
       
    70     zero length SUID array is provided. 
       
    71     
       
    72     @param aParams The query parameters.
       
    73     @param aContext The query context data. On completion this data indicates 
       
    74     if there are additional object handle data to retrieve.
       
    75     @param aHandles The MTP object handles array buffer to be populated.
       
    76     @leave One of the system wide error codes, if a processing failure occurs.
       
    77     @leave One of the system wide error codes, if a processing failure occurs.
       
    78     */
       
    79     void GetObjectHandlesL( const TMTPObjectMgrQueryParams& aParams,
       
    80     		RMTPObjectMgrQueryContext& aContext,
       
    81     		RArray<TUint>& aHandles ) const;
       
    82     
       
    83     /**
       
    84     Provides an array of object SUIDs present in the MTP data object 
       
    85     enumeration store. This query can be targeted at specific storage media 
       
    86     and/or object data formats, or can be used to query all MTP data objects 
       
    87     on the device. 
       
    88     
       
    89     Depending on the query parameter specified, this query may incur significant 
       
    90     RAM consumption, and so is intended to be called repeatedly in order to 
       
    91     retrieve all matching object SUID data. On completion, @see aContext can be used
       
    92     to determine if there is more data to be retrieved.
       
    93     
       
    94     If there are no object handles which match the specified parameters then a 
       
    95     zero length SUID array is provided. 
       
    96     
       
    97     @param aParams The query parameters.
       
    98     @param aContext The query context data. On completion this data indicates 
       
    99     if there are additional SUID data to retrieve.
       
   100     @param aSuids The object SUIDs array buffer to be populated.
       
   101     @leave One of the system wide error codes, if a processing failure occurs.
       
   102     */
       
   103     void GetObjectSuidsL( const TMTPObjectMgrQueryParams& aParams,
       
   104     		RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids ) const;
       
   105     
       
   106     /**
       
   107     Provides the MTP object handle of the object with the specified internal 
       
   108     object unique ID.
       
   109     @param aObjectUid The internal object unique ID.
       
   110     @return The MTP object handle.
       
   111     @leave One of the system wide error codes, if a processing failure occurs.
       
   112     */
       
   113     TUint32 HandleL( TInt64 aObjectUid ) const;
       
   114     
       
   115     /**
       
   116     Provides the MTP object handle of the object with the specified Persistent 
       
   117     Unique Identifier (PUID).
       
   118     @param aPuid The object PUID.
       
   119     @return The MTP object handle.
       
   120     @leave One of the system wide error codes, if a processing failure occurs.
       
   121     */
       
   122     TUint32 HandleL( const TMTPTypeUint128& aPuid ) const;
       
   123     
       
   124     /**
       
   125     Provides the MTP object handle of the object with the specified specified 
       
   126     System Unique Identifier (SUID).
       
   127     @param aSuid The object SUID.
       
   128     @return The MTP object handle.
       
   129     @leave One of the system wide error codes, if a processing failure occurs.
       
   130     */
       
   131     TUint32 HandleL( const TDesC& aSuid ) const;
       
   132     
       
   133     /**
       
   134     Inserts a single object information record into the MTP data object 
       
   135     enumeration store. A unique MTP object handle is assigned to the 
       
   136     data object.
       
   137     @param aObject The MTP data object information record to be inserted.
       
   138     @leave KErrAlreadyExists, if an object with the specified MTP object SUID
       
   139     already exists in the MTP data object enumeration store.
       
   140     @leave One of the system wide error codes, if a processing failure occurs.
       
   141     */
       
   142     void InsertObjectL( CMTPObjectMetaData& aObject );
       
   143     
       
   144     /**
       
   145     Inserts multiple object meta data records in the MTP data object 
       
   146     enumeration store. A unique MTP object handle is assigned to each of the 
       
   147     data objects. 
       
   148     @param aObjects The MTP data object meta data records to be inserted.
       
   149     @leave KErrAlreadyExists, if an object with the one of the specified MTP 
       
   150     object SUIDs already exists in the MTP data object enumeration store.
       
   151     already exists in the MTP data object enumeration store.
       
   152     @leave One of the system wide error codes, if a processing failure occurs.
       
   153     */
       
   154     void InsertObjectsL( RPointerArray<CMTPObjectMetaData>& aObjects );
       
   155     
       
   156     /**
       
   157     Modifies the specified MTP data object's object information record. 
       
   158     @param aObject The modified MTP data object information record values.
       
   159     */
       
   160     void ModifyObjectL( const CMTPObjectMetaData& aObject );
       
   161     
       
   162     /**
       
   163     Provides either the object information record associated with the 
       
   164     associated MTP object handle, or provides an indication that the specified
       
   165     object handle does not exist. 
       
   166     @param aHandle The MTP object handle associated with the object information 
       
   167     record to be provided.
       
   168     @param aObject On exit, the object information record of the requested object. 
       
   169     @return ETrue if the specified object handle exists, otherwise EFalse.
       
   170     @leave One of the system wide error codes, if a processing failure occurs.
       
   171     */
       
   172     TBool ObjectL( const TMTPTypeUint32& aHandle,
       
   173     		CMTPObjectMetaData& aObject ) const;
       
   174     
       
   175     /**
       
   176     Provides the object information record associated with the associated MTP
       
   177     object SUID, or provides an indication that the specified object handle 
       
   178     does not exist. 
       
   179     @param aSuid The MTP object SUID associated with the object information 
       
   180     record to be provided.
       
   181     @param aObject On exit, the object information record of the requested object. 
       
   182     @return ETrue if the specified object handle exists, otherwise EFalse.
       
   183     @leave One of the system wide error codes, if a processing failure occurs.
       
   184     */
       
   185     TBool ObjectL( const TDesC& aSuid, CMTPObjectMetaData& aObject ) const;
       
   186     
       
   187     /**
       
   188     Provides the ID of the data provider responsible for the specified MTP 
       
   189     data object.
       
   190     @param aHandle The MTP object handle.
       
   191     @return The responsible data provider ID.
       
   192     */
       
   193     TUint ObjectOwnerId( const TMTPTypeUint32& aHandle ) const;
       
   194     
       
   195     /**
       
   196     Provides the internal object unique ID of the object with the specified MTP
       
   197     object handle.
       
   198     @param aHandle The MTP object handle.
       
   199     @return The internal object unique ID.
       
   200     @leave One of the system wide error codes, if a processing failure occurs.
       
   201     */
       
   202     TInt64 ObjectUidL( TUint32 aHandle ) const;
       
   203     
       
   204     /**
       
   205     Provides the internal object unique ID of the object with the specified 
       
   206     System Unique Identifier (SUID).
       
   207     @param aSuid The object SUID.
       
   208     @return The internal object unique ID.
       
   209     @leave One of the system wide error codes, if a processing failure occurs.
       
   210     */
       
   211     TInt64 ObjectUidL( const TDesC& aSuid ) const;
       
   212     
       
   213     /**
       
   214     Provides the internal object unique ID of the object with the specified 
       
   215     Persistent Unique Identifier (PUID).
       
   216     @param aPuid The object PUID.
       
   217     @return The internal object unique ID.
       
   218     @leave One of the system wide error codes, if a processing failure occurs.
       
   219     */
       
   220     TInt64 ObjectUidL( TMTPTypeUint128 aPuid ) const;
       
   221     
       
   222     /**
       
   223     Provides the Persistent Unique Identifier (PUID) of the object with the 
       
   224     specified MTP object handle.
       
   225     @param aHandle The MTP object handle.
       
   226     @return The object PUID.
       
   227     @leave One of the system wide error codes, if a processing failure occurs.
       
   228     */
       
   229     TMTPTypeUint128 PuidL( TUint32 aHandle ) const;
       
   230     
       
   231     /**
       
   232     Provides the Persistent Unique Identifier (PUID) of the object with the 
       
   233     specified internal object unique ID.
       
   234     @param aObjectUid The internal object unique ID.
       
   235     @return The object PUID.
       
   236     @leave One of the system wide error codes, if a processing failure occurs.
       
   237     */
       
   238     TMTPTypeUint128 PuidL( TInt64 aObjectUid ) const;
       
   239     
       
   240     /**
       
   241     Provides the Persistent Unique Identifier (PUID) of the object with the 
       
   242     specified System Unique Identifier (SUID).
       
   243     @param aSuid The object SUID.
       
   244     @return The object PUID.
       
   245     @leave One of the system wide error codes, if a processing failure occurs.
       
   246     */
       
   247     TMTPTypeUint128 PuidL( const TDesC& aSuid ) const;
       
   248     
       
   249     /**
       
   250     Removes the object information record associated with the specified MTP 
       
   251     object handle from the MTP data object enumeration store.
       
   252     @param aHandle The MTP object handle associated with the object information 
       
   253     record to be removed.
       
   254     @leave One of the system wide error codes, if a processing failure occurs.
       
   255     */
       
   256     void RemoveObjectL( const TMTPTypeUint32& aHandle );
       
   257     
       
   258     /**
       
   259     Removes the object information record associated with the specified object
       
   260     SUID from the MTP data object enumeration store.
       
   261     @param aSuid The object SUID associated with the object information 
       
   262     record to be removed.
       
   263     @leave One of the system wide error codes, if a processing failure occurs.
       
   264     */
       
   265     void RemoveObjectL( const TDesC& aSuid );
       
   266     
       
   267     /**
       
   268     Removes multiple object meta data records from the MTP data object 
       
   269     enumeration store.
       
   270     @param aSuids The array of object SUIDs associated with the object 
       
   271     meta data records to be removed.
       
   272     @leave One of the system wide error codes, if a processing failure occurs.
       
   273     */
       
   274     void RemoveObjectsL( const CDesCArray& aSuids );
       
   275     
       
   276     /**
       
   277     Removes from the MTP data object enumeration store all object meta data 
       
   278     records owned by the specified data provider.
       
   279     @param aDataProviderId The ID of the data provider owning the object 
       
   280     meta data records to be deleted.
       
   281     @leave One of the system wide error codes, if a processing failure occurs.
       
   282     */
       
   283     void RemoveObjectsL( TUint aDataProviderId );
       
   284     
       
   285     /**
       
   286     Reserves space for and assigns an object handle to the object described
       
   287     by the specified object information record. This is typically used when
       
   288     processing MTP SendObjectInfo or SendObjectPropList operations.
       
   289     @param aObject The object information record of the object. On 
       
   290     successful completion this is updated with the assigned object handle.
       
   291     @param aSpaceRequired The storage space to be reserved for the object.
       
   292     @leave KErrTooBig, if aSpaceRequired exceeds the available capacity of the 
       
   293     storage. 
       
   294     @leave KErrOverflow, if an object handle cannot be assigned.
       
   295     @leave One of the system wide error codes, if a processing failure occurs.
       
   296     @see CommitReservedObjectL
       
   297     @see UnReserveObjectHandleL
       
   298     */
       
   299     void ReserveObjectHandleL( CMTPObjectMetaData& aObject,
       
   300     		TUint64 aSpaceRequired );
       
   301     
       
   302     /**
       
   303     Releases the object handle and storage space previously reserved for the 
       
   304     specified object. This is typically used when either an MTP 
       
   305     SendObjectInfo/SendObject, or SendObjectPropList/SendObject operation 
       
   306     sequence has not completed successfully.
       
   307     @param aObject The MTP data object information record of the object.
       
   308     @leave One of the system wide error codes, if a processing failure occurs.
       
   309     @see ReserveObjectHandleL
       
   310     */
       
   311     void UnreserveObjectHandleL( const CMTPObjectMetaData& aObject );
       
   312 private:
       
   313     CTestObjectManager();
       
   314     void ConstructL(); 
       
   315     
       
   316     void CopyObjectMetadataL( const CMTPObjectMetaData& aSource,
       
   317     		CMTPObjectMetaData& aTarget ) const;
       
   318 private:
       
   319     CStifLogger* iLog;
       
   320     RPointerArray<CMTPObjectMetaData> iMTPObjects;
       
   321     
       
   322     TInt iHandle;
       
   323     };
       
   324 
       
   325 #endif // CTESTOBJECTMANAGER_H