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