mtptransports/mtpptpiptransport/ptpipdatatypes/src/cptpipinitcmdack.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 /**
       
    17  @internalComponent
       
    18 */
       
    19 
       
    20 #include "cptpipinitcmdack.h"
       
    21 #include "ptpipdatatypes.h"   
       
    22 // Dataset constants
       
    23 const TUint CPTPIPInitCmdAck::KFlatChunkSize(28);  
       
    24 const CMTPTypeCompoundBase::TElementInfo CPTPIPInitCmdAck::iElementMetaData[CPTPIPInitCmdAck::ENumElements] = 
       
    25     {
       
    26         {EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	0,					KMTPTypeUINT32Size}},   // ELength
       
    27 		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	4,					KMTPTypeUINT32Size}},   // EType
       
    28 		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT32,	8,					KMTPTypeUINT32Size}},   // EConNumber
       
    29 		{EIdFlatChunk,      EMTPTypeFlat,       {EMTPTypeUINT128,	12,					KMTPTypeUINT128Size}},   // GUID
       
    30 	//	{EIdNameChunk,      EMTPTypeString,     {EMTPTypeString,    KMTPNotApplicable,	KMTPNotApplicable}},   // friendly name
       
    31         {EIdVersionChunk,	EMTPTypeUINT32,     {EMTPTypeUINT32,    KMTPNotApplicable,	KMTPNotApplicable}}   // version
       
    32         
       
    33     };
       
    34 
       
    35 EXPORT_C  CPTPIPInitCmdAck* CPTPIPInitCmdAck::NewL()
       
    36     {
       
    37     CPTPIPInitCmdAck* self = new (ELeave) CPTPIPInitCmdAck(); 
       
    38     CleanupStack::PushL(self); 
       
    39     self->ConstructL();   
       
    40     CleanupStack::Pop(self);
       
    41     return self; 
       
    42     }
       
    43 /**
       
    44 Constructor.
       
    45 */
       
    46 EXPORT_C CPTPIPInitCmdAck::CPTPIPInitCmdAck() : 
       
    47     CMTPTypeCompoundBase((!KJustInTimeConstruction), EIdNumChunks), 
       
    48     iChunkHeader(KFlatChunkSize, *this),
       
    49     iElementInfo(iElementMetaData, ENumElements)
       
    50     {
       
    51     
       
    52     }
       
    53 
       
    54 /**
       
    55 Destructor.
       
    56 */
       
    57  EXPORT_C CPTPIPInitCmdAck::~CPTPIPInitCmdAck()
       
    58     {
       
    59     iChunkHeader.Close();
       
    60     iBuffer.Close();
       
    61     }
       
    62     /**
       
    63 Second phase constructor.
       
    64 */   
       
    65  void CPTPIPInitCmdAck::ConstructL()
       
    66     {
       
    67     iChunkHeader.OpenL();
       
    68     ChunkAppendL(iChunkHeader);
       
    69     ChunkAppendL(iVersion);
       
    70    iChunkCount = EIdNumChunks;    
       
    71     }
       
    72     
       
    73     
       
    74  EXPORT_C TUint CPTPIPInitCmdAck::Type() const
       
    75     {
       
    76     return EPTPIPTypeInitCmdAck;
       
    77     } 
       
    78 const CMTPTypeCompoundBase::TElementInfo& CPTPIPInitCmdAck::ElementInfo(TInt aElementId) const
       
    79     {
       
    80     __ASSERT_DEBUG((aElementId < ENumElements), User::Invariant());
       
    81     return iElementInfo[aElementId];
       
    82     }
       
    83     
       
    84  EXPORT_C TInt CPTPIPInitCmdAck::FirstReadChunk(TPtrC8& aChunk) const
       
    85 {
       
    86 	iChunkCount = EIdFlatChunk;
       
    87 	return CMTPTypeCompoundBase::FirstReadChunk(aChunk);
       
    88 	
       
    89 }   		
       
    90 EXPORT_C TInt CPTPIPInitCmdAck::NextReadChunk(TPtrC8& aChunk) const
       
    91 {
       
    92 	TInt ret = KErrNone;
       
    93 	if(iChunkCount == EIdFlatChunk)
       
    94 		{	
       
    95 		aChunk.Set((const TUint8*)&iBuffer[0],iBuffer.Size());		
       
    96 		}
       
    97 	else
       
    98 		{
       
    99 		ret = CMTPTypeCompoundBase::NextReadChunk(aChunk);	
       
   100 		}
       
   101 	iChunkCount++;
       
   102 	return ret;
       
   103 }
       
   104 
       
   105 
       
   106 
       
   107 EXPORT_C  void CPTPIPInitCmdAck::SetDeviceFriendlyName(TDesC16& aName)
       
   108 {
       
   109 	iBuffer.Create(aName,aName.Length()+KMTPNullCharLen);
       
   110 	iBuffer.Append(KMTPNullChar);
       
   111 }    
       
   112 
       
   113 EXPORT_C TUint64 CPTPIPInitCmdAck::Size() const
       
   114 {
       
   115 	TUint64 size = CMTPTypeCompoundBase::Size();
       
   116 	size += iBuffer.Size();
       
   117 	return size;
       
   118 }
       
   119