phoneclientserver/phoneserver/Inc/Standard/CPhSrvSession.h
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Server Session.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHSRVSESSION_H
       
    20 #define CPHSRVSESSION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "PhCltClientServer.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CPhSrvServer;
       
    28 class CPhSrvCallNotify;
       
    29 class CPhSrvReqManager;
       
    30 class CPhSrvExtCall;
       
    31 class CPhSrvSubSessionBase;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 *  It is the session class for Phone Server.
       
    37 *
       
    38 *  @since 1.0
       
    39 */
       
    40 class CPhSrvSession : public CSession2
       
    41     {
       
    42     friend class CPhSrvSubSessionBase;
       
    43 
       
    44 
       
    45     public: // Constructors and destructor
       
    46         
       
    47         /**
       
    48          * Two-phased constructor.
       
    49          *
       
    50          * @param aServer It is the main server object.
       
    51          * @return Returns a new session.
       
    52          */
       
    53         static CPhSrvSession* NewL( 
       
    54             CPhSrvServer& aServer );
       
    55 
       
    56         /**
       
    57         * Destructor.
       
    58         */
       
    59         ~CPhSrvSession();
       
    60 
       
    61 
       
    62     public: // Functions from base classes
       
    63 
       
    64         /**
       
    65         * From CSession2, it is called whenever request is processed.
       
    66         * 
       
    67         * @param aMessage It is the request.
       
    68         */
       
    69         void ServiceL( const RMessage2& aMessage );
       
    70 
       
    71 
       
    72     public: // Sub-session access
       
    73 
       
    74         /**
       
    75         * Phone Server reference.
       
    76         *
       
    77         * @return The phone server.
       
    78         */
       
    79         CPhSrvServer& PhoneServer() const;
       
    80 
       
    81         /**
       
    82         * Get information of the count of subsessions.
       
    83         *
       
    84         * @return The number of subsession objects.
       
    85         */
       
    86         TInt SubSessionCount() const;
       
    87 
       
    88         /**
       
    89         * Return a specific subsession.
       
    90         *
       
    91         * @return The subsession at location aIndex.
       
    92         */
       
    93         CPhSrvSubSessionBase& SubSessionAt(TInt aIndex) const;
       
    94 
       
    95         /**
       
    96         * Closes subsession by handle.
       
    97         *
       
    98         * @param aMessage It contains the handle to the subsession.
       
    99         */
       
   100         void CloseSubSession( const RMessage2& aMessage );
       
   101 
       
   102         /**
       
   103         * Panics the client thread.
       
   104         *
       
   105         * @param aMessage The client to be panicked.
       
   106         * @param aPanic It is the reason for panic.
       
   107         */
       
   108         void PanicClient(
       
   109             const RMessage2& aMessage,
       
   110             TPhCltServerInitiatedPanic aPanic ) const;
       
   111             
       
   112         /**
       
   113         * Writes to client address space inside and
       
   114         * catch bad descriptors.
       
   115         *
       
   116         * @param aMessage The client.
       
   117         * @param aLocation The location where the data is written.
       
   118         * @param aDes The data that is written.
       
   119         * @param aOffset The data location where to start the writing.
       
   120         */
       
   121         void Write( 
       
   122             const RMessage2& aMessage,
       
   123             TInt aLocation,
       
   124             const TDesC8& aDes,
       
   125             TInt aOffset = 0 );
       
   126 
       
   127         /**
       
   128         * Reads from client address space and
       
   129         * catch bad descriptors.
       
   130         *
       
   131         * @param aMessage The client.
       
   132         * @param aLocation The location where the data is read.
       
   133         * @param aDes The read data storage.
       
   134         * @param aOffset The data location where to start the reading.
       
   135         */
       
   136         void Read(
       
   137             const RMessage2& aMessage,
       
   138             TInt aLocation,
       
   139             TDes8& aDes,
       
   140             TInt aOffset = 0 );
       
   141 
       
   142         /**
       
   143         * Reads from client address space and
       
   144         * catch bad descriptors (unicode aware)
       
   145         *
       
   146         * @param aMessage The client.
       
   147         * @param aLocation The location where the data is read.
       
   148         * @param aDes The read data storage.
       
   149         * @param aOffset The data location where to start the reading.
       
   150         */
       
   151         void Read(
       
   152             const RMessage2& aMessage,
       
   153             TInt aLocation,
       
   154             TDes& aDes,
       
   155             TInt aOffset = 0 );
       
   156 
       
   157         /**
       
   158         * Complete create all request.
       
   159         *
       
   160         * @param aError The error code that is returned.
       
   161         */
       
   162         void CompleteCreateAll( TInt aError );
       
   163 
       
   164 
       
   165     private:
       
   166 
       
   167         /**
       
   168         * C++ constructor.
       
   169         */
       
   170         CPhSrvSession();
       
   171         
       
   172         /**
       
   173         * Symbian OS constructor.
       
   174         */
       
   175         void ConstructL( CPhSrvServer& aServer );
       
   176 
       
   177         /**
       
   178         * Return the unique handle associated with this subsession
       
   179         *
       
   180         * @return The unique handle associated with a subsession.
       
   181         */
       
   182         TInt SubSessionUniqueHandle( 
       
   183             const CPhSrvSubSessionBase& aSubSession ) const;
       
   184 
       
   185         /**
       
   186         * Service a request - called by ServiceL within a trap
       
   187         * harness so that we can catch leaves, and complete messages
       
   188         * properly.
       
   189         * 
       
   190         * @param aMessage The message from the client [sub]session.
       
   191         */
       
   192         void ProcessRequestL( const RMessage2& aMessage );
       
   193 
       
   194         /**
       
   195         * Handle function.
       
   196         *
       
   197         * @param aFunction function.
       
   198         * @return ETrue iff handled here.
       
   199         */
       
   200         TBool HandleCommandL( const RMessage2& aMessage );
       
   201 
       
   202 
       
   203     private:    // Data
       
   204 
       
   205         // The container for all objects in this session (i.e. the 
       
   206         // subsession CObject's from the client-side).
       
   207         CObjectCon*     iContainer;
       
   208 
       
   209         // The index of open objects associated with this session.
       
   210         CObjectIx*      iObjectIx;
       
   211 
       
   212         // Server.
       
   213         CPhSrvServer*   iServer;
       
   214 
       
   215         // Flag, ETrue if message ok.
       
   216         TBool           iCreateAll;
       
   217 
       
   218         // Message for create all.
       
   219         RMessage2       iCreateAllMsg;
       
   220     };
       
   221 
       
   222 #endif      // CPHSRVSESSION_H
       
   223             
       
   224 // End of File