os/mm/mmlibs/mmfw/inc/mmf/ControllerFramework/mmfcontrollerframeworkclasses.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/ControllerFramework/mmfcontrollerframeworkclasses.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,479 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +#ifndef __MMFCONTROLLERFRAMEWORKCLASSES_H__
    1.21 +#define __MMFCONTROLLERFRAMEWORKCLASSES_H__
    1.22 +
    1.23 +#include <e32base.h>
    1.24 +#include <e32std.h>
    1.25 +#include <f32file.h>
    1.26 +#include <mmf/common/mmfutilities.h>
    1.27 +#include <mmf/common/mmfcontrollerframeworkbase.h>
    1.28 +#include <mmf/common/mmfipc.h>
    1.29 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.30 +#include <mmf/common/mmfipcserver.h>
    1.31 +#endif
    1.32 +
    1.33 +
    1.34 +// fwd ref
    1.35 +class CMMFControllerImplementationInformation;
    1.36 +class CLogonMonitor;
    1.37 +
    1.38 +
    1.39 +/**
    1.40 +@internalComponent
    1.41 +*/
    1.42 +#define KMMFControllerProxyVersion TVersion(7,1,1)
    1.43 +
    1.44 +/**
    1.45 +@internalComponent
    1.46 +*/
    1.47 +const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB
    1.48 +
    1.49 +/**
    1.50 +@internalComponent
    1.51 +*/
    1.52 +const TInt KMMFControllerProxyMaxCachedMessages = 10;
    1.53 +
    1.54 +/**
    1.55 +@internalComponent
    1.56 +
    1.57 +Signals that the message is destined for the controller proxy
    1.58 +*/
    1.59 +const TInt KMMFObjectHandleControllerProxy = -1;
    1.60 +
    1.61 +/**
    1.62 +@internalComponent
    1.63 +
    1.64 +The first valid object handle.  The MMF Object container will
    1.65 +begin iterating from here when generating object handles.
    1.66 +*/
    1.67 +const TInt KMMFObjectHandleFirstValid = 1;
    1.68 +
    1.69 +/**
    1.70 +@internalComponent
    1.71 +*/
    1.72 +const TInt KMmfControllerThreadShutdownTimeout = 20000000;	// 20 seconds
    1.73 +
    1.74 +/**
    1.75 +@internalComponent
    1.76 +
    1.77 +The UID and messages associated with the controller proxy interface.
    1.78 +*/
    1.79 +const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7};
    1.80 +
    1.81 +/**
    1.82 +@internalComponent
    1.83 +
    1.84 +Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads.
    1.85 +*/
    1.86 +struct TControllerProxyServerParams 
    1.87 +	{
    1.88 +	RServer2*	iServer;
    1.89 +	TBool		iUsingSharedHeap;
    1.90 +	};
    1.91 +	
    1.92 +
    1.93 +/**
    1.94 +@internalComponent
    1.95 +*/
    1.96 +enum TMMFControllerProxyMessages
    1.97 +	{
    1.98 +	EMMFControllerProxyLoadControllerPluginByUid,
    1.99 +	EMMFControllerProxyReceiveEvents,
   1.100 +	EMMFControllerProxyCancelReceiveEvents
   1.101 +	};
   1.102 +
   1.103 +/**
   1.104 +@internalComponent
   1.105 +
   1.106 +Used to Kill the controller thread either immediately or after a timeout.
   1.107 +Used by the controller thread on startup to prevent orphaning if no sessions are created to it.
   1.108 +*/
   1.109 +class CMMFControllerProxyShutdown : public CTimer
   1.110 +	{
   1.111 +	enum {EMMFControllerProxyShutdownDelay=1000000};	// 1s
   1.112 +public:
   1.113 +
   1.114 +	/**
   1.115 +	Create a new shutdown timer.
   1.116 +
   1.117 +	This method can leave with one of the system-wide error codes.
   1.118 +
   1.119 +	@since 7.0s
   1.120 +	*/
   1.121 +	static CMMFControllerProxyShutdown* NewL();
   1.122 +
   1.123 +	/**
   1.124 +	Start the shutdown timer.  The RunL of this active object will be called after
   1.125 +	EMMFControllerProxyShutdownDelay microseconds.
   1.126 +
   1.127 +	@since 7.0s
   1.128 +	*/
   1.129 +	void Start();
   1.130 +
   1.131 +	/**
   1.132 +	Shut down the controller thread immediately.
   1.133 +	
   1.134 +	Calls CActiveScheduler::Stop().
   1.135 +
   1.136 +	@since 7.0s
   1.137 +	*/
   1.138 +	void ShutdownNow();
   1.139 +private:
   1.140 +	CMMFControllerProxyShutdown();
   1.141 +	void ConstructL();
   1.142 +
   1.143 +	/**
   1.144 +	Calls ShutdownNow().
   1.145 +
   1.146 +	@since 7.0s
   1.147 +	*/
   1.148 +	void RunL();
   1.149 +	};
   1.150 +
   1.151 +
   1.152 +/**
   1.153 +@internalComponent
   1.154 +
   1.155 +Used to hold on to an TMMFMessage so we can complete it asynchronously to 
   1.156 +send an event to the client.
   1.157 +
   1.158 +@since 7.0s
   1.159 +*/
   1.160 +class CMMFEventReceiver : public CBase
   1.161 +	{
   1.162 +public:
   1.163 +
   1.164 +	/**
   1.165 +	Constructs a new event receiver.
   1.166 +	
   1.167 +	This method may leave with one of the system-wide error codes.
   1.168 +
   1.169 +	@param  aMessage
   1.170 +	        The message will be completed when an event occurs.
   1.171 +
   1.172 +	@return A pointer to the newly created event receiver.
   1.173 +
   1.174 +	@since  7.0s
   1.175 +	*/
   1.176 +	static CMMFEventReceiver* NewL(const TMMFMessage& aMessage);
   1.177 +
   1.178 +	/**
   1.179 +	Destructor.
   1.180 +
   1.181 +	Completes the message with KErrCancel if the message hasn't already been completed.
   1.182 +
   1.183 +	@since 7.0s
   1.184 +	*/
   1.185 +	~CMMFEventReceiver();
   1.186 +
   1.187 +	/**
   1.188 +	Sends an event to the client.
   1.189 +
   1.190 +	@param  aEvent
   1.191 +	        The event.
   1.192 +
   1.193 +	@since  7.0s
   1.194 +	*/
   1.195 +	void SendEvent(const TMMFEvent& aEvent);
   1.196 +private:
   1.197 +
   1.198 +	/**
   1.199 +	Constructor.
   1.200 +
   1.201 +	@param  aMessage
   1.202 +	        The message will be completed when an event occurs.
   1.203 +
   1.204 +	@since  7.0s
   1.205 +	*/
   1.206 +	CMMFEventReceiver(const TMMFMessage& aMessage);
   1.207 +private:
   1.208 +	/** 
   1.209 +	The message will be completed when an event occurs.
   1.210 +	*/
   1.211 +	TMMFMessage iMessage;
   1.212 +	};
   1.213 +
   1.214 +/**
   1.215 +@internalComponent
   1.216 +
   1.217 +The controller proxy server.
   1.218 +
   1.219 +The main server inside the controller thread, responsible for creating and destroying the single
   1.220 +session used to transmit messages from the client to the server.
   1.221 +
   1.222 +Every controller plugin runs in its own thread, and has its own controller proxy server.
   1.223 +
   1.224 +@since 7.0s
   1.225 +*/
   1.226 +class CMMFControllerProxyServer : public CMmfIpcServer
   1.227 +	{
   1.228 +public:
   1.229 +	/**
   1.230 +	Construct the server.
   1.231 +
   1.232 +	This method may leave with one of the system-wide error codes.
   1.233 +
   1.234 +	@return The newly created server.
   1.235 +
   1.236 +	@since  7.0s
   1.237 +	*/
   1.238 +	static CMMFControllerProxyServer* NewL(RServer2* aServer2 );
   1.239 +
   1.240 +	/**
   1.241 +	Destructor.
   1.242 +
   1.243 +	@since 7.0s
   1.244 +	*/
   1.245 +	~CMMFControllerProxyServer();
   1.246 +
   1.247 +	/**
   1.248 +	Static thread function.
   1.249 +
   1.250 +	The address of this function is passed into RThread::Create.
   1.251 +
   1.252 +	Unpackages the startup parameters and calls DoStartThreadL().
   1.253 +
   1.254 +	@param  aAny
   1.255 +	        A pointer to the packaged startup parameters.
   1.256 +
   1.257 +	@return One of the system-wide error codes.
   1.258 +
   1.259 +	@since 7.0s
   1.260 +	*/
   1.261 +	IMPORT_C static TInt StartThread(TAny* aParam);
   1.262 +
   1.263 +	/**
   1.264 +	Called by the active scheduler when the ServiceL of the session leaves.
   1.265 +	Completes the message with the error and restarts the server.
   1.266 +
   1.267 +	@param  aError
   1.268 +	        The error that the session ServiceL left with.
   1.269 +
   1.270 +	@return  KErrNone
   1.271 +	@since 7.0s
   1.272 +	*/
   1.273 +	TInt RunError(TInt aError);
   1.274 +
   1.275 +	/**
   1.276 +	Signals that the session has been created.
   1.277 +
   1.278 +	Stops the shutdown timer.
   1.279 +
   1.280 +	@since 7.0s
   1.281 +	*/
   1.282 +	void SessionCreated();
   1.283 +
   1.284 +	/**
   1.285 +	Signals that the session has been destroyed.
   1.286 +	Causes the server to shut down immediately.
   1.287 +
   1.288 +	@since 7.0s
   1.289 +	*/
   1.290 +	void SessionDestroyed();
   1.291 +private:
   1.292 +
   1.293 +	/**
   1.294 +	Thread startup code.
   1.295 +
   1.296 +	Creates the cleanup stack, installs the active scheduler and creates the server.
   1.297 +	Once all this is completed successfully, it signals the success back to the client.
   1.298 +
   1.299 +	This function may leave with one of the system-wide error codes.
   1.300 +
   1.301 +	@param  aParams
   1.302 +	        Used to signal startup success back to the client.
   1.303 +
   1.304 +	@since 7.0s
   1.305 +	*/
   1.306 +	static void DoStartThreadL(TAny* aParam);
   1.307 +
   1.308 +	/**
   1.309 +	Creates a new session.  Only one session may be created with the ControllerProxyServer.
   1.310 +
   1.311 +	This function may leave with one of the system-wide error codes.
   1.312 +
   1.313 +	@param  aVersion
   1.314 +	        The version number of the session.
   1.315 +
   1.316 +	@return A pointer to the new session.
   1.317 +
   1.318 +	@since 7.0s
   1.319 +	*/
   1.320 +	CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
   1.321 +
   1.322 +	/** 
   1.323 +	Constructor.
   1.324 +
   1.325 +	@since 7.0s
   1.326 +	*/
   1.327 +	CMMFControllerProxyServer();
   1.328 +
   1.329 +	/**
   1.330 +	Second phase constructor.
   1.331 +
   1.332 +	@since 7.0s
   1.333 +	*/
   1.334 +	void ConstructL(RServer2* aServer2);
   1.335 +	
   1.336 +	/**
   1.337 +	Renaming Controller Proxy Server name
   1.338 +	
   1.339 +	@since 9.2
   1.340 +	*/
   1.341 +	static void RenameControllerProxyThread();
   1.342 +
   1.343 +private:
   1.344 +	/** 
   1.345 +	The timer used to shut down the server in case the client fails to connect a session.
   1.346 +	*/
   1.347 +	CMMFControllerProxyShutdown* iShutdownTimer;
   1.348 +	/** 
   1.349 +	Indicates whether we have a session connected.  Only one session is allowed to connect to the server.
   1.350 +	*/
   1.351 +	TBool iHaveSession;
   1.352 +	};
   1.353 +
   1.354 +class CMMFController;
   1.355 +
   1.356 +/**
   1.357 +@internalComponent
   1.358 +
   1.359 +The controller proxy session.
   1.360 +
   1.361 +Only one session can be connected to a controller proxy server.
   1.362 +
   1.363 +@since 7.0s
   1.364 +*/
   1.365 +class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler
   1.366 +	{
   1.367 +public:
   1.368 +
   1.369 +	/**
   1.370 +	Construct the session.
   1.371 +
   1.372 +	This method may leave with one of the system-wide error codes.
   1.373 +
   1.374 +	@return The newly created server.
   1.375 +
   1.376 +	@since 7.0s
   1.377 +	*/
   1.378 +	static CMMFControllerProxySession* NewL();
   1.379 +
   1.380 +	/**
   1.381 +	Second phase constructor called by the CServer base class.
   1.382 +
   1.383 +	This function may leave with one of the system-wide error codes.
   1.384 +
   1.385 +	@param  aServer
   1.386 +	        A reference to the server to which this session is attached.
   1.387 +
   1.388 +	@since  7.0s
   1.389 +	*/
   1.390 +	void CreateL(const CMmfIpcServer& aServer);
   1.391 +
   1.392 +	/**
   1.393 +	Destructor.
   1.394 +	*/
   1.395 +	~CMMFControllerProxySession();
   1.396 +
   1.397 +	/**
   1.398 +	Called by the CServer baseclass when a request has been made by the client.
   1.399 +
   1.400 +	This function may leave with on of the system-wide error codes. If
   1.401 +	a leave occurs, the message will be automatically completed by the
   1.402 +	RunError() of the Controller Proxy Server.
   1.403 +
   1.404 +	@param  aMessage
   1.405 +	        The request to be handled.  The controller proxy session will create
   1.406 +	        a TMMFMessage from this, and pass on the request to the controller
   1.407 +	        base class to handle.
   1.408 +
   1.409 +	@since	7.0s
   1.410 +	*/
   1.411 +	void ServiceL(const RMmfIpcMessage& aMessage);
   1.412 +
   1.413 +	/**
   1.414 +	Derived from MAsyncEventHandler.
   1.415 +
   1.416 +	@see MAsyncEventHandler
   1.417 +
   1.418 +	@since	7.0s
   1.419 +	*/
   1.420 +	TInt SendEventToClient(const TMMFEvent& aEvent);
   1.421 +private:
   1.422 +	/**
   1.423 +	Constructor
   1.424 +	*/
   1.425 +	CMMFControllerProxySession();
   1.426 +
   1.427 +	/**
   1.428 +	Handle a request from the client to register to receive events from the controller framework.
   1.429 +
   1.430 +	This function may leave with one of the system-wide error codes.
   1.431 +
   1.432 +	@param  aMessage
   1.433 +	        The request to be handled.
   1.434 +
   1.435 +	@return ETrue if the message will be completed now, EFalse if the message will be completed 
   1.436 +	        later.
   1.437 +	*/
   1.438 +	TBool ReceiveEventsL(TMMFMessage& aMessage);
   1.439 +
   1.440 +	/**
   1.441 +	Handle a request from the client to stop receiving events from the controller framework.
   1.442 +
   1.443 +	This function may leave with one of the system-wide error codes.
   1.444 +
   1.445 +	@param  aMessage
   1.446 +	        The request to be handled.
   1.447 +
   1.448 +	@return ETrue if the message will be completed now, EFalse if the message will be completed later.
   1.449 +	*/
   1.450 +	TBool CancelReceiveEvents(TMMFMessage& aMessage);
   1.451 +
   1.452 +	/**
   1.453 +	Handle a request from the client to load a controller plugin.
   1.454 +
   1.455 +	This function may leave with one of the system-wide error codes.
   1.456 +
   1.457 +	@param  aMessage
   1.458 +	        The request to be handled.
   1.459 +
   1.460 +	@return ETrue if the message will be completed now, EFalse if the message will be completed later.
   1.461 +	*/
   1.462 +	TBool LoadControllerL(TMMFMessage& aMessage);
   1.463 +private:
   1.464 +	/** 
   1.465 +	The controller plugin. 
   1.466 +	*/
   1.467 +	CMMFController* iController;
   1.468 +	/** 
   1.469 +	A pointer to the server. 
   1.470 +	*/
   1.471 +	CMMFControllerProxyServer* iServer;
   1.472 +	/** 
   1.473 +	The event receiver.  Used to send events to the client.
   1.474 +	*/
   1.475 +	CMMFEventReceiver* iEventReceiver;
   1.476 +	/** 
   1.477 +	The events waiting to be sent to the client.
   1.478 +	*/
   1.479 +	RArray<TMMFEvent> iEvents;
   1.480 +	};
   1.481 +
   1.482 +#endif //__MMFCONTROLLERFRAMEWORKCLASSES_H__