messagingappbase/obexmtms/btmtm/btclient/source/btHeader.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2001-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 // $Workfile: btHeader.cpp $
       
    15 // $Author: Stevep $
       
    16 // $Revision: 10 $
       
    17 // $Date: 25/03/02 7:54 $
       
    18 // 
       
    19 //
       
    20 
       
    21 //class include
       
    22 #include <btheader.h>
       
    23 
       
    24 //system includes
       
    25 #include <s32strm.h> //RReadStream, RWriteStream
       
    26 #include <msvstore.h>   //CMsvStore, RMsvWriteStream, RMsvReadStream
       
    27 #include <obex.h>
       
    28 
       
    29 //user includes
       
    30 #include <obexinternalutils.h>
       
    31 
       
    32 CBtHeader::CBtHeader():
       
    33 	CObexMtmHeader(KUidStreamBtHeaders, KObexMessageStreamVersion)
       
    34 /**
       
    35  * Default constructor, initialises the base class and sets the value of iBtProtocolInfo.iTransport
       
    36  * as appropriate for BT
       
    37  */
       
    38 	{
       
    39 	iBtProtocolInfo.iTransport = KBtTransport;
       
    40 	}
       
    41 
       
    42 	
       
    43 EXPORT_C CBtHeader::~CBtHeader()
       
    44 /**
       
    45  * Destructor. Empty
       
    46  */
       
    47 	{
       
    48 	}
       
    49 
       
    50 
       
    51 EXPORT_C void CBtHeader::ConstructL()
       
    52 /**
       
    53  * Second-phase constructor. Calls BaseConstructL to initialise the base members
       
    54  */
       
    55 	{
       
    56 	BaseConstructL();
       
    57 	}
       
    58 
       
    59 EXPORT_C CBtHeader* CBtHeader::NewL()
       
    60 /**
       
    61  * Canonical NewL factory function
       
    62  */
       
    63 	{
       
    64 	CBtHeader* self = new (ELeave) CBtHeader;
       
    65 	CleanupStack::PushL(self);
       
    66 	self->ConstructL();
       
    67 	CleanupStack::Pop();	//self
       
    68 	return self;
       
    69 	}
       
    70 
       
    71 EXPORT_C void CBtHeader::ExternalizeL(RMsvWriteStream& aWriteStream) const
       
    72 /**
       
    73  * Externaliser. Writes data out to aWriteStream. Calls BaseExternalizeL() to write out
       
    74  * the base data first.
       
    75  *
       
    76  * @param aWriteStream Stream to write data to
       
    77  * @leave KErrXXX Standard EPOC stream leave codes
       
    78  */
       
    79 	{
       
    80 	BaseExternalizeL(aWriteStream);
       
    81 
       
    82 	//TBuf16
       
    83 	ObexInternalUtils::ExternalizeL(iBtProtocolInfo.iTransport, aWriteStream);
       
    84 
       
    85 	//TBuf8
       
    86 	ObexInternalUtils::ExternalizeL(iBtProtocolInfo.iAddr, aWriteStream);
       
    87 	}
       
    88 
       
    89 
       
    90 EXPORT_C void CBtHeader::InternalizeL(RMsvReadStream& aReadStream)
       
    91 /**
       
    92  * Internaliser. Reads data in from aReadStream. Calls BaseInternalizeL() to read in the base 
       
    93  * data first.
       
    94  *
       
    95  * @param aReadStream Stream to read data in from
       
    96  * @leave KErrXXX Standard EPOC stream leave codes
       
    97  */
       
    98 	{
       
    99 	BaseInternalizeL(aReadStream);
       
   100 
       
   101 	//TBuf16
       
   102 	ObexInternalUtils::InternalizeL(iBtProtocolInfo.iTransport, aReadStream);
       
   103 
       
   104 	//TBuf8
       
   105 	ObexInternalUtils::InternalizeL(iBtProtocolInfo.iAddr, aReadStream);
       
   106 	}
       
   107 
       
   108 
       
   109 EXPORT_C void CBtHeader::SetAddrL(const TDesC8& aAddr)
       
   110 /**
       
   111  * Set the BT address of the recipient.  The RfComm service slot will be obtained through 
       
   112  * an SDP lookup in the server side MTM.
       
   113  *
       
   114  *  @param aAddr the address of the recipient (NB: only one recipient is currently supported)
       
   115  */
       
   116 	{
       
   117 // put comment here about incoming data format
       
   118 	iBtProtocolInfo.iAddr.SetBTAddr(aAddr);
       
   119 	}
       
   120 
       
   121 EXPORT_C TPtrC8 CBtHeader::Addr() const
       
   122 /**
       
   123  * Get the BT address of the recipient
       
   124  *
       
   125  *  @return The address of the recipient (NB: only one recipient is currently supported)
       
   126  */
       
   127 	{
       
   128 	return iBtProtocolInfo.iAddr;
       
   129 	}
       
   130 
       
   131 
       
   132 EXPORT_C const TObexBluetoothProtocolInfo& CBtHeader::BtProtocolInfo() const
       
   133 /**
       
   134  * Get the BT protocol info of the recipient
       
   135  *
       
   136  * @return The protocol info of the recipient (NB: only one recipient is currently supported)
       
   137  */
       
   138 	{
       
   139 	return iBtProtocolInfo;
       
   140 	}