appfw/apparchitecture/inc/ApaServerApp.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // apaserverapp.h
       
    15 //
       
    16 
       
    17 #ifndef APASERVERAPP_H__
       
    18 #define APASERVERAPP_H__
       
    19 
       
    20 #include <e32base.h>	// class RSessionBase
       
    21 
       
    22 
       
    23 /** Server app connection and lifetime monitoring functionality.
       
    24 
       
    25 This is the base class for all server application service client
       
    26 support implementations.
       
    27 
       
    28 The class is derived from by the UI framework and is further derived from 
       
    29 by service implementations.
       
    30 
       
    31 Clients of these server application services will use these derived classes as
       
    32 the interface to the server application implementations of the services.
       
    33 
       
    34 @publishedPartner
       
    35 @released
       
    36 @see REikAppServiceBase */
       
    37 class RApaAppServiceBase : public RSessionBase
       
    38 	{
       
    39 public:
       
    40 	/** Constants defining the base IPC command ids usable by the system GUI and services. */
       
    41 	enum TApaAppServiceBaseCmdConstants
       
    42 		{
       
    43 		/** System GUI server app command IDs must start from this base. */
       
    44 		KSystemGuiCmdBase = 0x100,
       
    45 		/** Service specific command IDs must start from this base. */
       
    46 		KServiceCmdBase = 0x200
       
    47 		};
       
    48 public:
       
    49 	IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient);
       
    50 	IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient, const TSecurityPolicy& aSecurityPolicy);
       
    51 	IMPORT_C void ConnectExistingByNameL(const TDesC& aName);
       
    52 	IMPORT_C void ConnectExistingByNameL(const TDesC& aServerName, const TSecurityPolicy& aSecurityPolicy);
       
    53 	IMPORT_C void TransferExistingSessionL(RApaAppServiceBase& aClient);
       
    54 	IMPORT_C void Close(); //lint !e1511 Member hides non-virtual member
       
    55 
       
    56 	IMPORT_C void NotifyServerExit(TRequestStatus& aStatus) const;
       
    57 	IMPORT_C void CancelNotifyServerExit() const;
       
    58 	
       
    59 	IMPORT_C TPtrC ServerName() const;
       
    60 protected:
       
    61 	IMPORT_C RApaAppServiceBase();
       
    62 private:
       
    63 	IMPORT_C virtual void RApaAppServiceBase_Reserved1();
       
    64 	IMPORT_C virtual void RApaAppServiceBase_Reserved2();
       
    65 	
       
    66 	/** Returns the UID of the service that this session provides an interface for.
       
    67 	Client side service implementations must implement this function to return
       
    68 	the UID for the service that they implement.
       
    69 	@return The UID of the service implemented by the derived class.*/
       
    70 	virtual TUid ServiceUid() const = 0;
       
    71 private:
       
    72 	void ConnectL();
       
    73 	void ConnectL(const TSecurityPolicy& aSecurityPolicy);
       
    74 private:
       
    75 	IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion);
       
    76 private:
       
    77 	HBufC* iServerName;		// owned
       
    78 	TInt iApaReserved1;
       
    79 	TInt iApaReserved2;
       
    80 	};
       
    81 
       
    82 
       
    83 /** Interface for a class that wants to receive exit notification from
       
    84 a server application.
       
    85 
       
    86 @publishedPartner
       
    87 @released
       
    88 @see CApaServerAppExitMonitor*/
       
    89 class MApaServerAppExitObserver
       
    90 	{
       
    91 public:
       
    92 	/** Receives server exit notification.
       
    93 	Implementers of this interface must override this function to
       
    94 	receive notification of server app exit reasons.
       
    95 	@param aReason The reason that the server app exited, this may be
       
    96 	a command ID from the UI if exit was triggered from the UI, or an error code
       
    97 	if the server app exited unexpectedly. */
       
    98 	virtual void HandleServerAppExit(TInt aReason) = 0;
       
    99 protected:
       
   100 	IMPORT_C MApaServerAppExitObserver();
       
   101 private:
       
   102 	IMPORT_C virtual void MApaServerAppExitObserver_Reserved1();
       
   103 	IMPORT_C virtual void MApaServerAppExitObserver_Reserved2();
       
   104 private:
       
   105 	TInt iMApaServerAppExitObserver_Reserved1;
       
   106 	};
       
   107 
       
   108 
       
   109 /** Helper class that monitors the lifetime of a server app
       
   110 through a connected RApaAppServiceBase and reports server app exits
       
   111 to a MApaServerAppExitObserver derived class.
       
   112 
       
   113 @publishedPartner
       
   114 @released
       
   115 @see RApaAppServiceBase
       
   116 @see MApaServerAppExitObserver */
       
   117 NONSHARABLE_CLASS(CApaServerAppExitMonitor) : public CActive
       
   118 	{
       
   119 public:
       
   120 	IMPORT_C static CApaServerAppExitMonitor* NewL(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority);
       
   121 	IMPORT_C static CApaServerAppExitMonitor* NewLC(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority);
       
   122 	IMPORT_C ~CApaServerAppExitMonitor();
       
   123 private:
       
   124 	CApaServerAppExitMonitor(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority);
       
   125 private:	// from CActive
       
   126 	void RunL();
       
   127 	void DoCancel();
       
   128 	TInt RunError(TInt aError);
       
   129 private:
       
   130 	RApaAppServiceBase& iClient;
       
   131 	MApaServerAppExitObserver& iObserver;
       
   132 	};
       
   133 
       
   134 	
       
   135 //
       
   136 // Server application server support
       
   137 //
       
   138 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   139 /** Panic codes that the server application framework can generate.
       
   140 @internalComponent */
       
   141 enum TApaAppServerPanic
       
   142 	{
       
   143 	/** The IPC message ID used by the client is not recognised. */
       
   144 	EApaAppServerPanicIllegalFunction,
       
   145 	/** The client already has an active notification of server exit. */
       
   146 	EApaAppServerPanicNotifyExitActive,
       
   147 	/** The client has tried to connect an already connected session. */
       
   148 	EApaAppServerPanicClientAlreadyConnected
       
   149 	};
       
   150 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
   151 
       
   152 /** Base class for all service implementations.
       
   153 Provides the basic IPC and security framework that server applications
       
   154 can use to receive messages from their clients.
       
   155 In a typical service implementation, a service support class
       
   156 will be derived from this class, and the service implementation
       
   157 will then be derived from the service support class.
       
   158 
       
   159 Instances of this class are created by the server application
       
   160 in its override of CApaAppServer::CreateServiceL().
       
   161 
       
   162 @publishedPartner 
       
   163 @released
       
   164 @see CApaAppServer
       
   165 @see CPolicyServer */
       
   166 class CApaAppServiceBase : public CSession2
       
   167 	{
       
   168 public:
       
   169 	IMPORT_C CApaAppServiceBase();
       
   170 	IMPORT_C ~CApaAppServiceBase();
       
   171 
       
   172 	IMPORT_C virtual CPolicyServer::TCustomResult SecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
       
   173 public: // internal
       
   174 	void SendAppServerExitNotification(TInt aExitReason);
       
   175 protected: // from CSession2
       
   176 	IMPORT_C void CreateL();
       
   177 	IMPORT_C void ServiceL(const RMessage2& aMessage);
       
   178 	IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError);
       
   179 	IMPORT_C virtual TInt CountResources();
       
   180 	IMPORT_C virtual void Disconnect(const RMessage2& aMessage);
       
   181 private: // Server exit notification handlers
       
   182 	void NotifyServerExit(const RMessage2& aMessage);
       
   183 	void CancelNotifyServerExit(const RMessage2& aMessage) const;
       
   184 private:
       
   185 	IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion);
       
   186 	IMPORT_C virtual void CApaAppServiceBase_Reserved1();
       
   187 	IMPORT_C virtual void CApaAppServiceBase_Reserved2();
       
   188 private:
       
   189 	RMessagePtr2 iNotifyExitMsg;
       
   190 	TInt iExitReason;
       
   191 	TInt iApaReserved2;
       
   192 	};
       
   193 
       
   194 
       
   195 /** Base class for all server application's servers.
       
   196 Server applications must derive from this class to implement their
       
   197 servers. These must be instantiated in an override of
       
   198 CApaApplication::NewAppServerL().
       
   199 The main task of this class is to create service implementations
       
   200 that clients of a server app may connect to.
       
   201 
       
   202 @publishedPartner 
       
   203 @released
       
   204 @see CEikAppServer
       
   205 @see CPolicyServer */
       
   206 class CApaAppServer : public CPolicyServer
       
   207 	{
       
   208 public:
       
   209 	IMPORT_C ~CApaAppServer();
       
   210 	IMPORT_C virtual void ConstructL(const TDesC& aFixedServerName);
       
   211 	IMPORT_C void NotifyServerExit(TInt aReason);
       
   212 	IMPORT_C virtual CApaAppServiceBase* CreateServiceL(TUid aServiceType) const;
       
   213 	IMPORT_C virtual TCustomResult CreateServiceSecurityCheckL(TUid aServiceType, const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
       
   214 protected:
       
   215 	IMPORT_C CApaAppServer();
       
   216 protected:	// from CPolicyServer
       
   217 	IMPORT_C TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
       
   218 protected:	// from CServer2
       
   219 	IMPORT_C virtual void DoConnect(const RMessage2& aMessage);
       
   220 private: // from CServer2
       
   221 	IMPORT_C CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
   222 private:
       
   223 	TUid ConnectMessageServiceUid(const RMessage2& aMsg) const;
       
   224 private:
       
   225 	IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion);
       
   226 	// Extensions
       
   227 	IMPORT_C virtual void CApaAppServer_Reserved1();
       
   228 	IMPORT_C virtual void CApaAppServer_Reserved2();
       
   229 private:
       
   230 	TInt iApaReserved1;
       
   231 	TInt iApaReserved2;
       
   232 	};
       
   233 
       
   234 
       
   235 #endif	// APASERVERAPP_H__