2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Server applications framework.
20 #ifndef AKNSERVERAPP_H
21 #define AKNSERVERAPP_H
23 #include <eikserverapp.h>
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.
30 * Series 60 client-side service IPC implementations should be
31 * derived from this class.
33 class RAknAppServiceBase : public REikAppServiceBase
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
42 * If you want to launch a chained server app in a situation
43 * where a CEikonEnv does not exist, use REikAppServiceBase::ConnectNewChildAppL()
45 * @param aAppUid The UID of the server app which you wish to
48 IMPORT_C void ConnectChainedAppL(TUid aAppUid);
50 * Close the server app session.
52 IMPORT_C void Close();
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.
61 class MAknServerAppExitObserver : public MApaServerAppExitObserver
63 public: // from MApaServerAppExitObserver
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
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.
74 IMPORT_C virtual void HandleServerAppExit(TInt aReason);
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
85 class CAknAppServiceBase : public CApaAppServiceBase
91 IMPORT_C CAknAppServiceBase();
95 IMPORT_C ~CAknAppServiceBase();
97 protected: // from CSession2
99 * Override of CSession2::CreateL().
100 * If further overridden, this function must be base-called.
102 IMPORT_C void CreateL();
104 * Override of CSession2::ServiceL().
105 * If further overridden, this function must be base-called.
106 * @param aMessage The client message
108 IMPORT_C void ServiceL(const RMessage2& aMessage);
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
115 IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError);
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().
127 class CAknAppServer : public CEikAppServer
129 public: // from CAknAppServer
133 IMPORT_C ~CAknAppServer();
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.
141 IMPORT_C void ConstructL(const TDesC& aFixedServerName);
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
151 IMPORT_C CApaAppServiceBase* CreateServiceL(TUid aServiceType) const;
154 * Allows the server to handle the case when all client sessions
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
161 IMPORT_C virtual void HandleAllClientsClosed();
162 public: // not exported
163 void HandleSessionClose();
164 void HandleSessionOpen();