epoc32/include/mw/aknserverapp.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 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 applications framework.
    15  *
    16  *
    17 */
    18 
    19 
    20 #ifndef AKNSERVERAPP_H
    21 #define AKNSERVERAPP_H
    22 
    23 #include <eikserverapp.h>
    24 
    25 /**
    26  * Allows a server app client to connect to a new server app, which
    27  * will be chained from the client app, giving it the appearance
    28  * of being embedded within the client.
    29  *
    30  * Series 60 client-side service IPC implementations should be
    31  * derived from this class.
    32  */
    33 class RAknAppServiceBase : public REikAppServiceBase
    34     {
    35 public:
    36     /**
    37     * Launch a new server app instance, which will be chained
    38     * from the current application.
    39     * Note, this function can only be used from the context of
    40     * an application thread, as it depends on the existence of
    41     * a CEikonEnv object.
    42     * If you want to launch a chained server app in a situation
    43     * where a CEikonEnv does not exist, use REikAppServiceBase::ConnectNewChildAppL()
    44     * instead.
    45     * @param aAppUid The UID of the server app which you wish to
    46     * launch.
    47     */
    48     IMPORT_C void ConnectChainedAppL(TUid aAppUid);
    49     /**
    50     * Close the server app session.
    51     */
    52     IMPORT_C void Close();
    53     };
    54 
    55 
    56 /**
    57  * Interface for monitoring the lifetime of a server app.
    58  * This class adds Series 60 common behavior to the handling
    59  * of server app exits.
    60  */
    61 class MAknServerAppExitObserver : public MApaServerAppExitObserver
    62     {
    63 public: // from MApaServerAppExitObserver
    64     /**
    65     * Handle the exit of a connected server app.
    66     * This implementation provides Series 60 default behavior
    67     * for handling of the EAknCmdExit exit code. Derived classes
    68     * should base-call this implementation if they override this
    69     * function.
    70     * @param aReason The reason that the server application exited.
    71     * This will either be an error code, or the command id that caused
    72     * the server app to exit.
    73     */
    74     IMPORT_C virtual void HandleServerAppExit(TInt aReason);
    75     };
    76 
    77 
    78 /**
    79  * Base class for server app service IPC implementations.
    80  * This class provides notifications of service creation and
    81  * destruction to the server, to give the server the ability
    82  * to handle the case where all clients have closed their
    83  * sessions.
    84  */
    85 class CAknAppServiceBase : public CApaAppServiceBase
    86     {
    87 public:
    88     /**
    89     * Constructor
    90     */
    91     IMPORT_C CAknAppServiceBase();
    92     /**
    93     * Destructor
    94     */
    95     IMPORT_C ~CAknAppServiceBase();
    96 
    97 protected: // from CSession2
    98     /**
    99     * Override of CSession2::CreateL().
   100     * If further overridden, this function must be base-called.
   101     */
   102     IMPORT_C void CreateL();
   103     /**
   104     * Override of CSession2::ServiceL().
   105     * If further overridden, this function must be base-called.
   106     * @param aMessage The client message
   107     */
   108     IMPORT_C void ServiceL(const RMessage2& aMessage);
   109     /**
   110     * Override of CSession2::ServiceError().
   111     * If further overridden, this function must be base-called.
   112     * @param aMessage The client message.
   113     * @param aError The error code to which occured during message servicing
   114     */
   115     IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError);
   116     };
   117 
   118 
   119 /**
   120  * Base class for server app's servers.
   121  * Series 60 applications that want to implement services should
   122  * derive their server class from this.
   123  * This class already supports the standard Series 60 services,
   124  * and is instantiated by default if an application is launched
   125  * as a server app, but does not override CAknApp::NewServerAppL().
   126  */
   127 class CAknAppServer : public CEikAppServer
   128     {
   129 public: // from CAknAppServer
   130     /**
   131     * Destructor
   132     */
   133 	IMPORT_C ~CAknAppServer();
   134     /**
   135     * Second stage construction.
   136     * Derived classes may override this to add extra second
   137     * stage constuction, but they must base-call.
   138     * @param aFixedServerName the name that this server will have,
   139     * must be passed through in the base-call.
   140     */
   141     IMPORT_C void ConstructL(const TDesC& aFixedServerName);
   142     /**
   143     * Create a new service implementation.
   144     * This implementation creates common Series 60 services.
   145     * Derived classes can override this to add support for specific
   146     * services that they support. They must base-call for any
   147     * service UIDs that they do not support.
   148     * @param aServiceType the UID of the service that has been requested
   149     * @return a new service instance of the type requested
   150     */
   151     IMPORT_C CApaAppServiceBase* CreateServiceL(TUid aServiceType) const;
   152 public: // new
   153     /**
   154     * Allows the server to handle the case when all client sessions
   155     * have closed.
   156     * The default implementation provides the Series 60 policy of
   157     * closing the server application. If this is not appropriate for
   158     * a server app, it should override this function to provide its
   159     * own behavior.
   160     */
   161     IMPORT_C virtual void HandleAllClientsClosed();
   162 public: // not exported
   163     void HandleSessionClose();
   164     void HandleSessionOpen();
   165 private:
   166     TInt iSessionCount;
   167     };
   168 
   169 
   170 #endif
   171 
   172 // End of file.