bluetoothengine/btnotif/btnotifsrv/inc/btnotifsession.h
changeset 19 43824b19ee35
child 31 a0ea99b6fa53
equal deleted inserted replaced
17:f05641c183ff 19:43824b19ee35
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : btnotifsession.h
       
     4 *  Part of     : bluetoothengine / btnotif
       
     5 *  Description : Session class for handling commands from clients.
       
     6 *
       
     7 *  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 *  All rights reserved.
       
     9 *  This component and the accompanying materials are made available
       
    10 *  under the terms of "Eclipse Public License v1.0"
       
    11 *  which accompanies this distribution, and is available
       
    12 *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 *
       
    14 *  Initial Contributors:
       
    15 *  Nokia Corporation - initial contribution.
       
    16 *
       
    17 *  Contributors:
       
    18 *  Nokia Corporation
       
    19 * ============================================================================
       
    20 * Template version: 4.2
       
    21 */
       
    22 
       
    23 #ifndef BTNOTIFSESSION_H
       
    24 #define BTNOTIFSESSION_H
       
    25 
       
    26 #include "btnotifserver.h"
       
    27 
       
    28 /**
       
    29  *  CBTNotifSession maintains a session with a client.
       
    30  *
       
    31  *  @since Symbian^4
       
    32  */
       
    33 NONSHARABLE_CLASS( CBTNotifSession ) : public CSession2
       
    34     {
       
    35 
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Two-phased constructor.
       
    40      */
       
    41     static CBTNotifSession* NewL();
       
    42 
       
    43     /**
       
    44     * Destructor.
       
    45     */
       
    46     virtual ~CBTNotifSession();
       
    47 
       
    48 // from base class CSession2
       
    49 
       
    50     /**
       
    51      * From CSession2.
       
    52      * Receives a message from a client.
       
    53      *
       
    54      * @since Symbian^4
       
    55      * @param aMessage The message containing the details of the client request.
       
    56      */
       
    57     virtual void ServiceL( const RMessage2& aMessage );
       
    58 
       
    59     /**
       
    60      * From CSession2.
       
    61      * Completes construction of the session.
       
    62      *
       
    63      * @since Symbian^4
       
    64      */
       
    65     virtual void CreateL();
       
    66 
       
    67     /**
       
    68      * Complete a client message from a message handle.
       
    69      *
       
    70      * @since Symbian^4
       
    71      * @param aHandle The handle identifying the message.
       
    72      * @param aReason The reason code to complete the message with.
       
    73      * @param aReply Data to write back to the client.
       
    74      * @return KErrNone on success; KErrNotFound if the message is not found.
       
    75      */
       
    76     TInt CompleteMessage( TInt aHandle, TInt aReason, const TDesC8& aReply );
       
    77 
       
    78     /**
       
    79      * Find a message identified by an RMessage2 handle.
       
    80      *
       
    81      * @since Symbian^4
       
    82      * @param aHandle The handle identifying the message.
       
    83      * @return The message.
       
    84      */
       
    85     const RMessage2* FindMessageFromHandle( TInt aHandle ) const;
       
    86 
       
    87     /**
       
    88      * Find a message identified by an RNotifier notifier UID.
       
    89      *
       
    90      * @since Symbian^4
       
    91      * @param aUid The UID identifying the message.
       
    92      * @return The message.
       
    93      */
       
    94     const RMessage2* FindMessageFromUid( TInt aUid ) const;
       
    95 
       
    96 private:
       
    97 
       
    98     CBTNotifSession();
       
    99 
       
   100     void ConstructL();
       
   101 
       
   102     /**
       
   103      * Returns a handle to our server.
       
   104      *
       
   105      * @since Symbian^4
       
   106      * @param Pointer to our server.
       
   107      */
       
   108     inline CBTNotifServer* Server() const
       
   109         { return (CBTNotifServer*) CSession2::Server(); }
       
   110 
       
   111     /**
       
   112      * Processes a message from a client.
       
   113      *
       
   114      * @since Symbian^4
       
   115      * @param aMessage The message containing the details of the client request.
       
   116      */
       
   117     void DispatchMessageL( const RMessage2& aMessage );
       
   118 
       
   119 private: // data
       
   120 
       
   121     /**
       
   122      * Array of messages currently being processed.
       
   123      */
       
   124     RArray<RMessage2> iMessageQ;
       
   125 
       
   126     BTUNITTESTHOOK
       
   127 
       
   128     };
       
   129 
       
   130 #endif // BTNOTIFSESSION_H