servicediscoveryandcontrol/pnp/test/upnp/Client/pnp/src/rcontrolchannel.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 "rcontrolchannel.h"
       
    17 #include "ccontrolchannel.h"
       
    18 
       
    19 #include <inetprottextutils.h>
       
    20 
       
    21 EXPORT_C RControlChannel::RControlChannel ()
       
    22 : iControlChannelImpl ( NULL )
       
    23 	{	
       
    24 	}
       
    25 
       
    26 EXPORT_C void RControlChannel::Recv ( TControlMessage& aMessage, TRequestStatus& aStatus )
       
    27 	{
       
    28 	__ASSERT_DEBUG ( iControlChannelImpl, User::Invariant() );
       
    29 	iControlChannelImpl->Recv ( aMessage, aStatus );	
       
    30 	}
       
    31 
       
    32 EXPORT_C void RControlChannel::Send ( TControlMessage& aMessage, TRequestStatus& aStatus )
       
    33 	{
       
    34 	__ASSERT_DEBUG ( iControlChannelImpl, User::Invariant() );
       
    35 	iControlChannelImpl->Send ( aMessage, aStatus );
       
    36 	}
       
    37 
       
    38 EXPORT_C void RControlChannel::Close ()
       
    39 	{
       
    40 	delete iControlChannelImpl;
       
    41 	iControlChannelImpl = NULL;
       
    42 	}
       
    43 
       
    44 EXPORT_C TInt RControlChannel::Open ( RSocketServ& aSocketServ, RSubConnection& aSubConnection, TUint aAddrFamily, TBool aChannelType, TUint aProtocol, const TConnectionDetails& aConnInfo )
       
    45 	{
       
    46 	TRAPD( err, iControlChannelImpl = CControlChannel::NewL ( aSocketServ, aSubConnection, aAddrFamily, aChannelType, aProtocol, aConnInfo ) );
       
    47 	return err;
       
    48 	}
       
    49 
       
    50 // -----------------------------------------------------
       
    51 
       
    52 EXPORT_C TControlMessage::TControlMessage ()
       
    53 : iPtr(NULL, 0),
       
    54 iId (0),
       
    55 iMaxLength (KErrUnknown),
       
    56 iFlags(0)
       
    57 	{
       
    58 		
       
    59 	}
       
    60 
       
    61 EXPORT_C TControlMessage::~TControlMessage ()
       
    62 	{
       
    63 		
       
    64 	}
       
    65 
       
    66 EXPORT_C void TControlMessage::SetMessageDes ( const TDesC8& aData )
       
    67 	{
       
    68 	iPtr.Set((TUint8*)aData.Ptr(), aData.Length(), aData.Length() );
       
    69 	}
       
    70 
       
    71 EXPORT_C void TControlMessage::SetMessagePtr ( TDes8& aData )
       
    72 	{
       
    73 	iPtr.Set((TUint8*)aData.Ptr(), aData.Length(), aData.MaxLength() );
       
    74 	}
       
    75 
       
    76 EXPORT_C const TDesC8& TControlMessage::MessageDes () const
       
    77 	{
       
    78 	return iPtr;	
       
    79 	}
       
    80 
       
    81 EXPORT_C TDes8& TControlMessage::MessagePtr ()
       
    82 	{
       
    83 	return iPtr;	
       
    84 	}	
       
    85 
       
    86 EXPORT_C TBool TControlMessage::IsLast() const
       
    87 	{
       
    88 	return ( iFlags & 1 ); // 0th bit ( LSB )
       
    89 	}
       
    90 	
       
    91 EXPORT_C void TControlMessage::SetLast()
       
    92 	{
       
    93 	iFlags |= 1; // set the 0th bit
       
    94 	}
       
    95 
       
    96 EXPORT_C void TControlMessage::ClearFlags ()
       
    97 	{
       
    98 	// clear set last flag
       
    99 	iFlags &= ~1;
       
   100 	}
       
   101 
       
   102 EXPORT_C void TControlMessage::SetMaxLength ( TInt aLen )
       
   103 	{
       
   104 	iMaxLength = aLen;	
       
   105 	}
       
   106 
       
   107 EXPORT_C TInt TControlMessage::MaxLength () const
       
   108 	{
       
   109 	return iMaxLength;	
       
   110 	}
       
   111 	
       
   112 void TControlMessage::SetId ( TUint aId )
       
   113 	{
       
   114 	iId = aId;		
       
   115 	}
       
   116 
       
   117 TUint TControlMessage::Id () const	
       
   118 	{
       
   119 	return iId;	
       
   120 	}
       
   121 
       
   122 void TControlMessage::SetDirty ()
       
   123 	{
       
   124 	iFlags |= (1 << 1); // set the 0th bit	
       
   125 	}
       
   126 
       
   127 TBool TControlMessage::IsDirty () const
       
   128 	{
       
   129 	return ( iFlags & (1 << 1) );
       
   130 	}
       
   131 
       
   132 // ----------------------------------------------------
       
   133