hti/HtiCommPlugins/HtiBtCommPlugin/HtiBtCommServer/inc/HtiBtCommInterface.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
child 10 6c5f86e4c374
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Client side interface to HtiBtCommServer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __HTIBTCOMMINTERFACE_H__
       
    20 #define __HTIBTCOMMINTERFACE_H__
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32test.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // MACROS
       
    29 
       
    30 // DATA TYPES
       
    31 
       
    32 // FUNCTION PROTOTYPES
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39  * Remote interface to HtiBtCommServer.
       
    40  * HtiBtCommServer runs in separate thread, but always within the
       
    41  * client process.
       
    42  *
       
    43  * The thread is started and session to server created, when the
       
    44  * Connect is called for the first time.
       
    45  *
       
    46  * Server allows only one connection (session) at a time.
       
    47  *
       
    48  * Library: htibtcomminterface.lib
       
    49  */
       
    50 class RHtiBtCommInterface : public RSessionBase
       
    51     {
       
    52     public: // Constructor and destructor
       
    53 
       
    54         /**
       
    55         * C++ default constructor.
       
    56         */
       
    57         IMPORT_C RHtiBtCommInterface();
       
    58 
       
    59     public:
       
    60         /**
       
    61         * Connects and creates session to BtCommServer. Additionally,
       
    62         * connects to remote BT device. This may take a while
       
    63         * and may require user interaction (device selection).
       
    64         *
       
    65         * If the server is not running within this process, it is
       
    66         * started in a new thread. Note that server allows only one
       
    67         * connection (session).
       
    68         * @return Error code
       
    69         */
       
    70         IMPORT_C TInt Connect( TDesC8& aDeviceNameOrAddress, TInt aPort );
       
    71 
       
    72         /**
       
    73         * Close the session to server and wait for servers death.
       
    74         * Will disconnect the server from remote BT host, if connected.
       
    75         */
       
    76         IMPORT_C void Close();
       
    77 
       
    78         /**
       
    79         * Returns server version
       
    80         * @return Version
       
    81         */
       
    82         IMPORT_C TVersion Version() const;
       
    83 
       
    84         /**
       
    85          *  Return required buffer max size for Send operation.
       
    86          */
       
    87         IMPORT_C TInt GetSendBufferSize() const;
       
    88 
       
    89         /**
       
    90          *  Return required buffer max size for Receive operation.
       
    91          */
       
    92         IMPORT_C TInt GetReceiveBufferSize() const;
       
    93 
       
    94         /**
       
    95         * Receives data from BtCommServer.
       
    96         * Note: The aData buffer size must equal to GetReceiveBufferSize().
       
    97         * (server will write 1 to GetReceiveBufferSize bytes to the buffer).
       
    98         * @param aData Descriptor where data is received
       
    99         * @param aStatus Asynchronous request status
       
   100         */
       
   101         IMPORT_C void Receive( TDes8& aData,
       
   102                            TRequestStatus& aStatus );
       
   103 
       
   104         /**
       
   105         * Sends data to BtCommServer.
       
   106         * Note: The aData buffer size must equal to GetSendBufferSize().
       
   107         * (server will read as much as there is data in aData. There must
       
   108         * never be more data than GetSendBufferSize. This is important to notice,
       
   109         * if HBufC is used, because its actual max size can be greater than
       
   110         * initially suggested in its construction)
       
   111         *
       
   112         * @param aData Data to be sent
       
   113         * @param aStatus Asynchronous request status
       
   114         */
       
   115         IMPORT_C void Send( const TDesC8& aData,
       
   116                            TRequestStatus& aStatus );
       
   117 
       
   118 
       
   119         /**
       
   120         * Cancels pending Receive request on server.
       
   121         */
       
   122         IMPORT_C void CancelReceive();
       
   123 
       
   124         /**
       
   125         * Cancels pending Send request on server.
       
   126         */
       
   127         IMPORT_C void CancelSend();
       
   128 
       
   129         /**
       
   130         * Gets the port number of the remote service where the server is
       
   131         * connected.
       
   132         * @return Port number or KErrDisconnected if server is not connected
       
   133         */
       
   134          IMPORT_C TInt GetPortNumber() const;
       
   135 
       
   136     private:
       
   137 
       
   138         /**
       
   139         * During Connect(), connect the server
       
   140         * to remote BT host service.
       
   141         */
       
   142         TInt RHtiBtCommInterface::ConnectBt( TDesC8& aDeviceNameOrAddress,
       
   143                                              TInt aPort );
       
   144 
       
   145 };
       
   146 
       
   147 #endif // __HTIBTCOMMINTERFACE_H__
       
   148 
       
   149 // End of File