mtpfws/mtpfw/dataproviders/dataproviderapi/src/cmtpobjectmetadata.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <mtp/cmtpobjectmetadata.h>
       
    17 #include <mtp/mtpprotocolconstants.h>
       
    18     
       
    19 /**
       
    20 The element meta-data table content.
       
    21 */
       
    22 const CMTPMetaData::TElementMetaData CMTPObjectMetaData::KElements[CMTPObjectMetaData::ENumElements] = 
       
    23     {
       
    24         {0, CMTPObjectMetaData::EUint}, // EDataProviderId
       
    25         {1, CMTPObjectMetaData::EUint}, // EFormatCode
       
    26         {2, CMTPObjectMetaData::EUint}, // EFormatSubCode
       
    27         {3, CMTPObjectMetaData::EUint}, // EHandle
       
    28         {4, CMTPObjectMetaData::EUint}, // EModes
       
    29         {5, CMTPObjectMetaData::EUint}, // EParentHandle
       
    30         {6, CMTPObjectMetaData::EUint}, // EStorageId
       
    31         {7, CMTPObjectMetaData::EUint}, // EStorageVolumeId
       
    32         {0, CMTPObjectMetaData::EDesC}, // ESuid
       
    33         {8, CMTPObjectMetaData::EUint}, // EUserRating @deprecated 
       
    34         {9, CMTPObjectMetaData::EUint}, // EBuyNow @deprecated 
       
    35         {10, CMTPObjectMetaData::EUint}, // EPlayed @deprecated  
       
    36         {11, CMTPObjectMetaData::EUint},// EIdentifier
       
    37         //{0, CMTPObjectMetaData::EInt},// EParentId
       
    38         {12, CMTPObjectMetaData::EUint},// ENonConsumable
       
    39         {13, CMTPObjectMetaData::EUint},// EObjectMetaDataUpdate
       
    40         {1, CMTPObjectMetaData::EDesC},// EName
       
    41     };
       
    42     
       
    43 /**
       
    44 MTP object manager meta-data factory method. This method creates an 
       
    45 empty object meta-data record.
       
    46 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
    47 @leave One of the system wide error codes, if a processing failure occurs.
       
    48 */
       
    49 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL()
       
    50     {
       
    51     CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC();
       
    52     CleanupStack::Pop(self); // self
       
    53     return self;
       
    54     }
       
    55 
       
    56 /**
       
    57 MTP object manager meta-data factory method. This method creates an 
       
    58 empty object meta-data record. A pointer to the meta-data is
       
    59 placed on the cleanup stack.
       
    60 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
    61 @leave One of the system wide error codes, if a processing failure occurs.
       
    62 */
       
    63 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC()
       
    64     {
       
    65     CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
       
    66     CleanupStack::PushL(self);
       
    67     self->ConstructL();
       
    68     return self;
       
    69     }
       
    70     
       
    71 /**
       
    72 MTP object manager meta-data factory method. 
       
    73 @param aDataProviderId The identifier of the data provider which owns the data 
       
    74 object.
       
    75 @param aFormatCode The MTP object format code of the data object.
       
    76 @param aStorageId The MTP storage ID of the storage media on which the data 
       
    77 object resides.
       
    78 @param aSuid A buffer containing the SUID of the data object.
       
    79 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
    80 @leave One of the system wide error codes, if a processing failure occurs.
       
    81 */
       
    82 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
       
    83     {
       
    84     CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC(aDataProviderId, aFormatCode, aStorageId, aSuid);
       
    85     CleanupStack::Pop(self);
       
    86     return self;
       
    87     }
       
    88     
       
    89 /**
       
    90 MTP object manager meta-data factory method. A pointer to the meta-data is 
       
    91 placed on the cleanup stack.
       
    92 @param aDataProviderId The identifier of the data provider which owns the data 
       
    93 object.
       
    94 @param aFormatCode The MTP object format code of the data object.
       
    95 @param aStorageId The MTP storage ID of the storage media on which the data 
       
    96 object resides.
       
    97 @param aSuid A buffer containing the SUID of the data object.
       
    98 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
    99 @leave One of the system wide error codes, if a processing failure occurs.
       
   100 */
       
   101 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
       
   102     {
       
   103     CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
       
   104     CleanupStack::PushL(self);
       
   105     self->ConstructL(aDataProviderId, aFormatCode, aStorageId, aSuid);
       
   106     return self;
       
   107     }
       
   108 
       
   109 /**
       
   110 Destructor.
       
   111 */
       
   112 EXPORT_C CMTPObjectMetaData::~CMTPObjectMetaData()
       
   113     {
       
   114 
       
   115     } 
       
   116 
       
   117 /**
       
   118 Constructor.
       
   119 */
       
   120 CMTPObjectMetaData::CMTPObjectMetaData() :
       
   121     CMTPMetaData(KElements, ENumElements)
       
   122     {
       
   123     
       
   124     }
       
   125     
       
   126 /**
       
   127 Second phase constructor.
       
   128 @leave One of the system wide error code, if a processing failure occurs.
       
   129 */
       
   130 void CMTPObjectMetaData::ConstructL()
       
   131     {
       
   132     CMTPMetaData::ConstructL();
       
   133     SetUint(EParentHandle, KMTPHandleNoParent);
       
   134     //SetInt(EParentId, KErrNotFound);
       
   135     }
       
   136     
       
   137 /**
       
   138 Second phase constructor.
       
   139 @param aDataProviderId The identifier of the data provider which owns the data 
       
   140 object.
       
   141 @param aFormatCode The MTP object format code of the data object.
       
   142 @param aStorageId The MTP storage ID of the storage media on which the data 
       
   143 object resides.
       
   144 @param aSuid A buffer containing the SUID of the data object.
       
   145 @leave One of the system wide error code, if a processing failure occurs.
       
   146 */
       
   147 void CMTPObjectMetaData::ConstructL(TUint aDataProviderId, TUint aFormatCode, TUint aStorageId, const TDesC& aSuid)
       
   148     {
       
   149     ConstructL();
       
   150     SetUint(EDataProviderId, aDataProviderId);
       
   151     SetUint(EFormatCode, aFormatCode);
       
   152     SetUint(EStorageId, aStorageId);
       
   153     SetDesCL(ESuid, aSuid);
       
   154     }
       
   155     
       
   156 /**
       
   157 @deprecated
       
   158 Second phase constructor.
       
   159 @param aSuid A buffer containing the SUID of the data object.
       
   160 @param aUserRating  user rating of the data object.
       
   161 @param aBuyNow The MTP object BuyNow code of the data object.
       
   162 @param aPlayCount The MTP object aPlayCount code of the data object.
       
   163 @leave One of the system wide error code, if a processing failure occurs.
       
   164 */
       
   165 void CMTPObjectMetaData::ConstructL(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
       
   166     {
       
   167      ConstructL();
       
   168 
       
   169      SetUint(EUserRating, aUserRating);
       
   170      SetUint(EBuyNow, aBuyNow);
       
   171      SetUint(EPlayCount, aPlayCount);
       
   172      SetDesCL(ESuid, aSuid);
       
   173     }
       
   174 
       
   175 /**
       
   176 @deprecated
       
   177 MTP object manager meta-data factory method.
       
   178 @param aSuid A buffer containing the SUID of the data object.
       
   179 @param aUserRating  user rating of the data object.
       
   180 @param aBuyNow The MTP object BuyNow code of the data object.
       
   181 @param aPlayCount The MTP object aPlayCount code of the data object.
       
   182 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
   183 @leave One of the system wide error codes, if a processing failure occurs.
       
   184 */
       
   185 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewL(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
       
   186     {
       
   187     CMTPObjectMetaData* self = CMTPObjectMetaData::NewLC(aSuid, aUserRating, aBuyNow, aPlayCount);
       
   188     CleanupStack::Pop(self);
       
   189     return self;
       
   190     }
       
   191 
       
   192 /**
       
   193 @deprecated
       
   194 MTP object manager meta-data factory method. A pointer to the meta-data is 
       
   195 placed on the cleanup stack.
       
   196 @param aSuid A buffer containing the SUID of the data object.
       
   197 @param aUserRating  user rating of the data object.
       
   198 @param aBuyNow The MTP object BuyNow code of the data object.
       
   199 @param aPlayCount The MTP object aPlayCount code of the data object.
       
   200 @return A pointer to a new CMTPObjectMetaData instance, ownership IS transferred.
       
   201 @leave One of the system wide error codes, if a processing failure occurs.
       
   202 */
       
   203 EXPORT_C CMTPObjectMetaData* CMTPObjectMetaData::NewLC(const TDesC& aSuid, TUint aUserRating, TUint aBuyNow, TUint aPlayCount)
       
   204     {
       
   205     CMTPObjectMetaData* self = new(ELeave) CMTPObjectMetaData();
       
   206     CleanupStack::PushL(self);
       
   207     self->ConstructL(aSuid, aUserRating, aBuyNow, aPlayCount);
       
   208     return self;
       
   209     }
       
   210 
       
   211 
       
   212     
       
   213     
       
   214     
       
   215     
       
   216     
       
   217     
       
   218     
       
   219     
       
   220     
       
   221