servicediscoveryandcontrol/pnp/inc/rcontrolchannel.h
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 
       
    17 #ifndef __RCONTROLCHANNEL_H__
       
    18 #define __RCONTROLCHANNEL_H__
       
    19 
       
    20 #include <e32base.h>
       
    21 
       
    22 class CControlChannelBase;
       
    23 
       
    24 /* 
       
    25  This class is used to wrap the TDes8 data that is used for transmission
       
    26  @publishedPartner
       
    27  @prototype
       
    28 */
       
    29 class TControlMessage
       
    30 	{
       
    31 public: 
       
    32     /** Default constructor */
       
    33 	IMPORT_C TControlMessage ();
       
    34 
       
    35     /** Default destructor */
       
    36 	IMPORT_C ~TControlMessage ();
       
    37     /** 
       
    38 	Used to Set the data part of control message with data supplied in aData
       
    39     @param aData Supplied data
       
    40     */
       
    41 	IMPORT_C void SetMessageDes ( const TDesC8& aData );
       
    42     /** 
       
    43 	Used to Set the data part of control message with data supplied in aData
       
    44     @param aData Supplied data
       
    45     */
       
    46 	IMPORT_C void SetMessagePtr ( TDes8& aData );	
       
    47     /**
       
    48 	Used to retrieves the data part of control message
       
    49     @return 8 bit non-modifiable descriptor 
       
    50     */
       
    51 	IMPORT_C const TDesC8& MessageDes () const;
       
    52     /**
       
    53 	Used to retrieves the data part of control message
       
    54     @return 8 bit modifiable descriptor 
       
    55     */
       
    56 	IMPORT_C TDes8& MessagePtr ();	
       
    57     /**
       
    58 	Used to tell whether the data is the last message in the control data or not
       
    59     @param True if the msg is the last message
       
    60     */
       
    61 	IMPORT_C TBool IsLast() const;
       
    62     /**	Used to set the last message of the control data */
       
    63 	IMPORT_C void SetLast();
       
    64     /**
       
    65 	Used to set max length of Control Message
       
    66     @param aLen Max length of the msg
       
    67     */
       
    68 	IMPORT_C void SetMaxLength ( TInt aLen );
       
    69     /** 
       
    70 	Used to get max length of the Control Message
       
    71     @return Max length of the msg 
       
    72     */
       
    73 	IMPORT_C TInt MaxLength () const;
       
    74     /** Used to reset the SetLast flag */
       
    75 	IMPORT_C void ClearFlags ();
       
    76 	
       
    77 private:
       
    78 	TPtr8 		iPtr;
       
    79 	TInt 		iMaxLength;
       
    80 	TUint	 	iFlags;
       
    81 	};
       
    82 
       
    83 
       
    84 /** 
       
    85  This class is used to send and receive control messages
       
    86  @publishedPartner
       
    87  @prototype
       
    88  */
       
    89 class RControlChannel
       
    90 	{
       
    91 	friend class RPnPServiceDiscovery;
       
    92 	friend class RPnPServicePublisher;
       
    93 	
       
    94 public: 
       
    95 	
       
    96     /** default constructor */
       
    97 	IMPORT_C RControlChannel ( );
       
    98     /**
       
    99 	Used to receive control messages
       
   100     @param aMessage msg wrapped as TControlMessage 
       
   101     @param aStatus request status
       
   102     */
       
   103 	IMPORT_C void Recv ( TControlMessage& aMessage, TRequestStatus& aStatus );
       
   104     /**
       
   105 	Used to send control messages
       
   106     @param aMessage msg wrapped as TControlMessage 
       
   107     @param aStatus request status
       
   108     */
       
   109 	IMPORT_C void Send ( TControlMessage& aMessage, TRequestStatus& aStatus );
       
   110     
       
   111 	/** Used to close the channel */
       
   112 	IMPORT_C void Close ();	
       
   113 	
       
   114 	/** Used to cancel the asynchronous recv */
       
   115 	IMPORT_C void CancelRecv ();
       
   116 	
       
   117 	/** Used to cancel the asynchronous send */
       
   118 	IMPORT_C void CancelSend ();
       
   119 
       
   120 private:
       
   121     void Attach(CControlChannelBase& aChannelBase);	
       
   122     
       
   123 private:
       
   124 	CControlChannelBase* iControlChannelImpl;
       
   125 	};
       
   126 
       
   127 #endif //__RCONTROLCHANNEL_H__