sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #ifndef __MMFCONTROLLERFRAMEWORKCLASSES_H__ sl@0: #define __MMFCONTROLLERFRAMEWORKCLASSES_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: sl@0: // fwd ref sl@0: class CMMFControllerImplementationInformation; sl@0: class CLogonMonitor; sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define KMMFControllerProxyVersion TVersion(7,1,1) sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TInt KMMFControllerProxyMaxCachedMessages = 10; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Signals that the message is destined for the controller proxy sl@0: */ sl@0: const TInt KMMFObjectHandleControllerProxy = -1; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: The first valid object handle. The MMF Object container will sl@0: begin iterating from here when generating object handles. sl@0: */ sl@0: const TInt KMMFObjectHandleFirstValid = 1; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TInt KMmfControllerThreadShutdownTimeout = 20000000; // 20 seconds sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: The UID and messages associated with the controller proxy interface. sl@0: */ sl@0: const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads. sl@0: */ sl@0: struct TControllerProxyServerParams sl@0: { sl@0: RServer2* iServer; sl@0: TBool iUsingSharedHeap; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: enum TMMFControllerProxyMessages sl@0: { sl@0: EMMFControllerProxyLoadControllerPluginByUid, sl@0: EMMFControllerProxyReceiveEvents, sl@0: EMMFControllerProxyCancelReceiveEvents sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Used to Kill the controller thread either immediately or after a timeout. sl@0: Used by the controller thread on startup to prevent orphaning if no sessions are created to it. sl@0: */ sl@0: class CMMFControllerProxyShutdown : public CTimer sl@0: { sl@0: enum {EMMFControllerProxyShutdownDelay=1000000}; // 1s sl@0: public: sl@0: sl@0: /** sl@0: Create a new shutdown timer. sl@0: sl@0: This method can leave with one of the system-wide error codes. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: static CMMFControllerProxyShutdown* NewL(); sl@0: sl@0: /** sl@0: Start the shutdown timer. The RunL of this active object will be called after sl@0: EMMFControllerProxyShutdownDelay microseconds. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void Start(); sl@0: sl@0: /** sl@0: Shut down the controller thread immediately. sl@0: sl@0: Calls CActiveScheduler::Stop(). sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void ShutdownNow(); sl@0: private: sl@0: CMMFControllerProxyShutdown(); sl@0: void ConstructL(); sl@0: sl@0: /** sl@0: Calls ShutdownNow(). sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void RunL(); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: Used to hold on to an TMMFMessage so we can complete it asynchronously to sl@0: send an event to the client. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: class CMMFEventReceiver : public CBase sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Constructs a new event receiver. sl@0: sl@0: This method may leave with one of the system-wide error codes. sl@0: sl@0: @param aMessage sl@0: The message will be completed when an event occurs. sl@0: sl@0: @return A pointer to the newly created event receiver. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: static CMMFEventReceiver* NewL(const TMMFMessage& aMessage); sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: Completes the message with KErrCancel if the message hasn't already been completed. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: ~CMMFEventReceiver(); sl@0: sl@0: /** sl@0: Sends an event to the client. sl@0: sl@0: @param aEvent sl@0: The event. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void SendEvent(const TMMFEvent& aEvent); sl@0: private: sl@0: sl@0: /** sl@0: Constructor. sl@0: sl@0: @param aMessage sl@0: The message will be completed when an event occurs. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: CMMFEventReceiver(const TMMFMessage& aMessage); sl@0: private: sl@0: /** sl@0: The message will be completed when an event occurs. sl@0: */ sl@0: TMMFMessage iMessage; sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: The controller proxy server. sl@0: sl@0: The main server inside the controller thread, responsible for creating and destroying the single sl@0: session used to transmit messages from the client to the server. sl@0: sl@0: Every controller plugin runs in its own thread, and has its own controller proxy server. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: class CMMFControllerProxyServer : public CMmfIpcServer sl@0: { sl@0: public: sl@0: /** sl@0: Construct the server. sl@0: sl@0: This method may leave with one of the system-wide error codes. sl@0: sl@0: @return The newly created server. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: static CMMFControllerProxyServer* NewL(RServer2* aServer2 ); sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: ~CMMFControllerProxyServer(); sl@0: sl@0: /** sl@0: Static thread function. sl@0: sl@0: The address of this function is passed into RThread::Create. sl@0: sl@0: Unpackages the startup parameters and calls DoStartThreadL(). sl@0: sl@0: @param aAny sl@0: A pointer to the packaged startup parameters. sl@0: sl@0: @return One of the system-wide error codes. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: IMPORT_C static TInt StartThread(TAny* aParam); sl@0: sl@0: /** sl@0: Called by the active scheduler when the ServiceL of the session leaves. sl@0: Completes the message with the error and restarts the server. sl@0: sl@0: @param aError sl@0: The error that the session ServiceL left with. sl@0: sl@0: @return KErrNone sl@0: @since 7.0s sl@0: */ sl@0: TInt RunError(TInt aError); sl@0: sl@0: /** sl@0: Signals that the session has been created. sl@0: sl@0: Stops the shutdown timer. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void SessionCreated(); sl@0: sl@0: /** sl@0: Signals that the session has been destroyed. sl@0: Causes the server to shut down immediately. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void SessionDestroyed(); sl@0: private: sl@0: sl@0: /** sl@0: Thread startup code. sl@0: sl@0: Creates the cleanup stack, installs the active scheduler and creates the server. sl@0: Once all this is completed successfully, it signals the success back to the client. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aParams sl@0: Used to signal startup success back to the client. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: static void DoStartThreadL(TAny* aParam); sl@0: sl@0: /** sl@0: Creates a new session. Only one session may be created with the ControllerProxyServer. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aVersion sl@0: The version number of the session. sl@0: sl@0: @return A pointer to the new session. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: CMmfIpcSession* NewSessionL(const TVersion& aVersion) const; sl@0: sl@0: /** sl@0: Constructor. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: CMMFControllerProxyServer(); sl@0: sl@0: /** sl@0: Second phase constructor. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void ConstructL(RServer2* aServer2); sl@0: sl@0: /** sl@0: Renaming Controller Proxy Server name sl@0: sl@0: @since 9.2 sl@0: */ sl@0: static void RenameControllerProxyThread(); sl@0: sl@0: private: sl@0: /** sl@0: The timer used to shut down the server in case the client fails to connect a session. sl@0: */ sl@0: CMMFControllerProxyShutdown* iShutdownTimer; sl@0: /** sl@0: Indicates whether we have a session connected. Only one session is allowed to connect to the server. sl@0: */ sl@0: TBool iHaveSession; sl@0: }; sl@0: sl@0: class CMMFController; sl@0: sl@0: /** sl@0: @internalComponent sl@0: sl@0: The controller proxy session. sl@0: sl@0: Only one session can be connected to a controller proxy server. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Construct the session. sl@0: sl@0: This method may leave with one of the system-wide error codes. sl@0: sl@0: @return The newly created server. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: static CMMFControllerProxySession* NewL(); sl@0: sl@0: /** sl@0: Second phase constructor called by the CServer base class. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aServer sl@0: A reference to the server to which this session is attached. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void CreateL(const CMmfIpcServer& aServer); sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: ~CMMFControllerProxySession(); sl@0: sl@0: /** sl@0: Called by the CServer baseclass when a request has been made by the client. sl@0: sl@0: This function may leave with on of the system-wide error codes. If sl@0: a leave occurs, the message will be automatically completed by the sl@0: RunError() of the Controller Proxy Server. sl@0: sl@0: @param aMessage sl@0: The request to be handled. The controller proxy session will create sl@0: a TMMFMessage from this, and pass on the request to the controller sl@0: base class to handle. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void ServiceL(const RMmfIpcMessage& aMessage); sl@0: sl@0: /** sl@0: Derived from MAsyncEventHandler. sl@0: sl@0: @see MAsyncEventHandler sl@0: sl@0: @since 7.0s sl@0: */ sl@0: TInt SendEventToClient(const TMMFEvent& aEvent); sl@0: private: sl@0: /** sl@0: Constructor sl@0: */ sl@0: CMMFControllerProxySession(); sl@0: sl@0: /** sl@0: Handle a request from the client to register to receive events from the controller framework. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aMessage sl@0: The request to be handled. sl@0: sl@0: @return ETrue if the message will be completed now, EFalse if the message will be completed sl@0: later. sl@0: */ sl@0: TBool ReceiveEventsL(TMMFMessage& aMessage); sl@0: sl@0: /** sl@0: Handle a request from the client to stop receiving events from the controller framework. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aMessage sl@0: The request to be handled. sl@0: sl@0: @return ETrue if the message will be completed now, EFalse if the message will be completed later. sl@0: */ sl@0: TBool CancelReceiveEvents(TMMFMessage& aMessage); sl@0: sl@0: /** sl@0: Handle a request from the client to load a controller plugin. sl@0: sl@0: This function may leave with one of the system-wide error codes. sl@0: sl@0: @param aMessage sl@0: The request to be handled. sl@0: sl@0: @return ETrue if the message will be completed now, EFalse if the message will be completed later. sl@0: */ sl@0: TBool LoadControllerL(TMMFMessage& aMessage); sl@0: private: sl@0: /** sl@0: The controller plugin. sl@0: */ sl@0: CMMFController* iController; sl@0: /** sl@0: A pointer to the server. sl@0: */ sl@0: CMMFControllerProxyServer* iServer; sl@0: /** sl@0: The event receiver. Used to send events to the client. sl@0: */ sl@0: CMMFEventReceiver* iEventReceiver; sl@0: /** sl@0: The events waiting to be sent to the client. sl@0: */ sl@0: RArray iEvents; sl@0: }; sl@0: sl@0: #endif //__MMFCONTROLLERFRAMEWORKCLASSES_H__