servicediscoveryandcontrol/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 <pnp/ccontrolchannelbase.h>
       
    17 #include <pnp/pnpconstants.h>
       
    18 #include "rcontrolchannel.h"
       
    19 
       
    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::Panic( KControlChannelHandleNotOpen, KErrControlChannelNotOpen) );
       
    29 	iControlChannelImpl->Recv ( aMessage, aStatus );	
       
    30 	}
       
    31 
       
    32 EXPORT_C void RControlChannel::Send ( TControlMessage& aMessage, TRequestStatus& aStatus )
       
    33 	{
       
    34 	__ASSERT_DEBUG ( iControlChannelImpl, User::Panic( KControlChannelHandleNotOpen, KErrControlChannelNotOpen) );
       
    35 	iControlChannelImpl->Send ( aMessage, aStatus );
       
    36 	}
       
    37 	
       
    38 EXPORT_C void RControlChannel::Close ()
       
    39 	{
       
    40 	delete iControlChannelImpl;
       
    41 	iControlChannelImpl = NULL;
       
    42 	}
       
    43 EXPORT_C void RControlChannel::CancelRecv ()
       
    44 	{
       
    45 	iControlChannelImpl->CancelRecv();	
       
    46 	}
       
    47 
       
    48 EXPORT_C void RControlChannel::CancelSend ()
       
    49 	{
       
    50 	iControlChannelImpl->CancelSend();	
       
    51 	}
       
    52 void RControlChannel::Attach(CControlChannelBase& aChannelBase)
       
    53     {
       
    54     iControlChannelImpl = &aChannelBase;
       
    55 	}
       
    56 	
       
    57 // -----------------------------------------------------
       
    58 
       
    59 EXPORT_C TControlMessage::TControlMessage ()
       
    60 : iPtr(NULL, 0),
       
    61 iMaxLength (KErrUnknown),
       
    62 iFlags(0)
       
    63 	{
       
    64 		
       
    65 	}
       
    66 
       
    67 EXPORT_C TControlMessage::~TControlMessage ()
       
    68 	{
       
    69 		
       
    70 	}
       
    71 
       
    72 EXPORT_C void TControlMessage::SetMessageDes ( const TDesC8& aData )
       
    73 	{
       
    74 	iPtr.Set((TUint8*)aData.Ptr(), aData.Length(), aData.Length() );
       
    75 	}
       
    76 
       
    77 EXPORT_C void TControlMessage::SetMessagePtr ( TDes8& aData )
       
    78 	{
       
    79 	iPtr.Set((TUint8*)aData.Ptr(), aData.Length(), aData.MaxLength() );
       
    80 	}
       
    81 
       
    82 EXPORT_C const TDesC8& TControlMessage::MessageDes () const
       
    83 	{
       
    84 	return iPtr;	
       
    85 	}
       
    86 
       
    87 EXPORT_C TDes8& TControlMessage::MessagePtr ()
       
    88 	{
       
    89 	return iPtr;	
       
    90 	}	
       
    91 
       
    92 EXPORT_C TBool TControlMessage::IsLast() const
       
    93 	{
       
    94 	return ( iFlags & 1 ); // 0th bit ( LSB )
       
    95 	}
       
    96 	
       
    97 EXPORT_C void TControlMessage::SetLast()
       
    98 	{
       
    99 	iFlags |= 1; // set the 0th bit
       
   100 	}
       
   101 
       
   102 EXPORT_C void TControlMessage::ClearFlags ()
       
   103 	{
       
   104 	// clear set last flag
       
   105 	iFlags &= ~1;
       
   106 	}
       
   107 
       
   108 EXPORT_C void TControlMessage::SetMaxLength ( TInt aLen )
       
   109 	{
       
   110 	iMaxLength = aLen;	
       
   111 	}
       
   112 
       
   113 EXPORT_C TInt TControlMessage::MaxLength () const
       
   114 	{
       
   115 	return iMaxLength;	
       
   116 	}
       
   117 	
       
   118 
       
   119 // ----------------------------------------------------
       
   120