os/mm/mmlibs/mmfw/inc/mmf/ControllerFramework/mmfcontrollerframeworkclasses.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
#ifndef __MMFCONTROLLERFRAMEWORKCLASSES_H__
sl@0
    18
#define __MMFCONTROLLERFRAMEWORKCLASSES_H__
sl@0
    19
sl@0
    20
#include <e32base.h>
sl@0
    21
#include <e32std.h>
sl@0
    22
#include <f32file.h>
sl@0
    23
#include <mmf/common/mmfutilities.h>
sl@0
    24
#include <mmf/common/mmfcontrollerframeworkbase.h>
sl@0
    25
#include <mmf/common/mmfipc.h>
sl@0
    26
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    27
#include <mmf/common/mmfipcserver.h>
sl@0
    28
#endif
sl@0
    29
sl@0
    30
sl@0
    31
// fwd ref
sl@0
    32
class CMMFControllerImplementationInformation;
sl@0
    33
class CLogonMonitor;
sl@0
    34
sl@0
    35
sl@0
    36
/**
sl@0
    37
@internalComponent
sl@0
    38
*/
sl@0
    39
#define KMMFControllerProxyVersion TVersion(7,1,1)
sl@0
    40
sl@0
    41
/**
sl@0
    42
@internalComponent
sl@0
    43
*/
sl@0
    44
const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB
sl@0
    45
sl@0
    46
/**
sl@0
    47
@internalComponent
sl@0
    48
*/
sl@0
    49
const TInt KMMFControllerProxyMaxCachedMessages = 10;
sl@0
    50
sl@0
    51
/**
sl@0
    52
@internalComponent
sl@0
    53
sl@0
    54
Signals that the message is destined for the controller proxy
sl@0
    55
*/
sl@0
    56
const TInt KMMFObjectHandleControllerProxy = -1;
sl@0
    57
sl@0
    58
/**
sl@0
    59
@internalComponent
sl@0
    60
sl@0
    61
The first valid object handle.  The MMF Object container will
sl@0
    62
begin iterating from here when generating object handles.
sl@0
    63
*/
sl@0
    64
const TInt KMMFObjectHandleFirstValid = 1;
sl@0
    65
sl@0
    66
/**
sl@0
    67
@internalComponent
sl@0
    68
*/
sl@0
    69
const TInt KMmfControllerThreadShutdownTimeout = 20000000;	// 20 seconds
sl@0
    70
sl@0
    71
/**
sl@0
    72
@internalComponent
sl@0
    73
sl@0
    74
The UID and messages associated with the controller proxy interface.
sl@0
    75
*/
sl@0
    76
const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7};
sl@0
    77
sl@0
    78
/**
sl@0
    79
@internalComponent
sl@0
    80
sl@0
    81
Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads.
sl@0
    82
*/
sl@0
    83
struct TControllerProxyServerParams 
sl@0
    84
	{
sl@0
    85
	RServer2*	iServer;
sl@0
    86
	TBool		iUsingSharedHeap;
sl@0
    87
	};
sl@0
    88
	
sl@0
    89
sl@0
    90
/**
sl@0
    91
@internalComponent
sl@0
    92
*/
sl@0
    93
enum TMMFControllerProxyMessages
sl@0
    94
	{
sl@0
    95
	EMMFControllerProxyLoadControllerPluginByUid,
sl@0
    96
	EMMFControllerProxyReceiveEvents,
sl@0
    97
	EMMFControllerProxyCancelReceiveEvents
sl@0
    98
	};
sl@0
    99
sl@0
   100
/**
sl@0
   101
@internalComponent
sl@0
   102
sl@0
   103
Used to Kill the controller thread either immediately or after a timeout.
sl@0
   104
Used by the controller thread on startup to prevent orphaning if no sessions are created to it.
sl@0
   105
*/
sl@0
   106
class CMMFControllerProxyShutdown : public CTimer
sl@0
   107
	{
sl@0
   108
	enum {EMMFControllerProxyShutdownDelay=1000000};	// 1s
sl@0
   109
public:
sl@0
   110
sl@0
   111
	/**
sl@0
   112
	Create a new shutdown timer.
sl@0
   113
sl@0
   114
	This method can leave with one of the system-wide error codes.
sl@0
   115
sl@0
   116
	@since 7.0s
sl@0
   117
	*/
sl@0
   118
	static CMMFControllerProxyShutdown* NewL();
sl@0
   119
sl@0
   120
	/**
sl@0
   121
	Start the shutdown timer.  The RunL of this active object will be called after
sl@0
   122
	EMMFControllerProxyShutdownDelay microseconds.
sl@0
   123
sl@0
   124
	@since 7.0s
sl@0
   125
	*/
sl@0
   126
	void Start();
sl@0
   127
sl@0
   128
	/**
sl@0
   129
	Shut down the controller thread immediately.
sl@0
   130
	
sl@0
   131
	Calls CActiveScheduler::Stop().
sl@0
   132
sl@0
   133
	@since 7.0s
sl@0
   134
	*/
sl@0
   135
	void ShutdownNow();
sl@0
   136
private:
sl@0
   137
	CMMFControllerProxyShutdown();
sl@0
   138
	void ConstructL();
sl@0
   139
sl@0
   140
	/**
sl@0
   141
	Calls ShutdownNow().
sl@0
   142
sl@0
   143
	@since 7.0s
sl@0
   144
	*/
sl@0
   145
	void RunL();
sl@0
   146
	};
sl@0
   147
sl@0
   148
sl@0
   149
/**
sl@0
   150
@internalComponent
sl@0
   151
sl@0
   152
Used to hold on to an TMMFMessage so we can complete it asynchronously to 
sl@0
   153
send an event to the client.
sl@0
   154
sl@0
   155
@since 7.0s
sl@0
   156
*/
sl@0
   157
class CMMFEventReceiver : public CBase
sl@0
   158
	{
sl@0
   159
public:
sl@0
   160
sl@0
   161
	/**
sl@0
   162
	Constructs a new event receiver.
sl@0
   163
	
sl@0
   164
	This method may leave with one of the system-wide error codes.
sl@0
   165
sl@0
   166
	@param  aMessage
sl@0
   167
	        The message will be completed when an event occurs.
sl@0
   168
sl@0
   169
	@return A pointer to the newly created event receiver.
sl@0
   170
sl@0
   171
	@since  7.0s
sl@0
   172
	*/
sl@0
   173
	static CMMFEventReceiver* NewL(const TMMFMessage& aMessage);
sl@0
   174
sl@0
   175
	/**
sl@0
   176
	Destructor.
sl@0
   177
sl@0
   178
	Completes the message with KErrCancel if the message hasn't already been completed.
sl@0
   179
sl@0
   180
	@since 7.0s
sl@0
   181
	*/
sl@0
   182
	~CMMFEventReceiver();
sl@0
   183
sl@0
   184
	/**
sl@0
   185
	Sends an event to the client.
sl@0
   186
sl@0
   187
	@param  aEvent
sl@0
   188
	        The event.
sl@0
   189
sl@0
   190
	@since  7.0s
sl@0
   191
	*/
sl@0
   192
	void SendEvent(const TMMFEvent& aEvent);
sl@0
   193
private:
sl@0
   194
sl@0
   195
	/**
sl@0
   196
	Constructor.
sl@0
   197
sl@0
   198
	@param  aMessage
sl@0
   199
	        The message will be completed when an event occurs.
sl@0
   200
sl@0
   201
	@since  7.0s
sl@0
   202
	*/
sl@0
   203
	CMMFEventReceiver(const TMMFMessage& aMessage);
sl@0
   204
private:
sl@0
   205
	/** 
sl@0
   206
	The message will be completed when an event occurs.
sl@0
   207
	*/
sl@0
   208
	TMMFMessage iMessage;
sl@0
   209
	};
sl@0
   210
sl@0
   211
/**
sl@0
   212
@internalComponent
sl@0
   213
sl@0
   214
The controller proxy server.
sl@0
   215
sl@0
   216
The main server inside the controller thread, responsible for creating and destroying the single
sl@0
   217
session used to transmit messages from the client to the server.
sl@0
   218
sl@0
   219
Every controller plugin runs in its own thread, and has its own controller proxy server.
sl@0
   220
sl@0
   221
@since 7.0s
sl@0
   222
*/
sl@0
   223
class CMMFControllerProxyServer : public CMmfIpcServer
sl@0
   224
	{
sl@0
   225
public:
sl@0
   226
	/**
sl@0
   227
	Construct the server.
sl@0
   228
sl@0
   229
	This method may leave with one of the system-wide error codes.
sl@0
   230
sl@0
   231
	@return The newly created server.
sl@0
   232
sl@0
   233
	@since  7.0s
sl@0
   234
	*/
sl@0
   235
	static CMMFControllerProxyServer* NewL(RServer2* aServer2 );
sl@0
   236
sl@0
   237
	/**
sl@0
   238
	Destructor.
sl@0
   239
sl@0
   240
	@since 7.0s
sl@0
   241
	*/
sl@0
   242
	~CMMFControllerProxyServer();
sl@0
   243
sl@0
   244
	/**
sl@0
   245
	Static thread function.
sl@0
   246
sl@0
   247
	The address of this function is passed into RThread::Create.
sl@0
   248
sl@0
   249
	Unpackages the startup parameters and calls DoStartThreadL().
sl@0
   250
sl@0
   251
	@param  aAny
sl@0
   252
	        A pointer to the packaged startup parameters.
sl@0
   253
sl@0
   254
	@return One of the system-wide error codes.
sl@0
   255
sl@0
   256
	@since 7.0s
sl@0
   257
	*/
sl@0
   258
	IMPORT_C static TInt StartThread(TAny* aParam);
sl@0
   259
sl@0
   260
	/**
sl@0
   261
	Called by the active scheduler when the ServiceL of the session leaves.
sl@0
   262
	Completes the message with the error and restarts the server.
sl@0
   263
sl@0
   264
	@param  aError
sl@0
   265
	        The error that the session ServiceL left with.
sl@0
   266
sl@0
   267
	@return  KErrNone
sl@0
   268
	@since 7.0s
sl@0
   269
	*/
sl@0
   270
	TInt RunError(TInt aError);
sl@0
   271
sl@0
   272
	/**
sl@0
   273
	Signals that the session has been created.
sl@0
   274
sl@0
   275
	Stops the shutdown timer.
sl@0
   276
sl@0
   277
	@since 7.0s
sl@0
   278
	*/
sl@0
   279
	void SessionCreated();
sl@0
   280
sl@0
   281
	/**
sl@0
   282
	Signals that the session has been destroyed.
sl@0
   283
	Causes the server to shut down immediately.
sl@0
   284
sl@0
   285
	@since 7.0s
sl@0
   286
	*/
sl@0
   287
	void SessionDestroyed();
sl@0
   288
private:
sl@0
   289
sl@0
   290
	/**
sl@0
   291
	Thread startup code.
sl@0
   292
sl@0
   293
	Creates the cleanup stack, installs the active scheduler and creates the server.
sl@0
   294
	Once all this is completed successfully, it signals the success back to the client.
sl@0
   295
sl@0
   296
	This function may leave with one of the system-wide error codes.
sl@0
   297
sl@0
   298
	@param  aParams
sl@0
   299
	        Used to signal startup success back to the client.
sl@0
   300
sl@0
   301
	@since 7.0s
sl@0
   302
	*/
sl@0
   303
	static void DoStartThreadL(TAny* aParam);
sl@0
   304
sl@0
   305
	/**
sl@0
   306
	Creates a new session.  Only one session may be created with the ControllerProxyServer.
sl@0
   307
sl@0
   308
	This function may leave with one of the system-wide error codes.
sl@0
   309
sl@0
   310
	@param  aVersion
sl@0
   311
	        The version number of the session.
sl@0
   312
sl@0
   313
	@return A pointer to the new session.
sl@0
   314
sl@0
   315
	@since 7.0s
sl@0
   316
	*/
sl@0
   317
	CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
sl@0
   318
sl@0
   319
	/** 
sl@0
   320
	Constructor.
sl@0
   321
sl@0
   322
	@since 7.0s
sl@0
   323
	*/
sl@0
   324
	CMMFControllerProxyServer();
sl@0
   325
sl@0
   326
	/**
sl@0
   327
	Second phase constructor.
sl@0
   328
sl@0
   329
	@since 7.0s
sl@0
   330
	*/
sl@0
   331
	void ConstructL(RServer2* aServer2);
sl@0
   332
	
sl@0
   333
	/**
sl@0
   334
	Renaming Controller Proxy Server name
sl@0
   335
	
sl@0
   336
	@since 9.2
sl@0
   337
	*/
sl@0
   338
	static void RenameControllerProxyThread();
sl@0
   339
sl@0
   340
private:
sl@0
   341
	/** 
sl@0
   342
	The timer used to shut down the server in case the client fails to connect a session.
sl@0
   343
	*/
sl@0
   344
	CMMFControllerProxyShutdown* iShutdownTimer;
sl@0
   345
	/** 
sl@0
   346
	Indicates whether we have a session connected.  Only one session is allowed to connect to the server.
sl@0
   347
	*/
sl@0
   348
	TBool iHaveSession;
sl@0
   349
	};
sl@0
   350
sl@0
   351
class CMMFController;
sl@0
   352
sl@0
   353
/**
sl@0
   354
@internalComponent
sl@0
   355
sl@0
   356
The controller proxy session.
sl@0
   357
sl@0
   358
Only one session can be connected to a controller proxy server.
sl@0
   359
sl@0
   360
@since 7.0s
sl@0
   361
*/
sl@0
   362
class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler
sl@0
   363
	{
sl@0
   364
public:
sl@0
   365
sl@0
   366
	/**
sl@0
   367
	Construct the session.
sl@0
   368
sl@0
   369
	This method may leave with one of the system-wide error codes.
sl@0
   370
sl@0
   371
	@return The newly created server.
sl@0
   372
sl@0
   373
	@since 7.0s
sl@0
   374
	*/
sl@0
   375
	static CMMFControllerProxySession* NewL();
sl@0
   376
sl@0
   377
	/**
sl@0
   378
	Second phase constructor called by the CServer base class.
sl@0
   379
sl@0
   380
	This function may leave with one of the system-wide error codes.
sl@0
   381
sl@0
   382
	@param  aServer
sl@0
   383
	        A reference to the server to which this session is attached.
sl@0
   384
sl@0
   385
	@since  7.0s
sl@0
   386
	*/
sl@0
   387
	void CreateL(const CMmfIpcServer& aServer);
sl@0
   388
sl@0
   389
	/**
sl@0
   390
	Destructor.
sl@0
   391
	*/
sl@0
   392
	~CMMFControllerProxySession();
sl@0
   393
sl@0
   394
	/**
sl@0
   395
	Called by the CServer baseclass when a request has been made by the client.
sl@0
   396
sl@0
   397
	This function may leave with on of the system-wide error codes. If
sl@0
   398
	a leave occurs, the message will be automatically completed by the
sl@0
   399
	RunError() of the Controller Proxy Server.
sl@0
   400
sl@0
   401
	@param  aMessage
sl@0
   402
	        The request to be handled.  The controller proxy session will create
sl@0
   403
	        a TMMFMessage from this, and pass on the request to the controller
sl@0
   404
	        base class to handle.
sl@0
   405
sl@0
   406
	@since	7.0s
sl@0
   407
	*/
sl@0
   408
	void ServiceL(const RMmfIpcMessage& aMessage);
sl@0
   409
sl@0
   410
	/**
sl@0
   411
	Derived from MAsyncEventHandler.
sl@0
   412
sl@0
   413
	@see MAsyncEventHandler
sl@0
   414
sl@0
   415
	@since	7.0s
sl@0
   416
	*/
sl@0
   417
	TInt SendEventToClient(const TMMFEvent& aEvent);
sl@0
   418
private:
sl@0
   419
	/**
sl@0
   420
	Constructor
sl@0
   421
	*/
sl@0
   422
	CMMFControllerProxySession();
sl@0
   423
sl@0
   424
	/**
sl@0
   425
	Handle a request from the client to register to receive events from the controller framework.
sl@0
   426
sl@0
   427
	This function may leave with one of the system-wide error codes.
sl@0
   428
sl@0
   429
	@param  aMessage
sl@0
   430
	        The request to be handled.
sl@0
   431
sl@0
   432
	@return ETrue if the message will be completed now, EFalse if the message will be completed 
sl@0
   433
	        later.
sl@0
   434
	*/
sl@0
   435
	TBool ReceiveEventsL(TMMFMessage& aMessage);
sl@0
   436
sl@0
   437
	/**
sl@0
   438
	Handle a request from the client to stop receiving events from the controller framework.
sl@0
   439
sl@0
   440
	This function may leave with one of the system-wide error codes.
sl@0
   441
sl@0
   442
	@param  aMessage
sl@0
   443
	        The request to be handled.
sl@0
   444
sl@0
   445
	@return ETrue if the message will be completed now, EFalse if the message will be completed later.
sl@0
   446
	*/
sl@0
   447
	TBool CancelReceiveEvents(TMMFMessage& aMessage);
sl@0
   448
sl@0
   449
	/**
sl@0
   450
	Handle a request from the client to load a controller plugin.
sl@0
   451
sl@0
   452
	This function may leave with one of the system-wide error codes.
sl@0
   453
sl@0
   454
	@param  aMessage
sl@0
   455
	        The request to be handled.
sl@0
   456
sl@0
   457
	@return ETrue if the message will be completed now, EFalse if the message will be completed later.
sl@0
   458
	*/
sl@0
   459
	TBool LoadControllerL(TMMFMessage& aMessage);
sl@0
   460
private:
sl@0
   461
	/** 
sl@0
   462
	The controller plugin. 
sl@0
   463
	*/
sl@0
   464
	CMMFController* iController;
sl@0
   465
	/** 
sl@0
   466
	A pointer to the server. 
sl@0
   467
	*/
sl@0
   468
	CMMFControllerProxyServer* iServer;
sl@0
   469
	/** 
sl@0
   470
	The event receiver.  Used to send events to the client.
sl@0
   471
	*/
sl@0
   472
	CMMFEventReceiver* iEventReceiver;
sl@0
   473
	/** 
sl@0
   474
	The events waiting to be sent to the client.
sl@0
   475
	*/
sl@0
   476
	RArray<TMMFEvent> iEvents;
sl@0
   477
	};
sl@0
   478
sl@0
   479
#endif //__MMFCONTROLLERFRAMEWORKCLASSES_H__