Update contrib.
1 // Copyright (c) 2002-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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #ifndef __MMFCONTROLLERFRAMEWORKCLASSES_H__
18 #define __MMFCONTROLLERFRAMEWORKCLASSES_H__
23 #include <mmf/common/mmfutilities.h>
24 #include <mmf/common/mmfcontrollerframeworkbase.h>
25 #include <mmf/common/mmfipc.h>
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
27 #include <mmf/common/mmfipcserver.h>
32 class CMMFControllerImplementationInformation;
39 #define KMMFControllerProxyVersion TVersion(7,1,1)
44 const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB
49 const TInt KMMFControllerProxyMaxCachedMessages = 10;
54 Signals that the message is destined for the controller proxy
56 const TInt KMMFObjectHandleControllerProxy = -1;
61 The first valid object handle. The MMF Object container will
62 begin iterating from here when generating object handles.
64 const TInt KMMFObjectHandleFirstValid = 1;
69 const TInt KMmfControllerThreadShutdownTimeout = 20000000; // 20 seconds
74 The UID and messages associated with the controller proxy interface.
76 const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7};
81 Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads.
83 struct TControllerProxyServerParams
86 TBool iUsingSharedHeap;
93 enum TMMFControllerProxyMessages
95 EMMFControllerProxyLoadControllerPluginByUid,
96 EMMFControllerProxyReceiveEvents,
97 EMMFControllerProxyCancelReceiveEvents
103 Used to Kill the controller thread either immediately or after a timeout.
104 Used by the controller thread on startup to prevent orphaning if no sessions are created to it.
106 class CMMFControllerProxyShutdown : public CTimer
108 enum {EMMFControllerProxyShutdownDelay=1000000}; // 1s
112 Create a new shutdown timer.
114 This method can leave with one of the system-wide error codes.
118 static CMMFControllerProxyShutdown* NewL();
121 Start the shutdown timer. The RunL of this active object will be called after
122 EMMFControllerProxyShutdownDelay microseconds.
129 Shut down the controller thread immediately.
131 Calls CActiveScheduler::Stop().
137 CMMFControllerProxyShutdown();
152 Used to hold on to an TMMFMessage so we can complete it asynchronously to
153 send an event to the client.
157 class CMMFEventReceiver : public CBase
162 Constructs a new event receiver.
164 This method may leave with one of the system-wide error codes.
167 The message will be completed when an event occurs.
169 @return A pointer to the newly created event receiver.
173 static CMMFEventReceiver* NewL(const TMMFMessage& aMessage);
178 Completes the message with KErrCancel if the message hasn't already been completed.
182 ~CMMFEventReceiver();
185 Sends an event to the client.
192 void SendEvent(const TMMFEvent& aEvent);
199 The message will be completed when an event occurs.
203 CMMFEventReceiver(const TMMFMessage& aMessage);
206 The message will be completed when an event occurs.
208 TMMFMessage iMessage;
214 The controller proxy server.
216 The main server inside the controller thread, responsible for creating and destroying the single
217 session used to transmit messages from the client to the server.
219 Every controller plugin runs in its own thread, and has its own controller proxy server.
223 class CMMFControllerProxyServer : public CMmfIpcServer
227 Construct the server.
229 This method may leave with one of the system-wide error codes.
231 @return The newly created server.
235 static CMMFControllerProxyServer* NewL(RServer2* aServer2 );
242 ~CMMFControllerProxyServer();
245 Static thread function.
247 The address of this function is passed into RThread::Create.
249 Unpackages the startup parameters and calls DoStartThreadL().
252 A pointer to the packaged startup parameters.
254 @return One of the system-wide error codes.
258 IMPORT_C static TInt StartThread(TAny* aParam);
261 Called by the active scheduler when the ServiceL of the session leaves.
262 Completes the message with the error and restarts the server.
265 The error that the session ServiceL left with.
270 TInt RunError(TInt aError);
273 Signals that the session has been created.
275 Stops the shutdown timer.
279 void SessionCreated();
282 Signals that the session has been destroyed.
283 Causes the server to shut down immediately.
287 void SessionDestroyed();
293 Creates the cleanup stack, installs the active scheduler and creates the server.
294 Once all this is completed successfully, it signals the success back to the client.
296 This function may leave with one of the system-wide error codes.
299 Used to signal startup success back to the client.
303 static void DoStartThreadL(TAny* aParam);
306 Creates a new session. Only one session may be created with the ControllerProxyServer.
308 This function may leave with one of the system-wide error codes.
311 The version number of the session.
313 @return A pointer to the new session.
317 CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
324 CMMFControllerProxyServer();
327 Second phase constructor.
331 void ConstructL(RServer2* aServer2);
334 Renaming Controller Proxy Server name
338 static void RenameControllerProxyThread();
342 The timer used to shut down the server in case the client fails to connect a session.
344 CMMFControllerProxyShutdown* iShutdownTimer;
346 Indicates whether we have a session connected. Only one session is allowed to connect to the server.
351 class CMMFController;
356 The controller proxy session.
358 Only one session can be connected to a controller proxy server.
362 class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler
367 Construct the session.
369 This method may leave with one of the system-wide error codes.
371 @return The newly created server.
375 static CMMFControllerProxySession* NewL();
378 Second phase constructor called by the CServer base class.
380 This function may leave with one of the system-wide error codes.
383 A reference to the server to which this session is attached.
387 void CreateL(const CMmfIpcServer& aServer);
392 ~CMMFControllerProxySession();
395 Called by the CServer baseclass when a request has been made by the client.
397 This function may leave with on of the system-wide error codes. If
398 a leave occurs, the message will be automatically completed by the
399 RunError() of the Controller Proxy Server.
402 The request to be handled. The controller proxy session will create
403 a TMMFMessage from this, and pass on the request to the controller
404 base class to handle.
408 void ServiceL(const RMmfIpcMessage& aMessage);
411 Derived from MAsyncEventHandler.
413 @see MAsyncEventHandler
417 TInt SendEventToClient(const TMMFEvent& aEvent);
422 CMMFControllerProxySession();
425 Handle a request from the client to register to receive events from the controller framework.
427 This function may leave with one of the system-wide error codes.
430 The request to be handled.
432 @return ETrue if the message will be completed now, EFalse if the message will be completed
435 TBool ReceiveEventsL(TMMFMessage& aMessage);
438 Handle a request from the client to stop receiving events from the controller framework.
440 This function may leave with one of the system-wide error codes.
443 The request to be handled.
445 @return ETrue if the message will be completed now, EFalse if the message will be completed later.
447 TBool CancelReceiveEvents(TMMFMessage& aMessage);
450 Handle a request from the client to load a controller plugin.
452 This function may leave with one of the system-wide error codes.
455 The request to be handled.
457 @return ETrue if the message will be completed now, EFalse if the message will be completed later.
459 TBool LoadControllerL(TMMFMessage& aMessage);
462 The controller plugin.
464 CMMFController* iController;
466 A pointer to the server.
468 CMMFControllerProxyServer* iServer;
470 The event receiver. Used to send events to the client.
472 CMMFEventReceiver* iEventReceiver;
474 The events waiting to be sent to the client.
476 RArray<TMMFEvent> iEvents;
479 #endif //__MMFCONTROLLERFRAMEWORKCLASSES_H__