menucontentsrv/srvinc/menusrvsession.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __MENUSRVSESSION_H__
       
    19 #define __MENUSRVSESSION_H__
       
    20 
       
    21 //  INCLUDES
       
    22 
       
    23 #include <e32base.h>
       
    24 #include "menusrv.h"
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 
       
    28 class MStreamBuf;
       
    29 class CMenuSrvStream;
       
    30 class CMenuSrvOperation;
       
    31 class CMenuSrvNotifier;
       
    32 class CMenuSrvEng;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 * Menu Server Session.
       
    38 */
       
    39 NONSHARABLE_CLASS( CMenuSrvSession ) : public CSession2
       
    40     {
       
    41 
       
    42 public:     // construct / destruct
       
    43 
       
    44     /**
       
    45     * Destructor.
       
    46     */
       
    47     virtual ~CMenuSrvSession();
       
    48 
       
    49     /**
       
    50     * Two phase constructor. Leaves on failure.
       
    51     * @param aMenuSrv Menu Server.
       
    52     */
       
    53     static CMenuSrvSession* NewL( CMenuSrv& aMenuSrv );
       
    54 
       
    55 protected:  // construct
       
    56 
       
    57     /**
       
    58     * Constructor. Leaves on failure.
       
    59     * @param aMenuSrv Menu Server.
       
    60     */
       
    61     CMenuSrvSession( CMenuSrv& aMenuSrv );
       
    62 
       
    63     /**
       
    64     * Second phase constructor. Leaves on failure.
       
    65     */
       
    66     void ConstructL();
       
    67 
       
    68 public:     // From CSession2
       
    69 
       
    70     /**
       
    71     * Count resources.
       
    72     * @return Resource count.
       
    73     */
       
    74     virtual TInt CountResources();
       
    75 
       
    76     /**
       
    77     * Service message.
       
    78     * @param aMessage Message.
       
    79     */
       
    80     virtual void ServiceL( const RMessage2& aMessage );
       
    81 
       
    82     /**
       
    83     * Error in message processing.
       
    84     * @param aMessage Message.
       
    85     * @param aError Error.
       
    86     */
       
    87     virtual void ServiceError( const RMessage2& aMessage, TInt aError );
       
    88 
       
    89 public:     // new methods
       
    90 
       
    91     /**
       
    92     * Engine events -> complete matching notifiers.
       
    93     * @param aFolder Events occurred in this folder. (0==unspecified.)
       
    94     * @param aEvents Events. A combination of TEvent bits.
       
    95     */
       
    96     void EngineEvents( TInt aFolder, TInt aEvents );
       
    97 
       
    98     /**
       
    99     * Unrecoverable Engine error. The engine has stopped working and is
       
   100     * useless -> so are we. Disconnect this session from the Engine, this
       
   101     * allow it to delete itself. From now on, (almost) all messages are
       
   102     * completed with error.
       
   103     * @param aErr Error code.
       
   104     */
       
   105     void EngineError( TInt aErr );
       
   106 
       
   107 private:    // Message handling
       
   108 
       
   109     /**
       
   110     * Create new stream object, write its subsession handle back in slot 3.
       
   111     * @param aHost Host. Ownership taken by the stream.
       
   112     * @param aMessage Message.
       
   113     */
       
   114     void NewStreamL( MStreamBuf& aHost, const RMessage2& aMessage );
       
   115 
       
   116     /**
       
   117     * Get stream by handle. Leaves with KErrBadHandle (==panics client) if
       
   118     * not found.
       
   119     * @param aHandle Handle.
       
   120     * @return Stream.
       
   121     */
       
   122     CMenuSrvStream& StreamL( TInt aHandle );
       
   123 
       
   124     /**
       
   125     * Store operation, write its subsession handle back in slot 3.
       
   126     * @param aOperation Operation. Note: ownership taken BEFORE adding (at
       
   127     * the beginning of this method)!
       
   128     * @param aMessage Message.
       
   129     */
       
   130     void AddOperationL( CMenuSrvOperation* aOperation, const RMessage2& aMessage );
       
   131 
       
   132     /**
       
   133     * Get operation by handle. Leaves with KErrBadHandle (==panics client) if
       
   134     * not found.
       
   135     * @param aHandle Handle.
       
   136     * @return Operation.
       
   137     */
       
   138     CMenuSrvOperation& OperationL( TInt aHandle );
       
   139 
       
   140     /**
       
   141     * Create new notifier object, write its subsession handle back in slot 3.
       
   142     * @param aMessage Message.
       
   143     */
       
   144     void NewNotifierL( const RMessage2& aMessage );
       
   145 
       
   146     /**
       
   147     * Get notifier by handle. Leaves with KErrBadHandle (==panics client) if
       
   148     * not found.
       
   149     * @param aHandle Handle.
       
   150     * @return Notifier.
       
   151     */
       
   152     CMenuSrvNotifier& NotifierL( TInt aHandle );
       
   153 
       
   154     /**
       
   155     * Client error, panic client and leave.
       
   156     * @param aMessage Message.
       
   157     */
       
   158     void PanicClientL( const RMessage2& aMessage );
       
   159     
       
   160     /**
       
   161     * Service message.
       
   162     * @param aMessage Message.
       
   163     * @return ETrue if function was serviced 
       
   164     */
       
   165     TBool ServiceCapabilityTestL( const RMessage2& aMessage );
       
   166     
       
   167     /**
       
   168     * Service message.
       
   169     * @param aMessage Message.
       
   170     * @return ETrue if function was serviced
       
   171     */
       
   172     TBool ServiceCapReadL( const RMessage2& aMessage );
       
   173     
       
   174     /**
       
   175     * Service message.
       
   176     * @param aMessage Message.
       
   177     * @return ETrue if function was serviced
       
   178     */
       
   179     TBool ServiceCapWriteL( const RMessage2& aMessage );
       
   180 
       
   181 private:    // Data
       
   182 
       
   183     TBool iEngineDead; ///< If the engine dies, the session stops working.
       
   184     CMenuSrv& iMenuSrv; ///< Menu server. Not owned.
       
   185     CMenuSrvEng* iSharedEng; ///< Engine instance. Shared object, Close() needed.
       
   186     CObjectCon* iObjectCon; ///< Object container. Owned.
       
   187     CObjectIx* iNotifierIx; ///< Notifier index. Owned.
       
   188     CObjectIx* iStreamIx; ///< Stream index. Owned.
       
   189     CObjectIx* iOperationIx; ///< Operation index. Owned.
       
   190 
       
   191 };
       
   192 
       
   193 #endif // __MENUSRVSESSION_H__
       
   194 
       
   195 // End of File