mtpfws/mtpfw/datatypes/src/tmtptyperesponse.cpp
changeset 20 6e82ae192c3a
parent 0 d0791faffa3f
equal deleted inserted replaced
18:1b39655331a3 20:6e82ae192c3a
    18  @publishedPartner
    18  @publishedPartner
    19 */
    19 */
    20 
    20 
    21 #include <mtp/mtpdatatypeconstants.h>
    21 #include <mtp/mtpdatatypeconstants.h>
    22 #include <mtp/tmtptyperesponse.h>
    22 #include <mtp/tmtptyperesponse.h>
    23 
       
    24 // Dataset element metadata.
    23 // Dataset element metadata.
    25 const TMTPTypeResponse::TElementInfo TMTPTypeResponse::iElementMetaData[ENumElements] = 
    24 const TMTPTypeResponse::TElementInfo TMTPTypeResponse::iElementMetaData[ENumElements] = 
    26     {
    25     {
    27         {EMTPTypeUINT16,    0,  KMTPTypeUINT16Size},    // EResponseCode
    26         {EMTPTypeUINT16,    0,  KMTPTypeUINT16Size},    // EResponseCode
    28         {EMTPTypeUINT32,    2,  KMTPTypeUINT32Size},    // EResponseSessionID
    27         {EMTPTypeUINT32,    2,  KMTPTypeUINT32Size},    // EResponseSessionID
    30         {EMTPTypeUINT32,    10, KMTPTypeUINT32Size},    // EResponseParameter1
    29         {EMTPTypeUINT32,    10, KMTPTypeUINT32Size},    // EResponseParameter1
    31         {EMTPTypeUINT32,    14, KMTPTypeUINT32Size},    // EResponseParameter2
    30         {EMTPTypeUINT32,    14, KMTPTypeUINT32Size},    // EResponseParameter2
    32         {EMTPTypeUINT32,    18, KMTPTypeUINT32Size},    // EResponseParameter3
    31         {EMTPTypeUINT32,    18, KMTPTypeUINT32Size},    // EResponseParameter3
    33         {EMTPTypeUINT32,    22, KMTPTypeUINT32Size},    // EResponseParameter4
    32         {EMTPTypeUINT32,    22, KMTPTypeUINT32Size},    // EResponseParameter4
    34         {EMTPTypeUINT32,    26, KMTPTypeUINT32Size},    // EResponseParameter5
    33         {EMTPTypeUINT32,    26, KMTPTypeUINT32Size},    // EResponseParameter5
       
    34         {EMTPTypeINT32,    30, KMTPTypeUINT32Size},    // ENumValidParam
       
    35                 
    35     };
    36     };
    36 
    37 
    37 /**
    38 /**
    38 Constructor.
    39 Constructor.
    39 */
    40 */
    40 EXPORT_C TMTPTypeResponse::TMTPTypeResponse() :
    41 EXPORT_C TMTPTypeResponse::TMTPTypeResponse() :
    41     iElementInfo(iElementMetaData, ENumElements),
    42     iElementInfo(iElementMetaData, ENumElements),
    42     iBuffer(KSize)
    43     iBuffer(KSize)
    43     {
    44     {
    44     SetBuffer(iBuffer);
    45     SetBuffer(iBuffer);
       
    46     TMTPTypeFlatBase::Reset();
    45     }
    47     }
    46 
    48 
    47 EXPORT_C TMTPTypeResponse::TMTPTypeResponse(const TMTPTypeResponse& aResponse):
    49 EXPORT_C TMTPTypeResponse::TMTPTypeResponse(const TMTPTypeResponse& aResponse):
    48     iElementInfo(iElementMetaData, ENumElements),
    50     iElementInfo(iElementMetaData, ENumElements),
    49     iBuffer(KSize)
    51     iBuffer(KSize)
    59     
    61     
    60 EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPTypeResponse::ElementInfo(TInt aElementId) const
    62 EXPORT_C const TMTPTypeFlatBase::TElementInfo& TMTPTypeResponse::ElementInfo(TInt aElementId) const
    61     {
    63     {
    62     return iElementInfo[aElementId];
    64     return iElementInfo[aElementId];
    63     }
    65     }
       
    66 
       
    67 EXPORT_C void TMTPTypeResponse::SetUint32(TInt aElementId, TUint32 aData)
       
    68     {
       
    69     // Recalculate iNumOfValidParams
       
    70     if(aElementId - EResponseTransactionID > TMTPTypeFlatBase::Int32(ENumValidParam))
       
    71         {
       
    72         TMTPTypeFlatBase::SetInt32(ENumValidParam, aElementId - EResponseTransactionID);
       
    73         }
       
    74     //  Set the element value.
       
    75     TMTPTypeFlatBase::SetUint32(aElementId, aData);
       
    76     }
       
    77 
       
    78 
       
    79 EXPORT_C TInt TMTPTypeResponse::GetNumOfValidParams() const
       
    80     {
       
    81     return TMTPTypeFlatBase::Int32(ENumValidParam);
       
    82     }