williamr@2: // Copyright (c) 2004-2009 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: williamr@2: // williamr@2: williamr@2: #ifndef APASERVERAPP_H williamr@2: #define APASERVERAPP_H williamr@2: williamr@2: #include williamr@2: williamr@2: williamr@2: // williamr@2: // Server application client support williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: class RApaAppServiceBase : public RSessionBase williamr@2: /** Server app connection and lifetime monitoring functionality. williamr@2: williamr@2: This is the base class for all server application service client williamr@2: support implementations. williamr@2: williamr@2: The class is derived from by the UI framework and is further derived from williamr@2: by service implementations. williamr@2: williamr@2: Clients of these server application services will use these derived classes as williamr@2: the interface to the server application implementations of the services. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: @see REikAppServiceBase */ williamr@2: { williamr@2: public: williamr@2: williamr@2: /** Constants defining the base IPC command ids usable by the system GUI and services. */ williamr@2: enum TApaAppServiceBaseCmdConstants williamr@2: { williamr@2: /** System GUI server app command IDs must start from this base. */ williamr@2: KSystemGuiCmdBase = 0x100, williamr@2: /** Service specific command IDs must start from this base. */ williamr@2: KServiceCmdBase = 0x200 williamr@2: }; williamr@2: williamr@2: public: williamr@2: IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient); williamr@2: IMPORT_C void ConnectExistingAppL(const RApaAppServiceBase& aClient, const TSecurityPolicy& aSecurityPolicy); williamr@2: IMPORT_C void ConnectExistingByNameL(const TDesC& aName); williamr@2: IMPORT_C void ConnectExistingByNameL(const TDesC& aServerName, const TSecurityPolicy& aSecurityPolicy); williamr@2: IMPORT_C void TransferExistingSessionL(RApaAppServiceBase& aClient); williamr@2: IMPORT_C void Close(); //lint !e1511 Member hides non-virtual member williamr@2: williamr@2: IMPORT_C void NotifyServerExit(TRequestStatus& aStatus) const; williamr@2: IMPORT_C void CancelNotifyServerExit() const; williamr@2: williamr@2: IMPORT_C TPtrC ServerName() const; williamr@2: williamr@2: protected: williamr@2: IMPORT_C RApaAppServiceBase(); williamr@2: williamr@2: private: williamr@2: IMPORT_C virtual void RApaAppServiceBase_Reserved1(); williamr@2: IMPORT_C virtual void RApaAppServiceBase_Reserved2(); williamr@2: williamr@2: /** Returns the UID of the service that this session provides an interface for. williamr@2: Client side service implementations must implement this function to return williamr@2: the UID for the service that they implement. williamr@2: @return The UID of the service implemented by the derived class.*/ williamr@2: virtual TUid ServiceUid() const = 0; williamr@2: williamr@2: private: williamr@2: void ConnectL(); williamr@2: void ConnectL(const TSecurityPolicy& aSecurityPolicy); williamr@2: williamr@2: private: williamr@2: IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); williamr@2: williamr@2: private: williamr@2: HBufC* iServerName; // owned williamr@2: TInt iApaReserved1; williamr@2: TInt iApaReserved2; williamr@2: }; williamr@2: williamr@2: williamr@2: class MApaServerAppExitObserver williamr@2: /** Interface for a class that wants to receive exit notification from williamr@2: a server application. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CApaServerAppExitMonitor*/ williamr@2: { williamr@2: public: williamr@2: /** Receives server exit notification. williamr@2: Implementers of this interface must override this function to williamr@2: receive notification of server app exit reasons. williamr@2: @param aReason The reason that the server app exited, this may be williamr@2: a command ID from the UI if exit was triggered from the UI, or an error code williamr@2: if the server app exited unexpectedly. */ williamr@2: virtual void HandleServerAppExit(TInt aReason) = 0; williamr@2: protected: williamr@2: IMPORT_C MApaServerAppExitObserver(); williamr@2: private: williamr@2: IMPORT_C virtual void MApaServerAppExitObserver_Reserved1(); williamr@2: IMPORT_C virtual void MApaServerAppExitObserver_Reserved2(); williamr@2: private: williamr@2: TInt iMApaServerAppExitObserver_Reserved1; williamr@2: }; williamr@2: williamr@2: williamr@2: class CApaServerAppExitMonitor : public CActive williamr@2: /** Helper class that monitors the lifetime of a server app williamr@2: through a connected RApaAppServiceBase and reports server app exits williamr@2: to a MApaServerAppExitObserver derived class. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: @see RApaAppServiceBase williamr@2: @see MApaServerAppExitObserver */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CApaServerAppExitMonitor* NewL(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); williamr@2: IMPORT_C static CApaServerAppExitMonitor* NewLC(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); williamr@2: IMPORT_C ~CApaServerAppExitMonitor(); williamr@2: williamr@2: private: williamr@2: CApaServerAppExitMonitor(RApaAppServiceBase& aClient, MApaServerAppExitObserver& aObserver, TInt aPriority); williamr@2: williamr@2: private: // from CActive williamr@2: void RunL(); williamr@2: void DoCancel(); williamr@2: TInt RunError(TInt aError); williamr@2: williamr@2: private: williamr@2: RApaAppServiceBase& iClient; williamr@2: MApaServerAppExitObserver& iObserver; williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // Server application server support williamr@2: // williamr@2: williamr@2: /** Panic codes that the server application framework can generate. williamr@2: @internalComponent */ williamr@2: enum TApaAppServerPanic williamr@2: { williamr@2: /** The IPC message ID used by the client is not recognised. */ williamr@2: EApaAppServerPanicIllegalFunction, williamr@2: /** The client already has an active notification of server exit. */ williamr@2: EApaAppServerPanicNotifyExitActive, williamr@2: /** The client has tried to connect an already connected session. */ williamr@2: EApaAppServerPanicClientAlreadyConnected williamr@2: }; williamr@2: williamr@2: williamr@2: class CApaAppServiceBase : public CSession2 williamr@2: /** Base class for all service implementations. williamr@2: Provides the basic IPC and security framework that server applications williamr@2: can use to receive messages from their clients. williamr@2: In a typical service implementation, a service support class williamr@2: will be derived from this class, and the service implementation williamr@2: will then be derived from the service support class. williamr@2: williamr@2: Instances of this class are created by the server application williamr@2: in its override of CApaAppServer::CreateServiceL(). williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CApaAppServer williamr@2: @see CPolicyServer */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CApaAppServiceBase(); williamr@2: IMPORT_C ~CApaAppServiceBase(); williamr@2: williamr@2: IMPORT_C virtual CPolicyServer::TCustomResult SecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); williamr@2: williamr@2: public: // internal williamr@2: void SendAppServerExitNotification(TInt aExitReason); williamr@2: williamr@2: protected: // from CSession2 williamr@2: IMPORT_C void CreateL(); williamr@2: IMPORT_C void ServiceL(const RMessage2& aMessage); williamr@2: IMPORT_C void ServiceError(const RMessage2& aMessage,TInt aError); williamr@2: IMPORT_C virtual TInt CountResources(); williamr@2: IMPORT_C virtual void Disconnect(const RMessage2& aMessage); williamr@2: williamr@2: private: // Server exit notification handlers williamr@2: void NotifyServerExit(const RMessage2& aMessage); williamr@2: void CancelNotifyServerExit(const RMessage2& aMessage) const; williamr@2: williamr@2: private: williamr@2: IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); williamr@2: IMPORT_C virtual void CApaAppServiceBase_Reserved1(); williamr@2: IMPORT_C virtual void CApaAppServiceBase_Reserved2(); williamr@2: williamr@2: private: williamr@2: RMessagePtr2 iNotifyExitMsg; williamr@2: TInt iExitReason; williamr@2: TInt iApaReserved2; williamr@2: }; williamr@2: williamr@2: class CApaAppServer : public CPolicyServer williamr@2: /** Base class for all server application's servers. williamr@2: Server applications must derive from this class to implement their williamr@2: servers. These must be instantiated in an override of williamr@2: CApaApplication::NewAppServerL(). williamr@2: The main task of this class is to create service implementations williamr@2: that clients of a server app may connect to. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: @see CEikAppServer williamr@2: @see CPolicyServer */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C ~CApaAppServer(); williamr@2: IMPORT_C virtual void ConstructL(const TDesC& aFixedServerName); williamr@2: williamr@2: IMPORT_C void NotifyServerExit(TInt aReason); williamr@2: williamr@2: IMPORT_C virtual CApaAppServiceBase* CreateServiceL(TUid aServiceType) const; williamr@2: IMPORT_C virtual TCustomResult CreateServiceSecurityCheckL(TUid aServiceType, const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); williamr@2: williamr@2: protected: williamr@2: IMPORT_C CApaAppServer(); williamr@2: williamr@2: // From CPolicyServer williamr@2: IMPORT_C TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); williamr@2: // From CServer2 williamr@2: IMPORT_C virtual void DoConnect(const RMessage2& aMessage); williamr@2: williamr@2: private: williamr@2: IMPORT_C CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; williamr@2: williamr@2: private: williamr@2: TUid ConnectMessageServiceUid(const RMessage2& aMsg) const; williamr@2: williamr@2: private: williamr@2: IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion); williamr@2: // Extensions williamr@2: IMPORT_C virtual void CApaAppServer_Reserved1(); williamr@2: IMPORT_C virtual void CApaAppServer_Reserved2(); williamr@2: williamr@2: private: williamr@2: TInt iApaReserved1; williamr@2: TInt iApaReserved2; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif