atext/server/inc/atextcommonsession.h
changeset 0 29b1cd4cb562
child 22 9f17f914e828
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 /*
       
     2 * Copyright (c) 2008 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:  The session object for ATEXT common server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_ATEXTCOMMONSESSION_H
       
    20 #define C_ATEXTCOMMONSESSION_H
       
    21 
       
    22 #include <e32svr.h>
       
    23 #include "atextcommonobserver.h"
       
    24 
       
    25 class CATExtSrv;
       
    26 class CDesC8ArraySeg;
       
    27 
       
    28 /**
       
    29  *  Manages separate ATEXT common server sessions for client(s)
       
    30  *
       
    31  *  @since S60 v5.0
       
    32  */
       
    33 NONSHARABLE_CLASS( CATExtCommonSession ) : public CSession2,
       
    34                                            public MATExtCommonObserver
       
    35     {
       
    36 
       
    37 public:
       
    38 
       
    39     /**
       
    40      * Two-phased constructor.
       
    41      * @param aServer
       
    42      * @return Instance of self
       
    43      */
       
    44     static CATExtCommonSession* NewL( CATExtSrvCommon& aServer,
       
    45                                       const TVersion& aVersion );
       
    46 
       
    47     /**
       
    48     * Destructor.
       
    49     */
       
    50     ~CATExtCommonSession();
       
    51 
       
    52 private:
       
    53 
       
    54 // from base class CSession2
       
    55 
       
    56     /**
       
    57      * From CSession2.
       
    58      * Handles the servicing of client requests passed to the server
       
    59      *
       
    60      * @since S60 5.0
       
    61      * @param aMessage Message containing the client request
       
    62      * @return None
       
    63      */
       
    64     void ServiceL( const RMessage2& aMessage );
       
    65 
       
    66     CATExtCommonSession( CATExtSrvCommon& aServer, const TVersion& aVersion );
       
    67 
       
    68     /**
       
    69      * Handles the servicing of client requests passed to the server
       
    70      *
       
    71      * @since S60 5.0
       
    72      * @param aMessage Message containing the client request
       
    73      * @return Symbian error code on error, KErrNone otherwise
       
    74      */
       
    75     void DoServiceCommonL( const RMessage2& aMessage );
       
    76 
       
    77     /**
       
    78      * Handles the servicing of setting up interface
       
    79      *
       
    80      * @since S60 5.0
       
    81      * @param aMessage Message for Connect() client call
       
    82      * @return Symbian error code on error, KErrNone otherwise
       
    83      */
       
    84     void IpcSetCommonInterfaceL( const RMessage2& aMessage );
       
    85 
       
    86     /**
       
    87      * Synchronously closes the session
       
    88      * Optional: client can do either Close() or SynchronousClose()+Close()
       
    89      *
       
    90      * @since S60 5.0
       
    91      * @param aMessage Message for SynchronousClose() client call
       
    92      * @return None
       
    93      */
       
    94     TInt IpcSynchronousClose( const RMessage2& aMessage );
       
    95 
       
    96     /**
       
    97      * Handles the servicing of mode status reporting
       
    98      *
       
    99      * @since S60 5.0
       
   100      * @param aMessage Message for GetMode() client call
       
   101      * @return Symbian error code on error, KErrNone otherwise
       
   102      */
       
   103     TInt IpcGetMode( const RMessage2& aMessage );
       
   104 
       
   105     /**
       
   106      * Handles the servicing of mode status change receiving
       
   107      *
       
   108      * @since S60 5.0
       
   109      * @param aMessage Message for ReceiveModeStatusChange() client call
       
   110      * @return Symbian error code on error, KErrNone otherwise
       
   111      */
       
   112     TInt IpcReceiveModeStatusChange( const RMessage2& aMessage );
       
   113 
       
   114     /**
       
   115      * Handles the servicing of mode status change receive cancel
       
   116      *
       
   117      * @since S60 5.0
       
   118      * @param aMessage Message for CancelReceiveModeStatusChange() client call
       
   119      * @return Symbian error code on error, KErrNone otherwise
       
   120      */
       
   121     TInt IpcCancelReceiveModeStatusChange( const RMessage2& aMessage );
       
   122 
       
   123     /**
       
   124      * Handles the servicing of NVRAM status reporting
       
   125      *
       
   126      * @since S60 5.0
       
   127      * @param aMessage Message for GetNvramStatus() client call
       
   128      * @return Symbian error code on error, KErrNone otherwise
       
   129      */
       
   130     TInt IpcGetNvramStatus( const RMessage2& aMessage );
       
   131 
       
   132     /**
       
   133      * Handles the servicing of NVRAM status receiving
       
   134      *
       
   135      * @since S60 5.0
       
   136      * @param aMessage Message for ReceiveNvramStatusChange() client call
       
   137      * @return Symbian error code on error, KErrNone otherwise
       
   138      */
       
   139     TInt IpcReceiveNvramStatusChange( const RMessage2& aMessage );
       
   140 
       
   141     /**
       
   142      * Handles the servicing of pending NVRAM status receive cancel
       
   143      *
       
   144      * @since S60 5.0
       
   145      * @param aMessage Message for CancelReceiveNvramStatusChange() client call
       
   146      * @return Symbian error code on error, KErrNone otherwise
       
   147      */
       
   148     TInt IpcCancelReceiveNvramStatusChange( const RMessage2& aMessage );
       
   149 
       
   150     /**
       
   151      * Writes NVRAM status to client with WriteReplyBufferToClient() and
       
   152      * completes the client request message
       
   153      *
       
   154      * @since S60 5.0
       
   155      * @param aNvram
       
   156      * @param aNvramSlot
       
   157      * @return Symbian error code on error, KErrNone otherwise
       
   158      */
       
   159     TInt WriteNvramStatusToClient( const TDesC8& aNvram,
       
   160                                    TInt aNvramSlot );
       
   161 
       
   162     /**
       
   163      * Reads a string from a message
       
   164      *
       
   165      * @since S60 5.0
       
   166      * @param aBuffer Destination buffer to which to read the string
       
   167      * @param aDataSlot Slot for the aMessage from where to read the string
       
   168      * @param aMessage Message from where the string is to be read
       
   169      * @return Symbian error code on error, KErrNone otherwise
       
   170      */
       
   171     TInt ReadStringFromMessage( RBuf8& aBuffer,
       
   172                                 TInt aDataSlot,
       
   173                                 const RMessage2& aMessage );
       
   174 
       
   175     /**
       
   176      * Reads a struct from a message
       
   177      *
       
   178      * @since S60 5.0
       
   179      * @param aBuffer Destination buffer to which to read the struct
       
   180      * @param aDataSlot Slot for the aMessage from where to read the struct
       
   181      * @param aMessage Message from where the struct is to be read
       
   182      * @return Symbian error code on error, KErrNone otherwise
       
   183      */
       
   184     TInt ReadStructFromMessage( TDes8& aBuffer,
       
   185                                 TInt aDataSlot,
       
   186                                 const RMessage2& aMessage );
       
   187 
       
   188     /*
       
   189      * Writes specified input reply buffer to a client request message at
       
   190      * given message slot number.
       
   191      *
       
   192      * @since S60 5.0
       
   193      * @param aBuffer Input buffer to write to aDataSlot
       
   194      * @param aDataSlot Message slot where to write the buffer
       
   195      * @param aMessage Client request message for writing
       
   196      * @return Symbian error code on error, KErrNone otherwise
       
   197      */
       
   198     TInt WriteReplyBufferToClient( const TDesC8& aBuffer,
       
   199                                    TInt aDataSlot,
       
   200                                    const RMessage2& aMessage );
       
   201 
       
   202     /**
       
   203      * Destructs objects/associations for the current session
       
   204      *
       
   205      * @since S60 5.0
       
   206      * @param aSyncClose ETrue if synchronous close, EFalse if Close()
       
   207      * @return None
       
   208      */
       
   209     void Destruct( TBool aSyncClose );
       
   210 
       
   211 // from base class MATExtCommonObserver
       
   212 
       
   213     /**
       
   214      * From MATExtCommonObserver.
       
   215      * Called by concrete extension Plugin to inform that mode status has
       
   216      * changed.
       
   217      *
       
   218      * @since S60 5.0
       
   219      * @param aMode New mode
       
   220      * @return Symbian error code on error, KErrNone otherwise
       
   221      */
       
   222     TInt SendModeStatusChange( TUint aMode );
       
   223 
       
   224     /**
       
   225      * From MATExtCommonObserver.
       
   226      * Called by concrete extension plugin to inform that NVRAM status has
       
   227      * changed.
       
   228      *
       
   229      * @since S60 5.0
       
   230      * @param aNvram New NVRAM status. The new settings (delimited by "|")
       
   231      *               must differ from the Hayes defaults.
       
   232      * @return Symbian error code on error, KErrNone otherwise
       
   233      */
       
   234     TInt SendNvramStatusChange( const TDesC8& aNvram );
       
   235 
       
   236     /**
       
   237      * From MATExtCommonObserver.
       
   238      * Called by the destructor of CATExtPluginBase.
       
   239      * A concrete service provider implementation should not touch this.
       
   240      *
       
   241      * @param aPlugin Plugin that was closed
       
   242      * @return Symbian error code on error, KErrNone otherwise
       
   243      */
       
   244     TInt ATExtPluginClosed( CATExtCommonBase* aPlugin );
       
   245 
       
   246 private:  // data
       
   247 
       
   248     /**
       
   249      * The server
       
   250      */
       
   251     CATExtSrvCommon& iServer;
       
   252 
       
   253     /**
       
   254      * Session to ECOM
       
   255      */
       
   256     REComSession iEComSession;
       
   257 
       
   258     /**
       
   259      * Instance of plugin
       
   260      */
       
   261     CATExtCommonBase* iCommonBase;
       
   262 
       
   263     /**
       
   264      * Version of server
       
   265      */
       
   266     TVersion iVersion;
       
   267 
       
   268     /**
       
   269      * Mode status message
       
   270      */
       
   271     RMessage2 iModeStatusMessage;
       
   272 
       
   273     /**
       
   274      * NVRAM status message
       
   275      */
       
   276     RMessage2 iNvramStatusMessage;
       
   277 
       
   278     };
       
   279 
       
   280 #endif  // C_ATEXTCOMMONSESSION_H