ximpfw/tsrc/tsrcutils/testcaseutils/prfwtestfilesrvmsg.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Test support file tool server message
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <f32file.h>
       
    22 #include <s32file.h>
       
    23 
       
    24 #include "prfwtestfilesrvmsg.h"
       
    25 
       
    26 // ======== LOCAL FUNCTIONS ========
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // ?description_if_needed
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CXIMPTestFileSrvMsg::CXIMPTestFileSrvMsg()
       
    35     {
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // ?description_if_needed
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 void CXIMPTestFileSrvMsg::ConstructL()
       
    43     {
       
    44     iPayload = HBufC8::NewL(0);
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // ?description_if_needed
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CXIMPTestFileSrvMsg* CXIMPTestFileSrvMsg::NewLC()
       
    53     {
       
    54     CXIMPTestFileSrvMsg* self = new( ELeave ) CXIMPTestFileSrvMsg();
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // ?description_if_needed
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void CXIMPTestFileSrvMsg::ConstructL( const TDesC8& aPayload )
       
    65     {
       
    66     iPayload = aPayload.AllocL();
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // ?description_if_needed
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CXIMPTestFileSrvMsg::CXIMPTestFileSrvMsg( TInt aSrvMsgId ) :
       
    74     iSrvMsgId( aSrvMsgId )
       
    75     {
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // ?description_if_needed
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C CXIMPTestFileSrvMsg* CXIMPTestFileSrvMsg::NewL(
       
    83         TInt aSrvMsgId,
       
    84         const TDesC8& aPayload )
       
    85     {
       
    86     CXIMPTestFileSrvMsg* self = new( ELeave ) CXIMPTestFileSrvMsg( aSrvMsgId );
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL( aPayload );
       
    89     CleanupStack::Pop( self );
       
    90     return self;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // ?description_if_needed
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CXIMPTestFileSrvMsg::~CXIMPTestFileSrvMsg()
       
    98     {
       
    99     delete iPayload;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // ?description_if_needed
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 EXPORT_C void CXIMPTestFileSrvMsg::ExternalizeL( RWriteStream& aStream ) const
       
   107     {
       
   108     aStream.WriteUint32L( iSrvMsgId );
       
   109     aStream.WriteUint32L( iPayload->Length() );
       
   110     aStream.WriteL( *iPayload );
       
   111     }
       
   112         
       
   113 // ---------------------------------------------------------------------------
       
   114 // ?description_if_needed
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 EXPORT_C void CXIMPTestFileSrvMsg::InternalizeL( RReadStream& aStream )
       
   118     {
       
   119     iSrvMsgId = aStream.ReadUint32L();
       
   120     TInt len = aStream.ReadUint32L();
       
   121 
       
   122     HBufC8* buffer = HBufC8::NewLC( len );
       
   123     TPtr8 ptr = buffer->Des();
       
   124     aStream.ReadL( ptr, len );
       
   125 
       
   126     delete iPayload;
       
   127     CleanupStack::Pop( buffer );
       
   128     iPayload = buffer;   
       
   129     }
       
   130         
       
   131 // ---------------------------------------------------------------------------
       
   132 // ?description_if_needed
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C TDesC8& CXIMPTestFileSrvMsg::PayloadL()
       
   136     {
       
   137     return *iPayload;
       
   138     }
       
   139         
       
   140 // ---------------------------------------------------------------------------
       
   141 // ?description_if_needed
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TInt CXIMPTestFileSrvMsg::SrvMsgId()
       
   145     {
       
   146     return iSrvMsgId;
       
   147     }
       
   148 
       
   149 // End of file