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