williamr@2: /*
williamr@2: * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
williamr@2: * All rights reserved.
williamr@2: * This component and the accompanying materials are made available
williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2: * which accompanies this distribution, and is available
williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2: *
williamr@2: * Initial Contributors:
williamr@2: * Nokia Corporation - initial contribution.
williamr@2: *
williamr@2: * Contributors:
williamr@2: *
williamr@2: * Description:  Server applications framework.
williamr@2:  *
williamr@2:  *
williamr@2: */
williamr@2: 
williamr@2: 
williamr@2: #ifndef AKNSERVERAPP_H
williamr@2: #define AKNSERVERAPP_H
williamr@2: 
williamr@2: #include <EikServerApp.h>
williamr@2: 
williamr@2: /**
williamr@2:  * Allows a server app client to connect to a new server app, which
williamr@2:  * will be chained from the client app, giving it the appearance
williamr@2:  * of being embedded within the client.
williamr@2:  *
williamr@2:  * Series 60 client-side service IPC implementations should be
williamr@2:  * derived from this class.
williamr@2:  */
williamr@2: class RAknAppServiceBase : public REikAppServiceBase
williamr@2:     {
williamr@2: public:
williamr@2:     /**
williamr@2:     * Launch a new server app instance, which will be chained
williamr@2:     * from the current application.
williamr@2:     * Note, this function can only be used from the context of
williamr@2:     * an application thread, as it depends on the existence of
williamr@2:     * a CEikonEnv object.
williamr@2:     * If you want to launch a chained server app in a situation
williamr@2:     * where a CEikonEnv does not exist, use REikAppServiceBase::ConnectNewChildAppL()
williamr@2:     * instead.
williamr@2:     * @param aAppUid The UID of the server app which you wish to
williamr@2:     * launch.
williamr@2:     */
williamr@2:     IMPORT_C void ConnectChainedAppL(TUid aAppUid);
williamr@2:     /**
williamr@2:     * Close the server app session.
williamr@2:     */
williamr@2:     IMPORT_C void Close();
williamr@2:     };
williamr@2: 
williamr@2: 
williamr@2: /**
williamr@2:  * Interface for monitoring the lifetime of a server app.
williamr@2:  * This class adds Series 60 common behavior to the handling
williamr@2:  * of server app exits.
williamr@2:  */
williamr@2: class MAknServerAppExitObserver : public MApaServerAppExitObserver
williamr@2:     {
williamr@2: public: // from MApaServerAppExitObserver
williamr@2:     /**
williamr@2:     * Handle the exit of a connected server app.
williamr@2:     * This implementation provides Series 60 default behavior
williamr@2:     * for handling of the EAknCmdExit exit code. Derived classes
williamr@2:     * should base-call this implementation if they override this
williamr@2:     * function.
williamr@2:     * @param aReason The reason that the server application exited.
williamr@2:     * This will either be an error code, or the command id that caused
williamr@2:     * the server app to exit.
williamr@2:     */
williamr@2:     IMPORT_C virtual void HandleServerAppExit(TInt aReason);
williamr@2:     };
williamr@2: 
williamr@2: 
williamr@2: /**
williamr@2:  * Base class for server app service IPC implementations.
williamr@2:  * This class provides notifications of service creation and
williamr@2:  * destruction to the server, to give the server the ability
williamr@2:  * to handle the case where all clients have closed their
williamr@2:  * sessions.
williamr@2:  */
williamr@2: class CAknAppServiceBase : public CApaAppServiceBase
williamr@2:     {
williamr@2: public:
williamr@2:     /**
williamr@2:     * Constructor
williamr@2:     */
williamr@2:     IMPORT_C CAknAppServiceBase();
williamr@2:     /**
williamr@2:     * Destructor
williamr@2:     */
williamr@2:     IMPORT_C ~CAknAppServiceBase();
williamr@2: 
williamr@2: protected: // from CSession2
williamr@2:     /**
williamr@2:     * Override of CSession2::CreateL().
williamr@2:     * If further overridden, this function must be base-called.
williamr@2:     */
williamr@2:     IMPORT_C void CreateL();
williamr@2:     /**
williamr@2:     * Override of CSession2::ServiceL().
williamr@2:     * If further overridden, this function must be base-called.
williamr@2:     * @param aMessage The client message
williamr@2:     */
williamr@2:     IMPORT_C void ServiceL(const RMessage2& aMessage);
williamr@2:     /**
williamr@2:     * Override of CSession2::ServiceError().
williamr@2:     * If further overridden, this function must be base-called.
williamr@2:     * @param aMessage The client message.
williamr@2:     * @param aError The error code to which occured during message servicing
williamr@2:     */
williamr@2:     IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError);
williamr@2:     };
williamr@2: 
williamr@2: 
williamr@2: /**
williamr@2:  * Base class for server app's servers.
williamr@2:  * Series 60 applications that want to implement services should
williamr@2:  * derive their server class from this.
williamr@2:  * This class already supports the standard Series 60 services,
williamr@2:  * and is instantiated by default if an application is launched
williamr@2:  * as a server app, but does not override CAknApp::NewServerAppL().
williamr@2:  */
williamr@2: class CAknAppServer : public CEikAppServer
williamr@2:     {
williamr@2: public: // from CAknAppServer
williamr@2:     /**
williamr@2:     * Destructor
williamr@2:     */
williamr@2: 	IMPORT_C ~CAknAppServer();
williamr@2:     /**
williamr@2:     * Second stage construction.
williamr@2:     * Derived classes may override this to add extra second
williamr@2:     * stage constuction, but they must base-call.
williamr@2:     * @param aFixedServerName the name that this server will have,
williamr@2:     * must be passed through in the base-call.
williamr@2:     */
williamr@2:     IMPORT_C void ConstructL(const TDesC& aFixedServerName);
williamr@2:     /**
williamr@2:     * Create a new service implementation.
williamr@2:     * This implementation creates common Series 60 services.
williamr@2:     * Derived classes can override this to add support for specific
williamr@2:     * services that they support. They must base-call for any
williamr@2:     * service UIDs that they do not support.
williamr@2:     * @param aServiceType the UID of the service that has been requested
williamr@2:     * @return a new service instance of the type requested
williamr@2:     */
williamr@2:     IMPORT_C CApaAppServiceBase* CreateServiceL(TUid aServiceType) const;
williamr@2: public: // new
williamr@2:     /**
williamr@2:     * Allows the server to handle the case when all client sessions
williamr@2:     * have closed.
williamr@2:     * The default implementation provides the Series 60 policy of
williamr@2:     * closing the server application. If this is not appropriate for
williamr@2:     * a server app, it should override this function to provide its
williamr@2:     * own behavior.
williamr@2:     */
williamr@2:     IMPORT_C virtual void HandleAllClientsClosed();
williamr@2: public: // not exported
williamr@2:     void HandleSessionClose();
williamr@2:     void HandleSessionOpen();
williamr@2: private:
williamr@2:     TInt iSessionCount;
williamr@2:     };
williamr@2: 
williamr@2: 
williamr@2: #endif
williamr@2: 
williamr@2: // End of file.